Skip to content

Commit 7236bd7

Browse files
committed
make CCutsceneObjectHook more narrow
- fixes fps drop during cutscenes
1 parent 68a0e10 commit 7236bd7

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

source/framelimit.ixx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,20 @@ void __cdecl sub_855640()
154154
}
155155
}
156156

157+
bool bIsC64CB0XRef = false;
158+
injector::hook_back<void(__cdecl*)(void*)> hbsub_C64CB0;
159+
void __cdecl sub_C64CB0(void* a1)
160+
{
161+
bIsC64CB0XRef = true;
162+
hbsub_C64CB0.fun(a1);
163+
bIsC64CB0XRef = false;
164+
}
165+
157166
SafetyHookInline CCutsceneObjectHook{};
158167
void __fastcall sub_C64380(void* _this, void* edx)
159168
{
160-
LoadingFpsLimiter.Sync();
169+
if (bIsC64CB0XRef)
170+
LoadingFpsLimiter.Sync();
161171
return CCutsceneObjectHook.unsafe_fastcall(_this, edx);
162172
}
163173

@@ -245,6 +255,10 @@ public:
245255
auto pattern = hook::pattern("56 8B F1 83 BE ? ? ? ? ? C7 06 ? ? ? ? 0F 85");
246256
if (!pattern.empty())
247257
CCutsceneObjectHook = safetyhook::create_inline(pattern.get_first(0), sub_C64380);
258+
259+
pattern = hook::pattern("E8 ? ? ? ? 83 C4 0C C7 04 B5 ? ? ? ? ? ? ? ? 4E");
260+
if (!pattern.empty())
261+
hbsub_C64CB0.fun = injector::MakeCALL(pattern.get_first(0), sub_C64CB0).get();
248262
};
249263

250264
FusionFix::onShutdownEvent() += []()

0 commit comments

Comments
 (0)