mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-06 09:09:40 +02:00
Fixes following review
This commit is contained in:
@@ -788,29 +788,30 @@ bool AIGateway::makePossibleUpgrades(const CArmedInstance * obj)
|
||||
{
|
||||
if(const CStackInstance * s = obj->getStackPtr(SlotID(i)))
|
||||
{
|
||||
UpgradeInfo ui(s->getId());
|
||||
UpgradeInfo upgradeInfo(s->getId());
|
||||
do
|
||||
{
|
||||
myCb->fillUpgradeInfo(obj, SlotID(i), ui);
|
||||
myCb->fillUpgradeInfo(obj, SlotID(i), upgradeInfo);
|
||||
|
||||
if(ui.hasUpgrades())
|
||||
if(upgradeInfo.hasUpgrades())
|
||||
{
|
||||
// creature at given slot might have alternative upgrades, pick best one
|
||||
CreatureID upgID = *vstd::maxElementByFun(ui.getAvailableUpgrades(), [](const CreatureID & id)
|
||||
CreatureID upgID = *vstd::maxElementByFun(upgradeInfo.getAvailableUpgrades(), [](const CreatureID & id)
|
||||
{
|
||||
return id.toCreature()->getAIValue();
|
||||
});
|
||||
if(nullkiller->getFreeResources().canAfford(ui.getUpgradeCostsFor(upgID) * s->count))
|
||||
if(nullkiller->getFreeResources().canAfford(upgradeInfo.getUpgradeCostsFor(upgID) * s->count))
|
||||
{
|
||||
myCb->upgradeCreature(obj, SlotID(i), upgID);
|
||||
upgraded = true;
|
||||
logAi->debug("Upgraded %d %s to %s", s->count, ui.oldID.toCreature()->getNamePluralTranslated(), ui.getNextUpgrade().toCreature()->getNamePluralTranslated());
|
||||
logAi->debug("Upgraded %d %s to %s", s->count, upgradeInfo.oldID.toCreature()->getNamePluralTranslated(),
|
||||
upgradeInfo.getNextUpgrade().toCreature()->getNamePluralTranslated());
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
while(ui.hasUpgrades());
|
||||
while(upgradeInfo.hasUpgrades());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user