aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/tier0.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'NorthstarDedicatedTest/tier0.cpp')
-rw-r--r--NorthstarDedicatedTest/tier0.cpp49
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