Fix bug with OnStartGame not called after game is over

This commit is contained in:
Nikita Zyuzin 2015-05-21 16:08:59 +04:00
parent 002fb4c0a6
commit e3413e59cc

View file

@ -1065,26 +1065,25 @@ void CGameClient::OnNewSnapshot()
static bool s_GamePaused = 0; static bool s_GamePaused = 0;
m_Snap.m_pGameInfoObj = (const CNetObj_GameInfo *)pData; m_Snap.m_pGameInfoObj = (const CNetObj_GameInfo *)pData;
// update last round start tick after pause to avoid onStartGame call bool CurrentTickPaused = m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_PAUSED;
if(!(m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_PAUSED) && s_GamePaused) // update last round start tick after pause to avoid OnStartGame call
if(!CurrentTickPaused && s_GamePaused)
{ {
m_LastRoundStartTick = m_Snap.m_pGameInfoObj->m_RoundStartTick; m_LastRoundStartTick = m_Snap.m_pGameInfoObj->m_RoundStartTick;
} }
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(); OnGameOver();
// m_RoundStartTick is updated each tick if game is in state OVER or else if(!(CurrentTickGameOver || CurrentTickPaused) // not in game over or pause state
// PAUSED. But out of these states it serves as an indicator of game && (m_LastRoundStartTick != m_Snap.m_pGameInfoObj->m_RoundStartTick // and (new round started
// start || (s_GameOver && !CurrentTickGameOver))) // or game was over and now is not over)
else if(!(m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER
|| m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_PAUSED)
&& m_LastRoundStartTick != m_Snap.m_pGameInfoObj->m_RoundStartTick)
{ {
m_LastRoundStartTick = m_Snap.m_pGameInfoObj->m_RoundStartTick; m_LastRoundStartTick = m_Snap.m_pGameInfoObj->m_RoundStartTick;
OnStartGame(); OnStartGame();
} }
s_GameOver = m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER; s_GameOver = CurrentTickGameOver;
s_GamePaused = m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_PAUSED; s_GamePaused = CurrentTickPaused;
} }
else if(Item.m_Type == NETOBJTYPE_GAMEDATA) else if(Item.m_Type == NETOBJTYPE_GAMEDATA)
{ {