Skip to content

Commit

Permalink
implemented #25 somehow dirty
Browse files Browse the repository at this point in the history
  • Loading branch information
AssassinTee committed Apr 26, 2019
1 parent 25157de commit 7882109
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/game/server/gamecontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ IGameController::IGameController(CGameContext *pGameServer)
m_aNumSpawnPoints[0] = 0;
m_aNumSpawnPoints[1] = 0;
m_aNumSpawnPoints[2] = 0;

m_TopTeam = -1;
}

//activity
Expand Down Expand Up @@ -435,6 +437,7 @@ bool IGameController::DoWincheckMatch()
int Topscore = 0;
int TopscoreCount = 0;
int TopTeam = -1;
int TopTeamCount = 0;
bool AllInOneTeam=true;
for(int i = 0; i < MAX_CLIENTS; i++)
{
Expand All @@ -455,16 +458,18 @@ bool IGameController::DoWincheckMatch()
TopTeam = GameServer()->m_apPlayers[i]->GetTeamID();
else if(TopTeam != GameServer()->m_apPlayers[i]->GetTeamID())
AllInOneTeam = false;
TopTeamCount++;
}
}
}

// check score win condition
if((m_GameInfo.m_ScoreLimit > 0 && Topscore >= m_GameInfo.m_ScoreLimit) ||
(m_GameInfo.m_TimeLimit > 0 && (Server()->Tick()-m_GameStartTick) >= m_GameInfo.m_TimeLimit*Server()->TickSpeed()*60) ||
(AllInOneTeam))
(AllInOneTeam && TopTeamCount > 1))
{
m_TopTeam = TopTeam;
if(m_GameState == IGS_GAME_RUNNING)
m_TopTeam = TopTeam;
if(TopscoreCount == 1 || AllInOneTeam)
{
EndMatch();
Expand Down Expand Up @@ -642,7 +647,7 @@ void IGameController::SetGameState(EGameState GameState, int Timer)
m_GameStateTimer = Timer*Server()->TickSpeed();
m_SuddenDeath = 0;
GameServer()->m_World.m_Paused = true;
if(GameServer()->m_apPlayers[m_TopTeam]) {
if(m_TopTeam >= 0 && m_TopTeam < MAX_PLAYERS && GameServer()->m_apPlayers[m_TopTeam]) {
char aBuf[256];
GameServer()->m_apPlayers[m_TopTeam]->m_Score+=g_Config.m_SvWinBonus;
char colorbuf[5];
Expand Down
2 changes: 1 addition & 1 deletion src/game/server/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ CPlayer::CPlayer(CGameContext *pGameServer, int ClientID, bool Dummy, bool AsSpe
m_RespawnDisabled = GameServer()->m_pController->GetStartRespawnState();
m_DeadSpecMode = false;
m_Spawning = 0;
m_TeamID = 0;
m_TeamID = -1;//Value will be changed in later stage
}

CPlayer::~CPlayer()
Expand Down

0 comments on commit 7882109

Please sign in to comment.