瀏覽代碼

Fixed init of playerInfo. Fixes crash during save game where not all 8 players are present.

Frank Zago 16 年之前
父節點
當前提交
7a89b33ab7
共有 2 個文件被更改,包括 5 次插入1 次删除
  1. 0 1
      lib/map.cpp
  2. 5 0
      lib/map.h

+ 0 - 1
lib/map.cpp

@@ -262,7 +262,6 @@ void CMapHeader::loadPlayerInfo( int &pom, unsigned char * bufor, int &i )
 		players[pom].canComputerPlay = bufor[i++];
 		if ((!(players[pom].canHumanPlay || players[pom].canComputerPlay)))
 		{
-			memset(&players[pom],0,sizeof(PlayerInfo));
 			switch(version)
 			{
 			case SoD: case WoG: 

+ 5 - 0
lib/map.h

@@ -122,6 +122,11 @@ struct DLL_EXPORT PlayerInfo
 	ui8 team;
 	ui8 generateHero;
 
+	PlayerInfo(): p7(0), p8(0), p9(0), canHumanPlay(0), canComputerPlay(0),
+		AITactic(0), allowedFactions(0), isFactionRandom(0),
+		mainHeroPortrait(0), hasMainTown(0), generateHeroAtMainTown(0),
+		team(0), generateHero(0) {};
+
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
 		h & p7 & p8 & p9 & canHumanPlay & canComputerPlay & AITactic & allowedFactions & isFactionRandom &