Skip to content

Commit aec0063

Browse files
committed
fix: hopefully improve partner leaderboard close
i got no clue, lmk
1 parent f1b26d0 commit aec0063

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/Modules/Client.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -319,18 +319,20 @@ DETOUR_T(const char *, Client::GetName) {
319319
}
320320

321321
static bool g_leaderboardOpen = false;
322+
static bool g_leaderboardWillClose = false;
322323
DETOUR_COMMAND(Client::openleaderboard) {
323324
Client::openleaderboard_callback(args);
324325

325326
if (args.ArgC() == 2 && !strcmp(args[1], "4") && client->GetChallengeStatus() == CMStatus::CHALLENGE) {
326327
g_leaderboardOpen = true;
327-
if (sar.game->Is(SourceGame_Portal2) && sar_disable_challenge_stats_hud.GetInt() > 0 && (!engine->IsCoop() || engine->IsOrange())) {
328-
auto ticks = 6;
329-
if (sar_disable_challenge_stats_hud.GetInt() > 1) ticks = sar_disable_challenge_stats_hud.GetInt();
330-
Scheduler::InHostTicks(ticks, []() {
328+
auto ticks = 6;
329+
if (sar_disable_challenge_stats_hud.GetInt() > 1) ticks = sar_disable_challenge_stats_hud.GetInt();
330+
Scheduler::InHostTicks(ticks, []() {
331+
if (sar.game->Is(SourceGame_Portal2) && sar_disable_challenge_stats_hud.GetInt() > 0 && (!engine->IsCoop() || engine->IsOrange() || g_leaderboardWillClose)) {
332+
g_leaderboardWillClose = false;
331333
engine->ExecuteCommand("-leaderboard");
332-
});
333-
}
334+
}
335+
});
334336
}
335337
}
336338

@@ -432,6 +434,7 @@ ON_INIT {
432434
NetMessage::RegisterHandler(LEADERBOARD_MESSAGE_TYPE, +[](const void *data, size_t size) {
433435
// TODO: Investigate why this sometimes doesn't work - AMJ 2024-04-25
434436
if (sar_disable_challenge_stats_hud_partner.GetBool()) {
437+
g_leaderboardWillClose = true;
435438
engine->ExecuteCommand("-leaderboard");
436439
} });
437440
}

0 commit comments

Comments
 (0)