1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-05 00:49:09 +02:00

Remove pointer to boat from CGHeroInstance

This commit is contained in:
Ivan Savenko
2025-03-26 15:37:26 +00:00
parent 331debaa3f
commit 9e6397d1f9
24 changed files with 89 additions and 73 deletions

View File

@ -372,8 +372,8 @@ void MapViewController::fadeOutObject(const CGObjectInstance * obj)
if (obj->ID == Obj::HERO)
{
auto * hero = dynamic_cast<const CGHeroInstance*>(obj);
if (hero->boat)
movingObject = hero->boat;
if (hero->inBoat())
movingObject = hero->getBoat();
}
fadingOutContext->target = movingObject->id;
@ -393,8 +393,8 @@ void MapViewController::fadeInObject(const CGObjectInstance * obj)
if (obj->ID == Obj::HERO)
{
auto * hero = dynamic_cast<const CGHeroInstance*>(obj);
if (hero->boat)
movingObject = hero->boat;
if (hero->inBoat())
movingObject = hero->getBoat();
}
fadingInContext->target = movingObject->id;
@ -416,10 +416,10 @@ void MapViewController::removeObject(const CGObjectInstance * obj)
if (obj->ID == Obj::HERO)
{
auto * hero = dynamic_cast<const CGHeroInstance*>(obj);
if (hero->boat)
if (hero->inBoat())
{
view->invalidate(context, hero->boat->id);
state->removeObject(hero->boat);
view->invalidate(context, hero->getBoat()->id);
state->removeObject(hero->getBoat());
}
}
@ -514,8 +514,8 @@ void MapViewController::onAfterHeroTeleported(const CGHeroInstance * obj, const
assert(!hasOngoingAnimations());
const CGObjectInstance * movingObject = obj;
if(obj->boat)
movingObject = obj->boat;
if(obj->inBoat())
movingObject = obj->getBoat();
removeObject(movingObject);
addObject(movingObject);
@ -541,8 +541,8 @@ void MapViewController::onHeroMoved(const CGHeroInstance * obj, const int3 & fro
return;
const CGObjectInstance * movingObject = obj;
if(obj->boat)
movingObject = obj->boat;
if(obj->inBoat())
movingObject = obj->getBoat();
removeObject(movingObject);