Fix possible crashes

This commit is contained in:
def 2014-01-30 16:54:58 +01:00
parent d8533eea67
commit caa1f15d12
5 changed files with 12 additions and 8 deletions

View file

@ -478,7 +478,8 @@ int CServer::GetClientInfo(int ClientID, CClientInfo *pInfo)
pInfo->m_pName = m_aClients[ClientID].m_aName;
pInfo->m_Latency = m_aClients[ClientID].m_Latency;
CGameContext *GameServer = (CGameContext *) m_pGameServer;
pInfo->m_ClientVersion = GameServer->m_apPlayers[ClientID]->m_ClientVersion;
if (GameServer->m_apPlayers[ClientID])
pInfo->m_ClientVersion = GameServer->m_apPlayers[ClientID]->m_ClientVersion;
return 1;
}
return 0;
@ -1041,7 +1042,8 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
if(Unpacker.Error() == 0 && !str_comp(pCmd, "crashmeplx"))
{
CGameContext *GameServer = (CGameContext *) m_pGameServer;
GameServer->m_apPlayers[ClientID]->m_ClientVersion = VERSION_DDNET_OLD;
if (GameServer->m_apPlayers[ClientID])
GameServer->m_apPlayers[ClientID]->m_ClientVersion = VERSION_DDNET_OLD;
} else
if(Unpacker.Error() == 0 && m_aClients[ClientID].m_Authed)
{

View file

@ -406,7 +406,7 @@ void CGameContext::SendVoteSet(int ClientID)
void CGameContext::SendVoteStatus(int ClientID, int Total, int Yes, int No)
{
if (Total > VANILLA_MAX_CLIENTS && m_apPlayers[ClientID]->m_ClientVersion <= VERSION_DDRACE)
if (Total > VANILLA_MAX_CLIENTS && m_apPlayers[ClientID] && m_apPlayers[ClientID]->m_ClientVersion <= VERSION_DDRACE)
{
Yes = float(Yes) * VANILLA_MAX_CLIENTS / float(Total);
No = float(No) * VANILLA_MAX_CLIENTS / float(Total);
@ -2519,7 +2519,7 @@ void CGameContext::WhisperID(int ClientID, int VictimID, char *pMessage)
char aBuf[256];
if (m_apPlayers[ClientID]->m_ClientVersion >= VERSION_DDNET_WHISPER)
if (m_apPlayers[ClientID] && m_apPlayers[ClientID]->m_ClientVersion >= VERSION_DDNET_WHISPER)
{
CNetMsg_Sv_Chat Msg;
Msg.m_Team = CHAT_WHISPER_SEND;
@ -2532,7 +2532,7 @@ void CGameContext::WhisperID(int ClientID, int VictimID, char *pMessage)
SendChatTarget(ClientID, aBuf);
}
if (m_apPlayers[VictimID]->m_ClientVersion >= VERSION_DDNET_WHISPER)
if (m_apPlayers[VictimID] && m_apPlayers[VictimID]->m_ClientVersion >= VERSION_DDNET_WHISPER)
{
CNetMsg_Sv_Chat Msg2;
Msg2.m_Team = CHAT_WHISPER_RECV;

View file

@ -186,7 +186,8 @@ void CGameWorld::UpdatePlayerMaps()
if(SnapChar && !SnapChar->m_Super &&
GameServer()->m_apPlayers[SnappingClient]->GetTeam() != -1 &&
!ch->CanCollide(SnappingClient) &&
(GameServer()->m_apPlayers[SnappingClient]->m_ClientVersion == VERSION_VANILLA ||
(!GameServer()->m_apPlayers[SnappingClient] ||
GameServer()->m_apPlayers[SnappingClient]->m_ClientVersion == VERSION_VANILLA ||
(GameServer()->m_apPlayers[SnappingClient]->m_ClientVersion >= VERSION_DDRACE &&
!GameServer()->m_apPlayers[SnappingClient]->m_ShowOthers
)

View file

@ -266,7 +266,8 @@ void CPlayer::FakeSnap(int SnappingClient)
{
IServer::CClientInfo info;
Server()->GetClientInfo(SnappingClient, &info);
if (((CGameContext *) GameServer())->m_apPlayers[SnappingClient]->m_ClientVersion >= VERSION_DDNET_OLD)
CGameContext *GameContext = (CGameContext *) GameServer();
if (GameContext->m_apPlayers[SnappingClient] && GameContext->m_apPlayers[SnappingClient]->m_ClientVersion >= VERSION_DDNET_OLD)
return;
int id = VANILLA_MAX_CLIENTS - 1;

View file

@ -314,7 +314,7 @@ void CGameTeams::SendTeamsState(int ClientID)
if (g_Config.m_SvTeam == 3)
return;
if (m_pGameContext->m_apPlayers[ClientID]->m_ClientVersion <= VERSION_DDRACE)
if (m_pGameContext->m_apPlayers[ClientID] && m_pGameContext->m_apPlayers[ClientID]->m_ClientVersion <= VERSION_DDRACE)
return;
CMsgPacker Msg(NETMSGTYPE_SV_TEAMSSTATE);