From e4a9ce3efebfd28c84d05a17f8f7f123520a06e2 Mon Sep 17 00:00:00 2001 From: Dydzio Date: Wed, 18 Jul 2018 23:58:38 +0200 Subject: [PATCH] Do not create main menu UI for game restart (#462) --- client/CServerHandler.cpp | 19 +++++++++++-------- client/CServerHandler.h | 2 +- client/NetPacksLobbyClient.cpp | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/client/CServerHandler.cpp b/client/CServerHandler.cpp index f41076b50..e5d792c91 100644 --- a/client/CServerHandler.cpp +++ b/client/CServerHandler.cpp @@ -478,7 +478,7 @@ void CServerHandler::startGameplay() state = EClientState::GAMEPLAY; } -void CServerHandler::endGameplay(bool closeConnection) +void CServerHandler::endGameplay(bool closeConnection, bool restart) { client->endGame(); vstd::clear_pointer(client); @@ -490,14 +490,17 @@ void CServerHandler::endGameplay(bool closeConnection) CSH->sendClientDisconnecting(); logNetwork->info("Closed connection."); } - if(CMM) + if(!restart) { - GH.curInt = CMM; - CMM->enable(); - } - else - { - GH.curInt = CMainMenu::create(); + if(CMM) + { + GH.curInt = CMM; + CMM->enable(); + } + else + { + GH.curInt = CMainMenu::create(); + } } } diff --git a/client/CServerHandler.h b/client/CServerHandler.h index 17fa69f08..acb3c22d4 100644 --- a/client/CServerHandler.h +++ b/client/CServerHandler.h @@ -132,7 +132,7 @@ public: void sendStartGame(bool allowOnlyAI = false) const override; void startGameplay(); - void endGameplay(bool closeConnection = true); + void endGameplay(bool closeConnection = true, bool restart = false); void startCampaignScenario(std::shared_ptr cs = {}); // TODO: LobbyState must be updated within game so we should always know how many player interfaces our client handle diff --git a/client/NetPacksLobbyClient.cpp b/client/NetPacksLobbyClient.cpp index f1ab51cea..bc7d1c82f 100644 --- a/client/NetPacksLobbyClient.cpp +++ b/client/NetPacksLobbyClient.cpp @@ -100,7 +100,7 @@ bool LobbyStartGame::applyOnLobbyHandler(CServerHandler * handler) { if(handler->state == EClientState::GAMEPLAY) { - handler->endGameplay(false); + handler->endGameplay(false, true); } handler->state = EClientState::STARTING; if(handler->si->mode != StartInfo::LOAD_GAME)