Skip to content

Commit

Permalink
Remove unnecessary patch & move water surface resolution code to comv…
Browse files Browse the repository at this point in the history
…ars (#515)

* Remove unnecessary patch & move water surface resolution code to comvars

* Improved pool ball transparency code for updated shaders

* Restore increased player transparency in air hockey minigame
  • Loading branch information
sTc2201 authored Jul 19, 2024
1 parent cc14083 commit d80b842
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 25 deletions.
Binary file modified data/update/GTAIV.EFLC.FusionFix/GTAIV.FusionFix/pool_game.sco
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified data/update/GTAIV.EFLC.FusionFix/TLAD.FusionFix/pool_game.sco
Binary file not shown.
8 changes: 8 additions & 0 deletions source/comvars.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -598,13 +598,21 @@ export namespace rage
static inline SafetyHookInline shCreateRT{};
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")
{
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")
{
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; }
Expand Down
27 changes: 2 additions & 25 deletions source/fixes.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -411,34 +411,11 @@ public:
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);

// WATER_SURFACE0_COLOUR & WATER_SURFACE1_COLOUR texture resolution forced to 256x256. Restores console water tiling from game code side.
pattern = hook::pattern("E8 ? ? ? ? 8B 0D ? ? ? ? 8D 54 24 20 52 6A 20 57 57 C6 44 24");
if (!pattern.empty())
{
static auto WaterSurfaceResHook = safetyhook::create_mid(pattern.get_first(),
[](SafetyHookContext& ctx)
{
ctx.edi = 256;
});
}
else
{
pattern = hook::pattern("E8 ? ? ? ? 8B 0D ? ? ? ? 8D 44 24 24 50 6A 20 56 56 88 5C 24 34 C7 44 24");
static auto WaterSurfaceResHook = safetyhook::create_mid(pattern.get_first(),
[](SafetyHookContext& ctx)
{
ctx.esi = 256;
});
}

// 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 ? ? ? ? 83 C4 08 03 F0 83 D5 00 BA ? ? ? ? 8B C2 D3 E0 8B 0D", "8B 0D ? ? ? ? 03 F8 B8 ? ? ? ? D3 E0 8B 0D");
pattern = find_pattern("8B 0D ? ? ? ? 53 BB ? ? ? ? D3 E3 85 D2 0F 85", "8B 0D ? ? ? ? BF ? ? ? ? D3 E7 85 C0 0F 85");
if (!pattern.empty())
{
injector::WriteMemory(pattern.get_first(2), &dwWaterQuality, true);
pattern = find_pattern("8B 0D ? ? ? ? 03 F0 BA ? ? ? ? 8B C2 D3 E0 8B 0D", "8B 0D ? ? ? ? 03 F0 B8 ? ? ? ? D3 E0 83 C4 04 0F AF C0 8D 0C 80");
injector::WriteMemory(pattern.get_first(2), &dwWaterQuality, true);
pattern = find_pattern("8B 0D ? ? ? ? 53 BB ? ? ? ? D3 E3 85 D2 0F 85", "8B 0D ? ? ? ? BF ? ? ? ? D3 E7 85 C0 0F 85");
injector::WriteMemory(pattern.get_first(2), &dwWaterQuality, true);
pattern = find_pattern("8B 0D ? ? ? ? F3 0F 10 0D ? ? ? ? B8 ? ? ? ? D3 E0 8B 0D", "8B 0D ? ? ? ? F3 0F 10 05 ? ? ? ? 6A 02 6A 01 BA");
injector::WriteMemory(pattern.get_first(2), &dwWaterQuality, true);
Expand Down

0 comments on commit d80b842

Please sign in to comment.