Skip to content

Commit

Permalink
Fix merge
Browse files Browse the repository at this point in the history
  • Loading branch information
SandeMC committed Aug 24, 2024
2 parents 9dcf18c + 174cf90 commit 5cf26d9
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 36 deletions.
1 change: 1 addition & 0 deletions data/plugins/GTAIV.EFLC.FusionFix.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ DynamicShadowForTrees = 1 // replaces static tree shadows wi
OverrideCascadeRanges = 1 // increases shadow view distance and improves quality at lower settings
ShadowBlendRange = 0.3 // controls the size of the cascade blending regions | [0.0; 1.0]
ForceShadowFilter = 0 // 0 : shadow filter tied to definition | 1 : force 4 sample filter | 2 : force 16 sample filter
HighResolutionShadows = 0 // doubles cascaded shadowmap resolution, very GPU intensive

[SHADOWFILTERSHARP] // CE-like shadows
ShadowSoftness = 1.5 // controls shadow blur
Expand Down
1 change: 0 additions & 1 deletion shaders/GTAIV.EFLC.FusionShaders
Submodule GTAIV.EFLC.FusionShaders deleted from 641a1e
9 changes: 4 additions & 5 deletions source/comvars.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -610,22 +610,21 @@ export namespace rage
static grcRenderTargetPC* __stdcall CreateRT(const char* name, int32_t a2, uint32_t width, uint32_t height, uint32_t bitsPerPixel, grcRenderTargetDesc* desc)
{
// Scale phone screen/phone camera rendertarget resolution with game resolution.
if(std::string_view(name) == "PHONE_SCREEN" || std::string_view(name) == "PHOTO")
if (std::string_view(name) == "PHONE_SCREEN" || std::string_view(name) == "PHOTO")
{
auto res = (int32_t)(std::ceil((float)*rage::grcDevice::ms_nActiveHeight / 720.0f) * 256.0f);
width = res;
height = res;
}

// Force water surface rendertarget resolution to always be 256x256. This matches the water tiling on the console version.
if(std::string_view(name) == "WATER_SURFACE0_COLOUR" || std::string_view(name) == "WATER_SURFACE1_COLOUR")
else if (std::string_view(name) == "WATER_SURFACE0_COLOUR" || std::string_view(name) == "WATER_SURFACE1_COLOUR")
{
// Force water surface rendertarget resolution to always be 256x256. This matches the water tiling on the console version.
width = 256;
height = 256;
}

auto ret = shCreateRT.stdcall<grcRenderTargetPC*>(name, a2, width, height, bitsPerPixel, desc);

// if(strcmp("WATER_REFLECTION_COLOUR", name) == 0) { ret->mMultisampleCount=1; }
//else if(strcmp("WATER_REFLECTION_DEPTH" , name) == 0) { ret->mMultisampleCount=1; }
//else if(strcmp("REFLECTION_MAP_COLOUR" , name) == 0) { ret->mMultisampleCount=1; }
Expand Down
48 changes: 42 additions & 6 deletions source/episodiccontent.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,34 @@ public:
injector::MakeNOP(pattern.get_first(7), 2, true);
}

pattern = hook::pattern("83 3D ? ? ? ? ? 75 26 8B 4C 24 04"); // Sticky bomb something?
if (!pattern.empty())
injector::MakeNOP(pattern.get_first(7), 2, true);
else {
pattern = hook::pattern("83 3D ? ? ? ? ? 75 29 8B 44 24 04");
injector::MakeNOP(pattern.get_first(7), 2, true);
}

pattern = hook::pattern("83 3D ? ? ? ? ? 89 44 24 1C"); // Sticky bomb ???
if (!pattern.empty())
injector::MakeNOP(pattern.get_first(15), 2, true);
else {
pattern = hook::pattern("83 3D ? ? ? ? ? 88 44 24 1C");
injector::MakeNOP(pattern.get_first(11), 2, true);
}

pattern = hook::pattern("83 3D ? ? ? ? ? 75 1F 8B 44 24 0C"); // CTaskSimplePlayerAimProjectile::process
if (!pattern.empty())
injector::MakeNOP(pattern.get_first(7), 2, true);
else {
pattern = hook::pattern("83 3D ? ? ? ? ? 75 1C 8B 47 18");
injector::MakeNOP(pattern.get_first(7), 2, true);
}

pattern = hook::pattern("83 3D ? ? ? ? ? 75 07 68 ? ? ? ? EB 05 68 ? ? ? ? E8"); // E2 Bullet traces
if (!pattern.empty())
injector::MakeNOP(pattern.get_first(7), 2, true);

pattern = hook::pattern("83 3D ? ? ? ? ? 75 2D 83 7E 14 19"); // Grenade launcher explode on impact from E2
if (!pattern.empty())
injector::MakeNOP(pattern.get_first(7), 2, true);
Expand Down Expand Up @@ -333,6 +361,10 @@ public:
injector::MakeNOP(pattern.get_first(7), 6, true);
}

pattern = hook::pattern("83 3D ? ? ? ? ? 75 22 83 F8 02"); // weap checks? nearby explosive weapon checks
if (!pattern.empty())
injector::MakeNOP(pattern.get_first(7), 2, true);

pattern = hook::pattern("83 3D ? ? ? ? ? 0F 8C ? ? ? ? 83 7F 54 20"); // P90 scroll block
if (!pattern.empty())
injector::MakeNOP(pattern.get_first(7), 6, true);
Expand Down Expand Up @@ -387,31 +419,31 @@ public:
else {
pattern = hook::pattern("83 3D ? ? ? ? ? 75 0D 80 7E 7D 00");
injector::MakeNOP(pattern.get_first(7), 2, true);
}
}

pattern = hook::pattern("83 3D ? ? ? ? ? 5D 75 1E"); // Give parachute during load save
if (!pattern.empty())
injector::MakeNOP(pattern.get_first(8), 2, true);
else {
pattern = hook::pattern("83 3D ? ? ? ? ? 75 1E E8");
injector::MakeNOP(pattern.get_first(7), 2, true);
}
}

pattern = hook::pattern("83 3D ? ? ? ? ? 53 57 8B 7C 24 20"); // TBoGT counter anims fix
if (!pattern.empty())
injector::MakeNOP(pattern.get_first(15), 2, true);
else {
pattern = hook::pattern("83 3D ? ? ? ? ? 53 55 8B 6C 24 20");
injector::MakeNOP(pattern.get_first(21), 2, true);
}
}

pattern = hook::pattern("83 3D ? ? ? ? ? 75 36 80 7B 28 00"); // TBoGT counter anims fix
if (!pattern.empty())
injector::MakeNOP(pattern.get_first(7), 2, true);
else {
pattern = hook::pattern("39 1D ? ? ? ? 75 2A 80 7F 28 00");
injector::MakeNOP(pattern.get_first(7), 2, true);
}
}
}

if (bExplosiveAnnihilator)
Expand Down Expand Up @@ -480,16 +512,20 @@ public:
}

pattern = hook::pattern("B8 ? ? ? ? 0F 44 E8 57"); // E2_landing marker
if (!pattern.empty())
if (!pattern.empty()) {
injector::WriteMemory<uint8_t>(pattern.get_first(0), 0xBD, true);
injector::MakeNOP(pattern.get_first(5), 3, true);
}
else {
pattern = hook::pattern("BD ? ? ? ? 75 05");
injector::MakeNOP(pattern.get_first(5), 2, true);
}

pattern = hook::pattern("83 3D ? ? ? ? ? BB ? ? ? ? B8"); // E2_landing marker
if (!pattern.empty())
if (!pattern.empty()) {
injector::WriteMemory<uint8_t>(pattern.get_first(12), 0xBB, true);
injector::MakeNOP(pattern.get_first(17), 3, true);
}
else {
pattern = hook::pattern("83 3D ? ? ? ? ? BB ? ? ? ? 75 05");
injector::MakeNOP(pattern.get_first(12), 2, true);
Expand Down
35 changes: 30 additions & 5 deletions source/fixes.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,6 @@ public:
injector::WriteMemory(pattern.count(2).get(0).get<void*>(8), 0x200, true);
}

// Remove code that doubled shadow cascade resolution.
pattern = find_pattern("03 F6 E8 ? ? ? ? 8B 0D ? ? ? ? 8D 54 24 0C", "03 F6 E8 ? ? ? ? 8B 0D ? ? ? ? 8D 44 24 0C");
injector::MakeNOP(pattern.get_first(0), 2, true);

// Force water surface rendertarget resolution to always be 256x256. This matches the water tiling on the console version.
static uint32_t dwWaterQuality = 1;
pattern = find_pattern("8B 0D ? ? ? ? 53 BB ? ? ? ? D3 E3 85 D2 0F 85", "8B 0D ? ? ? ? BF ? ? ? ? D3 E7 85 C0 0F 85");
Expand All @@ -432,12 +428,41 @@ public:

// Switch texture formats
// CASCADE_ATLAS
constexpr auto NewCascadeAtlasFormat = D3DFMT_R32F;

pattern = find_pattern("C7 05 ? ? ? ? ? ? ? ? C7 05 ? ? ? ? ? ? ? ? 8B 08 50 FF 51 08 5E 59 C3 8B 44 24 04 6A 72", "C7 05 ? ? ? ? ? ? ? ? C7 05 ? ? ? ? ? ? ? ? 8B 08");
injector::WriteMemory(pattern.get_first(6), rage::getEngineTextureFormat(D3DFMT_R32F), true);
injector::WriteMemory(pattern.get_first(6), rage::getEngineTextureFormat(NewCascadeAtlasFormat), true);

// _DEFERRED_GBUFFER_0_ / _DEFERRED_GBUFFER_1_ / _DEFERRED_GBUFFER_2_
pattern = find_pattern("BA ? ? ? ? 84 C0 0F 45 CA 8B 15", "40 05 00 00 00 8B 0D ? ? ? ? 8B 11 8B 52 38 8D 74 24 14 56 50 A1");
injector::WriteMemory(pattern.get_first(1), rage::getEngineTextureFormat(D3DFMT_A8R8G8B8), true);

if (bHighResolutionShadows)
{
auto pattern = find_pattern("8D 7D 40 8B 01 57 FF 75 10 FF 75 24 FF 75 0C FF 75 20 FF 75 18");
if (!pattern.empty())
{
static auto FixCascadedShadowMapResolution = safetyhook::create_mid(pattern.get_first(0), [](SafetyHookContext& regs)
{
auto& Width = *(uint32_t*)(regs.ebp + 0x14);
auto& Height = *(uint32_t*)(regs.ebp + 0x18);
auto& Levels = *(uint32_t*)(regs.ebp + 0x20);
auto& Format = *(uint32_t*)(regs.ebp + 0x24);

if (D3DFORMAT(Format) == NewCascadeAtlasFormat && Height >= 256 && Width == Height * 4 && Levels == 1)
{
Width *= 2;
Height *= 2;
}
});
}
}
else
{
// Remove code that doubled shadow cascade resolution.
pattern = find_pattern("03 F6 E8 ? ? ? ? 8B 0D ? ? ? ? 8D 54 24 0C", "03 F6 E8 ? ? ? ? 8B 0D ? ? ? ? 8D 44 24 0C");
injector::MakeNOP(pattern.get_first(0), 2, true);
}
}

// P90 Selector Fix (Prev Weapon key)
Expand Down
35 changes: 17 additions & 18 deletions source/limits.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,6 @@ public:

for (size_t i = CModelInfoStore::ms_baseModels; i < CModelInfoStore::amount; i++)
{
if (i == CModelInfoStore::ms_weaponModels) // bugs out buzzard rockets
continue;
CModelInfoStore__ms_baseModels[i].nSize *= 2;
}

Expand All @@ -326,23 +324,23 @@ public:
auto ms_iBikeLines = 40;
auto ms_iFlyingLines = 40;
auto ms_iBoatLines = 40;

auto ms_iStandardLinesLimit = ms_iStandardLines * increaseby;
auto ms_iBikeLinesLimit = ms_iBikeLines * increaseby;
auto ms_iFlyingLinesLimit = ms_iFlyingLines * increaseby;
auto ms_iBoatLinesLimit = ms_iBoatLines * increaseby;

static std::vector<uint8_t> handling((0x110 * ms_iStandardLinesLimit) + (0x40 * ms_iBikeLinesLimit) + (0x60 * ms_iFlyingLinesLimit) + (0xE0 * ms_iBoatLinesLimit), 0);
auto aHandlingLines = *hook::get_pattern<uintptr_t>("8D B0 ? ? ? ? 57 8B CE E8 ? ? ? ? 8B CE E8", 2);
auto aBikeHandlingLines = aHandlingLines + (0x110 * ms_iStandardLines);
auto aFlyingHandlingLines = aHandlingLines + (0x110 * ms_iStandardLines) + (0x40 * ms_iBikeLines);
auto aBoatHandlingLines = aHandlingLines + (0x110 * ms_iStandardLines) + (0x40 * ms_iBikeLines) + (0x60 * ms_iFlyingLines);

auto HandlingLines = LimitAdjuster(aHandlingLines, 0x110, ms_iStandardLines, 26).IncreaseBy(increaseby).InsertNewArrayPointer(handling.data()).ReplaceXrefs(0x0, 0xF8, 0xFC, 0x100, 0x5F60, 0xAA00, 0xAAFC);
//auto BikeHandlingLines = LimitAdjuster(aBikeHandlingLines, 0x40, ms_iBikeLines, 7).IncreaseBy(increaseby).InsertNewArrayPointer(handling.data() + (0x110 * ms_iStandardLinesLimit)).ReplaceXrefs(0);
auto FlyingHandlingLines = LimitAdjuster(aFlyingHandlingLines, 0x40, ms_iFlyingLines, 5).IncreaseBy(increaseby).InsertNewArrayPointer(handling.data() + (0x110 * ms_iStandardLinesLimit) + (0x40 * ms_iBikeLinesLimit)).ReplaceXrefs(0);
auto BoatHandlingLines = LimitAdjuster(aBoatHandlingLines, 0x40, ms_iBoatLines, 5).IncreaseBy(increaseby).InsertNewArrayPointer(handling.data() + (0x110 * ms_iStandardLinesLimit) + (0x40 * ms_iBikeLinesLimit) + (0x60 * ms_iFlyingLinesLimit)).ReplaceXrefs(0);

auto pattern = hook::pattern("BF ? ? ? ? 8D 64 24 00 8B CE E8 ? ? ? ? 81 C6 ? ? ? ? 4F 79 F0 5F 5E C3 CC CC CC CC CC CC CC CC CC CC CC CC CC 56 57 BE ? ? ? ? BF ? ? ? ? 8D 64 24 00 8B CE E8 ? ? ? ? 83 C6 20");
injector::WriteMemory(pattern.get_first(1), ms_iStandardLinesLimit - 1, true);
pattern = hook::pattern("BF ? ? ? ? 8D 64 24 00 8B CE E8 ? ? ? ? 83 C6 40 4F 79 F3 5F 5E C3 56 57 BE ? ? ? ? BF ? ? ? ? 8D 64 24 00 8B CE E8 ? ? ? ? 81 C6 ? ? ? ? 4F 79 F0 5F");
Expand All @@ -351,17 +349,17 @@ public:
injector::WriteMemory(pattern.get_first(1), ms_iFlyingLinesLimit - 1, true);
pattern = hook::pattern("BF ? ? ? ? 8D 64 24 00 8B CE E8 ? ? ? ? 81 C6 ? ? ? ? 4F 79 F0 5F 5E C3 CC CC CC CC CC CC CC CC CC CC CC CC CC 56 57 BE ? ? ? ? BF ? ? ? ? 8D 64 24 00 8B CE E8 ? ? ? ? 83 C6 60");
injector::WriteMemory(pattern.get_first(1), ms_iBoatLinesLimit - 1, true);

pattern = hook::pattern("7D 1B 8B C2"); //bikeHandlingCount
injector::MakeNOP(pattern.get_first(), 2);

pattern = hook::pattern("7D 1C 8D 04 52"); //flyingHandlingCount
injector::MakeNOP(pattern.get_first(), 2);

pattern = hook::pattern("7D 1E 8B C2"); //boatHandlingCount
injector::MakeNOP(pattern.get_first(), 2);
}

//carcols
{
auto pattern = hook::pattern("8B 87 ? ? ? ? 25 ? ? ? ? 0B C8 89 8F");
Expand All @@ -374,14 +372,15 @@ public:
auto adwPoliceScannerCarColors = LimitAdjuster(*pattern.get_first<uintptr_t>(3), 4, 196, 3).ReplaceXrefs(0);
}

{
auto pattern = hook::pattern("81 C3 ? ? ? ? 89 03");
auto ref1 = (intptr_t)hook::get_pattern("BF ? ? ? ? 8D 64 24 00 8B CE E8 ? ? ? ? 81 C6 ? ? ? ? 4F 79 F0 68 ? ? ? ? E8 ? ? ? ? 83 C4 04 5F 5E C3 56", 1);
auto WeaponInfo = LimitAdjuster(*pattern.get_first<uintptr_t>(2), 0x110, 60, 4).ReplaceXrefs(0).ReplaceNumericRefs(ref1);
pattern = hook::pattern("7D 0C 69 C0");
injector::MakeNOP(pattern.get_first(), 2);
}

//{ //breaks buzzard rockets
// auto pattern = hook::pattern("81 C3 ? ? ? ? 89 03");
// auto ref1 = (intptr_t)hook::get_pattern("BF ? ? ? ? 8D 64 24 00 8B CE E8 ? ? ? ? 81 C6 ? ? ? ? 4F 79 F0 68 ? ? ? ? E8 ? ? ? ? 83 C4 04 5F 5E C3 56", 1);
// auto ref2 = (intptr_t)hook::get_pattern("83 F8 3C 7C F1", 2);
// auto WeaponInfo = LimitAdjuster(*pattern.get_first<uintptr_t>(2), 0x110, 60, 4).ReplaceXrefs(0).ReplaceNumericRefs(ref1, ref2);
// pattern = hook::pattern("7D 0C 69 C0");
// injector::MakeNOP(pattern.get_first(), 2);
//}

{
auto pattern = hook::pattern("81 C7 ? ? ? ? 83 BB");
auto VehOff = LimitAdjuster(*pattern.get_first<uintptr_t>(2), 640, 205, 4).ReplaceXrefs(0);
Expand Down
2 changes: 1 addition & 1 deletion source/windowed.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public:
bSkipWindowedCallback1 = false;
});

pattern = find_pattern("C6 05 ? ? ? ? ? FF 75 14", "C6 05 ? ? ? ? ? 8B 54 24 1C", "C6 05 ? ? ? ? ? FF 15 ? ? ? ? 5F");
pattern = find_pattern("C6 05 ? ? ? ? ? FF 75 14", "C6 05 ? ? ? ? ? 0F 94 05 ? ? ? ? FF 75 14", "C6 05 ? ? ? ? ? 8B 54 24 1C", "C6 05 ? ? ? ? ? FF 15 ? ? ? ? 5F");
static auto AltEnterHandlerHook = safetyhook::create_mid(pattern.get_first(),
[](SafetyHookContext& ctx)
{
Expand Down

0 comments on commit 5cf26d9

Please sign in to comment.