mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
Fixed possible crash on invalid town building name
This commit is contained in:
parent
a4ff408c9d
commit
8b0f9c86f8
@ -1183,11 +1183,19 @@ void CTownHandler::initializeRequirements()
|
||||
{
|
||||
if (node.Vector().size() > 1)
|
||||
{
|
||||
logMod->warn("Unexpected length of town buildings requirements: %d", node.Vector().size());
|
||||
logMod->warn("Entry contains: ");
|
||||
logMod->warn(node.toJson());
|
||||
logMod->error("Unexpected length of town buildings requirements: %d", node.Vector().size());
|
||||
logMod->error("Entry contains: ");
|
||||
logMod->error(node.toJson());
|
||||
}
|
||||
return BuildingID(VLC->modh->identifiers.getIdentifier(requirement.town->getBuildingScope(), node.Vector()[0]).value());
|
||||
|
||||
auto index = VLC->modh->identifiers.getIdentifier(requirement.town->getBuildingScope(), node[0]);
|
||||
|
||||
if (!index.has_value())
|
||||
{
|
||||
logMod->error("Unknown building in town buildings: %s", node[0].String());
|
||||
return BuildingID::NONE;
|
||||
}
|
||||
return BuildingID(index.value());
|
||||
});
|
||||
}
|
||||
requirementsToLoad.clear();
|
||||
|
Loading…
x
Reference in New Issue
Block a user