mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 22:48:18 +00:00
added additional win checks for ctf. closes #1515
This commit is contained in:
parent
c4d46668dc
commit
40b6e75552
|
@ -426,7 +426,7 @@ void IGameController::OnReset()
|
|||
}
|
||||
|
||||
// game
|
||||
void IGameController::DoWincheckMatch()
|
||||
bool IGameController::DoWincheckMatch()
|
||||
{
|
||||
if(IsTeamplay())
|
||||
{
|
||||
|
@ -435,7 +435,10 @@ void IGameController::DoWincheckMatch()
|
|||
(m_GameInfo.m_TimeLimit > 0 && (Server()->Tick()-m_GameStartTick) >= m_GameInfo.m_TimeLimit*Server()->TickSpeed()*60))
|
||||
{
|
||||
if(m_aTeamscore[TEAM_RED] != m_aTeamscore[TEAM_BLUE] || m_GameFlags&GAMEFLAG_SURVIVAL)
|
||||
{
|
||||
EndMatch();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
m_SuddenDeath = 1;
|
||||
}
|
||||
|
@ -464,11 +467,15 @@ void IGameController::DoWincheckMatch()
|
|||
(m_GameInfo.m_TimeLimit > 0 && (Server()->Tick()-m_GameStartTick) >= m_GameInfo.m_TimeLimit*Server()->TickSpeed()*60))
|
||||
{
|
||||
if(TopscoreCount == 1)
|
||||
{
|
||||
EndMatch();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
m_SuddenDeath = 1;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void IGameController::ResetGame()
|
||||
|
@ -603,8 +610,7 @@ void IGameController::SetGameState(EGameState GameState, int Timer)
|
|||
}
|
||||
break;
|
||||
case IGS_END_ROUND:
|
||||
DoWincheckMatch();
|
||||
if(m_GameState == IGS_END_MATCH)
|
||||
if(DoWincheckMatch())
|
||||
break;
|
||||
case IGS_END_MATCH:
|
||||
// only possible when game is running or over
|
||||
|
|
|
@ -54,7 +54,7 @@ class IGameController
|
|||
EGameState m_GameState;
|
||||
int m_GameStateTimer;
|
||||
|
||||
virtual void DoWincheckMatch();
|
||||
virtual bool DoWincheckMatch(); // returns true when the match is over
|
||||
virtual void DoWincheckRound() {};
|
||||
bool HasEnoughPlayers() const { return (IsTeamplay() && m_aTeamSize[TEAM_RED] > 0 && m_aTeamSize[TEAM_BLUE] > 0) || (!IsTeamplay() && m_aTeamSize[TEAM_RED] > 1); }
|
||||
void ResetGame();
|
||||
|
|
|
@ -86,7 +86,7 @@ bool CGameControllerCTF::OnEntity(int Index, vec2 Pos)
|
|||
}
|
||||
|
||||
// game
|
||||
void CGameControllerCTF::DoWincheckMatch()
|
||||
bool CGameControllerCTF::DoWincheckMatch()
|
||||
{
|
||||
// check score win condition
|
||||
if((m_GameInfo.m_ScoreLimit > 0 && (m_aTeamscore[TEAM_RED] >= m_GameInfo.m_ScoreLimit || m_aTeamscore[TEAM_BLUE] >= m_GameInfo.m_ScoreLimit)) ||
|
||||
|
@ -95,16 +95,23 @@ void CGameControllerCTF::DoWincheckMatch()
|
|||
if(m_SuddenDeath)
|
||||
{
|
||||
if(m_aTeamscore[TEAM_RED]/100 != m_aTeamscore[TEAM_BLUE]/100)
|
||||
{
|
||||
EndMatch();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_aTeamscore[TEAM_RED] != m_aTeamscore[TEAM_BLUE])
|
||||
{
|
||||
EndMatch();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
m_SuddenDeath = 1;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// general
|
||||
|
@ -182,6 +189,9 @@ void CGameControllerCTF::Tick()
|
|||
GameServer()->SendGameMsg(GAMEMSG_CTF_CAPTURE, fi, F->GetCarrier()->GetPlayer()->GetCID(), Server()->Tick()-F->GetGrabTick(), -1);
|
||||
for(int i = 0; i < 2; i++)
|
||||
m_apFlags[i]->Reset();
|
||||
// do a win check(capture could trigger win condition)
|
||||
if(DoWincheckMatch())
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -232,4 +242,6 @@ void CGameControllerCTF::Tick()
|
|||
}
|
||||
}
|
||||
}
|
||||
// do a win check(grabbing flags could trigger win condition)
|
||||
DoWincheckMatch();
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ class CGameControllerCTF : public IGameController
|
|||
// game
|
||||
class CFlag *m_apFlags[2];
|
||||
|
||||
virtual void DoWincheckMatch();
|
||||
virtual bool DoWincheckMatch();
|
||||
|
||||
public:
|
||||
CGameControllerCTF(class CGameContext *pGameServer);
|
||||
|
|
Loading…
Reference in a new issue