From c10c7d9ac3410e103b2d2e5b69fb6d7833f6a2e3 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 19 Jun 2011 17:32:00 +0200 Subject: improved sudden death in ctf. Closes #617 --- src/game/server/gamemodes/ctf.cpp | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'src/game/server/gamemodes/ctf.cpp') diff --git a/src/game/server/gamemodes/ctf.cpp b/src/game/server/gamemodes/ctf.cpp index 58087c86..66cc4c2c 100644 --- a/src/game/server/gamemodes/ctf.cpp +++ b/src/game/server/gamemodes/ctf.cpp @@ -1,6 +1,9 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ +#include + #include + #include #include #include @@ -63,6 +66,30 @@ int CGameControllerCTF::OnCharacterDeath(class CCharacter *pVictim, class CPlaye return HadFlag; } +void CGameControllerCTF::DoWincheck() +{ + if(m_GameOverTick == -1 && !m_Warmup) + { + // check score win condition + if((g_Config.m_SvScorelimit > 0 && (m_aTeamscore[TEAM_RED] >= g_Config.m_SvScorelimit || m_aTeamscore[TEAM_BLUE] >= g_Config.m_SvScorelimit)) || + (g_Config.m_SvTimelimit > 0 && (Server()->Tick()-m_RoundStartTick) >= g_Config.m_SvTimelimit*Server()->TickSpeed()*60)) + { + if(m_SuddenDeath) + { + if(m_aTeamscore[TEAM_RED]/100 != m_aTeamscore[TEAM_BLUE]/100) + EndRound(); + } + else + { + if(m_aTeamscore[TEAM_RED] != m_aTeamscore[TEAM_BLUE]) + EndRound(); + else + m_SuddenDeath = 1; + } + } + } +} + bool CGameControllerCTF::CanBeMovedOnBalance(int ClientID) { CCharacter* Character = GameServer()->m_apPlayers[ClientID]->GetCharacter(); @@ -117,12 +144,7 @@ void CGameControllerCTF::Tick() { IGameController::Tick(); - if(GameServer()->m_World.m_ResetRequested) - return; - - DoTeamScoreWincheck(); - - if(GameServer()->m_World.m_Paused) + if(GameServer()->m_World.m_ResetRequested || GameServer()->m_World.m_Paused) return; for(int fi = 0; fi < 2; fi++) -- cgit 1.4.1