aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/gameutils.cpp
diff options
context:
space:
mode:
authorp0358 <p0358@users.noreply.github.com>2021-12-30 02:58:19 +0100
committerp0358 <p0358@users.noreply.github.com>2021-12-30 02:58:19 +0100
commitd2ee389192aa425ef9c81b2c3367ffb0de6976d0 (patch)
treef244033f6d85055ca272f8369942969848d053f5 /NorthstarDedicatedTest/gameutils.cpp
parentc18b293ba739424bee6db39e2e5a3081b0010a13 (diff)
downloadNorthstarLauncher-d2ee389192aa425ef9c81b2c3367ffb0de6976d0.tar.gz
NorthstarLauncher-d2ee389192aa425ef9c81b2c3367ffb0de6976d0.zip
Refactor and fix of various issues, add run_northstar.txt support
Diffstat (limited to 'NorthstarDedicatedTest/gameutils.cpp')
-rw-r--r--NorthstarDedicatedTest/gameutils.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/NorthstarDedicatedTest/gameutils.cpp b/NorthstarDedicatedTest/gameutils.cpp
index 97011059..3e62037c 100644
--- a/NorthstarDedicatedTest/gameutils.cpp
+++ b/NorthstarDedicatedTest/gameutils.cpp
@@ -78,16 +78,25 @@ void InitialiseServerGameUtilFunctions(HMODULE baseAddress)
void InitialiseTier0GameUtilFunctions(HMODULE baseAddress)
{
- baseAddress = GetModuleHandleA("tier0.dll");
- 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)
+ if (!ppMemAllocSingleton)
+ {
+ spdlog::critical("Address of g_pMemAllocSingleton is a null pointer, this should never happen");
+ throw "Address of g_pMemAllocSingleton is a null pointer, this should never happen";
+ }
+ if (!*ppMemAllocSingleton)
+ {
g_pMemAllocSingleton = CreateGlobalMemAlloc();
+ *ppMemAllocSingleton = g_pMemAllocSingleton;
+ spdlog::warn("Created new g_pMemAllocSingleton");
+ }
else
+ {
g_pMemAllocSingleton = *ppMemAllocSingleton;
+ extern size_t g_iStaticAllocated;
+ spdlog::info("Using existing g_pMemAllocSingleton for memory allocations, preallocated {} bytes beforehand", g_iStaticAllocated);
+ }
Error = reinterpret_cast<ErrorType>(GetProcAddress(baseAddress, "Error"));
CommandLine = reinterpret_cast<CommandLineType>(GetProcAddress(baseAddress, "CommandLine"));