aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/rpakfilesystem.cpp
diff options
context:
space:
mode:
authorp0358 <p0358@users.noreply.github.com>2022-01-02 08:08:01 +0100
committerp0358 <p0358@users.noreply.github.com>2022-01-02 08:08:01 +0100
commit9cb76890b310fe8872dfbe68a880c75e5eb5a7ac (patch)
tree728256a8a41c95d9867febb90b69107ac6ead863 /NorthstarDedicatedTest/rpakfilesystem.cpp
parent664d5d434e8e31f8f74992f2f2b94ffd8a7609c0 (diff)
parent49acb6d831919022745b68f474b65c19f4e62bcd (diff)
downloadNorthstarLauncher-9cb76890b310fe8872dfbe68a880c75e5eb5a7ac.tar.gz
NorthstarLauncher-9cb76890b310fe8872dfbe68a880c75e5eb5a7ac.zip
Merge upstream
Diffstat (limited to 'NorthstarDedicatedTest/rpakfilesystem.cpp')
-rw-r--r--NorthstarDedicatedTest/rpakfilesystem.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/NorthstarDedicatedTest/rpakfilesystem.cpp b/NorthstarDedicatedTest/rpakfilesystem.cpp
new file mode 100644
index 00000000..006a57c5
--- /dev/null
+++ b/NorthstarDedicatedTest/rpakfilesystem.cpp
@@ -0,0 +1,44 @@
+#include "pch.h"
+#include "rpakfilesystem.h"
+#include "hookutils.h"
+#include "modmanager.h"
+
+typedef void*(*LoadCommonPaksForMapType)(char* map);
+LoadCommonPaksForMapType LoadCommonPaksForMap;
+
+typedef void*(*LoadPakSyncType)(char* path, void* unknownSingleton, int flags);
+typedef void*(*LoadPakAsyncType)(char* path, void* unknownSingleton, int flags, void* callback0, void* callback1);
+
+// there are more i'm just too lazy to add
+struct PakLoadFuncs
+{
+ void* unknown[2];
+ LoadPakSyncType func2;
+ LoadPakAsyncType LoadPakAsync;
+};
+
+PakLoadFuncs* g_pakLoadApi;
+void** pUnknownPakLoadSingleton;
+
+void LoadPakAsync(char* path)
+{
+ g_pakLoadApi->LoadPakAsync(path, *pUnknownPakLoadSingleton, 2, nullptr, nullptr);
+}
+
+void LoadCommonPaksForMapHook(char* map)
+{
+ LoadCommonPaksForMap(map);
+
+ // for sp => mp conversions, load the sp rpaks
+ if (!strcmp(map, "mp_skyway_v1") || !strcmp(map, "mp_crashsite") || !strcmp(map, "mp_hub_timeshift"))
+ map[0] = 's';
+}
+
+void InitialiseEngineRpakFilesystem(HMODULE baseAddress)
+{
+ g_pakLoadApi = (PakLoadFuncs*)((char*)baseAddress + 0x5BED78);
+ pUnknownPakLoadSingleton = (void**)((char*)baseAddress + 0x7C5E20);
+
+ HookEnabler hook;
+ ENABLER_CREATEHOOK(hook, (char*)baseAddress + 0x15AD20, &LoadCommonPaksForMapHook, reinterpret_cast<LPVOID*>(&LoadCommonPaksForMap));
+} \ No newline at end of file