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:
parent
28a3deb42b
commit
4835a1f695
@ -117,9 +117,17 @@ void CGMine::initObj(CRandomGenerator & rand)
|
||||
putStack(SlotID(0), troglodytes);
|
||||
|
||||
assert(!abandonedMineResources.empty());
|
||||
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
|
||||
{
|
||||
producedResource = GameResID(getObjTypeIndex().getNum());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user