diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index e4b09e7a7..9be134cc3 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -1676,7 +1676,7 @@ void CCharacter::HandleTiles(int Index) { for (int i = 0; i < MAX_CLIENTS; i++) { - if(Teams()->m_Core.Team(i) == Team && i != m_Core.m_Id) + if(Teams()->m_Core.Team(i) == Team && i != m_Core.m_Id && GameServer()->m_apPlayers[i]) { CCharacter* pChar = GameServer()->m_apPlayers[i]->GetCharacter(); @@ -2029,7 +2029,7 @@ void CCharacter::DDRaceInit() { for (int i = 0; i < MAX_CLIENTS; i++) { - if(Teams()->m_Core.Team(i) == Team && i != m_Core.m_Id) + if(Teams()->m_Core.Team(i) == Team && i != m_Core.m_Id && GameServer()->m_apPlayers[i]) { CCharacter* pChar = GameServer()->m_apPlayers[i]->GetCharacter(); diff --git a/src/game/server/entities/projectile.cpp b/src/game/server/entities/projectile.cpp index 7a692fd58..5da8555b1 100644 --- a/src/game/server/entities/projectile.cpp +++ b/src/game/server/entities/projectile.cpp @@ -117,8 +117,6 @@ void CProjectile::Tick() int Collide = GameServer()->Collision()->IntersectLine(PrevPos, CurPos, &ColPos, &NewPos, false); CCharacter *pOwnerChar = 0; - - if(m_Owner >= 0) pOwnerChar = GameServer()->GetPlayerChar(m_Owner); diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index fa8ef9e9d..d827be93b 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -166,7 +166,7 @@ void CGameContext::CreateExplosion(vec2 Pos, int Owner, int Weapon, bool NoDamag ForceDir = normalize(Diff); l = 1-clamp((l-InnerRadius)/(Radius-InnerRadius), 0.0f, 1.0f); float Strength; - if (Owner == -1 || !m_apPlayers[Owner]->m_TuneZone) + if (Owner == -1 || !m_apPlayers[Owner] || !!m_apPlayers[Owner]->m_TuneZone) Strength = Tuning()->m_ExplosionStrength; else Strength = TuningList()[m_apPlayers[Owner]->m_TuneZone].m_ExplosionStrength; @@ -260,6 +260,10 @@ void CGameContext::CallVote(int ClientID, const char *aDesc, const char *aCmd, c int64 Now = Server()->Tick(); CPlayer *pPlayer = m_apPlayers[ClientID]; + + if(!pPlayer) + return; + SendChat(-1, CGameContext::CHAT_ALL, aChatmsg); StartVote(aDesc, aCmd, pReason); pPlayer->m_Vote = 1; @@ -2720,7 +2724,8 @@ void CGameContext::WhisperID(int ClientID, int VictimID, char *pMessage) if (!CheckClientID2(VictimID)) return; - m_apPlayers[ClientID]->m_LastWhisperTo = VictimID; + if (m_apPlayers[ClientID]) + m_apPlayers[ClientID]->m_LastWhisperTo = VictimID; char aBuf[256]; diff --git a/src/game/server/gameworld.cpp b/src/game/server/gameworld.cpp index cddb69026..ae2222fa7 100644 --- a/src/game/server/gameworld.cpp +++ b/src/game/server/gameworld.cpp @@ -169,7 +169,7 @@ void CGameWorld::UpdatePlayerMaps() for (int j = 0; j < MAX_CLIENTS; j++) { dist[j].second = j; - if (!Server()->ClientIngame(j)) + if (!Server()->ClientIngame(j) || !GameServer()->m_apPlayers[j]) { dist[j].first = 1e10; continue; diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index 466fd902a..ee546b8a6 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -558,6 +558,9 @@ void CPlayer::AfkVoteTimer(CNetObj_PlayerInput *NewTarget) void CPlayer::ProcessPause() { + if(!m_pCharacter) + return; + char aBuf[128]; if(m_Paused >= PAUSED_PAUSED) { diff --git a/src/game/server/score/sql_score.cpp b/src/game/server/score/sql_score.cpp index 74343301d..578b5a616 100644 --- a/src/game/server/score/sql_score.cpp +++ b/src/game/server/score/sql_score.cpp @@ -224,7 +224,8 @@ void CSqlScore::LoadScoreThread(void *pUser) float time = (float)pData->m_pSqlData->m_pResults->getDouble("Time"); pData->m_pSqlData->PlayerData(pData->m_ClientID)->m_BestTime = time; pData->m_pSqlData->PlayerData(pData->m_ClientID)->m_CurrentTime = time; - pData->m_pSqlData->m_pGameServer->m_apPlayers[pData->m_ClientID]->m_Score = -time; + if(pData->m_pSqlData->m_pGameServer->m_apPlayers[pData->m_ClientID]) + pData->m_pSqlData->m_pGameServer->m_apPlayers[pData->m_ClientID]->m_Score = -time; char aColumn[8]; if(g_Config.m_SvCheckpointSave) @@ -428,6 +429,10 @@ void CSqlScore::MapVoteThread(void *pUser) pData->m_pSqlData->m_pResults = pData->m_pSqlData->m_pStatement->executeQuery(aBuf); CPlayer *pPlayer = pData->m_pSqlData->m_pGameServer->m_apPlayers[pData->m_ClientID]; + + if(!pPlayer) + goto end; + int64 Now = pData->m_pSqlData->Server()->Tick(); int Timeleft = pPlayer->m_LastVoteCall + pData->m_pSqlData->Server()->TickSpeed()*g_Config.m_SvVoteDelay - Now; @@ -465,6 +470,7 @@ void CSqlScore::MapVoteThread(void *pUser) pData->m_pSqlData->GameServer()->CallVote(pData->m_ClientID, aMap, aCmd, "/map", aChatmsg); } + end: delete pData->m_pSqlData->m_pResults; } catch (sql::SQLException &e) diff --git a/src/game/server/teams.cpp b/src/game/server/teams.cpp index 0d7345c77..581ee063e 100644 --- a/src/game/server/teams.cpp +++ b/src/game/server/teams.cpp @@ -581,7 +581,7 @@ void CGameTeams::OnCharacterDeath(int ClientID, int Weapon) if (GetTeamState(Team) != TEAMSTATE_OPEN) for (int i = 0; i < MAX_CLIENTS; i++) - if(m_Core.Team(i) == Team && i != ClientID) + if(m_Core.Team(i) == Team && i != ClientID && GameServer()->m_apPlayers[i]) GameServer()->m_apPlayers[i]->KillCharacter(-2); ChangeTeamState(Team, CGameTeams::TEAMSTATE_OPEN);