浏览代码

Fixed single map victory crash

Dydzio 6 年之前
父节点
当前提交
97869fc36f
共有 4 个文件被更改,包括 10 次插入2 次删除
  1. 5 1
      client/CPlayerInterface.cpp
  2. 2 0
      client/CServerHandler.cpp
  3. 1 1
      client/mainmenu/CMainMenu.cpp
  4. 2 0
      server/CVCMIServer.cpp

+ 5 - 1
client/CPlayerInterface.cpp

@@ -2467,12 +2467,16 @@ void CPlayerInterface::showShipyardDialogOrProblemPopup(const IShipyard *obj)
 
 void CPlayerInterface::requestReturningToMainMenu(bool won)
 {
-	CSH->state = EClientState::DISCONNECTING;
 	CCS->soundh->ambientStopAllChannels();
 	if(won && cb->getStartInfo()->campState)
+	{
+		CSH->state = EClientState::DISCONNECTING; // do not close server, it's not intended for campaign continuation
 		CSH->startCampaignScenario(cb->getStartInfo()->campState);
+	}
 	else
+	{
 		sendCustomEvent(EUserEvent::RETURN_TO_MAIN_MENU);
+	}
 }
 
 void CPlayerInterface::sendCustomEvent( int code )

+ 2 - 0
client/CServerHandler.cpp

@@ -495,6 +495,7 @@ void CServerHandler::endGameplay(bool closeConnection, bool restart)
 	{
 		if(CMM)
 		{
+			GH.terminate_cond->setn(false);
 			GH.curInt = CMM.get();
 			CMM->enable();
 		}
@@ -644,6 +645,7 @@ void CServerHandler::threadHandleConnection()
 			logNetwork->error(e.what());
 			if(client)
 			{
+				state = EClientState::DISCONNECTING;
 				CGuiHandler::pushSDLEvent(SDL_USEREVENT, EUserEvent::RETURN_TO_MAIN_MENU);
 			}
 			else

+ 1 - 1
client/mainmenu/CMainMenu.cpp

@@ -352,7 +352,7 @@ std::shared_ptr<CMainMenu> CMainMenu::create()
 	if(!CMM)
 		CMM = std::shared_ptr<CMainMenu>(new CMainMenu());
 
-	GH.terminate_cond->set(false);
+	GH.terminate_cond->setn(false);
 	return CMM;
 }
 

+ 2 - 0
server/CVCMIServer.cpp

@@ -191,6 +191,8 @@ void CVCMIServer::run()
 	{
 		gh->run(si->mode == StartInfo::LOAD_GAME);
 	}
+	while(state == EServerState::GAMEPLAY_ENDED)
+		boost::this_thread::sleep(boost::posix_time::milliseconds(50));
 }
 
 void CVCMIServer::threadAnnounceLobby()