diff --git a/core/AMBuilder b/core/AMBuilder index 99125bee..e412fa46 100644 --- a/core/AMBuilder +++ b/core/AMBuilder @@ -60,7 +60,6 @@ for i in SM.sdkInfo: 'smn_bitbuffer.cpp', 'smn_halflife.cpp', 'Translator.cpp', - 'MemoryUtils.cpp', 'PluginSys.cpp', 'smn_console.cpp', 'smn_handles.cpp', diff --git a/core/GameConfigs.cpp b/core/GameConfigs.cpp index 56920b22..46a7900b 100644 --- a/core/GameConfigs.cpp +++ b/core/GameConfigs.cpp @@ -36,9 +36,9 @@ #include "HalfLife2.h" #include "Logger.h" #include "ShareSys.h" -#include "MemoryUtils.h" #include "LibrarySys.h" #include "HandleSys.h" +#include #include "logic_bridge.h" #if defined PLATFORM_LINUX @@ -558,7 +558,7 @@ SMCResult CGameConfig::ReadSMC_LeavingSection(const SMCStates *states) if (handle) { #if (SOURCE_ENGINE == SE_ORANGEBOXVALVE) || (SOURCE_ENGINE == SE_LEFT4DEAD2) - final_addr = g_MemUtils.ResolveSymbol(handle, &s_TempSig.sig[1]); + final_addr = memutils->ResolveSymbol(handle, &s_TempSig.sig[1]); #else final_addr = dlsym(handle, &s_TempSig.sig[1]); #endif @@ -591,7 +591,7 @@ SMCResult CGameConfig::ReadSMC_LeavingSection(const SMCStates *states) if (real_bytes >= 1) { - final_addr = g_MemUtils.FindPattern(addrInBase, (char*)real_sig, real_bytes); + final_addr = memutils->FindPattern(addrInBase, (char*)real_sig, real_bytes); } } diff --git a/core/Makefile b/core/Makefile index c35e695f..674bf0c3 100644 --- a/core/Makefile +++ b/core/Makefile @@ -16,7 +16,7 @@ MMSOURCE17 = ../../mmsource-central OBJECTS = AdminCache.cpp CDataPack.cpp ConCmdManager.cpp ConVarManager.cpp CoreConfig.cpp \ Database.cpp DebugReporter.cpp EventManager.cpp GameConfigs.cpp HalfLife2.cpp Logger.cpp \ - MemoryUtils.cpp PlayerManager.cpp TimerSys.cpp Translator.cpp UserMessages.cpp \ + PlayerManager.cpp TimerSys.cpp Translator.cpp UserMessages.cpp \ sm_autonatives.cpp sm_memtable.cpp sm_srvcmds.cpp sm_stringutil.cpp sm_trie.cpp \ sourcemm_api.cpp sourcemod.cpp MenuStyle_Base.cpp MenuStyle_Valve.cpp MenuManager.cpp \ MenuStyle_Radio.cpp ChatTriggers.cpp ADTFactory.cpp MenuVoting.cpp \ diff --git a/core/logic/AMBuilder b/core/logic/AMBuilder index f02693c0..49a02411 100644 --- a/core/logic/AMBuilder +++ b/core/logic/AMBuilder @@ -32,6 +32,7 @@ files = [ 'smn_functions.cpp', 'smn_timers.cpp', 'smn_players.cpp', + 'MemoryUtils.cpp', 'sm_crc32.cpp' ] if AMBuild.target['platform'] == 'windows': diff --git a/core/logic/Makefile b/core/logic/Makefile index d59319c9..94c1f138 100644 --- a/core/logic/Makefile +++ b/core/logic/Makefile @@ -28,6 +28,7 @@ OBJECTS = \ smn_functions.cpp \ sm_crc32.cpp \ smn_timers.cpp \ + MemoryUtils.cpp \ smn_players.cpp ############################################## diff --git a/core/MemoryUtils.cpp b/core/logic/MemoryUtils.cpp similarity index 95% rename from core/MemoryUtils.cpp rename to core/logic/MemoryUtils.cpp index 89471c01..3c07ed67 100644 --- a/core/MemoryUtils.cpp +++ b/core/logic/MemoryUtils.cpp @@ -28,7 +28,6 @@ */ #include "MemoryUtils.h" -#include "ShareSys.h" #ifdef PLATFORM_LINUX #include #include @@ -69,7 +68,7 @@ MemoryUtils::~MemoryUtils() void MemoryUtils::OnSourceModAllInitialized() { - g_ShareSys.AddInterface(NULL, this); + sharesys->AddInterface(NULL, this); } void *MemoryUtils::FindPattern(const void *libPtr, const char *pattern, size_t len) diff --git a/core/MemoryUtils.h b/core/logic/MemoryUtils.h similarity index 95% rename from core/MemoryUtils.h rename to core/logic/MemoryUtils.h index 8615e904..4e83e34c 100644 --- a/core/MemoryUtils.h +++ b/core/logic/MemoryUtils.h @@ -30,8 +30,8 @@ #ifndef _INCLUDE_SOURCEMOD_MEMORYUTILS_H_ #define _INCLUDE_SOURCEMOD_MEMORYUTILS_H_ +#include "common_logic.h" #include -#include "sm_globals.h" #if defined PLATFORM_LINUX || defined PLATFORM_APPLE #include #include "sm_symtable.h" diff --git a/core/logic/common_logic.cpp b/core/logic/common_logic.cpp index 0b03101e..43d6774b 100644 --- a/core/logic/common_logic.cpp +++ b/core/logic/common_logic.cpp @@ -37,6 +37,7 @@ #include "TextParsers.h" #include "Profiler.h" #include "sm_crc32.h" +#include "MemoryUtils.h" sm_core_t smcore; IHandleSys *handlesys; @@ -59,6 +60,7 @@ static sm_logic_t logic = NULL, g_pThreader, sm_profiler, + &g_MemUtils, UTIL_CRC32 }; diff --git a/core/logic/intercom.h b/core/logic/intercom.h index 8b1a73e9..426e9d87 100644 --- a/core/logic/intercom.h +++ b/core/logic/intercom.h @@ -42,7 +42,7 @@ using namespace SourceMod; * Add 1 to the RHS of this expression to bump the intercom file * This is to prevent mismatching core/logic binaries */ -#define SM_LOGIC_MAGIC (0x0F47C0DE - 5) +#define SM_LOGIC_MAGIC (0x0F47C0DE - 6) #if defined SM_LOGIC class IVEngineServer @@ -65,6 +65,7 @@ namespace SourceMod class IForwardManager; class ITimerSystem; class IPlayerManager; + class IMemoryUtils; } class IVEngineServer; @@ -110,6 +111,7 @@ struct sm_logic_t SMGlobalClass *head; IThreader *threader; IProfiler *profiler; + IMemoryUtils *memutils; unsigned int (*CRC32)(const void *, size_t); }; diff --git a/core/sm_symtable.h b/core/logic/sm_symtable.h similarity index 100% rename from core/sm_symtable.h rename to core/logic/sm_symtable.h diff --git a/core/logic_bridge.cpp b/core/logic_bridge.cpp index bde7fb47..26059346 100644 --- a/core/logic_bridge.cpp +++ b/core/logic_bridge.cpp @@ -54,6 +54,7 @@ static LogicInitFunction logic_init_fn; IThreader *g_pThreader; ITextParsers *textparsers; SM_FN_CRC32 UTIL_CRC32; +IMemoryUtils *memutils; class VEngineServer_Logic : public IVEngineServer_Logic { @@ -151,6 +152,7 @@ void InitLogicBridge() g_pThreader = logic.threader; g_pSourcePawn2->SetProfiler(logic.profiler); UTIL_CRC32 = logic.CRC32; + memutils = logic.memutils; } bool StartLogicBridge(char *error, size_t maxlength) diff --git a/core/sm_globals.h b/core/sm_globals.h index 03e749cf..d4ba97ea 100644 --- a/core/sm_globals.h +++ b/core/sm_globals.h @@ -201,10 +201,12 @@ namespace SourceMod { class IThreader; class ITextParsers; + class IMemoryUtils; } extern IThreader *g_pThreader; extern ITextParsers *textparsers; +extern IMemoryUtils *memutils; #include "sm_autonatives.h"