mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2025-12-18 22:12:18 +00:00
Fix logic for the grind booster HFR fix. (#431)
This commit is contained in:
parent
b8ae355915
commit
f123ec7083
3 changed files with 13 additions and 10 deletions
|
|
@ -60,6 +60,7 @@ PPC_FUNC(sub_822C1130)
|
|||
}
|
||||
|
||||
App::s_deltaTime = ctx.f1.f64;
|
||||
App::s_time += App::s_deltaTime;
|
||||
|
||||
// This function can also be called by the loading thread,
|
||||
// which SDL does not like. To prevent the OS from thinking
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ public:
|
|||
static inline ELanguage s_language;
|
||||
|
||||
static inline double s_deltaTime;
|
||||
static inline double s_time = 0.0; // How much time elapsed since the game started.
|
||||
|
||||
static void Restart(std::vector<std::string> restartArgs = {});
|
||||
static void Exit();
|
||||
|
|
|
|||
|
|
@ -106,14 +106,14 @@ static constexpr size_t OBJ_GRIND_DASH_PANEL_SIZE = 0x160;
|
|||
|
||||
void ObjGrindDashPanelAllocMidAsmHook(PPCRegister& r3)
|
||||
{
|
||||
r3.u32 += sizeof(std::chrono::steady_clock::time_point);
|
||||
r3.u32 += sizeof(double);
|
||||
}
|
||||
|
||||
// SWA::CObjGrindDashPanel::CObjGrindDashPanel
|
||||
PPC_FUNC_IMPL(__imp__sub_82614228);
|
||||
PPC_FUNC(sub_82614228)
|
||||
{
|
||||
new (base + ctx.r3.u32 + OBJ_GRIND_DASH_PANEL_SIZE) std::chrono::steady_clock::time_point();
|
||||
*reinterpret_cast<double*>(base + ctx.r3.u32 + OBJ_GRIND_DASH_PANEL_SIZE) = 0.0;
|
||||
__imp__sub_82614228(ctx, base);
|
||||
}
|
||||
|
||||
|
|
@ -121,14 +121,15 @@ PPC_FUNC(sub_82614228)
|
|||
PPC_FUNC_IMPL(__imp__sub_826145D8);
|
||||
PPC_FUNC(sub_826145D8)
|
||||
{
|
||||
auto pLastHitTime = (std::chrono::steady_clock::time_point*)g_memory.Translate(ctx.r3.u32 + OBJ_GRIND_DASH_PANEL_SIZE);
|
||||
auto now = std::chrono::steady_clock::now();
|
||||
auto deltaTime = std::min(std::chrono::duration<double>(now - *pLastHitTime).count(), 1.0 / 15.0);
|
||||
constexpr double REFERENCE_DELTA_TIME = 1.0 / 30.0;
|
||||
constexpr double DELTA_TIME_TOLERANCE = 0.0001;
|
||||
|
||||
*pLastHitTime = now;
|
||||
auto lastHitTime = reinterpret_cast<double*>(base + ctx.r3.u32 + OBJ_GRIND_DASH_PANEL_SIZE);
|
||||
auto deltaTime = App::s_time - *lastHitTime;
|
||||
|
||||
if (deltaTime < 1.0 / 30.0)
|
||||
return;
|
||||
|
||||
__imp__sub_826145D8(ctx, base);
|
||||
if ((deltaTime + DELTA_TIME_TOLERANCE) > REFERENCE_DELTA_TIME)
|
||||
{
|
||||
__imp__sub_826145D8(ctx, base);
|
||||
*lastHitTime = App::s_time;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue