Skip to content

refactor(pathfinder): Split several individual classes off of AIPathfind.cpp into separate source files. - #3429

Draft
Skyaero42 wants to merge 10 commits into
TheSuperHackers:mainfrom
Skyaero42:skyaero/extract-pathfind-implementation
Draft

Skyaero42 wants to merge 10 commits into
TheSuperHackers:mainfrom
Skyaero42:skyaero/extract-pathfind-implementation

Conversation

@Skyaero42

Copy link
Copy Markdown

This PR extracts several pathfinder class implementations from the aipathfind.cpp source file into their own source files to increase readability and maintainability. This is another step into refactoring the pathfinding code.

  • Background info: Refactor pathfinding code for easier readability and maintainability #3333
  • Each class is extract in its own commit.
  • An extra commit has been made to move global constants and defines in the cpp into their own header/implementation class.
  • Formatting hasn't been touched
  • The pathfinder class implementation and some remnants used by the pathfinder remain in aipathfind.cpp and are left as-is

Todo:

  • Reword commit messages to include PR number

@Skyaero42 Skyaero42 added the Refactor Edits the code with insignificant behavior changes, is never user facing label Oct 5, 2026
@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2355db12-e2d0-4db6-ba7f-ef5082b24a43
📥 Commits

Reviewing files that changed from the base of the PR and between 673db51 and 0912535.

📒 Files selected for processing (1)
  • Core/GameEngine/Source/GameLogic/AI/Pathfinder/PathfindZoneManager.cpp

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.


Walkthrough

The change adds Pathfinder constants, cell and pooled-info state, path nodes and route operations, bridge and wall layer handling, and zone calculation and lookup. It registers the Pathfinder headers and sources in the GameEngine build and includes compatibility-specific behavior under documented compile-time conditions.

Changes

Pathfinder implementation

Layer / File(s) Summary
Constants and build registration
Core/GameEngine/Include/GameLogic/Pathfinder/PathfindConstants.h, Core/GameEngine/Source/GameLogic/AI/Pathfinder/PathfindConstants.cpp, Core/GameEngine/Include/GameLogic/AIPathfind.h, Core/GameEngine/CMakeLists.txt
Defines shared pathfinding limits and costs, imports them through AIPathfind.h, removes the former local definitions, and registers the Pathfinder headers and source files in the GameEngine build.
Cell state and search lists
Core/GameEngine/Include/GameLogic/Pathfinder/PathfindCell.h, Core/GameEngine/Source/GameLogic/AI/Pathfinder/PathfindCell.cpp, Core/GameEngine/Include/GameLogic/Pathfinder/PathfindCellInfo.h, Core/GameEngine/Source/GameLogic/AI/Pathfinder/PathfindCellInfo.cpp, Core/GameEngine/Source/GameLogic/AI/Pathfinder/PathfindCellList.cpp
Implements cell state, pooled cell-info allocation, obstacle and unit data, open and closed search lists, path costs, and cell-type compatibility checks.
Map layers and zone management
Core/GameEngine/Include/GameLogic/Pathfinder/ZoneBlock.h, Core/GameEngine/Source/GameLogic/AI/Pathfinder/PathfindLayer.cpp, Core/GameEngine/Source/GameLogic/AI/Pathfinder/ZoneBlock.cpp, Core/GameEngine/Source/GameLogic/AI/Pathfinder/PathfindZoneManager.cpp
Implements bridge and wall cell classification, zone equivalencies, zone calculation and updates, block passability and bridge flags, and effective-zone lookup.
Path operations
Core/GameEngine/Source/GameLogic/AI/Pathfinder/PathNode.cpp, Core/GameEngine/Source/GameLogic/AI/Pathfinder/Path.cpp
Implements path-node links, path serialization and insertion, path optimization, movement-point selection, and flight-path distance calculation.

Priority: ⬇️ Low

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Refactor

Merge Risk: ⚪ Minimal · up to 09125

This change moves the pathfinder zone-management code into its own source file. No concrete defects were found in this update, so it appears ready to merge after normal build checks.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: splitting pathfinder class implementations into separate source files.
Description check ✅ Passed The description explains the extraction of pathfinder implementations and the move of constants into separate files, which matches the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Skyaero42
Skyaero42 force-pushed the skyaero/extract-pathfind-implementation branch from fc7abbf to 673db51 Compare October 5, 2026 18:32
Skyaero42 added a commit to Skyaero42/GeneralsGameCode that referenced this pull request Oct 5, 2026
Skyaero42 added a commit to Skyaero42/GeneralsGameCode that referenced this pull request Oct 5, 2026
inline UnsignedShort getXIndex() const {return m_info->m_pos.x;}
inline UnsignedShort getYIndex() const {return m_info->m_pos.y;}

inline Bool isBlockedByAlly() const;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compiler didn't want to play nice with some of the functions being inlined, so it was removed.

void setConnectLayer( PathfindLayerEnum layer ) { m_connectsToLayer = layer; } ///< set the cell layer connect id
PathfindLayerEnum getConnectLayer() const { return (PathfindLayerEnum)m_connectsToLayer; } ///< get the cell layer connect id

static Bool typesMatch(const PathfindCell& targetCell, const PathfindCell& sourceCell);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were global functions that better fit as a static function in the PathfindCell class

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2b56a31b-122e-4e08-b863-f35a3f59cbc5
📥 Commits

Reviewing files that changed from the base of the PR and between 171894d and 673db51.

📒 Files selected for processing (16)
  • Core/GameEngine/CMakeLists.txt
  • Core/GameEngine/Include/GameLogic/AIPathfind.h
  • Core/GameEngine/Include/GameLogic/Pathfinder/PathfindCell.h
  • Core/GameEngine/Include/GameLogic/Pathfinder/PathfindCellInfo.h
  • Core/GameEngine/Include/GameLogic/Pathfinder/PathfindConstants.h
  • Core/GameEngine/Include/GameLogic/Pathfinder/ZoneBlock.h
  • Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp
  • Core/GameEngine/Source/GameLogic/AI/Pathfinder/Path.cpp
  • Core/GameEngine/Source/GameLogic/AI/Pathfinder/PathNode.cpp
  • Core/GameEngine/Source/GameLogic/AI/Pathfinder/PathfindCell.cpp
  • Core/GameEngine/Source/GameLogic/AI/Pathfinder/PathfindCellInfo.cpp
  • Core/GameEngine/Source/GameLogic/AI/Pathfinder/PathfindCellList.cpp
  • Core/GameEngine/Source/GameLogic/AI/Pathfinder/PathfindConstants.cpp
  • Core/GameEngine/Source/GameLogic/AI/Pathfinder/PathfindLayer.cpp
  • Core/GameEngine/Source/GameLogic/AI/Pathfinder/PathfindZoneManager.cpp
  • Core/GameEngine/Source/GameLogic/AI/Pathfinder/ZoneBlock.cpp

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@Skyaero42
Skyaero42 force-pushed the skyaero/extract-pathfind-implementation branch from 673db51 to 0912535 Compare October 5, 2026 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Refactor Edits the code with insignificant behavior changes, is never user facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants