当前位置: 首页>>代码示例>>C++>>正文


C++ CVehicle::GetUpgrades方法代码示例

本文整理汇总了C++中CVehicle::GetUpgrades方法的典型用法代码示例。如果您正苦于以下问题:C++ CVehicle::GetUpgrades方法的具体用法?C++ CVehicle::GetUpgrades怎么用?C++ CVehicle::GetUpgrades使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CVehicle的用法示例。


在下文中一共展示了CVehicle::GetUpgrades方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: UpdateSimPlayer

///////////////////////////////////////////////////////////////////////////
//
// CSimPlayerManager::UpdateSimPlayer
//
// Thread:              main
// CS should be locked: no
//
// Update matching sim player object with new datum
//
///////////////////////////////////////////////////////////////////////////
void CSimPlayerManager::UpdateSimPlayer ( CPlayer* pPlayer )
{
    LockSimSystem ();     // TODO - only lock the CSimPlayer

    // Get matching sim player
    CSimPlayer* pSim = pPlayer->m_pSimPlayer;

    // Validate
    if ( !pSim )
    {
        UnlockSimSystem ();
        return;
    }

    //
    // Copy relevant data
    //
    CVehicle* pVehicle = pPlayer->GetOccupiedVehicle ();

    pSim->m_iStatus                 = pPlayer->GetStatus ();
    pSim->m_usBitStreamVersion      = pPlayer->GetBitStreamVersion ();
    pSim->m_bHasOccupiedVehicle     = pVehicle != NULL;
    pSim->m_PlayerID                = pPlayer->GetID ();
    pSim->m_usLatency               = pPlayer->GetPing ();
    pSim->m_ucWeaponType            = pPlayer->GetWeaponType ();
    pSim->m_usVehicleModel          = pVehicle ? pVehicle->GetModel () : 0;
    pSim->m_ucSyncTimeContext       = pPlayer->GetSyncTimeContext ();
    pSim->m_ucOccupiedVehicleSeat   = pPlayer->GetOccupiedVehicleSeat ();
    pSim->m_fWeaponRange            = pPlayer->GetWeaponRangeFromSlot();
    pSim->m_bVehicleHasHydraulics   = pVehicle ? pVehicle->GetUpgrades ()->HasUpgrade ( 1087 ) : false;
    pSim->m_bVehicleIsPlaneOrHeli   = pVehicle ? pVehicle->GetVehicleType () == VEHICLE_PLANE || pVehicle->GetVehicleType () == VEHICLE_HELI : false;
    pSim->m_sharedControllerState.Copy ( pPlayer->GetPad ()->GetCurrentControllerState () );
    pSim->m_fCameraRotation         = pPlayer->GetCameraRotation ();
    pSim->m_fPlayerRotation         = pPlayer->GetRotation ();

    // Update Puresync send list
    if ( pPlayer->m_bPureSyncSimSendListDirty )
    {
        pPlayer->m_bPureSyncSimSendListDirty = false;
        pSim->m_PuresyncSendListFlat.clear ();
        pSim->m_bSendListChanged = true;
        for ( CFastHashSet < CPlayer* > ::const_iterator iter = pPlayer->m_PureSyncSimSendList.begin (); iter != pPlayer->m_PureSyncSimSendList.end (); ++iter )
        {
            CSimPlayer* pSendSimPlayer = (*iter)->m_pSimPlayer;
            if ( pSendSimPlayer && pSendSimPlayer->m_bDoneFirstUpdate )
                pSim->m_PuresyncSendListFlat.push_back ( pSendSimPlayer );
            else
                pPlayer->m_bPureSyncSimSendListDirty = true;    // Retry next time
        }
    }

    // Set this flag
    pSim->m_bDoneFirstUpdate = true;

    UnlockSimSystem ();
}
开发者ID:Jusonex,项目名称:mtasa-awesomium,代码行数:66,代码来源:CSimPlayerManager.cpp

示例2: Write


//.........这里部分代码省略.........
                    memcpy ( damage.data.ucWheelStates, pVehicle->m_ucWheelStates, MAX_WHEELS );
                    memcpy ( damage.data.ucPanelStates, pVehicle->m_ucPanelStates, MAX_PANELS );
                    memcpy ( damage.data.ucLightStates, pVehicle->m_ucLightStates, MAX_LIGHTS );
                    BitStream.Write ( &damage );

                    // If the vehicle has a turret, send its position too
                    unsigned short usModel = pVehicle->GetModel ();
                    if ( CVehicleManager::HasTurret ( usModel ) )
                    {
                        SVehicleTurretSync specific;
                        specific.data.fTurretX = pVehicle->GetTurretPositionX ();
                        specific.data.fTurretY = pVehicle->GetTurretPositionY ();
                        BitStream.Write ( &specific );
                    }

                    // If the vehicle has an adjustable property send its value
                    if ( CVehicleManager::HasAdjustableProperty ( usModel ) )
                    {
                        BitStream.WriteCompressed ( pVehicle->GetAdjustableProperty () );
                    }

                    // If the vehicle has doors, sync their open angle ratios.
                    if ( CVehicleManager::HasDoors ( usModel ) )
                    {
                        SDoorOpenRatioSync door;
                        for ( unsigned char i = 0; i < 6; ++i )
                        {
                            door.data.fRatio = pVehicle->GetDoorOpenRatio ( i );
                            BitStream.Write ( &door );
                        }
                    }

                    // Write all the upgrades
                    CVehicleUpgrades* pUpgrades = pVehicle->GetUpgrades ();
                    unsigned char ucNumUpgrades = pUpgrades->Count ();
                    unsigned short* usSlotStates = pUpgrades->GetSlotStates ();
                    BitStream.Write ( ucNumUpgrades );

                    if ( ucNumUpgrades > 0 )
                    {
                        unsigned char ucSlot = 0;
                        for ( ; ucSlot < VEHICLE_UPGRADE_SLOTS ; ucSlot++ )
                        {
                            unsigned short usUpgrade = usSlotStates [ ucSlot ];

                            /*
                            * This is another retarded modification in an attempt to save
                            * a byte.  We're apparently subtracting 1000 so we can store the
                            * information in a single byte instead of two.  This only gives us
                            * a maximum of 256 vehicle slots.
                            *
                            * --slush
                            * -- ChrML: Ehm, GTA only has 17 upgrade slots... This is a valid optimization.
                            */
                            if ( usUpgrade )
                                BitStream.Write ( static_cast < unsigned char > ( usSlotStates [ ucSlot ] - 1000 ) );
                        }
                    }

                    // Get the vehicle's reg plate as 8 bytes of chars with the not used bytes
                    // nulled.
                    const char* cszRegPlate = pVehicle->GetRegPlate ();
                    BitStream.Write ( cszRegPlate, 8 );

                    // Light override
                    SOverrideLightsSync overrideLights;
开发者ID:qaisjp,项目名称:green-candy,代码行数:67,代码来源:CEntityAddPacket.cpp


注:本文中的CVehicle::GetUpgrades方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。