From dd4e2d615b6dacff9c7223c3241b81897264ace8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Tue, 3 Jan 2023 22:40:03 +0100 Subject: [PATCH 1/3] Send updated teams state to clients after resetting round --- src/game/server/teams.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/game/server/teams.cpp b/src/game/server/teams.cpp index 4761daf64..faa47cb4f 100644 --- a/src/game/server/teams.cpp +++ b/src/game/server/teams.cpp @@ -24,6 +24,7 @@ void CGameTeams::Reset() m_aTeeStarted[i] = false; m_aTeeFinished[i] = false; m_aLastChat[i] = 0; + SendTeamsState(i); } for(int i = 0; i < NUM_TEAMS; ++i) From dfe0ec33854221f57d7ad334de43fd0155bc9643 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Tue, 3 Jan 2023 22:54:53 +0100 Subject: [PATCH 2/3] Restart client race demo when round is restarted --- src/game/client/gameclient.cpp | 21 ++++++++++++++------- src/game/client/gameclient.h | 1 + 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 4bf77e61b..cbbdba2b8 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -883,6 +883,17 @@ void CGameClient::OnStartGame() m_Statboard.OnReset(); } +void CGameClient::OnStartRound() +{ + // In GamePaused or GameOver state RoundStartTick is updated on each tick + // hence no need to reset stats until player leaves GameOver + // and it would be a mistake to reset stats after or during the pause + m_Statboard.OnReset(); + + // Restart automatic race demo recording + m_RaceDemo.OnReset(); +} + void CGameClient::OnFlagGrab(int TeamID) { if(TeamID == TEAM_RED) @@ -1404,14 +1415,10 @@ void CGameClient::OnNewSnapshot() OnGameOver(); else if(s_GameOver && !CurrentTickGameOver) OnStartGame(); - // Reset statboard when new round is started (RoundStartTick changed) + // Handle case that a new round is started (RoundStartTick changed) // New round is usually started after `restart` on server - if(m_Snap.m_pGameInfoObj->m_RoundStartTick != m_LastRoundStartTick - // In GamePaused or GameOver state RoundStartTick is updated on each tick - // hence no need to reset stats until player leaves GameOver - // and it would be a mistake to reset stats after or during the pause - && !(CurrentTickGameOver || m_Snap.m_pGameInfoObj->m_GameStateFlags & GAMESTATEFLAG_PAUSED || s_GamePaused)) - m_Statboard.OnReset(); + if(m_Snap.m_pGameInfoObj->m_RoundStartTick != m_LastRoundStartTick && !(CurrentTickGameOver || m_Snap.m_pGameInfoObj->m_GameStateFlags & GAMESTATEFLAG_PAUSED || s_GamePaused)) + OnStartRound(); m_LastRoundStartTick = m_Snap.m_pGameInfoObj->m_RoundStartTick; s_GameOver = CurrentTickGameOver; s_GamePaused = (bool)(m_Snap.m_pGameInfoObj->m_GameStateFlags & GAMESTATEFLAG_PAUSED); diff --git a/src/game/client/gameclient.h b/src/game/client/gameclient.h index 605748753..fcf0a15f9 100644 --- a/src/game/client/gameclient.h +++ b/src/game/client/gameclient.h @@ -470,6 +470,7 @@ public: void OnRconLine(const char *pLine) override; virtual void OnGameOver(); virtual void OnStartGame(); + virtual void OnStartRound(); virtual void OnFlagGrab(int TeamID); void OnWindowResize(); From 21636912c035cb6b25ea587edf57c748e0a5745b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Tue, 3 Jan 2023 23:27:00 +0100 Subject: [PATCH 3/3] Refactor team state unpacking --- src/game/client/gameclient.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index cbbdba2b8..0a33445b9 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -810,18 +810,10 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker, int Conn, bool Dumm for(i = 0; i < MAX_CLIENTS; i++) { - int Team = pUnpacker->GetInt(); - bool WentWrong = false; - - if(pUnpacker->Error()) - WentWrong = true; - - if(!WentWrong && Team >= TEAM_FLOCK && Team <= TEAM_SUPER) + const int Team = pUnpacker->GetInt(); + if(!pUnpacker->Error() && Team >= TEAM_FLOCK && Team <= TEAM_SUPER) m_Teams.Team(i, Team); else - WentWrong = true; - - if(WentWrong) { m_Teams.Team(i, 0); break;