Skip to content

Commit cbef04b

Browse files
PreCE fixes (#1102)
* PreCE fixes * Use parameter names from natives.ixx * Restore old code
1 parent f47ea39 commit cbef04b

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

source/fixes.ixx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ public:
935935
hbCOMPARE_STRING.fun = NativeOverride::Register(Natives::NativeHashes::COMPARE_STRING, NATIVE_COMPARE_STRING, "E8 ? ? ? ? ? ? ? ? ? 83 C4 ? 89 ? 5E C3", 30);
936936
}
937937

938-
// TLAD Marta Full of Grace's crash https://github.com/GTAmodding/GTAIV-Issues-List/issues/235
938+
// TLAD Marta Full of Grace's crash (https://github.com/GTAmodding/GTAIV-Issues-List/issues/235)
939939
{
940940
auto pattern = find_pattern("F6 80 ? ? ? ? ? 74 ? 8B 80 ? ? ? ? 56");
941941
if (!pattern.empty())
@@ -961,14 +961,14 @@ public:
961961
pattern = find_pattern("E8 ? ? ? ? 85 C0 0F 84 ? ? ? ? 8B 4C 24 ? 3B F9", "E8 ? ? ? ? 85 C0 0F 84 ? ? ? ? 3B F7");
962962
hbIsSphereVisible.fun = injector::MakeCALL(pattern.get_first(0), DrawWaterIsSphereVisible, true).get();
963963

964-
pattern = find_pattern("E8 ? ? ? ? 8B D0 8B B4 BA", "8B B4 00 ? ? ? ? 03 C0 8B 80 ? ? ? ? 03 C6 3B F0 0F 83 ? ? ? ? 8D 64 24");
964+
pattern = find_pattern("E8 ? ? ? ? 8B D0 8B B4 BA", "E8 ? ? ? ? 8B BC B0 ? ? ? ? 8B 94 B0");
965965
static auto RenderWaterHook = safetyhook::create_mid(pattern.get_first(0), [](SafetyHookContext& regs)
966966
{
967967
bAnyVisibleNearbyWaterOnScreen = false;
968968
WaterQuadsCount = 0;
969969
});
970970

971-
pattern = find_pattern("0F B7 0C 72 C1 E1 ? 0F BF 81", "0F B7 04 55 ? ? ? ? C1 E0 ? 0F BF 88");
971+
pattern = find_pattern("0F B7 0C 72 C1 E1 ? 0F BF 81", "0F B7 04 78 C1 E0 04 0F BF 88 ? ? ? ? 8B 14 CD ? ? ? ? 0F BF 88 ? ? ? ? 03 C9");
972972
static auto RenderWaterCounterHook = safetyhook::create_mid(pattern.get_first(0), [](SafetyHookContext& regs)
973973
{
974974
WaterQuadsCount++;
@@ -986,36 +986,36 @@ public:
986986
bAnyVisibleNearbyLightOnScreen = false;
987987
});
988988

989-
pattern = find_pattern("A8 ? 0F 84 ? ? ? ? 8B C8");
989+
pattern = hook::pattern("A8 ? 0F 84 ? ? ? ? 8B C8");
990990
static auto loc_927DE0 = resolve_next_displacement(pattern.get_first(0)).value();
991991
injector::MakeNOP(pattern.get_first(2), 6);
992992
static auto LightCounterHook = safetyhook::create_mid(pattern.get_first(0), [](SafetyHookContext& regs)
993993
{
994-
static auto extraNightShadows = FusionFixSettings.GetRef("PREF_EXTRANIGHTSHADOWS");
995-
if (extraNightShadows->get())
994+
static auto ExtraNightShadows = FusionFixSettings.GetRef("PREF_EXTRANIGHTSHADOWS");
995+
if (ExtraNightShadows->get())
996996
{
997997
if ((regs.eax & 6) != 0)
998998
{
999999
if (Natives::IsInteriorScene())
10001000
{
1001-
return; //flicker - always in interiors
1001+
return; // Flicker - Always in interiors
10021002
}
10031003

10041004
if (!bAnyVisibleNearbyWaterOnScreen)
10051005
{
1006-
return; //flicker - no water on screen
1006+
return; // Flicker - No water on screen
10071007
}
10081008
else if (bAnyVisibleNearbyLightOnScreen)
10091009
{
1010-
return; //flicker - water and lights
1010+
return; // Flicker - Water and lights
10111011
}
10121012
}
10131013
}
10141014
else
10151015
{
10161016
if ((regs.eax & 6) != 0 && Natives::IsInteriorScene())
10171017
{
1018-
return; //flicker
1018+
return; // Flicker
10191019
}
10201020
}
10211021

source/frameratevigilante.ixx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,17 @@ void __cdecl NATIVE_SET_CAM_FOV(int cam, float targetFOV)
206206
}
207207

208208
injector::hook_back<decltype(&Natives::SlideObject)> hbSLIDE_OBJECT;
209-
bool __cdecl NATIVE_SLIDE_OBJECT(Object object, float toX, float toY, float toZ, float speedX, float speedY, float speedZ, char collision)
209+
bool __cdecl NATIVE_SLIDE_OBJECT_1(Object object, float x, float y, float z, float xs, float ys, float zs, bool flag)
210210
{
211211
float delta = *CTimer::fTimeStep * 30.0f;
212-
return hbSLIDE_OBJECT.fun(object, toX, toY, toZ, speedX * delta, speedY * delta, speedZ * delta, collision);
212+
return hbSLIDE_OBJECT.fun(object, x, y, z, xs * delta, ys * delta, zs * delta, flag);
213+
}
214+
215+
SafetyHookInline shNATIVE_SLIDE_OBJECT{};
216+
bool __cdecl NATIVE_SLIDE_OBJECT_2(Object object, float x, float y, float z, float xs, float ys, float zs, bool flag)
217+
{
218+
float delta = *CTimer::fTimeStep * 30.0f;
219+
return shNATIVE_SLIDE_OBJECT.unsafe_ccall<bool>(object, x, y, z, xs * delta, ys * delta, zs * delta, flag);
213220
}
214221

215222
class FramerateVigilante
@@ -356,9 +363,12 @@ public:
356363

357364
// Natives
358365
hbSET_CAM_FOV.fun = NativeOverride::Register(Natives::NativeHashes::SET_CAM_FOV, NATIVE_SET_CAM_FOV, "E8 ? ? ? ? 83 C4 08 C3", 30);
359-
hbSLIDE_OBJECT.fun = NativeOverride::Register(Natives::NativeHashes::SLIDE_OBJECT, NATIVE_SLIDE_OBJECT, "E8 ? ? ? ? 0F B6 C8", 107);
366+
hbSLIDE_OBJECT.fun = NativeOverride::Register(Natives::NativeHashes::SLIDE_OBJECT, NATIVE_SLIDE_OBJECT_1, "E8 ? ? ? ? 0F B6 C8", 107);
360367
if (!hbSLIDE_OBJECT.fun)
361-
hbSLIDE_OBJECT.fun = NativeOverride::Register(Natives::NativeHashes::SLIDE_OBJECT, NATIVE_SLIDE_OBJECT, "E8 ? ? ? ? 83 C4 ? C3", 30);
368+
{
369+
pattern = hook::pattern("55 8B EC 83 E4 F0 8B 45 08 8B 0D ? ? ? ? 81 EC ? ? ? ? 56 50");
370+
shNATIVE_SLIDE_OBJECT = safetyhook::create_inline(pattern.get_first(0), NATIVE_SLIDE_OBJECT_2);
371+
}
362372

363373
// CCamFollowVehicle
364374
pattern = find_pattern("77 ? 0F 28 C2 F3 0F 5C 8F", "77 ? 0F 28 D3 F3 0F 10 8E");

0 commit comments

Comments
 (0)