1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +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

@ -1313,9 +1313,11 @@ void TryMoveHero::applyGs(CGameState *gs)
if(result == EMBARK) //hero enters boat at destination tile
{
assert(destTile.visitableObjects.size() >= 1 && destTile.visitableObjects.back()->ID == Obj::BOAT); //the only visitable object at destination is Boat
auto * boat = dynamic_cast<CGBoat *>(destTile.visitableObjects.back());
const TerrainTile &tt = gs->getMap().getTile(h->convertToVisitablePos(end));
ObjectInstanceID topObjectID = tt.visitableObjects.back();
CGObjectInstance * topObject = gs->getObjInstance(topObjectID);
assert(tt.visitableObjects.size() >= 1 && topObject->ID == Obj::BOAT); //the only visitable object at destination is Boat
auto * boat = dynamic_cast<CGBoat *>(topObject);
assert(boat);
gs->getMap().removeBlockVisTiles(boat); //hero blockvis mask will be used, we don't need to duplicate it with boat