From 6425bf902c92c86800fc95f75d4d638b6ba907cb Mon Sep 17 00:00:00 2001 From: ThirteenAG Date: Tue, 16 Jan 2024 19:42:34 +0800 Subject: [PATCH] add extra info --- data/plugins/GTAIV.EFLC.FusionFix.ini | 2 + source/comvars.ixx | 25 ++++++++++++ source/cutscenecam.ixx | 15 ++++++++ source/extrainfo.ixx | 55 +++++++++++++++++++++++++++ source/loadingdelays.ixx | 12 +++--- 5 files changed, 103 insertions(+), 6 deletions(-) create mode 100644 source/extrainfo.ixx diff --git a/data/plugins/GTAIV.EFLC.FusionFix.ini b/data/plugins/GTAIV.EFLC.FusionFix.ini index 23dd5ce5..090eaea9 100644 --- a/data/plugins/GTAIV.EFLC.FusionFix.ini +++ b/data/plugins/GTAIV.EFLC.FusionFix.ini @@ -23,6 +23,8 @@ FixRainDrops = 1 RainDropsBlur = 2 // 1, 2 or 4 only WalkKey = 0x12 // VK_MENU, used by Always Run option FixAutoExposure = 1 +ExtraCutsceneFix = 1 +ExraInfo = 1 // shows extra info in the pause menu (loaded img files amount) [BudgetedIV] VehicleBudget = 0 // may cause issues, set to e.g. 260000000 to increase budget limit diff --git a/source/comvars.ixx b/source/comvars.ixx index 034d3e65..926ffc37 100644 --- a/source/comvars.ixx +++ b/source/comvars.ixx @@ -6,6 +6,8 @@ export module comvars; import common; +#define VALIDATE_SIZE(struc, size) static_assert(sizeof(struc) == size, "Invalid structure size of " #struc) + export int32_t* _dwCurrentEpisode; export uint8_t* CTimer__m_UserPause = nullptr; export uint8_t* CTimer__m_CodePause = nullptr; @@ -39,6 +41,26 @@ export inline LONG getWindowHeight() return gRect.bottom - gRect.top; } +#pragma pack(push, 1) +struct CImgFile +{ + int m_nTimeLow; + int m_nTimeHigh; + int field_8; + int field_C; + char pszFilename[128]; + int m_pDevice; + int field_94; + int m_hFile; + char field_9C; + char field_9D; + char m_bEpisode; + char m_bEpisodicContent; +}; VALIDATE_SIZE(CImgFile, 160); +#pragma pack(pop) + +export CImgFile(*pCGameConfigReader__ms_imgFiles)[255]; + class Common { public: @@ -77,6 +99,9 @@ public: pattern = find_pattern("F3 0F 10 05 ? ? ? ? F3 0F 59 05 ? ? ? ? 8B 43 20 53", "F3 0F 10 05 ? ? ? ? F3 0F 59 44 24 ? 83 C4 04 83 7C 24"); fTimeStep = *pattern.get_first(4); + + pattern = hook::pattern("BE ? ? ? ? 8D 44 24 0C"); + pCGameConfigReader__ms_imgFiles = *pattern.get_first(1); }; } } Common; \ No newline at end of file diff --git a/source/cutscenecam.ixx b/source/cutscenecam.ixx index 3ef64085..9fcf236e 100644 --- a/source/cutscenecam.ixx +++ b/source/cutscenecam.ixx @@ -14,6 +14,9 @@ public: { FusionFix::onInitEvent() += []() { + CIniReader iniReader(""); + auto bExtraCutsceneFix = iniReader.ReadInteger("MISC", "ExtraCutsceneFix", 1) != 0; + // By Sergeanur auto pattern = find_pattern("74 20 83 FF 03 74 1B 83", "74 24 8B 44 24 2C"); injector::WriteMemory(pattern.get_first(), 0xEB, true); @@ -83,6 +86,18 @@ public: pattern = find_pattern("E8 ? ? ? ? 8B CD 88 44 24 0F", "E8 ? ? ? ? 8B CF 88 44 24 0F"); injector::MakeCALL(pattern.get_first(), *(void**)&dest, true); + + if (bExtraCutsceneFix) + { + // ??? + pattern = hook::pattern("F3 0F 11 86 ? ? ? ? 5E 5B 8B 4C 24 30 33 CC E8 ? ? ? ? 83 C4 34 C2 04 00"); + if (!pattern.empty()) + injector::MakeNOP(pattern.get_first(), 8, true); + + pattern = hook::pattern("F3 0F 11 86 ? ? ? ? 5F 5E B8 ? ? ? ? 5B 8B 4C 24 30 33 CC E8 ? ? ? ? 83 C4 34 C2 04 00"); + if (!pattern.empty()) + injector::MakeNOP(pattern.get_first(), 8, true); + } }; } } CutsceneCam; \ No newline at end of file diff --git a/source/extrainfo.ixx b/source/extrainfo.ixx new file mode 100644 index 00000000..3c5a693f --- /dev/null +++ b/source/extrainfo.ixx @@ -0,0 +1,55 @@ +module; + +#include + +export module extrainfo; + +import common; +import comvars; + +class ExtraInfo +{ +public: + ExtraInfo() + { + FusionFix::onInitEvent() += []() + { + CIniReader iniReader(""); + + auto bExraInfo = iniReader.ReadInteger("MISC", "ExraInfo", 1) != 0; + + if (bExraInfo) + { + auto pattern = hook::pattern("05 ? ? ? ? E9 ? ? ? ? E8 ? ? ? ? 84 C0"); + if (!pattern.empty()) + { + struct MS_PAUSED_HOOK + { + void operator()(injector::reg_pack& regs) + { + static std::wstring extra = L""; + regs.eax += 0x78; + auto s = std::wstring_view((wchar_t*)regs.eax); + + auto imgNum = 0; + auto imgArrSize = 0; + for (auto& it : *pCGameConfigReader__ms_imgFiles) + { + if (it.m_hFile != -1) + imgNum++; + imgArrSize++; + } + extra = s; + extra += L"~n~"; + extra += L" "; + extra += L"IMG Files: " + std::to_wstring(imgNum) + L" / " + std::to_wstring(imgArrSize); + if (imgNum >= imgArrSize) extra += L"; WARNING: IMG Files limit reached!"; + + regs.eax = (uintptr_t)extra.c_str(); + } + }; injector::MakeInline(pattern.get_first(0)); + } + } + }; + } +} ExtraInfo; \ No newline at end of file diff --git a/source/loadingdelays.ixx b/source/loadingdelays.ixx index 8e82643a..02a09ed7 100644 --- a/source/loadingdelays.ixx +++ b/source/loadingdelays.ixx @@ -8,10 +8,10 @@ import common; import framelimit; import comvars; -bool bRestoreSleep = false; +//bool bRestoreSleep = false; void WINAPI FusionSleep(DWORD dwMilliseconds) { - if (!bRestoreSleep) + //if (!bRestoreSleep) { auto bMenuActive = CMenuManager__m_MenuActive && *CMenuManager__m_MenuActive; auto bLoadscreenActive = (bLoadscreenShown && *bLoadscreenShown) || bLoadingShown; @@ -43,9 +43,9 @@ public: ); }; - FusionFix::onGameInitEvent() += []() - { - bRestoreSleep = true; - }; + //FusionFix::onGameInitEvent() += []() + //{ + // bRestoreSleep = true; + //}; } } LoadingDelays; \ No newline at end of file