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

NullkillerAI: fix build analyser when town has no upgrade for creature

This commit is contained in:
Andrii Danylchenko 2022-05-01 10:26:07 +03:00
parent 0d15089dd4
commit 6da233c387

View File

@ -194,7 +194,9 @@ BuildingInfo BuildAnalyzer::getBuildingOrPrerequisite(
{
int level = toBuild - BuildingID::DWELL_FIRST;
auto creatures = townInfo->creatures.at(level % GameConstants::CREATURES_PER_TOWN);
auto creatureID = creatures.at(level / GameConstants::CREATURES_PER_TOWN);
auto creatureID = creatures.size() > level / GameConstants::CREATURES_PER_TOWN
? creatures.at(level / GameConstants::CREATURES_PER_TOWN)
: creatures.front();
baseCreatureID = creatures.front();
creature = creatureID.toCreature();