Kaynağa Gözat

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 yıl önce
ebeveyn
işleme
886042dc11
1 değiştirilmiş dosya ile 10 ekleme ve 10 silme
  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;