From 9ee3133077c6784f80154533050268917c6eaf88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=2E=20Urba=C5=84czyk?= Date: Sun, 29 Sep 2013 20:53:45 +0000 Subject: [PATCH] Fixed crash on game start when buildings are customized, should finally solve #1444. --- lib/CGameState.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/CGameState.cpp b/lib/CGameState.cpp index 2a585e051..b880ea2b3 100644 --- a/lib/CGameState.cpp +++ b/lib/CGameState.cpp @@ -1347,6 +1347,10 @@ void CGameState::init(StartInfo * si) vti->builtBuildings.insert(BuildingID::DWELL_LVL_2); } + //#1444 - remove entries that don't have buildings defined (like some unused extra town hall buildings) + vstd::erase_if(vti->builtBuildings, [vti](BuildingID bid){ + return !vti->town->buildings.count(bid) || !vti->town->buildings.at(bid); }); + if (vstd::contains(vti->builtBuildings, BuildingID::SHIPYARD) && vti->shipyardStatus()==IBoatGenerator::TILE_BLOCKED) vti->builtBuildings.erase(BuildingID::SHIPYARD);//if we have harbor without water - erase it (this is H3 behaviour)