Skip to content

Commit

Permalink
add extra info
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirteenAG committed Jan 16, 2024
1 parent 5ce2503 commit 123a3f3
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 6 deletions.
2 changes: 2 additions & 0 deletions data/plugins/GTAIV.EFLC.FusionFix.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
ExtraInfo = 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
Expand Down
25 changes: 25 additions & 0 deletions source/comvars.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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<float*>(4);

pattern = hook::pattern("BE ? ? ? ? 8D 44 24 0C");
pCGameConfigReader__ms_imgFiles = *pattern.get_first<decltype(pCGameConfigReader__ms_imgFiles)>(1);
};
}
} Common;
15 changes: 15 additions & 0 deletions source/cutscenecam.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint8_t>(pattern.get_first(), 0xEB, true);
Expand Down Expand Up @@ -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;
55 changes: 55 additions & 0 deletions source/extrainfo.ixx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
module;

#include <common.hxx>

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()(SafetyHookContext& 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::MakeInline2<MS_PAUSED_HOOK>(pattern.get_first(0));
}
}
};
}
} ExtraInfo;
1 change: 1 addition & 0 deletions source/includes/assembly2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ namespace injector
template<class FuncT>
void MakeInline2(memory_pointer_tr at)
{
MakeNOP(at, 5);
typedef injector_asm2::wrapper<FuncT> functor;
if(false) functor::call(nullptr); // To instantiate the template, if not done _asm will fail
injector_asm2::make_SafetyHookContext_and_call<functor>(at);
Expand Down
12 changes: 6 additions & 6 deletions source/loadingdelays.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -43,9 +43,9 @@ public:
);
};

FusionFix::onGameInitEvent() += []()
{
bRestoreSleep = true;
};
//FusionFix::onGameInitEvent() += []()
//{
// bRestoreSleep = true;
//};
}
} LoadingDelays;

0 comments on commit 123a3f3

Please sign in to comment.