aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/clientvideooverrides.cpp
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2022-03-15 05:57:15 +0000
committerBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2022-03-15 05:57:15 +0000
commit50e69bde548c5a1af3385f0eff6aa14c088c21c5 (patch)
tree24a050f6d31b43b7196f0ea8b6283e2d76bc561a /NorthstarDedicatedTest/clientvideooverrides.cpp
parent96aa95aede1fb1f3fde3d2c08728c37520bea4c2 (diff)
downloadNorthstarLauncher-50e69bde548c5a1af3385f0eff6aa14c088c21c5.tar.gz
NorthstarLauncher-50e69bde548c5a1af3385f0eff6aa14c088c21c5.zip
add mod binks, mod rpak loading, and support for non-preload vpks/rpaks
Diffstat (limited to 'NorthstarDedicatedTest/clientvideooverrides.cpp')
-rw-r--r--NorthstarDedicatedTest/clientvideooverrides.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/NorthstarDedicatedTest/clientvideooverrides.cpp b/NorthstarDedicatedTest/clientvideooverrides.cpp
new file mode 100644
index 00000000..3a63c181
--- /dev/null
+++ b/NorthstarDedicatedTest/clientvideooverrides.cpp
@@ -0,0 +1,42 @@
+#include "pch.h"
+#include "clientvideooverrides.h"
+#include "modmanager.h"
+#include "dedicated.h"
+
+typedef void*(*BinkOpenType)(const char* path, uint32_t flags);
+BinkOpenType BinkOpen;
+
+void* BinkOpenHook(const char* path, uint32_t flags)
+{
+ std::string filename(fs::path(path).filename().string());
+ spdlog::info("BinkOpen {}", filename);
+
+ // figure out which mod is handling the bink
+ Mod* fileOwner = nullptr;
+ for (Mod& mod : g_ModManager->m_loadedMods)
+ {
+ if (!mod.Enabled)
+ continue;
+
+ if (std::find(mod.BinkVideos.begin(), mod.BinkVideos.end(), filename) != mod.BinkVideos.end())
+ fileOwner = &mod;
+ }
+
+ if (fileOwner)
+ {
+ // create new path
+ fs::path binkPath(fileOwner->ModDirectory / "media" / filename);
+ return BinkOpen(binkPath.string().c_str(), flags);
+ }
+ else
+ return BinkOpen(path, flags);
+}
+
+void InitialiseClientVideoOverrides(HMODULE baseAddress)
+{
+ if (IsDedicated())
+ return;
+
+ HookEnabler hook;
+ ENABLER_CREATEHOOK(hook, GetProcAddress(GetModuleHandleA("bink2w64.dll"), "BinkOpen"), &BinkOpenHook, reinterpret_cast<LPVOID*>(&BinkOpen));
+} \ No newline at end of file