Browse Source

CGPathNode: apply suggested optimizations

Also make EPathfindingLayers ui8 too
ArseniyShestakov 10 years ago
parent
commit
adeefe903a
2 changed files with 14 additions and 14 deletions
  1. 12 12
      lib/CPathfinder.h
  2. 2 2
      lib/GameConstants.h

+ 12 - 12
lib/CPathfinder.h

@@ -26,18 +26,18 @@ struct DLL_LINKAGE CGPathNode
 {
 	typedef EPathfindingLayer ELayer;
 
-	enum ENodeAction
+	enum ENodeAction : ui8
 	{
-		UNKNOWN = -1,
-		NORMAL = 0,
+		UNKNOWN = 0,
 		EMBARK = 1,
-		DISEMBARK, //2
-		BATTLE,//3
-		VISIT,//4
-		BLOCKING_VISIT//5
+		DISEMBARK,
+		NORMAL,
+		BATTLE,
+		VISIT,
+		BLOCKING_VISIT
 	};
 
-	enum EAccessibility
+	enum EAccessibility : ui8
 	{
 		NOT_SET = 0,
 		ACCESSIBLE = 1, //tile can be entered and passed
@@ -47,14 +47,14 @@ struct DLL_LINKAGE CGPathNode
 		BLOCKED //tile can't be entered nor visited
 	};
 
-	bool locked;
-	EAccessibility accessible;
-	ui8 turns; //how many turns we have to wait before reachng the tile - 0 means current turn
-	ui32 moveRemains; //remaining tiles after hero reaches the tile
 	CGPathNode * theNodeBefore;
 	int3 coord; //coordinates
+	ui32 moveRemains; //remaining tiles after hero reaches the tile
+	ui8 turns; //how many turns we have to wait before reachng the tile - 0 means current turn
 	ELayer layer;
+	EAccessibility accessible;
 	ENodeAction action;
+	bool locked;
 
 	CGPathNode();
 	void reset();

+ 2 - 2
lib/GameConstants.h

@@ -748,9 +748,9 @@ ID_LIKE_OPERATORS_DECLS(ETerrainType, ETerrainType::EETerrainType)
 class DLL_LINKAGE EPathfindingLayer
 {
 public:
-	enum EEPathfindingLayer
+	enum EEPathfindingLayer : ui8
 	{
-		WRONG = -2, AUTO = -1, LAND = 0, SAIL = 1, WATER, AIR, NUM_LAYERS
+		WRONG = 0, AUTO = 1, LAND = 2, SAIL = 3, WATER, AIR, NUM_LAYERS
 	};
 
 	EPathfindingLayer(EEPathfindingLayer _num = WRONG) : num(_num)