1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-03 13:01:33 +02:00

Fix crash which coudl occur if we can't add any Seer Hut to RMG pool (Fear template).

This commit is contained in:
Tomasz Zieliński 2023-06-14 20:50:14 +02:00
parent 46e367bdec
commit ce25ed4de2

View File

@ -406,6 +406,10 @@ void TreasurePlacer::addAllPossibleObjects()
}
const int questArtsRemaining = qap->getMaxQuestArtifactCount();
if (!questArtsRemaining)
{
return;
}
//Generate Seer Hut one by one. Duplicated oi possible and should work fine.
oi.maxPerZone = 1;
@ -520,6 +524,10 @@ void TreasurePlacer::addAllPossibleObjects()
possibleSeerHuts.push_back(oi);
}
if (possibleSeerHuts.empty())
{
return;
}
for (size_t i = 0; i < questArtsRemaining; i++)
{
addObjectToRandomPool(*RandomGeneratorUtil::nextItem(possibleSeerHuts, zone.getRand()));