diff options
| author | Teetime <TeetimeTW@yahoo.de> | 2013-03-24 01:48:27 +0100 |
|---|---|---|
| committer | Teetime <TeetimeTW@yahoo.de> | 2013-03-24 01:48:27 +0100 |
| commit | dfb161739ceed848587e11d418ef30e0f5142f16 (patch) | |
| tree | 28490f707b156cadc297d04b82371dc7027f59f6 /src/game/server/gamemodes/zcatch.cpp | |
| parent | b22f178e0f0a639c3dcd2323b076fb9da5888b14 (diff) | |
| download | zcatch-dfb161739ceed848587e11d418ef30e0f5142f16.tar.gz zcatch-dfb161739ceed848587e11d418ef30e0f5142f16.zip | |
Let calculate the playercolor on each tick to be always up to date, even with leaving and joining players and let DoWinCheck check if the game is over before checking
Diffstat (limited to 'src/game/server/gamemodes/zcatch.cpp')
| -rw-r--r-- | src/game/server/gamemodes/zcatch.cpp | 63 |
1 files changed, 39 insertions, 24 deletions
diff --git a/src/game/server/gamemodes/zcatch.cpp b/src/game/server/gamemodes/zcatch.cpp index 4a810e04..6200d0e0 100644 --- a/src/game/server/gamemodes/zcatch.cpp +++ b/src/game/server/gamemodes/zcatch.cpp @@ -18,8 +18,9 @@ CGameController_zCatch::CGameController_zCatch(class CGameContext *pGameServer) void CGameController_zCatch::Tick() { - DoWincheck(); IGameController::Tick(); + if(m_GameOverTick == -1) + CalcPlayerColor(); if(m_OldMode != g_Config.m_SvMode) { @@ -30,35 +31,38 @@ void CGameController_zCatch::Tick() void CGameController_zCatch::DoWincheck() { - int Players = 0, Players_Spec = 0, Players_SpecExplicit = 0; - - for(int i = 0; i < MAX_CLIENTS; i++) + if(m_GameOverTick == -1) { - if(GameServer()->m_apPlayers[i]) + int Players = 0, Players_Spec = 0, Players_SpecExplicit = 0; + + for(int i = 0; i < MAX_CLIENTS; i++) { - Players++; - if(GameServer()->m_apPlayers[i]->GetTeam() == TEAM_SPECTATORS) - Players_Spec++; - if(GameServer()->m_apPlayers[i]->m_SpecExplicit == 1) - Players_SpecExplicit++; + if(GameServer()->m_apPlayers[i]) + { + Players++; + if(GameServer()->m_apPlayers[i]->GetTeam() == TEAM_SPECTATORS) + Players_Spec++; + if(GameServer()->m_apPlayers[i]->m_SpecExplicit == 1) + Players_SpecExplicit++; + } } - } - if(Players == 1) - { - //Do nothing - } - else if((Players - Players_Spec == 1) && (Players != Players_Spec) && (Players - Players_SpecExplicit != 1)) - { - for(int i = 0; i < MAX_CLIENTS; i++) + if(Players == 1) { - if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS) - GameServer()->m_apPlayers[i]->m_Score += g_Config.m_SvBonus; + //Do nothing + } + else if((Players - Players_Spec == 1) && (Players != Players_Spec) && (Players - Players_SpecExplicit != 1)) + { + for(int i = 0; i < MAX_CLIENTS; i++) + { + if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS) + GameServer()->m_apPlayers[i]->m_Score += g_Config.m_SvBonus; + } + EndRound(); } - EndRound(); - } - IGameController::DoWincheck(); //do also usual wincheck + IGameController::DoWincheck(); //do also usual wincheck + } } int CGameController_zCatch::OnCharacterDeath(class CCharacter *pVictim, class CPlayer *pKiller, int WeaponID) @@ -111,7 +115,6 @@ int CGameController_zCatch::OnCharacterDeath(class CCharacter *pVictim, class CP } // Update colors - OnPlayerInfoChange(pKiller); OnPlayerInfoChange(pVictim->GetPlayer()); return 0; @@ -246,3 +249,15 @@ bool CGameController_zCatch::OnEntity(int Index, vec2 Pos) return false; } + +void CGameController_zCatch::CalcPlayerColor() +{ + for(int i = 0; i < MAX_CLIENTS; i++) + { + CPlayer *pP = GameServer()->m_apPlayers[i]; + if(!pP) + continue; + if(pP->GetTeam() != TEAM_SPECTATORS) + OnPlayerInfoChange(pP); + } +} |