1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

Fix crashes on game start, gamestate now derives from GameCallbackHolder

This commit is contained in:
Ivan Savenko
2025-04-01 15:59:08 +03:00
parent d34b47bb20
commit d1d2cf4189
21 changed files with 99 additions and 81 deletions

View File

@@ -1324,9 +1324,9 @@ void CGHeroInstance::deserializationFix()
void CGHeroInstance::boatDeserializationFix()
{
auto boat = cb->gameState()->getObjInstance(boardedBoat);
if (boat)
attachTo(dynamic_cast<CGBoat&>(*boat));
// auto boat = cb->gameState()->getObjInstance(boardedBoat);
// if (boat)
// attachTo(dynamic_cast<CGBoat&>(*boat));
}
CBonusSystemNode * CGHeroInstance::whereShouldBeAttachedOnSiege(const bool isBattleOutsideTown) const
@@ -1349,14 +1349,14 @@ CBonusSystemNode * CGHeroInstance::whereShouldBeAttachedOnSiege(CGameState * gs)
CBonusSystemNode & CGHeroInstance::whereShouldBeAttached(CGameState * gs)
{
if(getVisitedTown())
{
if(isGarrisoned())
return *getVisitedTown();
else
return getVisitedTown()->townAndVis;
}
else
// if(getVisitedTown())
// {
// if(isGarrisoned())
// return *getVisitedTown();
// else
// return getVisitedTown()->townAndVis;
// }
// else
return CArmedInstance::whereShouldBeAttached(gs);
}

View File

@@ -708,13 +708,6 @@ std::string CGTownInstance::nodeName() const
void CGTownInstance::deserializationFix()
{
attachTo(townAndVis);
//Hero is already handled by CGameState::attachArmedObjects
// if(getVisitingHero())
// getVisitingHero()->attachTo(&townAndVis);
// if(getGarrisonHero())
// getGarrisonHero()->attachTo(this);
}
void CGTownInstance::updateMoraleBonusFromArmy()