1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-12-01 23:12:49 +02:00

Unit stack rebalancing rework

- CStackInstance::count is now private with accessor methods
- CStackInstance::experience renamed to totalExperience and now stores
total stack experience (multiplied by stack size) to reduce rounding
errors
- CStackInstance::totalExperience is now private with accessors methods
- stack experience is now automatically reallocated on stack management
- Removed buggy BulkSmartRebalanceStacks pack, that mostly duplicates
BulkRebalanceStacks
- Renamed BulkSmartSplitStack to BulkSplitAndRebalanceStack to drop
unclear "smart" in name
- Reworked split-and-rebalance logic to correctly reallocate stack
experience
This commit is contained in:
Ivan Savenko
2025-05-01 13:41:48 +03:00
parent ac26b3ed9b
commit 283adc37d7
52 changed files with 339 additions and 328 deletions

View File

@@ -98,7 +98,7 @@ std::vector<SlotInfo> ArmyManager::getSortedSlots(const CCreatureSet * target, c
slotInfp.creature = cre;
slotInfp.power += i.second->getPower();
slotInfp.count += i.second->count;
slotInfp.count += i.second->getCount();
}
}
@@ -491,7 +491,7 @@ void ArmyManager::update()
{
for(const auto & slot : army->Slots())
{
totalArmy[slot.second->getCreatureID()].count += slot.second->count;
totalArmy[slot.second->getCreatureID()].count += slot.second->getCount();
}
}
@@ -511,7 +511,7 @@ std::vector<SlotInfo> ArmyManager::convertToSlots(const CCreatureSet * army) con
SlotInfo slotInfo;
slotInfo.creature = slot.second->getCreatureID().toCreature();
slotInfo.count = slot.second->count;
slotInfo.count = slot.second->getCount();
slotInfo.power = evaluateStackPower(slotInfo.creature, slotInfo.count);
result.push_back(slotInfo);
@@ -537,7 +537,7 @@ std::vector<StackUpgradeInfo> ArmyManager::getHillFortUpgrades(const CCreatureSe
return cre.toCreature()->getAIValue();
});
StackUpgradeInfo upgrade = StackUpgradeInfo(initial, strongestUpgrade, creature.second->count);
StackUpgradeInfo upgrade = StackUpgradeInfo(initial, strongestUpgrade, creature.second->getCount());
if(initial.toCreature()->getLevel() == 1)
upgrade.cost = TResources();
@@ -576,7 +576,7 @@ std::vector<StackUpgradeInfo> ArmyManager::getDwellingUpgrades(const CCreatureSe
return cre.toCreature()->getAIValue();
});
StackUpgradeInfo upgrade = StackUpgradeInfo(initial, strongestUpgrade, creature.second->count);
StackUpgradeInfo upgrade = StackUpgradeInfo(initial, strongestUpgrade, creature.second->getCount());
upgrades.push_back(upgrade);
}