Fix: sar_disable_challenge_stats_hud -1 causes incorrect ending dialogue to play - #374
Merged
Conversation
ThisAMJ
force-pushed
the
stats_hud_audio
branch
from
August 8, 2026 02:58
930a16b to
d43ada4
Compare
ThisAMJ
pushed a commit
that referenced
this pull request
Aug 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #19
When
sar_disable_challenge_stats_hudwas set to-1sometimes (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 4callback 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).