Skip to content

Commit

Permalink
Merge pull request #111 from F2/fix-pause-uber-bug
Browse files Browse the repository at this point in the history
Fixed pauses being detected incorrectly causing full ubers after pauses
  • Loading branch information
ldesgoui authored Sep 22, 2024
2 parents 77814ba + e75bd25 commit 212823c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion scripting/tf2-comp-fixes.sp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void OnLibraryAdded(const char[] name) {
}

public
void OnMapStart() { FixPostPauseState_OnMapStart(); }
void OnGameFrame() { FixPostPauseState_OnGameFrame(); }

public
void OnClientPutInServer(int client) {
Expand Down
18 changes: 15 additions & 3 deletions scripting/tf2-comp-fixes/fix-post-pause-state.sp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,21 @@ void FixPostPauseState_Setup() {
CreateBoolConVar("sm_fix_post_pause_state", WhenConVarChange);
}

void FixPostPauseState_OnMapStart() { g_paused = false; }
void FixPostPauseState_OnGameFrame()
{
static float lastGameTime = -1.0;
float flCurrentGameTime = GetGameTime();

if (flCurrentGameTime == lastGameTime)
{
g_paused = true;
}
else
{
g_paused = false;
lastGameTime = flCurrentGameTime;
}
}

static void WhenConVarChange(ConVar cvar, const char[] before, const char[] after) {
if (cvar.BoolValue == TruthyConVar(before)) {
Expand Down Expand Up @@ -69,7 +83,5 @@ static Action WhenPause(int author, const char[] command, int argc) {
}
}

g_paused = !g_paused;

return Plugin_Continue;
}

0 comments on commit 212823c

Please sign in to comment.