From 7a89b33ab7844e0ff5e70cb49496a065a62a4a49 Mon Sep 17 00:00:00 2001 From: Frank Zago Date: Fri, 29 May 2009 03:53:53 +0000 Subject: [PATCH] Fixed init of playerInfo. Fixes crash during save game where not all 8 players are present. --- lib/map.cpp | 1 - lib/map.h | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/map.cpp b/lib/map.cpp index 4e7a0c21c..2a26991b6 100644 --- a/lib/map.cpp +++ b/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: diff --git a/lib/map.h b/lib/map.h index 1f6a049f2..3fd3219f0 100644 --- a/lib/map.h +++ b/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 void serialize(Handler &h, const int version) { h & p7 & p8 & p9 & canHumanPlay & canComputerPlay & AITactic & allowedFactions & isFactionRandom &