diff options
author | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2021-07-17 22:33:00 +0100 |
---|---|---|
committer | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2021-07-17 22:33:00 +0100 |
commit | ca5db71e8215a6c5660fe03088a6d7349f55f817 (patch) | |
tree | 534b79d2599475b1da3edb4f232223d9e32d3174 /NorthstarDedicatedTest/tier0.cpp | |
parent | 51d3d4a40c8579e29571bc80d35bbb62fa50661b (diff) | |
download | NorthstarLauncher-ca5db71e8215a6c5660fe03088a6d7349f55f817.tar.gz NorthstarLauncher-ca5db71e8215a6c5660fe03088a6d7349f55f817.zip |
add support for custom convars and concommands
Diffstat (limited to 'NorthstarDedicatedTest/tier0.cpp')
-rw-r--r-- | NorthstarDedicatedTest/tier0.cpp | 49 |
1 files changed, 46 insertions, 3 deletions
diff --git a/NorthstarDedicatedTest/tier0.cpp b/NorthstarDedicatedTest/tier0.cpp index a52c72ce..717432bf 100644 --- a/NorthstarDedicatedTest/tier0.cpp +++ b/NorthstarDedicatedTest/tier0.cpp @@ -12,6 +12,49 @@ void* ResolveTier0Function(const char* name) return GetProcAddress(tier0, name); } +// memory stuff +typedef IMemAlloc* (*Tier0CreateGlobalMemAlloc)(); +void* operator new(size_t n) +{ + // we should be trying to use tier0's g_pMemAllocSingleton, but atm i can't get it stable + // this actually seems relatively stable though, somehow??? + return malloc(n); + + //IMemAlloc** alloc = (IMemAlloc**)ResolveTier0Function("g_pMemAllocSingleton"); + //if (!alloc) + //{ + // Tier0CreateGlobalMemAlloc createAlloc = (Tier0CreateGlobalMemAlloc)ResolveTier0Function("CreateGlobalMemAlloc"); + // if (!createAlloc) + // return malloc(n); + // else + // (*alloc) = createAlloc(); + //} + // + //return (*alloc)->m_vtable->Alloc(*alloc, n); +} + +void operator delete(void* p) throw() +{ + // we should be trying to use tier0's g_pMemAllocSingleton, but atm i can't get it stable + // this actually seems relatively stable though, somehow??? + free(p); + + //IMemAlloc** alloc = (IMemAlloc**)ResolveTier0Function("g_pMemAllocSingleton"); + //if (!alloc) + //{ + // Tier0CreateGlobalMemAlloc createAlloc = (Tier0CreateGlobalMemAlloc)ResolveTier0Function("CreateGlobalMemAlloc"); + // if (!createAlloc) + // { + // free(p); + // return; + // } + // else + // (*alloc) = createAlloc(); + //} + // + //(*alloc)->m_vtable->Free(*alloc, p); +} + typedef void(*Tier0Error)(const char* fmt, ...); void Error(const char* fmt, ...) { @@ -26,8 +69,8 @@ void Error(const char* fmt, ...) va_end(args); // tier0 isn't loaded yet - if (tier0Func) - tier0Func(buf); - else + //if (tier0Func) + // tier0Func(buf); + //else std::cout << "FATAL ERROR " << buf << std::endl; }
\ No newline at end of file |