mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Better make sure that something exists before using it
This commit is contained in:
parent
a8ad349ed8
commit
4c87cedd4d
|
@ -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();
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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];
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue