1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-06 09:09:40 +02:00

Correctly restore bonus system on deserialization

This commit is contained in:
Ivan Savenko
2025-04-08 16:37:45 +03:00
parent f9989d9152
commit e6a8e5d4bd
24 changed files with 149 additions and 117 deletions

View File

@@ -153,6 +153,34 @@ CBonusSystemNode & CArmedInstance::whatShouldBeAttached()
return *this;
}
void CArmedInstance::attachToBonusSystem(CGameState * gs)
{
CArmedInstance::restoreBonusSystem(gs);
}
void CArmedInstance::restoreBonusSystem(CGameState * gs)
{
whatShouldBeAttached().attachTo(whereShouldBeAttached(gs));
for(const auto & elem : stacks)
elem.second->artDeserializationFix(gs, elem.second.get());
}
void CArmedInstance::detachFromBonusSystem(CGameState * gs)
{
whatShouldBeAttached().detachFrom(whereShouldBeAttached(gs));
// TODO: the opposite
// for(const auto & elem : stacks)
// elem.second->artDeserializationFix(elem.second.get());
}
void CArmedInstance::attachUnitsToArmy()
{
for(const auto & elem : stacks)
elem.second->attachTo(*getArmy());
}
const IBonusBearer* CArmedInstance::getBonusBearer() const
{
return this;