From 909a3d787647c1286631a28a928e2617af74da03 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Tue, 17 Jan 2023 00:07:53 +0100 Subject: [PATCH] Initialize pointer to CVEngineServer VFTable --- r5dev/public/eiface.h | 4 +++- r5dev/server/vengineserver_impl.cpp | 3 +++ r5dev/server/vengineserver_impl.h | 8 +++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/r5dev/public/eiface.h b/r5dev/public/eiface.h index f07dd899..efc6f6a9 100644 --- a/r5dev/public/eiface.h +++ b/r5dev/public/eiface.h @@ -8,6 +8,8 @@ #ifndef EIFACE_H #define EIFACE_H #include "edict.h" +#include "tier1/bitbuf.h" +#include "vpc/keyvalues.h" //----------------------------------------------------------------------------- // Forward declarations @@ -58,7 +60,7 @@ public: virtual bool IsDedicatedServer(void) = 0; // Is this server active? virtual bool IsActive(void) = 0; - virtual void NullSub0(void) = 0; + virtual void NullSub0(void) = 0; // get arbitrary launch options virtual KeyValues* GetLaunchOptions(void) = 0; diff --git a/r5dev/server/vengineserver_impl.cpp b/r5dev/server/vengineserver_impl.cpp index dc64b5e3..038ccd97 100644 --- a/r5dev/server/vengineserver_impl.cpp +++ b/r5dev/server/vengineserver_impl.cpp @@ -52,3 +52,6 @@ void IVEngineServer_Detach() /////////////////////////////////////////////////////////////////////////////// ServerPlayer_t g_ServerPlayer[MAX_PLAYERS]; + +IVEngineServer* g_pEngineServerVFTable = nullptr; +CVEngineServer* g_pEngineServer = reinterpret_cast(&g_pEngineServerVFTable); \ No newline at end of file diff --git a/r5dev/server/vengineserver_impl.h b/r5dev/server/vengineserver_impl.h index c42d64e3..9a3ee422 100644 --- a/r5dev/server/vengineserver_impl.h +++ b/r5dev/server/vengineserver_impl.h @@ -60,10 +60,10 @@ extern ServerPlayer_t g_ServerPlayer[MAX_PLAYERS]; class CVEngineServer : public IVEngineServer { - + // Implementation in GameDLL. }; - -inline CVEngineServer* g_pEngineServer; +extern CVEngineServer* g_pEngineServer; +extern IVEngineServer* g_pEngineServerVFTable; /////////////////////////////////////////////////////////////////////////////// class HVEngineServer : public IDetour @@ -77,6 +77,7 @@ class HVEngineServer : public IDetour spdlog::debug("| FUN: CVEngineServer::CreateFakeClient : {:#18x} |\n", p_IVEngineServer__CreateFakeClient.GetPtr()); //spdlog::debug("| FUN: RunFrameServer : {:#18x} |\n", p_RunFrameServer.GetPtr()); spdlog::debug("| VAR: g_bDedicated : {:#18x} |\n", reinterpret_cast(g_bDedicated)); + spdlog::debug("| VAR: g_pEngineServerVFTable : {:#18x} |\n", reinterpret_cast(g_pEngineServerVFTable)); spdlog::debug("+----------------------------------------------------------------+\n"); } virtual void GetFun(void) const @@ -98,6 +99,7 @@ class HVEngineServer : public IDetour virtual void GetVar(void) const { g_bDedicated = p_IVEngineServer__IsDedicatedServer.ResolveRelativeAddress(0x3, 0x7).RCast(); + g_pEngineServerVFTable = g_GameDll.GetVirtualMethodTable(".?AVCVEngineServer@@", 0).RCast(); } virtual void GetCon(void) const { } virtual void Attach(void) const { }