mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-06 09:09:40 +02:00
Remove pointer to objects from TerrainTile
This commit is contained in:
@@ -1332,8 +1332,7 @@ bool AIGateway::moveHeroToTile(int3 dst, HeroPtr h)
|
||||
{
|
||||
auto tile = cb->getTile(coord, false);
|
||||
assert(tile);
|
||||
return tile->topVisitableObj(ignoreHero);
|
||||
//return cb->getTile(coord,false)->topVisitableObj(ignoreHero);
|
||||
return cb->getObj(tile->topVisitableObj(ignoreHero));
|
||||
};
|
||||
|
||||
auto isTeleportAction = [&](EPathNodeAction action) -> bool
|
||||
|
||||
@@ -202,7 +202,7 @@ bool canBeEmbarkmentPoint(const TerrainTile * t, bool fromWater)
|
||||
}
|
||||
else if(!fromWater) // do not try to board when in water sector
|
||||
{
|
||||
if(t->visitableObjects.size() == 1 && t->topVisitableId() == Obj::BOAT)
|
||||
if(t->visitableObjects.size() == 1 && cb->getObjInstance(t->topVisitableObj())->ID == Obj::BOAT)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -192,7 +192,7 @@ bool canBeEmbarkmentPoint(const TerrainTile * t, bool fromWater)
|
||||
}
|
||||
else if(!fromWater) // do not try to board when in water sector
|
||||
{
|
||||
if(t->visitableObjects.size() == 1 && t->topVisitableId() == Obj::BOAT)
|
||||
if(t->visitableObjects.size() == 1 && cb->getObjInstance(t->topVisitableObj())->ID == Obj::BOAT)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -200,9 +200,11 @@ bool canBeEmbarkmentPoint(const TerrainTile * t, bool fromWater)
|
||||
|
||||
bool isBlockedBorderGate(int3 tileToHit) //TODO: is that function needed? should be handled by pathfinder
|
||||
{
|
||||
if(cb->getTile(tileToHit)->topVisitableId() != Obj::BORDER_GATE)
|
||||
const auto * object = cb->getTopObj(tileToHit);
|
||||
if( object && object->id != Obj::BORDER_GATE)
|
||||
return false;
|
||||
auto gate = dynamic_cast<const CGKeys *>(cb->getTile(tileToHit)->topVisitableObj());
|
||||
|
||||
auto gate = dynamic_cast<const CGKeys *>(object);
|
||||
return !gate->passableFor(ai->playerID);
|
||||
}
|
||||
|
||||
|
||||
@@ -192,7 +192,7 @@ Goals::TSubgoal PathfindingManager::clearWayTo(HeroPtr hero, int3 firstTileToGet
|
||||
if(isBlockedBorderGate(firstTileToGet))
|
||||
{
|
||||
//FIXME: this way we'll not visit gate and activate quest :?
|
||||
return sptr(Goals::FindObj(Obj::KEYMASTER, cb->getTile(firstTileToGet)->visitableObjects.back()->getObjTypeIndex()));
|
||||
return sptr(Goals::FindObj(Obj::KEYMASTER, cb->getTopObj(firstTileToGet)->getObjTypeIndex()));
|
||||
}
|
||||
|
||||
auto topObj = cb->getTopObj(firstTileToGet);
|
||||
|
||||
@@ -1868,10 +1868,7 @@ bool VCAI::moveHeroToTile(int3 dst, HeroPtr h)
|
||||
|
||||
auto getObj = [&](int3 coord, bool ignoreHero)
|
||||
{
|
||||
auto tile = cb->getTile(coord, false);
|
||||
assert(tile);
|
||||
return tile->topVisitableObj(ignoreHero);
|
||||
//return cb->getTile(coord,false)->topVisitableObj(ignoreHero);
|
||||
return cb->getObj(cb->getTile(coord)->topVisitableObj(ignoreHero));
|
||||
};
|
||||
|
||||
auto isTeleportAction = [&](EPathNodeAction action) -> bool
|
||||
|
||||
Reference in New Issue
Block a user