浏览代码

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.
ArseniyShestakov 10 年之前
父节点
当前提交
c6f9cd1e52
共有 2 个文件被更改,包括 6 次插入7 次删除
  1. 5 6
      lib/CGameState.cpp
  2. 1 1
      lib/CGameState.h

+ 5 - 6
lib/CGameState.cpp

@@ -3414,12 +3414,8 @@ void CPathfinder::calculatePaths()
 			useEmbarkCost = 0; //0 - usual movement; 1 - embark; 2 - disembark
 			const bool destIsGuardian = sourceGuardPosition == neighbour;
 
-			if(!goodForLandSeaTransition()
-			   || !canMoveBetween(cp->coord, dp->coord)
-			   || dp->accessible == CGPathNode::BLOCKED)
-			{
+			if(!isMovementPossible())
 				continue;
-			}
 
 			//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)
@@ -3549,8 +3545,11 @@ CGPathNode::EAccessibility CPathfinder::evaluateAccessibility(const TerrainTile
 	return ret;
 }
 
-bool CPathfinder::goodForLandSeaTransition()
+bool CPathfinder::isMovementPossible()
 {
+	if(!canMoveBetween(cp->coord, dp->coord) || dp->accessible == CGPathNode::BLOCKED)
+		return false;
+
 	Obj destTopVisObjID = dt->topVisitableId();
 	if(cp->land != dp->land) //hero can traverse land<->sea only in special circumstances
 	{

+ 1 - 1
lib/CGameState.h

@@ -305,7 +305,7 @@ private:
 
 	CGPathNode *getNode(const int3 &coord);
 	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 getTeleportExits(bool noTeleportExcludes = false);