Skip to content

Fix: sar_disable_challenge_stats_hud -1 causes incorrect ending dialogue to play - #374

Merged
ThisAMJ merged 2 commits into
p2sr:masterfrom
betsruner:stats_hud_audio
Aug 8, 2026
Merged

Fix: sar_disable_challenge_stats_hud -1 causes incorrect ending dialogue to play#374
ThisAMJ merged 2 commits into
p2sr:masterfrom
betsruner:stats_hud_audio

Conversation

@betsruner

Copy link
Copy Markdown
Member

Fixes #19

When sar_disable_challenge_stats_hud was set to -1 sometimes (not consistently) when the player got a Personal Best it would use the incorrect line of dialogue "Maybe I was wrong about you".

This happened because SAR detours CHud::GetName to return an empty string. Due to that when the game searched for the challenge stats hud panel it was unable to find it, which of course means that it couldn't set its open leaderboard flag. The leaderboards OnThink function would normally then see that flag and open the leaderboard which would eventually asynchronously preload the leaderboard data. Since the data is never preloaded, when the level is completed the end screen tries to create the leaderboard and query for the scores. That causes a race, if the time is updated first then the query sees the new score as equal to the current score instead of an improvement. If the query finishes first then the game has the correct data so it will play the appropriate dialogue.

The fix is whenever the original +leaderboard 4 callback is run SAR then directly calls CPortalLeaderboardManager::FindOrCreateLeaderboard for the current map. This ends up preloading the data preventing the race and causing the correct dialogue to play 100% of the time. This is the same async preload the leaderboard window would have done anyway so there shouldn't be any particular issues with resolving it like this.

I tested the change pretty thoroughly. When initially figuring out what was causing the incorrect dialogue to play I learned you could almost always get bad dialogue to play if you completed a run that didn't PB prior to PBing. So I tested it doing that + some runs when I just got a PB right away just in case. Did that on both Windows and Linux, Cooperative and Singleplayer. With the fix I've never had the incorrect dialogue play.

Marginally interesting, the original fix of just patching the dialogue after the fact (not the current implementation) actually worked on Windows (both Coop and SP), but it didn't work on Linux. The clankers and I couldn't find any platform specific reason why that was the case. That's why I decided to switch to doing it the more correct way (actually preloading the data the same way the game would).

@ThisAMJ
ThisAMJ merged commit 55f3dab into p2sr:master Aug 8, 2026
2 checks passed
ThisAMJ pushed a commit that referenced this pull request Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using sar_disable_challenge_stats_hud 1 results in same voice line

2 participants