コード例 #1
0
ファイル: CNetGame.cpp プロジェクト: trisz404/OpenSAMP-WIP
void CNetGame::Packet_SpectatorSync(Packet* p)
{
	CPlayer* pPlayer = this->playerPool->GetPlayer((_PlayerID)p->playerIndex);
	RakNet::BitStream bsSpectatorSync((char*)p->data, p->length, false);

	if(this->gameState != 1) return;

	uint8_t			bytePacketID=0;
	SPECTATING_SYNC	spSync;
	
	bsSpectatorSync.Read(bytePacketID);
#ifdef _BIG_ENDIAN_SYSTEM
	bsSpectatorSync.Read(spSync.leftRightKeysOnSpectating);
	bsSpectatorSync.Read(spSync.updownKeysOnSpectating);
	bsSpectatorSync.Read(spSync.keysOnSpectating);
	bsSpectatorSync.Read(spSync.position.X), bsSpectatorSync.Read(spSync.position.Y), bsSpectatorSync.Read(spSync.position.Z);
#else
	bsSpectatorSync.Read((char*)&spSync,sizeof(SPECTATING_SYNC));
#endif

	if(pPlayer)
	{
		pPlayer->ProcessSpectatingSyncData(&spSync);
		if( this->gamemodeManager && this->filterscriptsManager )
		{
			if( this->gamemodeManager->OnPlayerUpdate( ( cell )p->playerIndex ) == 0 || this->filterscriptsManager->OnPlayerUpdate( ( cell )p->playerIndex ) == 0 )
				pPlayer->setSyncingType( SYNCING_TYPE_NONE );
		}
	}
}
コード例 #2
0
ファイル: netgame.cpp プロジェクト: jovazxc/samp
void CNetGame::Packet_SpectatorSync(Packet *p)
{
	CPlayer * pPlayer = GetPlayerPool()->GetAt((BYTE)p->playerIndex);
	RakNet::BitStream bsSpectatorSync(p->data, p->length, false);

	if(GetGameState() != GAMESTATE_RUNNING) return;

	BYTE bytePacketID=0;
	SPECTATOR_SYNC_DATA spSync;
	
	bsSpectatorSync.Read(bytePacketID);
	bsSpectatorSync.Read((PCHAR)&spSync,sizeof(SPECTATOR_SYNC_DATA));

	if(pPlayer)	{
	    pPlayer->StoreSpectatorFullSyncData(&spSync);
	}
}