瀏覽代碼

CPathfinder: clean calculatePaths of code unsused for pathfinding

Map graph initialization should be there as well because it's needed for path checking.
This change wouldn't affect anything since currently CPathfinder object created from scratch every time.
ArseniyShestakov 10 年之前
父節點
當前提交
886042dc11
共有 1 個文件被更改,包括 10 次插入10 次删除
  1. 10 10
      lib/CGameState.cpp

+ 10 - 10
lib/CGameState.cpp

@@ -3426,17 +3426,7 @@ void CPathfinder::calculatePaths()
 		return cp->land ? maxMovePointsLand : maxMovePointsWater;
 	};
 
-	out.hero = hero;
-	out.hpos = hero->getPosition(false);
-
-	if(!gs->map->isInTheMap(out.hpos)/* || !gs->map->isInTheMap(dest)*/) //check input
-	{
-		logGlobal->errorStream() << "CGameState::calculatePaths: Hero outside the gs->map? How dare you...";
-		return;
-	}
-
 	//logGlobal->infoStream() << boost::format("Calculating paths for hero %s (adress  %d) of player %d") % hero->name % hero % hero->tempOwner;
-	initializeGraph();
 
 	//initial tile - set cost on 0 and add to the queue
 	CGPathNode &initialNode = *getNode(out.hpos);
@@ -3612,6 +3602,16 @@ CPathfinder::CPathfinder(CPathsInfo &_out, CGameState *_gs, const CGHeroInstance
 	assert(hero);
 	assert(hero == getHero(hero->id));
 
+	out.hero = hero;
+	out.hpos = hero->getPosition(false);
+	if(!gs->map->isInTheMap(out.hpos)/* || !gs->map->isInTheMap(dest)*/) //check input
+	{
+		logGlobal->errorStream() << "CGameState::calculatePaths: Hero outside the gs->map? How dare you...";
+		throw std::runtime_error("Wrong checksum");
+	}
+
+	initializeGraph();
+
 	allowEmbarkAndDisembark = true;
 	allowTeleportTwoWay = true;
 	allowTeleportOneWay = true;