1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Fix possible crash on abandoned mine with no valid resources

This commit is contained in:
Ivan Savenko 2023-12-24 22:05:47 +02:00
parent 28a3deb42b
commit 4835a1f695

View File

@ -117,7 +117,15 @@ void CGMine::initObj(CRandomGenerator & rand)
putStack(SlotID(0), troglodytes);
assert(!abandonedMineResources.empty());
producedResource = *RandomGeneratorUtil::nextItem(abandonedMineResources, rand);
if (!abandonedMineResources.empty())
{
producedResource = *RandomGeneratorUtil::nextItem(abandonedMineResources, rand);
}
else
{
logGlobal->error("Abandoned mine at (%s) has no valid resource candidates!", pos.toString());
producedResource = GameResID::GOLD;
}
}
else
{