1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +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

@ -263,19 +263,6 @@ void ApplyClientNetPackVisitor::visitBulkRebalanceStacks(BulkRebalanceStacks & p
}
}
void ApplyClientNetPackVisitor::visitBulkSmartRebalanceStacks(BulkSmartRebalanceStacks & pack)
{
if(!pack.moves.empty())
{
assert(pack.moves[0].srcArmy == pack.moves[0].dstArmy);
dispatchGarrisonChange(cl, pack.moves[0].srcArmy, ObjectInstanceID());
}
else if(!pack.changes.empty())
{
dispatchGarrisonChange(cl, pack.changes[0].army, ObjectInstanceID());
}
}
void ApplyClientNetPackVisitor::visitPutArtifact(PutArtifact & pack)
{
callInterfaceIfPresent(cl, cl.getOwner(pack.al.artHolder), &IGameEventsReceiver::artifactPut, pack.al);
@ -880,7 +867,7 @@ void ApplyClientNetPackVisitor::visitBattleResultsApplied(BattleResultsApplied &
if(pack.raisedStack.getCreature())
callInterfaceIfPresent(cl, pack.victor, &CGameInterface::showInfoDialog, EInfoWindowMode::AUTO,
UIHelper::getNecromancyInfoWindowText(pack.raisedStack), std::vector<Component>{Component(ComponentType::CREATURE, pack.raisedStack.getId(),
pack.raisedStack.count)}, UIHelper::getNecromancyInfoWindowSound());
pack.raisedStack.getCount())}, UIHelper::getNecromancyInfoWindowSound());
callInterfaceIfPresent(cl, pack.victor, &IGameEventsReceiver::battleResultsApplied);
callInterfaceIfPresent(cl, pack.loser, &IGameEventsReceiver::battleResultsApplied);