Skip to content

Commit

Permalink
add ForceNoMemRestrict
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirteenAG committed Sep 14, 2024
1 parent 9478586 commit f097569
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 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 = 1
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
10 changes: 10 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 All @@ -24,6 +25,8 @@ public:
auto pattern = hook::pattern("F3 0F 10 44 24 ? 6A FF 6A FF 50 83 EC 08 F3 0F 11 44 24 ? F3 0F 10 44 24 ? F3 0F 11 04 24 E8 ? ? ? ? 83 C4 14");
if (!pattern.empty())
{
static auto dword_1BB5538 = *hook::get_pattern<uint32_t*>("89 1D ? ? ? ? 89 2D ? ? ? ? 85 FF", 2);

static auto PauseHook = safetyhook::create_mid(pattern.get_first(0), [](SafetyHookContext& regs)
{
static std::wstring extra = L"";
Expand All @@ -45,6 +48,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" / " + std::to_wstring(*dword_1BB5538 / 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
16 changes: 16 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 @@ -473,6 +474,21 @@ public:
}
}
}

if (bForceNoMemRestrict)
{
auto 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
}
}
};
}
} Fixes;

0 comments on commit f097569

Please sign in to comment.