mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
CPathfinder: move isLayerTransitionPossible and remove outdated comment
This commit is contained in:
parent
934c682733
commit
330c1666fc
@ -225,6 +225,40 @@ void CPathfinder::addTeleportExits(bool noTeleportExcludes)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CPathfinder::isLayerTransitionPossible()
|
||||||
|
{
|
||||||
|
if((cp->layer == EPathfindingLayer::AIR || cp->layer == EPathfindingLayer::WATER)
|
||||||
|
&& dp->layer != EPathfindingLayer::LAND)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if(cp->layer == EPathfindingLayer::SAIL && dp->layer != EPathfindingLayer::LAND)
|
||||||
|
return false;
|
||||||
|
else if(cp->layer == EPathfindingLayer::SAIL && dp->layer == EPathfindingLayer::LAND)
|
||||||
|
{
|
||||||
|
if(!dt->isCoastal())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
//tile must be accessible -> exception: unblocked blockvis tiles -> clear but guarded by nearby monster coast
|
||||||
|
if((dp->accessible != CGPathNode::ACCESSIBLE && (dp->accessible != CGPathNode::BLOCKVIS || dt->blocked))
|
||||||
|
|| dt->visitable) //TODO: passableness problem -> town says it's passable (thus accessible) but we obviously can't disembark onto town gate
|
||||||
|
return false;
|
||||||
|
|
||||||
|
useEmbarkCost = 2;
|
||||||
|
}
|
||||||
|
else if(cp->layer == EPathfindingLayer::LAND && dp->layer == EPathfindingLayer::SAIL)
|
||||||
|
{
|
||||||
|
Obj destTopVisObjID = dt->topVisitableId();
|
||||||
|
if(dp->accessible == CGPathNode::ACCESSIBLE || destTopVisObjID < 0) //cannot enter empty water tile from land -> it has to be visitable
|
||||||
|
return false;
|
||||||
|
if(destTopVisObjID != Obj::HERO && destTopVisObjID != Obj::BOAT) //only boat or hero can be accessed from land
|
||||||
|
return false;
|
||||||
|
if(destTopVisObjID == Obj::BOAT)
|
||||||
|
useEmbarkCost = 1;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool CPathfinder::isMovementToDestPossible()
|
bool CPathfinder::isMovementToDestPossible()
|
||||||
{
|
{
|
||||||
switch (dp->layer)
|
switch (dp->layer)
|
||||||
@ -463,40 +497,6 @@ bool CPathfinder::canVisitObject() const
|
|||||||
return cp->layer == EPathfindingLayer::LAND || cp->layer == EPathfindingLayer::SAIL;
|
return cp->layer == EPathfindingLayer::LAND || cp->layer == EPathfindingLayer::SAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CPathfinder::isLayerTransitionPossible()
|
|
||||||
{
|
|
||||||
if((cp->layer == EPathfindingLayer::AIR || cp->layer == EPathfindingLayer::WATER)
|
|
||||||
&& dp->layer != EPathfindingLayer::LAND)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if(cp->layer == EPathfindingLayer::SAIL && dp->layer != EPathfindingLayer::LAND)
|
|
||||||
return false;
|
|
||||||
else if(cp->layer == EPathfindingLayer::SAIL && dp->layer == EPathfindingLayer::LAND)
|
|
||||||
{
|
|
||||||
if(!dt->isCoastal())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
//tile must be accessible -> exception: unblocked blockvis tiles -> clear but guarded by nearby monster coast
|
|
||||||
if((dp->accessible != CGPathNode::ACCESSIBLE && (dp->accessible != CGPathNode::BLOCKVIS || dt->blocked))
|
|
||||||
|| dt->visitable) //TODO: passableness problem -> town says it's passable (thus accessible) but we obviously can't disembark onto town gate
|
|
||||||
return false;
|
|
||||||
|
|
||||||
useEmbarkCost = 2;
|
|
||||||
}
|
|
||||||
else if(cp->layer == EPathfindingLayer::LAND && dp->layer == EPathfindingLayer::SAIL)
|
|
||||||
{
|
|
||||||
Obj destTopVisObjID = dt->topVisitableId();
|
|
||||||
if(dp->accessible == CGPathNode::ACCESSIBLE || destTopVisObjID < 0) //cannot enter empty water tile from land -> it has to be visitable
|
|
||||||
return false;
|
|
||||||
if(destTopVisObjID != Obj::HERO && destTopVisObjID != Obj::BOAT) //only boat or hero can be accessed from land
|
|
||||||
return false;
|
|
||||||
if(destTopVisObjID == Obj::BOAT)
|
|
||||||
useEmbarkCost = 1;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
CGPathNode::CGPathNode()
|
CGPathNode::CGPathNode()
|
||||||
:coord(-1,-1,-1)
|
:coord(-1,-1,-1)
|
||||||
{
|
{
|
||||||
|
@ -105,7 +105,8 @@ private:
|
|||||||
void addNeighbours(const int3 &coord);
|
void addNeighbours(const int3 &coord);
|
||||||
void addTeleportExits(bool noTeleportExcludes = false);
|
void addTeleportExits(bool noTeleportExcludes = false);
|
||||||
|
|
||||||
bool isMovementToDestPossible(); //checks if current move will be between sea<->land. If so, checks it legality (returns false if movement is not possible) and sets useEmbarkCost
|
bool isLayerTransitionPossible();
|
||||||
|
bool isMovementToDestPossible();
|
||||||
bool isMovementAfterDestPossible();
|
bool isMovementAfterDestPossible();
|
||||||
|
|
||||||
int3 getSourceGuardPosition();
|
int3 getSourceGuardPosition();
|
||||||
@ -125,5 +126,4 @@ private:
|
|||||||
|
|
||||||
bool canVisitObject() const;
|
bool canVisitObject() const;
|
||||||
|
|
||||||
bool isLayerTransitionPossible();
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user