mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-10 22:31:40 +02:00
Fix possible crash on loading save with invalid buildings, e.g. Mage
Guild 4 in towns without one
This commit is contained in:
@@ -1247,6 +1247,14 @@ void CGTownInstance::postDeserialize()
|
||||
setNodeType(CBonusSystemNode::TOWN);
|
||||
for(auto & building : rewardableBuildings)
|
||||
building.second->town = this;
|
||||
|
||||
if (getFactionID().hasValue())
|
||||
{
|
||||
vstd::erase_if(builtBuildings, [this](const BuildingID & buildID)
|
||||
{
|
||||
return getTown()->buildings.count(buildID) == 0;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
std::map<BuildingID, TownRewardableBuildingInstance*> CGTownInstance::convertOldBuildings(std::vector<TownRewardableBuildingInstance*> oldVector)
|
||||
|
Reference in New Issue
Block a user