瀏覽代碼

Fix campaign serialization

nordsoft 3 年之前
父節點
當前提交
628abd1428
共有 3 個文件被更改,包括 9 次插入5 次删除
  1. 5 3
      client/Client.cpp
  2. 2 1
      client/NetPacksLobbyClient.cpp
  3. 2 1
      lib/mapping/CMap.h

+ 5 - 3
client/Client.cpp

@@ -200,6 +200,8 @@ void CClient::newGame(CGameState * initializedGameState)
 void CClient::loadGame(CGameState * initializedGameState)
 {
 	logNetwork->info("Loading procedure started!");
+	
+	std::unique_ptr<CLoadFile> loader;
 
 	if(initializedGameState)
 	{
@@ -208,7 +210,6 @@ void CClient::loadGame(CGameState * initializedGameState)
 	}
 	else
 	{
-		std::unique_ptr<CLoadFile> loader;
 		try
 		{
 			boost::filesystem::path clientSaveName = *CResourceHandler::get("local")->getResourceName(ResourceID(CSH->si->mapname, EResType::CLIENT_SAVEGAME));
@@ -234,8 +235,6 @@ void CClient::loadGame(CGameState * initializedGameState)
 				loadCommonState(checkingLoader);
 				loader = checkingLoader.decay();
 			}
-			
-			serialize(loader->serializer, loader->serializer.fileVersion);
 		}
 		catch(std::exception & e)
 		{
@@ -253,6 +252,9 @@ void CClient::loadGame(CGameState * initializedGameState)
 	reinitScripting();
 
 	initPlayerEnvironments();
+	
+	if(loader)
+		serialize(loader->serializer, loader->serializer.fileVersion);
 
 	initPlayerInterfaces();
 }

+ 2 - 1
client/NetPacksLobbyClient.cpp

@@ -57,7 +57,8 @@ bool LobbyClientDisconnected::applyOnLobbyHandler(CServerHandler * handler)
 
 void LobbyClientDisconnected::applyOnLobbyScreen(CLobbyScreen * lobby, CServerHandler * handler)
 {
-	GH.popInts(1);
+	if(GH.listInt.size())
+		GH.popInts(1);
 }
 
 void LobbyChatMessage::applyOnLobbyScreen(CLobbyScreen * lobby, CServerHandler * handler)

+ 2 - 1
lib/mapping/CMap.h

@@ -330,7 +330,7 @@ public:
 		h & players;
 		h & howManyTeams;
 		h & allowedHeroes;
-		h & triggeredEvents;
+		//Do not serialize triggeredEvents in header as they can contain information about heroes and armies
 		h & victoryMessage;
 		h & victoryIconIndex;
 		h & defeatMessage;
@@ -424,6 +424,7 @@ public:
 	void serialize(Handler &h, const int formatVersion)
 	{
 		h & static_cast<CMapHeader&>(*this);
+		h & triggeredEvents; //from CMapHeader
 		h & rumors;
 		h & allowedSpell;
 		h & allowedAbilities;