From 2cc47f60e29c124e955f3e9e9ba744a3cdbc72b8 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Fri, 27 May 2022 22:31:52 +0200 Subject: [PATCH] Cleanup for 'StreamDB_Init' --- r5dev/materialsystem/cmaterialsystem.cpp | 20 ++++++++++---------- r5dev/materialsystem/cmaterialsystem.h | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/r5dev/materialsystem/cmaterialsystem.cpp b/r5dev/materialsystem/cmaterialsystem.cpp index c9802616..32bd50b0 100644 --- a/r5dev/materialsystem/cmaterialsystem.cpp +++ b/r5dev/materialsystem/cmaterialsystem.cpp @@ -12,9 +12,9 @@ // (overrides level name if stbsp field has value in prerequisites file) // Input : *pszStreamDBFile - //--------------------------------------------------------------------------------- -void HStreamDB_Init(const char* pszStreamDBFile) +void StreamDB_Init(const char* pszStreamDBFile) { - std::ostringstream ostream; + ostringstream ostream; ostream << "platform\\scripts\\levels\\settings\\" << pszStreamDBFile << ".json"; fs::path fsPath = fs::current_path() /= ostream.str(); @@ -23,7 +23,7 @@ void HStreamDB_Init(const char* pszStreamDBFile) nlohmann::json jsIn; try { - std::ifstream iPakLoadDefFile(fsPath, std::ios::binary); // Parse prerequisites file. + ifstream iPakLoadDefFile(fsPath, std::ios::binary); // Parse prerequisites file. iPakLoadDefFile >> jsIn; iPakLoadDefFile.close(); @@ -31,19 +31,19 @@ void HStreamDB_Init(const char* pszStreamDBFile) { if (!jsIn["stbsp"].is_null()) { - std::string svStreamDBFile = jsIn["stbsp"].get(); - DevMsg(eDLL_T::MS, "StreamDB_Init: Loading override STBSP file '%s.stbsp'\n", svStreamDBFile.c_str(), pszStreamDBFile); - StreamDB_Init(svStreamDBFile.c_str()); + string svStreamDBFile = jsIn["stbsp"].get(); + DevMsg(eDLL_T::MS, "%s: Loading override STBSP file '%s.stbsp'\n", __FUNCTION__, svStreamDBFile.c_str(), pszStreamDBFile); + v_StreamDB_Init(svStreamDBFile.c_str()); return; } } } catch (const std::exception& ex) { - DevMsg(eDLL_T::MS, "StreamDB_Init: Exception while parsing STBSP override: '%s'\n", ex.what()); + DevMsg(eDLL_T::MS, "%s: Exception while parsing STBSP override: '%s'\n", __FUNCTION__, ex.what()); } } - StreamDB_Init(pszStreamDBFile); + v_StreamDB_Init(pszStreamDBFile); } //--------------------------------------------------------------------------------- @@ -70,12 +70,12 @@ void* __fastcall DispatchDrawCall(int64_t a1, uint64_t a2, int a3, int a4, int64 /////////////////////////////////////////////////////////////////////////////// void CMaterialSystem_Attach() { - DetourAttach((LPVOID*)&StreamDB_Init, &HStreamDB_Init); + DetourAttach((LPVOID*)&v_StreamDB_Init, &StreamDB_Init); DetourAttach((LPVOID*)&v_DispatchDrawCall, &DispatchDrawCall); } void CMaterialSystem_Detach() { - DetourDetach((LPVOID*)&StreamDB_Init, &HStreamDB_Init); + DetourDetach((LPVOID*)&v_StreamDB_Init, &StreamDB_Init); DetourDetach((LPVOID*)&v_DispatchDrawCall, &DispatchDrawCall); } \ No newline at end of file diff --git a/r5dev/materialsystem/cmaterialsystem.h b/r5dev/materialsystem/cmaterialsystem.h index 7999b98d..418ff121 100644 --- a/r5dev/materialsystem/cmaterialsystem.h +++ b/r5dev/materialsystem/cmaterialsystem.h @@ -18,7 +18,7 @@ inline CMemory p_DrawStreamOverlay; inline auto DrawStreamOverlay = p_DrawStreamOverlay.RCast(); inline CMemory p_StreamDB_Init; -inline auto StreamDB_Init = p_StreamDB_Init.RCast(); +inline auto v_StreamDB_Init = p_StreamDB_Init.RCast(); inline CMemory s_pRenderContext; @@ -60,7 +60,7 @@ class VMaterialSystem : public IDetour DrawStreamOverlay = p_DrawStreamOverlay.RCast(); // 41 56 B8 ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 2B E0 C6 02 00 // p_StreamDB_Init = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x41\x54\x41\x56\x41\x57\x48\x83\xEC\x40\x48\x8B\xE9"), "xxxx?xxxx?xxxx?xxxx?xxxxxxxxxxxxx"); - StreamDB_Init = p_StreamDB_Init.RCast(); /*48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 41 54 41 56 41 57 48 83 EC 40 48 8B E9*/ + v_StreamDB_Init = p_StreamDB_Init.RCast(); /*48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 41 54 41 56 41 57 48 83 EC 40 48 8B E9*/ #endif // !DEDICATED } virtual void GetVar(void) const