1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

Fix regressions

This commit is contained in:
Ivan Savenko
2025-04-10 12:27:18 +03:00
parent e6a8e5d4bd
commit 912c2eae94
17 changed files with 94 additions and 98 deletions

View File

@@ -1317,10 +1317,19 @@ CGBoat * CGHeroInstance::getBoat()
void CGHeroInstance::setBoat(CGBoat* newBoat)
{
assert(newBoat);
boardedBoat = newBoat->id;
attachTo(*newBoat);
newBoat->setBoardedHero(this);
if (newBoat)
{
boardedBoat = newBoat->id;
attachTo(*newBoat);
newBoat->setBoardedHero(this);
}
else if (boardedBoat.hasValue())
{
auto oldBoat = getBoat();
boardedBoat = {};
detachFrom(*oldBoat);
oldBoat->setBoardedHero(nullptr);
}
}
void CGHeroInstance::restoreBonusSystem(CGameState * gs)
@@ -1348,7 +1357,7 @@ void CGHeroInstance::attachToBonusSystem(CGameState * gs)
void CGHeroInstance::detachFromBonusSystem(CGameState * gs)
{
CArmedInstance::attachToBonusSystem(gs);
CArmedInstance::detachFromBonusSystem(gs);
if (boardedBoat.hasValue())
{
auto boat = gs->getObjInstance(boardedBoat);