Forráskód Böngészése

made quick load logic follow restart logic more closely

Andrej Dudenhefner 2 hete
szülő
commit
0af15610e1

+ 0 - 7
client/CServerHandler.cpp

@@ -724,13 +724,6 @@ std::optional<std::string> CServerHandler::canQuickLoadGame(const std::string &
 
 void CServerHandler::quickLoadGame(const std::string & path)
 {
-	if(!settings["session"]["headless"].Bool())
-	{
-		if(si->campState && !si->campState->getLoadingBackground().empty())
-			ENGINE->windows().createAndPushWindow<CLoadingScreen>(si->campState->getLoadingBackground());
-		else
-			ENGINE->windows().createAndPushWindow<CLoadingScreen>();
-	}
 	LobbyQuickLoadGame pack;
 	pack.saveFilePath = path;
 	sendLobbyPack(pack);

+ 3 - 7
client/NetPacksLobbyClient.cpp

@@ -44,6 +44,9 @@
 void ApplyOnLobbyHandlerNetPackVisitor::visitLobbyQuickLoadGame(LobbyQuickLoadGame & pack)
 {
 	assert(handler.getState() == EClientState::GAMEPLAY);
+
+	handler.restartGameplay();
+	handler.sendStartGame();
 }
 
 void ApplyOnLobbyHandlerNetPackVisitor::visitLobbyClientConnected(LobbyClientConnected & pack)
@@ -160,13 +163,6 @@ void ApplyOnLobbyHandlerNetPackVisitor::visitLobbyPrepareStartGame(LobbyPrepareS
 
 void ApplyOnLobbyHandlerNetPackVisitor::visitLobbyStartGame(LobbyStartGame & pack)
 {
-	// Handle mid-game reload
-	if (handler.getState() == EClientState::GAMEPLAY) {
-			handler.client->finishGameplay();
-			handler.client->endGame();
-			handler.client.reset();
-	}
-
 	handler.setState(EClientState::STARTING);
 	if(handler.si->mode != EStartMode::LOAD_GAME)
 	{

+ 3 - 12
server/NetPacksLobbyServer.cpp

@@ -118,26 +118,17 @@ void ClientPermissionsCheckerNetPackVisitor::visitLobbyChatMessage(LobbyChatMess
 
 void ApplyOnServerNetPackVisitor::visitLobbyQuickLoadGame(LobbyQuickLoadGame & pack)
 {
+	srv.prepareToRestart();
 	// modify StartInfo to load the quicksave
 	srv.si->mode = EStartMode::LOAD_GAME;
 	srv.si->mapname = pack.saveFilePath;
-
-	// prepare game state (loads the save file)
-	if (!srv.prepareToStartGame()) {
-		//failure is destructive and an exception is the only way
-		throw std::runtime_error("Failed to prepare to start game during quick load.");
-	}
-
-	// create LobbyStartGame packet with loaded state and announce to all clients
-	LobbyStartGame startPack;
-	startPack.initializedStartInfo = std::make_shared<StartInfo>(*srv.gh->gameState().getInitialStartInfo());
-	startPack.initializedGameState = srv.gh->gs;
-	srv.announcePack(startPack);
 	result = true;
 }
 
 void ApplyOnServerAfterAnnounceNetPackVisitor::visitLobbyQuickLoadGame(LobbyQuickLoadGame & pack)
 {
+	for(const auto & connection : srv.activeConnections)
+		connection->enterLobbyConnectionMode();
 }
 
 void ApplyOnServerNetPackVisitor::visitLobbySetMap(LobbySetMap & pack)