mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge pull request #366 from nzyuzin/master
Reset statboard after a game restart
This commit is contained in:
commit
2fbccb8133
|
@ -1063,12 +1063,24 @@ void CGameClient::OnNewSnapshot()
|
|||
else if(Item.m_Type == NETOBJTYPE_GAMEINFO)
|
||||
{
|
||||
static bool s_GameOver = 0;
|
||||
static bool s_GamePaused = 0;
|
||||
m_Snap.m_pGameInfoObj = (const CNetObj_GameInfo *)pData;
|
||||
if(!s_GameOver && m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER)
|
||||
bool CurrentTickGameOver = m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER;
|
||||
if(!s_GameOver && CurrentTickGameOver)
|
||||
OnGameOver();
|
||||
else if(s_GameOver && !(m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER))
|
||||
else if(s_GameOver && !CurrentTickGameOver)
|
||||
OnStartGame();
|
||||
s_GameOver = m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER;
|
||||
// Reset statboard when 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_pStatboard->OnReset();
|
||||
m_LastRoundStartTick = m_Snap.m_pGameInfoObj->m_RoundStartTick;
|
||||
s_GameOver = CurrentTickGameOver;
|
||||
s_GamePaused = m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_PAUSED;
|
||||
}
|
||||
else if(Item.m_Type == NETOBJTYPE_GAMEDATA)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue