1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Fixes following review

This commit is contained in:
MichalZr6
2024-12-16 16:05:46 +01:00
parent bbc41fc1b9
commit af9445c16f
11 changed files with 39 additions and 38 deletions

View File

@@ -2414,18 +2414,18 @@ bool CGameHandler::upgradeCreature(ObjectInstanceID objid, SlotID pos, CreatureI
{
COMPLAIN_RET("Cannot upgrade, no stack at slot " + std::to_string(pos));
}
UpgradeInfo ui(obj->getStackPtr(pos)->getId());
fillUpgradeInfo(obj, pos, ui);
UpgradeInfo upgradeInfo(obj->getStackPtr(pos)->getId());
fillUpgradeInfo(obj, pos, upgradeInfo);
PlayerColor player = obj->tempOwner;
const PlayerState *p = getPlayerState(player);
int crQuantity = obj->stacks.at(pos)->count;
//check if upgrade is possible
if (!ui.hasUpgrades() && complain("That upgrade is not possible!"))
if (!upgradeInfo.hasUpgrades() && complain("That upgrade is not possible!"))
{
return false;
}
TResources totalCost = ui.getUpgradeCostsFor(upgID) * crQuantity;
TResources totalCost = upgradeInfo.getUpgradeCostsFor(upgID) * crQuantity;
//check if player has enough resources
if (!p->resources.canAfford(totalCost))