Skip to content

unify(pathfinder): Merge PathfindLayer::doDebugIcons(), Pathfinder::Classify functions, Pathfinder::checkDestination() and Pathfinder::checkForMovement()#2414

Open
Mauller wants to merge 2 commits intoTheSuperHackers:mainfrom
Mauller:Mauller/unify-pathfinder-classify-functions
Open

unify(pathfinder): Merge PathfindLayer::doDebugIcons(), Pathfinder::Classify functions, Pathfinder::checkDestination() and Pathfinder::checkForMovement()#2414
Mauller wants to merge 2 commits intoTheSuperHackers:mainfrom
Mauller:Mauller/unify-pathfinder-classify-functions

Conversation

@Mauller
Copy link

@Mauller Mauller commented Mar 6, 2026

This PR merges the next block of functions.

PathfindLayer::doDebugIcons() inherits the Zero Hour implementation.

Pathfinder::classifyCells(), PathfindLayer::classifyLayerMapCell() and PathfindLayer::classifyWallMapCell() have small conditional cahnges that are required for Generals to not mismatch with retail.

Pathfinder::classifyFence, Pathfinder::classifyObjectFootprint and Pathfinder::internal_classifyObjectFootprint have heavy amounts of conditional compilation within them due to significant changes from Generals to Zero Hour.

Pathfinder::checkDesination() and Pathfinder::checkForMovement() only have smaller changes.

I stopped at this point as going further requires dragging in all of the rest of the merge worth of changes and would be too much in this one.

This PR can be squash merged

@Mauller Mauller self-assigned this Mar 6, 2026
@Mauller Mauller added Gen Relates to Generals ZH Relates to Zero Hour Unify Unifies code between Generals and Zero Hour labels Mar 6, 2026
@greptile-apps
Copy link

greptile-apps bot commented Mar 6, 2026

Greptile Summary

This PR introduces conditional-compilation guards (#if RTS_GENERALS && RETAIL_COMPATIBLE_PATHFINDING) across PathfindLayer::doDebugIcons(), the Pathfinder::classify* family, checkDestination(), and checkForMovement() to unify the Generals and Zero Hour source trees while keeping each game's retail-compatible behaviour correct.

Key changes:

  • doDebugIcons() in Generals inherits the ZH flashing debug-icon behaviour (static Int flash) and uses a per-cell size variable instead of the fixed 0.8f scale factor; empty now defaults to false so every cell renders a (small) icon.
  • Bridge-layer cell-type assignments (CELL_IMPASSABLE vs CELL_BRIDGE_IMPASSABLE, CELL_CLIFF vs CELL_BRIDGE_IMPASSABLE) are now split by build macro in both files.
  • classifyFence and internal_classifyObjectFootprint in the non-retail-compat path now track per-cell zone dirtying incrementally and call updateZonesForModify only when something changed, rather than always calling markZonesDirty up-front.
  • checkDestination adds an IS_IMPASSABLE early-out for the non-retail-compat path; checkForMovement() branches are properly gated by conditional compilation.
  • Newly introduced single-line if bodies in doDebugIcons() and the cellBounds tracking loops violate the project style guide and should place bodies on their own lines for debugger breakpoint placement.

Confidence Score: 4/5

  • Safe to merge after style violations are corrected; well-structured conditional-compilation unification with no logic errors.
  • The ZH file changes are well-structured reorganisations with no behavioural delta. The Generals file correctly gates code paths via conditional compilation. Minor style violations (single-line if bodies) are the only issue requiring correction before merge.
  • Generals/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp — style violations in doDebugIcons() and cellBounds tracking loops (lines 3327–3328, 4160–4163, 4343–4346, 4414–4417).

Last reviewed commit: 72f9a0d

#if RTS_GENERALS && RETAIL_COMPATIBLE_PATHFINDING
cell->setType(PathfindCell::CELL_CLIFF); // it's off the bridge.
#else
cell->setType(PathfindCell::CELL_BRIDGE_IMPASSABLE); // it's off the bridge.
Copy link

Choose a reason for hiding this comment

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

I wonder if another way to write this was doing CELL_BRIDGE_IMPASSABLE = CELL_CLIFF for CRC Generals.

Copy link
Author

Choose a reason for hiding this comment

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

i will have a nother look at this, i didn't consider tweaking the struct

Copy link
Author

@Mauller Mauller Mar 6, 2026

Choose a reason for hiding this comment

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

Actually looking back at it, they swap between using CELL_CLIFF and CELL_IMPASSABLE for different parts of a bridge, while Zero Hour replaced them with just CELL_BRIDGE_IMPASSABLE

// removing, so it's safer to just remove it, as by the time some units "die", they've become
// lifeless immobile husks of debris, but we still need to remove them. jba.

#if !RTS_GENERALS
Copy link

Choose a reason for hiding this comment

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

Needs RETAIL_COMPATIBLE_PATHFINDING ?

Copy link
Author

Choose a reason for hiding this comment

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

If this involved KINDOF_BLAST_CRATER, they don't exist in generals so compiling without retail compatible in generals is invalid for this.

I left an issue about KindOfType, since the structures changed between generals and zero hour in a way that will make them incompatible. But it also depends on how these are used relative to data.

return;
}

#if RTS_GENERALS
Copy link

Choose a reason for hiding this comment

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

Needs RETAIL_COMPATIBLE_PATHFINDING ?

// removing, so it's safer to just remove it, as by the time some units "die", they've become
// lifeless immobile husks of debris, but we still need to remove them. jba.

#if !RTS_GENERALS
Copy link

Choose a reason for hiding this comment

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

Needs RETAIL_COMPATIBLE_PATHFINDING ?

return;
}

#if RTS_GENERALS
Copy link

Choose a reason for hiding this comment

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

Needs RETAIL_COMPATIBLE_PATHFINDING ?

@Mauller Mauller changed the title unify(pathfinder): Merge PathfindLayer::doDebugIcons(), Pathfinder::Classify functions, Pathfinder::checkDesination() and Pathfinder::checkForMovement() unify(pathfinder): Merge PathfindLayer::doDebugIcons(), Pathfinder::Classify functions, Pathfinder::checkDesyination() and Pathfinder::checkForMovement() Mar 6, 2026
@Mauller Mauller changed the title unify(pathfinder): Merge PathfindLayer::doDebugIcons(), Pathfinder::Classify functions, Pathfinder::checkDesyination() and Pathfinder::checkForMovement() unify(pathfinder): Merge PathfindLayer::doDebugIcons(), Pathfinder::Classify functions, Pathfinder::checkDestination() and Pathfinder::checkForMovement() Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Gen Relates to Generals Unify Unifies code between Generals and Zero Hour ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants