From 10433e0c711e41af4339de5ff1f3abb3de1e6567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Sat, 19 Nov 2022 12:11:24 +0100 Subject: [PATCH] Reset teams when restarting round The state of teams was not reset when restarting a round with `restart`, which led to various issues (#5144): - Switchers kept their previous state instead of being reset to the initial state after restarting. - Teams that started racing sometimes could not be joined after restarting. - Sometimes teams cannot finish a race after restarting. I cannot reproduce this issue, so I don't know if it's fixed by these changes. --- src/game/server/gamecontroller.h | 2 +- src/game/server/gamemodes/DDRace.cpp | 6 ++++++ src/game/server/gamemodes/DDRace.h | 2 ++ src/game/server/teams.cpp | 9 +++------ 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/game/server/gamecontroller.h b/src/game/server/gamecontroller.h index f3a2cf6ed..e4cbc80b8 100644 --- a/src/game/server/gamecontroller.h +++ b/src/game/server/gamecontroller.h @@ -108,7 +108,7 @@ public: virtual void OnPlayerConnect(class CPlayer *pPlayer); virtual void OnPlayerDisconnect(class CPlayer *pPlayer, const char *pReason); - void OnReset(); + virtual void OnReset(); // game void DoWarmup(int Seconds); diff --git a/src/game/server/gamemodes/DDRace.cpp b/src/game/server/gamemodes/DDRace.cpp index 945a953ac..ecd81b9f8 100644 --- a/src/game/server/gamemodes/DDRace.cpp +++ b/src/game/server/gamemodes/DDRace.cpp @@ -159,6 +159,12 @@ void CGameControllerDDRace::OnPlayerDisconnect(CPlayer *pPlayer, const char *pRe m_Teams.SetForceCharacterTeam(ClientID, TEAM_FLOCK); } +void CGameControllerDDRace::OnReset() +{ + IGameController::OnReset(); + m_Teams.Reset(); +} + void CGameControllerDDRace::Tick() { IGameController::Tick(); diff --git a/src/game/server/gamemodes/DDRace.h b/src/game/server/gamemodes/DDRace.h index eafb0d89b..df9bd602f 100644 --- a/src/game/server/gamemodes/DDRace.h +++ b/src/game/server/gamemodes/DDRace.h @@ -23,6 +23,8 @@ public: void OnPlayerConnect(class CPlayer *pPlayer) override; void OnPlayerDisconnect(class CPlayer *pPlayer, const char *pReason) override; + void OnReset() override; + void Tick() override; void DoTeamChange(class CPlayer *pPlayer, int Team, bool DoChatMsg = true) override; diff --git a/src/game/server/teams.cpp b/src/game/server/teams.cpp index 15d9a72e6..8e6ca9955 100644 --- a/src/game/server/teams.cpp +++ b/src/game/server/teams.cpp @@ -31,19 +31,16 @@ void CGameTeams::Reset() m_aTeamState[i] = TEAMSTATE_EMPTY; m_aTeamLocked[i] = false; m_apSaveTeamResult[i] = nullptr; - - m_aInvited[i] = 0; - m_aPractice[i] = false; - m_aLastSwap[i] = 0; m_aTeamSentStartWarning[i] = false; - m_aTeamUnfinishableKillTick[i] = -1; + ResetRoundState(i); } } void CGameTeams::ResetRoundState(int Team) { ResetInvited(Team); - ResetSwitchers(Team); + if(Team != TEAM_SUPER) + ResetSwitchers(Team); m_aLastSwap[Team] = 0; m_aPractice[Team] = false;