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

@ -96,9 +96,12 @@ int3 IBoatGenerator::bestLocation() const
if (tile->blocked())
{
bool hasBoat = false;
for (auto const * object : tile->blockingObjects)
for (auto const & objectID : tile->blockingObjects)
{
const auto * object = getObject()->cb->getObj(objectID);
if (object->ID == Obj::BOAT || object->ID == Obj::HERO)
hasBoat = true;
}
if (!hasBoat)
continue; // tile is blocked, but not by boat -> check next potential position
@ -122,7 +125,9 @@ IBoatGenerator::EGeneratorState IBoatGenerator::shipyardStatus() const
if(t->blockingObjects.empty())
return GOOD; //OK
if(t->blockingObjects.front()->ID == Obj::BOAT || t->blockingObjects.front()->ID == Obj::HERO)
auto blockerObject = getObject()->cb->getObjInstance(t->blockingObjects.front());
if(blockerObject->ID == Obj::BOAT || blockerObject->ID == Obj::HERO)
return BOAT_ALREADY_BUILT; //blocked with boat
return TILE_BLOCKED; //blocked