Skip to content

Commit

Permalink
fix: unclamp frame time
Browse files Browse the repository at this point in the history
untested because apparently my pc sucks and cant pull 1000, and i dont know what to look for below 10
Fixes #130
  • Loading branch information
ThisAMJ committed Feb 3, 2024
1 parent 86f3ed6 commit 79a3df3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Modules/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ bool Engine::IsSkipping() {
}

static float *host_frametime;
static float *host_frametime_unbounded;
void Host_AccumulateTime_Detour(float dt);
void (*Host_AccumulateTime)(float dt);
static Hook Host_AccumulateTime_Hook(&Host_AccumulateTime_Detour);
Expand All @@ -657,10 +658,12 @@ void Host_AccumulateTime_Detour(float dt) {
Host_AccumulateTime_Hook.Disable();
Host_AccumulateTime(dt);
Host_AccumulateTime_Hook.Enable();
*host_frametime = *host_frametime_unbounded;
} else if (g_advance > 0) {
Host_AccumulateTime_Hook.Disable();
Host_AccumulateTime(1.0f/60);
Host_AccumulateTime_Hook.Enable();
*host_frametime = *host_frametime_unbounded;
--g_advance;
} else {
*host_frametime = 0;
Expand Down Expand Up @@ -998,6 +1001,7 @@ bool Engine::Init() {
host_frametime = *(float **)((uintptr_t)Host_AccumulateTime + 70);
}
#endif
host_frametime_unbounded = host_frametime + Offsets::host_frametime_unbounded;

Host_AccumulateTime_Hook.SetFunc(Host_AccumulateTime);

Expand Down
1 change: 1 addition & 0 deletions src/OffsetsData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ OFFSET_DEFAULT(Con_IsVisible, 11, 11)
OFFSET_DEFAULT(GetLevelNameShort, 53, 53)
OFFSET_DEFAULT(GetLightForPoint, 1, 1)
OFFSET_DEFAULT(GetPlayerInfo, 8, 8);
OFFSET_DEFAULT(host_frametime_unbounded, 1, -1);

// CHLClient
OFFSET_DEFAULT(GetAllClasses, 8, 8)
Expand Down

0 comments on commit 79a3df3

Please sign in to comment.