Fix crash when in-game menu opened when going to result screen in network game

This commit is contained in:
Benau 2018-07-11 15:37:55 +08:00
parent db8a92a2d6
commit a8959f604c
3 changed files with 17 additions and 12 deletions

View File

@ -413,6 +413,14 @@ void MainLoop::run()
double time_spent = StkTime::getRealTime();
for(int i = 0; i < num_steps; i++)
{
PROFILER_PUSH_CPU_MARKER("Protocol manager update",
0x7F, 0x00, 0x7F);
if (auto pm = ProtocolManager::lock())
{
pm->update(1);
}
PROFILER_POP_CPU_MARKER();
PROFILER_PUSH_CPU_MARKER("Update race", 0, 255, 255);
if (World::getWorld()) updateRace(1);
PROFILER_POP_CPU_MARKER();
@ -422,14 +430,6 @@ void MainLoop::run()
// since the GUI engine is no more to be called then.
if (m_abort) break;
PROFILER_PUSH_CPU_MARKER("Protocol manager update",
0x7F, 0x00, 0x7F);
if (auto pm = ProtocolManager::lock())
{
pm->update(1);
}
PROFILER_POP_CPU_MARKER();
if (m_frame_before_loading_world)
{
time_spent = StkTime::getRealTime();

View File

@ -663,8 +663,6 @@ void World::terminateRace()
results->clearHighscores();
}
// In case someone opened paused race dialog in network game
GUIEngine::ModalDialog::dismiss();
results->push();
WorldStatus::terminateRace();
} // terminateRace
@ -869,8 +867,9 @@ void World::updateWorld(int ticks)
}
// Don't update world if a menu is shown or the race is over.
if( getPhase() == FINISH_PHASE ||
getPhase() == IN_GAME_MENU_PHASE )
if (getPhase() == FINISH_PHASE ||
(!NetworkConfig::get()->isNetworking() &&
getPhase() == IN_GAME_MENU_PHASE))
return;
try

View File

@ -321,7 +321,13 @@ void ClientLobby::update(int ticks)
!GameProtocol::emptyInstance())
return;
if (!m_received_server_result)
{
m_received_server_result = true;
// In case someone opened paused race dialog or menu in network game
GUIEngine::ModalDialog::dismiss();
if (StateManager::get()->getGameState() == GUIEngine::INGAME_MENU)
StateManager::get()->enterGameState();
}
break;
case DONE:
m_state.store(EXITING);