aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/tier0.cpp
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2022-05-09 18:28:27 +0100
committerBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2022-05-09 18:28:27 +0100
commit7a2f17c9d13371e1beb62014f2ec0169124c9862 (patch)
tree3f12d8c25392fb461f0a3b03dc9cd510631c7400 /NorthstarDedicatedTest/tier0.cpp
parent5a58dd1c05e943d6b440bea5b4a6ae80ce16841e (diff)
downloadNorthstarLauncher-7a2f17c9d13371e1beb62014f2ec0169124c9862.tar.gz
NorthstarLauncher-7a2f17c9d13371e1beb62014f2ec0169124c9862.zip
move tier0 and playlist funcs to namespaces
Diffstat (limited to 'NorthstarDedicatedTest/tier0.cpp')
-rw-r--r--NorthstarDedicatedTest/tier0.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/NorthstarDedicatedTest/tier0.cpp b/NorthstarDedicatedTest/tier0.cpp
new file mode 100644
index 00000000..1a0957ad
--- /dev/null
+++ b/NorthstarDedicatedTest/tier0.cpp
@@ -0,0 +1,37 @@
+#include "pch.h"
+#include "tier0.h"
+
+// use the Tier0 namespace for tier0 funcs
+namespace Tier0
+{
+ IMemAlloc* g_pMemAllocSingleton;
+
+ ErrorType Error;
+ CommandLineType CommandLine;
+ Plat_FloatTimeType Plat_FloatTime;
+ ThreadInServerFrameThreadType ThreadInServerFrameThread;
+} // namespace Tier0
+
+typedef Tier0::IMemAlloc* (*CreateGlobalMemAllocType)();
+CreateGlobalMemAllocType CreateGlobalMemAlloc;
+
+// needs to be a seperate function, since memalloc.cpp calls it
+void TryCreateGlobalMemAlloc()
+{
+ // init memalloc stuff
+ CreateGlobalMemAlloc = reinterpret_cast<CreateGlobalMemAllocType>(GetProcAddress(GetModuleHandleA("tier0.dll"), "CreateGlobalMemAlloc"));
+ Tier0::g_pMemAllocSingleton = CreateGlobalMemAlloc(); // if it already exists, this returns the preexisting IMemAlloc instance
+}
+
+ON_DLL_LOAD("tier0.dll", Tier0GameFuncs, (HMODULE baseAddress)
+{
+ // shouldn't be necessary, but do this just in case
+ TryCreateGlobalMemAlloc();
+
+ // setup tier0 funcs
+ Tier0::Error = reinterpret_cast<Tier0::ErrorType>(GetProcAddress(baseAddress, "Error"));
+ Tier0::CommandLine = reinterpret_cast<Tier0::CommandLineType>(GetProcAddress(baseAddress, "CommandLine"));
+ Tier0::Plat_FloatTime = reinterpret_cast<Tier0::Plat_FloatTimeType>(GetProcAddress(baseAddress, "Plat_FloatTime"));
+ Tier0::ThreadInServerFrameThread =
+ reinterpret_cast<Tier0::ThreadInServerFrameThreadType>(GetProcAddress(baseAddress, "ThreadInServerFrameThread"));
+}) \ No newline at end of file