mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-19 21:10:12 +02:00
Merge pull request #5176 from IvanSavenko/ai_upgrades
Fix potentially infinite attempts to upgrade units by AI
This commit is contained in:
commit
dfa8a956cc
@ -805,7 +805,11 @@ bool AIGateway::makePossibleUpgrades(const CArmedInstance * obj)
|
||||
{
|
||||
return id.toCreature()->getAIValue();
|
||||
});
|
||||
if(nullkiller->getFreeResources().canAfford(upgradeInfo.getUpgradeCostsFor(upgID) * s->count))
|
||||
|
||||
int oldValue = s->getCreature()->getAIValue();
|
||||
int newValue = upgID.toCreature()->getAIValue();
|
||||
|
||||
if(newValue > oldValue && nullkiller->getFreeResources().canAfford(upgradeInfo.getUpgradeCostsFor(upgID) * s->count))
|
||||
{
|
||||
myCb->upgradeCreature(obj, SlotID(i), upgID);
|
||||
upgraded = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user