1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-12-24 00:36:29 +02:00

Fix boat positioning

This commit is contained in:
Ivan Savenko
2023-06-20 23:09:11 +03:00
parent caccd58eb0
commit 44261ecc21
3 changed files with 7 additions and 4 deletions

View File

@@ -92,12 +92,13 @@ int3 IBoatGenerator::bestLocation() const
for (auto & offset : offsets)
{
const TerrainTile *tile = getObject()->cb->getTile(getObject()->visitablePos() + offset, false);
int3 targetTile = getObject()->visitablePos() + offset;
const TerrainTile *tile = getObject()->cb->getTile(targetTile, false);
if(tile) //tile is in the map
{
if(tile->terType->isWater() && (!tile->blocked || tile->blockingObjects.front()->ID == Obj::BOAT)) //and is water and is not blocked or is blocked by boat
return getObject()->getPosition() + offset;
return targetTile;
}
}
return int3 (-1,-1,-1);