本文整理汇总了C++中CVehicle::GetSyncer方法的典型用法代码示例。如果您正苦于以下问题:C++ CVehicle::GetSyncer方法的具体用法?C++ CVehicle::GetSyncer怎么用?C++ CVehicle::GetSyncer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CVehicle
的用法示例。
在下文中一共展示了CVehicle::GetSyncer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Deserialize
bool CPlayer::Deserialize(CBitStream * pBitStream)
{
// Copy the current net pad state to the previous net pad state
memcpy(&m_previousNetPadState, &m_currentNetPadState, sizeof(CNetworkPadState));
// Read the net pad state
if(!pBitStream->Read(m_currentNetPadState))
{
CLogFile::Printf("CPlayer::Deserialize fail (Error code 1)");
return false;
}
// Read the health
if(!pBitStream->Read(m_uiHealth))
{
CLogFile::Printf("CPlayer::Deserialize fail (Error code 10)");
return false;
}
// Read if we are on foot
bool bIsOnFoot = pBitStream->ReadBit();
// Are we on foot or in a vehicle when we are not meant to be?
if(bIsOnFoot != IsOnFoot())
{
CLogFile::Printf("CPlayer::Deserialize fail (Error code 2)");
return false;
}
// Are we on foot?
if(bIsOnFoot)
{
// Read the player position
if(!pBitStream->Read(m_vecPosition))
{
CLogFile::Printf("CPlayer::Deserialize fail (Error code 3)");
return false;
}
// Read the player heading
if(!pBitStream->Read(m_fHeading))
{
CLogFile::Printf("CClientPlayer::Deserialize fail (Error code 4)");
return false;
}
// Read the player move speed
if(!pBitStream->Read(m_vecMoveSpeed))
{
CLogFile::Printf("CClientPlayer::Deserialize fail (Error code 5)");
return false;
}
// Read the player duck state
m_bIsDucking = pBitStream->ReadBit();
// Read the player current weapon
pBitStream->Read(m_uiCurrentWeapon);
}
else
{
// Read the vehicle id
EntityId vehicleId;
if(!pBitStream->ReadCompressed(vehicleId))
{
CLogFile::Printf("CClientPlayer::Deserialize fail (Error code 6)");
return false;
}
// Read the vehicle seat id
BYTE byteSeatId;
if(!pBitStream->Read(byteSeatId))
{
CLogFile::Printf("CClientPlayer::Deserialize fail (Error code 7)");
return false;
}
// TODO: Check against vehicle seat id for validity?
// Get the vehicle pointer
CVehicle * pVehicle = g_pServer->GetVehicleManager()->Get(vehicleId);
// Is the vehicle pointer valid?
if(!pVehicle)
{
CLogFile::Printf("CClientPlayer::Deserialize fail (Error code 8)");
return false;
}
// Are we not already in the vehicle?
/*if(m_pVehicle != pVehicle)
{
// Force us in to the vehicle
PutInVehicle(pVehicle, byteSeatId);
}*/
// Are we responsible for syncing the vehicle?
if(pVehicle->GetSyncer() == this)
//.........这里部分代码省略.........