Restart client race demo when round is restarted

This commit is contained in:
Robert Müller 2023-01-03 22:54:53 +01:00
parent dd4e2d615b
commit dfe0ec3385
2 changed files with 15 additions and 7 deletions

View file

@ -883,6 +883,17 @@ void CGameClient::OnStartGame()
m_Statboard.OnReset(); 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) void CGameClient::OnFlagGrab(int TeamID)
{ {
if(TeamID == TEAM_RED) if(TeamID == TEAM_RED)
@ -1404,14 +1415,10 @@ void CGameClient::OnNewSnapshot()
OnGameOver(); OnGameOver();
else if(s_GameOver && !CurrentTickGameOver) else if(s_GameOver && !CurrentTickGameOver)
OnStartGame(); 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 // New round is usually started after `restart` on server
if(m_Snap.m_pGameInfoObj->m_RoundStartTick != m_LastRoundStartTick if(m_Snap.m_pGameInfoObj->m_RoundStartTick != m_LastRoundStartTick && !(CurrentTickGameOver || m_Snap.m_pGameInfoObj->m_GameStateFlags & GAMESTATEFLAG_PAUSED || s_GamePaused))
// In GamePaused or GameOver state RoundStartTick is updated on each tick OnStartRound();
// 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();
m_LastRoundStartTick = m_Snap.m_pGameInfoObj->m_RoundStartTick; m_LastRoundStartTick = m_Snap.m_pGameInfoObj->m_RoundStartTick;
s_GameOver = CurrentTickGameOver; s_GameOver = CurrentTickGameOver;
s_GamePaused = (bool)(m_Snap.m_pGameInfoObj->m_GameStateFlags & GAMESTATEFLAG_PAUSED); s_GamePaused = (bool)(m_Snap.m_pGameInfoObj->m_GameStateFlags & GAMESTATEFLAG_PAUSED);

View file

@ -470,6 +470,7 @@ public:
void OnRconLine(const char *pLine) override; void OnRconLine(const char *pLine) override;
virtual void OnGameOver(); virtual void OnGameOver();
virtual void OnStartGame(); virtual void OnStartGame();
virtual void OnStartRound();
virtual void OnFlagGrab(int TeamID); virtual void OnFlagGrab(int TeamID);
void OnWindowResize(); void OnWindowResize();