mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
Fix boat positioning
This commit is contained in:
parent
caccd58eb0
commit
44261ecc21
@ -384,7 +384,9 @@ struct DLL_LINKAGE ChangeObjPos : public CPackForClient
|
||||
{
|
||||
void applyGs(CGameState * gs);
|
||||
|
||||
/// Object to move
|
||||
ObjectInstanceID objid;
|
||||
/// New position of visitable tile of an object
|
||||
int3 nPos;
|
||||
|
||||
virtual void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
@ -1019,7 +1019,7 @@ void ChangeObjPos::applyGs(CGameState *gs)
|
||||
return;
|
||||
}
|
||||
gs->map->removeBlockVisTiles(obj);
|
||||
obj->pos = nPos;
|
||||
obj->pos = nPos + obj->getVisitableOffset();
|
||||
gs->map->addBlockVisTiles(obj);
|
||||
}
|
||||
|
||||
@ -1528,7 +1528,7 @@ void NewObject::applyGs(CGameState *gs)
|
||||
o->id = ObjectInstanceID(static_cast<si32>(gs->map->objects.size()));
|
||||
o->ID = ID;
|
||||
o->subID = subID;
|
||||
o->pos = targetPos - o->getVisitableOffset();
|
||||
o->pos = targetPos + o->getVisitableOffset();
|
||||
|
||||
gs->map->objects.emplace_back(o);
|
||||
gs->map->addBlockVisTiles(o);
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user