Skip to content

Commit

Permalink
Merge to upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
SandeMC committed Sep 14, 2024
2 parents d0ac44d + e293747 commit 4288f60
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 4 deletions.
1 change: 1 addition & 0 deletions data/plugins/GTAIV.EFLC.FusionFix.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[MAIN]
RecoilFix = 0
AimingZoomFix = 1
ForceNoMemRestrict = 1 // forces -nomemrestrict commandline parameter, necessary if playing with high draw distance sliders to prevent pop-in

[SHADOWS]
ExtraDynamicShadows = 2 // adds some missing shadows | 1: for fences and grates | 2: for fences, grates and vegetation
Expand Down
Binary file not shown.
5 changes: 3 additions & 2 deletions source/consoleshadows.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ namespace CShadows
return hbStoreStaticShadow.fun(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15);
}
}

class ConsoleShadows
{
public:
Expand Down Expand Up @@ -135,13 +136,13 @@ public:
}

// Enable player/ped shadows while in vehicles
if (bHeadlightShadows && bVehicleNightShadows && (regs.eax == 3 || regs.eax == 4))
if ((bHeadlightShadows || bVehicleNightShadows) && (((*(uint8_t*)(regs.esi + 620) & 4) != 0) && (regs.eax == 3 || regs.eax == 4)))
{
*(uintptr_t*)(regs.esp - 4) = loc_AE376B;
return;
}

if ((*(uint8_t*)(regs.esi + 620) & 4) == 0)
if (regs.eax != 3 || (*(uint8_t*)(regs.esi + 620) & 4) == 0)
{
*(uintptr_t*)(regs.esp - 4) = loc_AE374F;
}
Expand Down
8 changes: 8 additions & 0 deletions source/extrainfo.ixx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module;

#include <common.hxx>
#include <psapi.h>

export module extrainfo;

Expand Down Expand Up @@ -45,6 +46,13 @@ public:

auto FF_WARN0 = CText::getText("FF_WARN0");
extra += (FF_WARN0[0] ? FF_WARN0 : L"~p~IMG Files:") + std::wstring(L" ") + std::to_wstring(imgNum) + L" / " + std::to_wstring(imgArrSize);

::PROCESS_MEMORY_COUNTERS pmc;
if (::GetProcessMemoryInfo(::GetCurrentProcess(), &pmc, sizeof(pmc)))
{
extra += L"; RAM: " + std::to_wstring(pmc.WorkingSetSize / 1000 / 1000) + L" MB";
}

auto FF_WARN1 = CText::getText("FF_WARN1");
if (imgNum >= imgArrSize) extra += FF_WARN1[0] ? FF_WARN1 : L"; ~r~WARNING: 255 IMG limit exceeded, will cause streaming issues.";

Expand Down
56 changes: 56 additions & 0 deletions source/fixes.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public:

int32_t nAimingZoomFix = iniReader.ReadInteger("MAIN", "AimingZoomFix", 1);
bool bRecoilFix = iniReader.ReadInteger("MAIN", "RecoilFix", 1) != 0;
bool bForceNoMemRestrict = iniReader.ReadInteger("MAIN", "ForceNoMemRestrict", 1) != 0;

//[MISC]
bool bDefaultCameraAngleInTLAD = iniReader.ReadInteger("MISC", "DefaultCameraAngleInTLAD", 0) != 0;
Expand Down Expand Up @@ -205,6 +206,22 @@ public:
auto sub_477300 = injector::GetBranchDestination(pattern.get_first(0));
pattern = find_pattern("E8 ? ? ? ? E8 ? ? ? ? E8 ? ? ? ? E8 ? ? ? ? E8 ? ? ? ? E8 ? ? ? ? 83 C4 2C C3", "E8 ? ? ? ? E8 ? ? ? ? E8 ? ? ? ? 8B 35 ? ? ? ? E8 ? ? ? ? 25 FF FF 00 00");
injector::MakeCALL(pattern.get_first(0), sub_477300, true);

// related to the same issue
if (bForceNoMemRestrict)
{
pattern = find_pattern("0F 85 ? ? ? ? A1 ? ? ? ? 85 C0 74 5C", "0F 85 ? ? ? ? A1 ? ? ? ? 85 C0 74 5A");
if (!pattern.empty())
{
injector::WriteMemory<uint16_t>(pattern.get_first(0), 0xE990, true); // jnz -> jmp
}
else
{
pattern = find_pattern("75 7E A1 ? ? ? ? 85 C0");
if (!pattern.empty())
injector::WriteMemory<uint8_t>(pattern.get_first(0), 0xEB, true); // jnz -> jmp
}
}
}

// Make LOD lights appear at the appropriate time like on the console version (consoles: 7 PM, pc: 10 PM)
Expand Down Expand Up @@ -434,6 +451,45 @@ public:
injector::MakeNOP(pattern.get_first(6), 6, true);
}
}

// Skybox Black Bottom Fix
{
auto PatchVertices = [](float* ptr)
{
for (auto i = 0; i < ((6156 / 4) / 3); i++)
{
auto pVertex = (ptr + i * 3);
if (i < 32)
{
if (pVertex[1] < 0.0f)
{
injector::WriteMemory<float>(pVertex, 0.0f, true);
injector::WriteMemory<float>(pVertex + 2, 0.0f, true);
}
}
else
{
injector::WriteMemory<float>(pVertex + 1, (pVertex[1] - 0.16037700f) * 1.78f - 1.0f, true);
}
}
};

auto pattern = hook::pattern("C7 44 24 ? ? ? ? ? C7 44 24 ? ? ? ? ? E8 ? ? ? ? 8B 44 24 44");
if (!pattern.empty())
{
auto addr = pattern.get_first<float*>(4);
PatchVertices(*addr);
}
else
{
pattern = hook::pattern("C7 46 ? ? ? ? ? C7 46 ? ? ? ? ? 5E 59 C3");
if (!pattern.empty())
{
auto addr = pattern.get_first<float*>(3);
PatchVertices(*addr);
}
}
}
};
}
} Fixes;
4 changes: 2 additions & 2 deletions text/germanFF.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Kantenglättung
FPS-Begrenzung

[LamppostShadows]
Schatten für Straßenlaternen
Straßenlaternen-Schatten

[Tree Alpha]
Baumtransparenz
Expand All @@ -92,7 +92,7 @@ Scheinwerfer-Schatten
; ~r~ACHTUNG: Obergrenze von 255 IMG-Dateien überschritten, was zu Streaming-Problemen führt.

[FF_WARN2]
~r~ACHTUNG: "Schatten für Straßenlaternen" kann zu Artefakten und Performance-Problemen führen.
~r~ACHTUNG: Straßenlaternen-Schatten können zu Artefakten und Performance-Problemen führen.

[FF_WARN3]
~r~ACHTUNG: Bei Werten von über 25 für die Sichtdistanz und über 31 für die Detaildistanz kann es zu Pop-in von Objekten kommen.
Expand Down

0 comments on commit 4288f60

Please sign in to comment.