Skip to content

Commit fe12f1d

Browse files
Maullerxezon
authored andcommitted
unify(pathfinder): Merge CellTypes and CELL_BRIDGE_IMPASSABLE code from Zero Hour (TheSuperHackers#2381)
1 parent bb37a9b commit fe12f1d

2 files changed

Lines changed: 25 additions & 3 deletions

File tree

Generals/Code/GameEngine/Include/GameLogic/AIPathfind.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,9 @@ class PathfindCell
281281
CELL_WATER = 0x01, ///< water area
282282
CELL_CLIFF = 0x02, ///< steep altitude change
283283
CELL_RUBBLE = 0x03, ///< Cell is occupied by rubble.
284-
CELL_OBSTACLE = 0x04, ///< impassable area
285-
CELL_unused = 0x08, ///< Unused.
286-
CELL_IMPASSABLE = 0x0B ///< Just plain impassable except for aircraft.
284+
CELL_OBSTACLE = 0x04, ///< Occupied by a structure
285+
CELL_BRIDGE_IMPASSABLE = 0x05, ///< Piece of a bridge that is impassable.
286+
CELL_IMPASSABLE = 0x06 ///< Just plain impassable except for aircraft.
287287
};
288288

289289
enum CellFlags

Generals/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,20 @@
7676
//-------------------------------------------------------------------------------------------------
7777

7878

79+
static inline Bool IS_IMPASSABLE(PathfindCell::CellType type) {
80+
// Return true if cell is impassable to ground units. jba. [8/18/2003]
81+
if (type==PathfindCell::CELL_IMPASSABLE) {
82+
return true;
83+
}
84+
if (type==PathfindCell::CELL_OBSTACLE) {
85+
return true;
86+
}
87+
if (type==PathfindCell::CELL_BRIDGE_IMPASSABLE) {
88+
return true;
89+
}
90+
return false;
91+
}
92+
7993

8094
struct TCheckMovementInfo
8195
{
@@ -3088,6 +3102,9 @@ void PathfindLayer::doDebugIcons() {
30883102
} else if (cell->getType() == PathfindCell::CELL_IMPASSABLE) {
30893103
color.red = color.green = color.blue = 1;
30903104
empty = false;
3105+
} else if (cell->getType() == PathfindCell::CELL_BRIDGE_IMPASSABLE) {
3106+
color.blue = color.red = 1;
3107+
empty = false;
30913108
} else if (cell->getType() == PathfindCell::CELL_CLIFF) {
30923109
color.red = 1;
30933110
empty = false;
@@ -4388,6 +4405,7 @@ Locomotor* Pathfinder::chooseBestLocomotorForPosition(PathfindLayerEnum layer, L
43884405
return LOCOMOTORSURFACE_RUBBLE | LOCOMOTORSURFACE_AIR;
43894406

43904407
case PathfindCell::CELL_OBSTACLE:
4408+
case PathfindCell::CELL_BRIDGE_IMPASSABLE:
43914409
case PathfindCell::CELL_IMPASSABLE:
43924410
return LOCOMOTORSURFACE_AIR;
43934411

@@ -5311,6 +5329,10 @@ void Pathfinder::doDebugIcons() {
53115329
color.red = 1;
53125330
empty = false;
53135331
break;
5332+
case PathfindCell::CELL_BRIDGE_IMPASSABLE:
5333+
color.blue = color.red = 1;
5334+
empty = false;
5335+
break;
53145336
case PathfindCell::CELL_IMPASSABLE:
53155337
color.green = 1;
53165338
empty = false;

0 commit comments

Comments
 (0)