1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00

CPathfinder: move passability checks into renamed goodForLandSeaTransition

There no need in dedicated function for embark / disembark and other conditions belong there perfectly.
This function is going to check what movements are plain impossible so we don't have to bother check their cost.
This commit is contained in:
ArseniyShestakov 2015-10-12 07:10:33 +03:00
parent ee4305cd6d
commit c6f9cd1e52
2 changed files with 6 additions and 7 deletions

View File

@ -3414,12 +3414,8 @@ void CPathfinder::calculatePaths()
useEmbarkCost = 0; //0 - usual movement; 1 - embark; 2 - disembark useEmbarkCost = 0; //0 - usual movement; 1 - embark; 2 - disembark
const bool destIsGuardian = sourceGuardPosition == neighbour; const bool destIsGuardian = sourceGuardPosition == neighbour;
if(!goodForLandSeaTransition() if(!isMovementPossible())
|| !canMoveBetween(cp->coord, dp->coord)
|| dp->accessible == CGPathNode::BLOCKED)
{
continue; continue;
}
//special case -> hero embarked a boat standing on a guarded tile -> we must allow to move away from that tile //special case -> hero embarked a boat standing on a guarded tile -> we must allow to move away from that tile
if(cp->accessible == CGPathNode::VISITABLE && guardedSource && cp->theNodeBefore->land && ct->topVisitableId() == Obj::BOAT) if(cp->accessible == CGPathNode::VISITABLE && guardedSource && cp->theNodeBefore->land && ct->topVisitableId() == Obj::BOAT)
@ -3549,8 +3545,11 @@ CGPathNode::EAccessibility CPathfinder::evaluateAccessibility(const TerrainTile
return ret; return ret;
} }
bool CPathfinder::goodForLandSeaTransition() bool CPathfinder::isMovementPossible()
{ {
if(!canMoveBetween(cp->coord, dp->coord) || dp->accessible == CGPathNode::BLOCKED)
return false;
Obj destTopVisObjID = dt->topVisitableId(); Obj destTopVisObjID = dt->topVisitableId();
if(cp->land != dp->land) //hero can traverse land<->sea only in special circumstances if(cp->land != dp->land) //hero can traverse land<->sea only in special circumstances
{ {

View File

@ -305,7 +305,7 @@ private:
CGPathNode *getNode(const int3 &coord); CGPathNode *getNode(const int3 &coord);
void initializeGraph(); void initializeGraph();
bool goodForLandSeaTransition(); //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 isMovementPossible(); //checks if current move will be between sea<->land. If so, checks it legality (returns false if movement is not possible) and sets useEmbarkCost
void getNeighbours(const int3 &coord); void getNeighbours(const int3 &coord);
void getTeleportExits(bool noTeleportExcludes = false); void getTeleportExits(bool noTeleportExcludes = false);