Skip to content

tweak(pathfinder): Add audio event and message to announce pathfinding failover#2242

Merged
xezon merged 1 commit intoTheSuperHackers:mainfrom
Mauller:Mauller/tweak-add-pathfinding-failover-notification
Feb 4, 2026
Merged

tweak(pathfinder): Add audio event and message to announce pathfinding failover#2242
xezon merged 1 commit intoTheSuperHackers:mainfrom
Mauller:Mauller/tweak-add-pathfinding-failover-notification

Conversation

@Mauller
Copy link

@Mauller Mauller commented Feb 2, 2026

This PR is to help people, on the TSH or TSH vs Retail, know that the pathfinding has switched to the crash fixed code path.

The Unicode Message is used simply since it can write straight to the game ui without any kind of tags.

I chose the cheering audio event since it's noticeable and people don't often use it during a game.

Example of the notification ingame. (ignore the mismatch message, this pathfinder crash replay always mismatches near the end).

image

@Mauller Mauller self-assigned this Feb 2, 2026
@Mauller Mauller added Enhancement Is new feature or request GUI For graphical user interface Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour labels Feb 2, 2026
@greptile-apps
Copy link

greptile-apps bot commented Feb 2, 2026

Greptile Overview

Greptile Summary

Added player notification when pathfinding crashes are prevented and the system failovers to fixed pathfinding code. The changes display a localized message via TheInGameUI and play a distinctive cheer sound to alert players when the pathfinding switches from retail-compatible mode to the crash-fixed implementation.

Key Changes:

  • Added conditional includes for InGameUI.h, GameText.h, GameAudio.h, and MiscAudio.h under the RETAIL_COMPATIBLE_PATHFINDING macro
  • Implemented user-facing notification in Pathfinder::forceCleanCells() using localized text lookup with fallback message
  • Plays m_allCheerSound audio event to provide audible feedback to players
  • Applied identical changes to both Generals (vanilla) and GeneralsMD (Zero Hour) codebases

Technical Review:

  • The notification code is correctly placed within forceCleanCells(), which is already guarded by #if RETAIL_COMPATIBLE_PATHFINDING (lines 1096-1140)
  • The function is only called when !s_useFixedPathfinding, ensuring the notification displays exactly once per game session
  • Global pointers (TheGameText, TheInGameUI, TheAudio) are used without null checks, consistent with codebase patterns where these are guaranteed to be initialized during active gameplay
  • Grammar has been corrected to use lowercase "now" after the comma
  • Copyright headers are correct per custom instructions (EA copyright retained for original source files)

Confidence Score: 5/5

  • This PR is safe to merge with no identified issues
  • The changes are straightforward and well-implemented: adds user notification and audio feedback to an existing failover mechanism without altering core pathfinding logic. The code follows established patterns in the codebase, is properly guarded by existing preprocessor macros, and includes appropriate localization support with fallback text. Previous review concerns about grammar and macro guards have been addressed.
  • No files require special attention

Important Files Changed

Filename Overview
Generals/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp Added user notification and audio feedback when pathfinding failover occurs
GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp Added user notification and audio feedback when pathfinding failover occurs (Zero Hour version)

Sequence Diagram

sequenceDiagram
    participant Pathfinder
    participant PathfindCell
    participant TheGameText
    participant TheInGameUI
    participant TheAudio
    
    Note over Pathfinder: Pathfinding crash detected
    Pathfinder->>Pathfinder: Check !s_useFixedPathfinding
    Pathfinder->>Pathfinder: Set s_useFixedPathfinding = true
    Pathfinder->>Pathfinder: Call forceCleanCells()
    
    activate Pathfinder
    Pathfinder->>TheGameText: FETCH_OR_SUBSTITUTE("GUI:PathfindingCrashPrevented", fallback)
    TheGameText-->>Pathfinder: UnicodeString message
    Pathfinder->>TheInGameUI: message(pathfinderFailoverMessage)
    Note over TheInGameUI: Display notification to player
    Pathfinder->>TheAudio: addAudioEvent(&m_allCheerSound)
    Note over TheAudio: Play cheer sound alert
    Pathfinder->>PathfindCell: forceCleanPathFindCellInfos()
    Note over PathfindCell: Clear all cell info states
    Pathfinder->>Pathfinder: Clear m_openList and m_closedList
    Pathfinder->>Pathfinder: Reset pathfind cells and release info
    deactivate Pathfinder
    
    Note over Pathfinder: Continue with fixed pathfinding
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Copy link

@xezon xezon left a comment

Choose a reason for hiding this comment

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

Looks correct. Perhaps use FETCH_OR_SUBSTITUTE to allow localized texts.

@xezon
Copy link

xezon commented Feb 2, 2026

Some tests were cancelled.

@Mauller
Copy link
Author

Mauller commented Feb 3, 2026

Some tests were cancelled.

Git Runner issues

@Mauller
Copy link
Author

Mauller commented Feb 3, 2026

Adjusted the text and used FETCH_OR_SUBSTITUTE.

image

@Mauller Mauller force-pushed the Mauller/tweak-add-pathfinding-failover-notification branch from da1b9a9 to 08a2b99 Compare February 3, 2026 17:51
@Mauller Mauller force-pushed the Mauller/tweak-add-pathfinding-failover-notification branch from 08a2b99 to 5a23987 Compare February 3, 2026 20:44
@Mauller
Copy link
Author

Mauller commented Feb 3, 2026

Updated wording based on feedback.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@Mauller Mauller force-pushed the Mauller/tweak-add-pathfinding-failover-notification branch from 5a23987 to 7823384 Compare February 3, 2026 21:09
@Mauller
Copy link
Author

Mauller commented Feb 3, 2026

image

@xezon xezon merged commit 32a2789 into TheSuperHackers:main Feb 4, 2026
24 checks passed
@xezon xezon deleted the Mauller/tweak-add-pathfinding-failover-notification branch February 4, 2026 19:25
githubawn pushed a commit to githubawn/GeneralsGameCode that referenced this pull request Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement Is new feature or request Gen Relates to Generals GUI For graphical user interface Minor Severity: Minor < Major < Critical < Blocker ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants