Example #1
0
void Chat(RakNet::BitStream *bitStream, Packet *packet)
{
	EntityId playerID;
	BYTE byteTextLen;
	CHAR szText[256];

	bitStream->Read(playerID);
	bitStream->Read(byteTextLen);
	bitStream->Read(szText,byteTextLen);

	szText[byteTextLen] = '\0';

	CPlayerManager * pPlayerManager = pNetowkManager->GetPlayerManager();
	if(playerID == pPlayerManager->GetLocalPlayerID()) {
		pChatWindow->AddChatMessage(pNetowkManager->GetPlayerManager()->GetLocalPlayerName(),
			pPlayerManager->GetLocalPlayer()->GetTeamColorAsARGB(),szText);
	}
	else
	{
		CRemotePlayer *pRemotePlayer = pNetowkManager->GetPlayerManager()->GetAt(playerID);
		if(pRemotePlayer) {
			pRemotePlayer->Say(szText);	
		}
	}
}
Example #2
0
void UpdateScoreAndPing(RakNet::BitStream *bitStream, Packet *packet)
{	
	CPlayerManager * pPlayerManager = pNetowkManager->GetPlayerManager();
	EntityId playerID;
	int iPlayerScore;
	int iPlayerPing;
	unsigned long ulIp;

	while(bitStream->Read(playerID))
	{
		bitStream->Read(iPlayerScore);
		bitStream->Read(iPlayerPing);
		bitStream->Read(ulIp);

		if(pPlayerManager->GetSlotState(playerID) || playerID == pPlayerManager->GetLocalPlayerID())
		{
			pPlayerManager->UpdateScore(playerID, iPlayerScore);
			pPlayerManager->UpdatePing(playerID, iPlayerPing);
			pPlayerManager->UpdateIPAddress(playerID, ulIp);
		}
	}
}