8000 refactor(pathfinder): Implement PathfindCellList class for PathfindCell open and closed lists by Mauller · Pull Request #2327 · TheSuperHackers/GeneralsGameCode · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 27 additions & 9 deletions Generals/Code/GameEngine/Include/GameLogic/AIPathfind.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,24 @@ class PathfindCellInfo
UnsignedInt m_closed:1; ///< place for marking this cell as on the closed list
};

// TheSuperHackers @info The PathfindCellList class acts as a new management class for the pathfindcell open and closed lists
class PathfindCellList
{
friend class PathfindCell;

public:
PathfindCellList() : m_head(nullptr) {}

void reset(PathfindCell* newHead = nullptr) { m_head = newHead; }

PathfindCell* getHead() const { return m_head; }

Bool empty() const { return m_head == nullptr; }

private:
PathfindCell* m_head;
};

/**
* This represents one cell in the pathfinding grid.
* These cells categorize the world into idealized cellular states,
Expand Down Expand Up @@ -307,23 +325,23 @@ class PathfindCell

UnsignedInt costSoFar( PathfindCell *parent );

/// put self on "open" list in ascending cost order, return new list
PathfindCell *putOnSortedOpenList( PathfindCell *list );
/// put self on "open" list in ascending cost order
void putOnSortedOpenList( PathfindCellList &list );

/// remove self from "open" list
PathfindCell *removeFromOpenList( PathfindCell *list );
void removeFromOpenList( PathfindCellList &list );

/// put self on "closed" list, return new list
PathfindCell *putOnClosedList( PathfindCell *list );
void putOnClosedList( PathfindCellList &list );

/// remove self from "closed" list
PathfindCell *removeFromClosedList( PathfindCell *list );
void removeFromClosedList( PathfindCellList &list );

/// remove all cells from closed list.
static Int releaseClosedList( PathfindCell *list );
static Int releaseClosedList( PathfindCellList &list );

/// remove all cells from closed list.
static Int releaseOpenList( PathfindCell *list );
static Int releaseOpenList( PathfindCellList &list );

inline PathfindCell *getNextOpen(void) {return m_info->m_nextOpen?m_info->m_nextOpen->m_cell: nullptr;}

Expand Down Expand Up @@ -848,8 +866,8 @@ class Pathfinder : PathfindServicesInterface, public Snapshot
IRegion2D m_extent; ///< Grid extent limits
IRegion2D m_logicalExtent; ///< Logical grid extent limits

PathfindCell *m_openList; ///< Cells ready to be explored
PathfindCell *m_closedList; ///< Cells already explored
PathfindCellList m_openList; ///< Cells ready to be explored
PathfindCellList m_closedList; ///< Cells already explored

Bool m_isMapReady; ///< True if all cells of map have been classified
Bool m_isTunneling; ///< True if path started in an obstacle
Expand Down
Loading
Loading
0