Browse Source

Move base movement cost to GameConstants

ArseniyShestakov 10 years ago
parent
commit
226650582d
2 changed files with 5 additions and 3 deletions
  1. 1 0
      lib/GameConstants.h
  2. 4 3
      lib/mapObjects/CGHeroInstance.cpp

+ 1 - 0
lib/GameConstants.h

@@ -51,6 +51,7 @@ namespace GameConstants
 	const int SPELLS_QUANTITY=70;
 	const int CREATURES_COUNT = 197;
 
+	const ui32 BASE_MOVEMENT_COST = 100; //default cost for non-diagonal movement
 }
 
 class CArtifact;

+ 4 - 3
lib/mapObjects/CGHeroInstance.cpp

@@ -58,8 +58,7 @@ static int lowestSpeed(const CGHeroInstance * chi)
 
 ui32 CGHeroInstance::getTileCost(const TerrainTile &dest, const TerrainTile &from) const
 {
-	//base move cost
-	unsigned ret = 100;
+	unsigned ret = GameConstants::BASE_MOVEMENT_COST;
 
 	//if there is road both on dest and src tiles - use road movement cost
 	if(dest.roadType != ERoadType::NO_ROAD && from.roadType != ERoadType::NO_ROAD)
@@ -95,7 +94,9 @@ ui32 CGHeroInstance::getTileCost(const TerrainTile &dest, const TerrainTile &fro
 			{
 				ret = VLC->heroh->terrCosts[from.terType];
 				ret -= getSecSkillLevel(SecondarySkill::PATHFINDING) * 25;
-				ret = ret < 100 ? 100 : ret;
+				if(ret < GameConstants::BASE_MOVEMENT_COST)
+					ret = GameConstants::BASE_MOVEMENT_COST;
+
 				break;
 			}
 		}