1
0
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:
ArseniyShestakov 2015-11-04 12:29:51 +03:00
parent 934c682733
commit 330c1666fc
2 changed files with 36 additions and 36 deletions

View File

@ -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()
{
switch (dp->layer)
@ -463,40 +497,6 @@ bool CPathfinder::canVisitObject() const
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()
:coord(-1,-1,-1)
{

View File

@ -105,7 +105,8 @@ private:
void addNeighbours(const int3 &coord);
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();
int3 getSourceGuardPosition();
@ -125,5 +126,4 @@ private:
bool canVisitObject() const;
bool isLayerTransitionPossible();
};