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


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

本文整理汇总了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)
//.........这里部分代码省略.........
开发者ID:Azon099,项目名称:networked-iv,代码行数:101,代码来源:CPlayer.cpp


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