aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/gameutils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'NorthstarDedicatedTest/gameutils.cpp')
-rw-r--r--NorthstarDedicatedTest/gameutils.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/NorthstarDedicatedTest/gameutils.cpp b/NorthstarDedicatedTest/gameutils.cpp
index 642c44e6..97011059 100644
--- a/NorthstarDedicatedTest/gameutils.cpp
+++ b/NorthstarDedicatedTest/gameutils.cpp
@@ -79,11 +79,17 @@ void InitialiseServerGameUtilFunctions(HMODULE baseAddress)
void InitialiseTier0GameUtilFunctions(HMODULE baseAddress)
{
baseAddress = GetModuleHandleA("tier0.dll");
-
- CreateGlobalMemAlloc = (CreateGlobalMemAllocType)GetProcAddress(baseAddress, "CreateGlobalMemAlloc");
- g_pMemAllocSingleton = CreateGlobalMemAlloc();
-
- Error = (ErrorType)GetProcAddress(baseAddress, "Error");
- CommandLine = (CommandLineType)GetProcAddress(baseAddress, "CommandLine");
- Plat_FloatTime = (Plat_FloatTimeType)GetProcAddress(baseAddress, "Plat_FloatTime");
+ if (!baseAddress)
+ throw "tier0.dll is not loaded";
+
+ CreateGlobalMemAlloc = reinterpret_cast<CreateGlobalMemAllocType>(GetProcAddress(baseAddress, "CreateGlobalMemAlloc"));
+ IMemAlloc** ppMemAllocSingleton = reinterpret_cast<IMemAlloc**>(GetProcAddress(baseAddress, "g_pMemAllocSingleton"));
+ if (!ppMemAllocSingleton || !*ppMemAllocSingleton)
+ g_pMemAllocSingleton = CreateGlobalMemAlloc();
+ else
+ g_pMemAllocSingleton = *ppMemAllocSingleton;
+
+ Error = reinterpret_cast<ErrorType>(GetProcAddress(baseAddress, "Error"));
+ CommandLine = reinterpret_cast<CommandLineType>(GetProcAddress(baseAddress, "CommandLine"));
+ Plat_FloatTime = reinterpret_cast<Plat_FloatTimeType>(GetProcAddress(baseAddress, "Plat_FloatTime"));
} \ No newline at end of file