1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-17 00:07:41 +02:00

Remove pointer to objects from TerrainTile

This commit is contained in:
Ivan Savenko
2025-03-19 14:40:45 +00:00
parent 63d00b080e
commit cd7732456a
26 changed files with 164 additions and 113 deletions

View File

@ -103,6 +103,7 @@ PathNodeInfo::PathNodeInfo()
void PathNodeInfo::setNode(CGameState * gs, CGPathNode * n)
{
node = n;
guarded = false;
if(coord != node->coord)
{
@ -110,23 +111,25 @@ void PathNodeInfo::setNode(CGameState * gs, CGPathNode * n)
coord = node->coord;
tile = gs->getTile(coord);
nodeObject = tile->topVisitableObj();
nodeObject = nullptr;
nodeHero = nullptr;
if(nodeObject && nodeObject->ID == Obj::HERO)
ObjectInstanceID topObjectID = tile->topVisitableObj();
if (topObjectID.hasValue())
{
nodeHero = dynamic_cast<const CGHeroInstance *>(nodeObject);
nodeObject = tile->topVisitableObj(true);
nodeObject = gs->getObjInstance(topObjectID);
if(!nodeObject)
nodeObject = nodeHero;
}
else
{
nodeHero = nullptr;
if (nodeObject->ID == Obj::HERO)
{
nodeHero = dynamic_cast<const CGHeroInstance *>(nodeObject);
ObjectInstanceID bottomObjectID = tile->topVisitableObj(true);
if (bottomObjectID.hasValue())
nodeObject = gs->getObjInstance(bottomObjectID);
}
}
}
guarded = false;
}
void PathNodeInfo::updateInfo(CPathfinderHelper * hlp, CGameState * gs)