From 1ba6b2653a6af6335649b12257c505a1d69b5683 Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Wed, 9 Oct 2013 08:43:08 -0400 Subject: [PATCH] Move ForwardSys from core to logic (bug 5953, r=fyren). --HG-- rename : core/ForwardSys.cpp => core/logic/ForwardSys.cpp rename : core/ForwardSys.h => core/logic/ForwardSys.h --- core/AMBuilder | 1 - core/AdminCache.cpp | 5 +-- core/ChatTriggers.cpp | 16 ++++---- core/ConCmdManager.h | 2 +- core/ConVarManager.cpp | 7 ++-- core/ConsoleDetours.cpp | 8 ++-- core/ConsoleDetours.h | 2 +- core/CoreConfig.cpp | 13 +++--- core/EventManager.cpp | 15 ++++--- core/PlayerManager.cpp | 53 ++++++++++++------------- core/TimerSys.cpp | 9 ++--- core/logic/AMBuilder | 1 + core/{ => logic}/ForwardSys.cpp | 5 ++- core/{ => logic}/ForwardSys.h | 27 +------------ core/logic/common_logic.cpp | 5 ++- core/logic/intercom.h | 5 ++- core/logic_bridge.cpp | 4 +- core/logic_bridge.h | 1 + core/smn_console.cpp | 1 + core/smn_core.cpp | 5 +-- core/sourcemod.cpp | 5 +-- public/IForwardSys.h | 70 +++++++++++++++++++++------------ 22 files changed, 127 insertions(+), 133 deletions(-) rename core/{ => logic}/ForwardSys.cpp (94%) rename core/{ => logic}/ForwardSys.h (91%) diff --git a/core/AMBuilder b/core/AMBuilder index dbe05310..27c50180 100644 --- a/core/AMBuilder +++ b/core/AMBuilder @@ -61,7 +61,6 @@ for i in SM.sdkInfo: 'logic_bridge.cpp', 'smn_entities.cpp', 'sm_stringutil.cpp', - 'ForwardSys.cpp', 'MenuVoting.cpp', 'smn_events.cpp', 'smn_menus.cpp', diff --git a/core/AdminCache.cpp b/core/AdminCache.cpp index 87cafd6b..d530b3e3 100644 --- a/core/AdminCache.cpp +++ b/core/AdminCache.cpp @@ -33,7 +33,6 @@ #include #include #include "AdminCache.h" -#include "ForwardSys.h" #include "PlayerManager.h" #include "ConCmdManager.h" #include "Logger.h" @@ -276,7 +275,7 @@ void AdminCache::OnSourceModStartup(bool late) void AdminCache::OnSourceModAllInitialized() { - m_pCacheFwd = g_Forwards.CreateForward("OnRebuildAdminCache", ET_Ignore, 1, NULL, Param_Cell); + m_pCacheFwd = forwardsys->CreateForward("OnRebuildAdminCache", ET_Ignore, 1, NULL, Param_Cell); sharesys->AddInterface(NULL, this); } @@ -303,7 +302,7 @@ void AdminCache::OnSourceModLevelChange(const char *mapName) void AdminCache::OnSourceModShutdown() { - g_Forwards.ReleaseForward(m_pCacheFwd); + forwardsys->ReleaseForward(m_pCacheFwd); m_pCacheFwd = NULL; } diff --git a/core/ChatTriggers.cpp b/core/ChatTriggers.cpp index 307ff339..dfc01fee 100644 --- a/core/ChatTriggers.cpp +++ b/core/ChatTriggers.cpp @@ -108,10 +108,10 @@ ConfigResult ChatTriggers::OnSourceModConfigChanged(const char *key, void ChatTriggers::OnSourceModAllInitialized() { - m_pShouldFloodBlock = g_Forwards.CreateForward("OnClientFloodCheck", ET_Event, 1, NULL, Param_Cell); - m_pDidFloodBlock = g_Forwards.CreateForward("OnClientFloodResult", ET_Event, 2, NULL, Param_Cell, Param_Cell); - m_pOnClientSayCmd = g_Forwards.CreateForward("OnClientSayCommand", ET_Event, 3, NULL, Param_Cell, Param_String, Param_String); - m_pOnClientSayCmd_Post = g_Forwards.CreateForward("OnClientSayCommand_Post", ET_Ignore, 3, NULL, Param_Cell, Param_String, Param_String); + m_pShouldFloodBlock = forwardsys->CreateForward("OnClientFloodCheck", ET_Event, 1, NULL, Param_Cell); + m_pDidFloodBlock = forwardsys->CreateForward("OnClientFloodResult", ET_Event, 2, NULL, Param_Cell, Param_Cell); + m_pOnClientSayCmd = forwardsys->CreateForward("OnClientSayCommand", ET_Event, 3, NULL, Param_Cell, Param_String, Param_String); + m_pOnClientSayCmd_Post = forwardsys->CreateForward("OnClientSayCommand_Post", ET_Ignore, 3, NULL, Param_Cell, Param_String, Param_String); } void ChatTriggers::OnSourceModAllInitialized_Post() @@ -186,10 +186,10 @@ void ChatTriggers::OnSourceModShutdown() } #endif - g_Forwards.ReleaseForward(m_pShouldFloodBlock); - g_Forwards.ReleaseForward(m_pDidFloodBlock); - g_Forwards.ReleaseForward(m_pOnClientSayCmd); - g_Forwards.ReleaseForward(m_pOnClientSayCmd_Post); + forwardsys->ReleaseForward(m_pShouldFloodBlock); + forwardsys->ReleaseForward(m_pDidFloodBlock); + forwardsys->ReleaseForward(m_pOnClientSayCmd); + forwardsys->ReleaseForward(m_pOnClientSayCmd_Post); } #if SOURCE_ENGINE == SE_DOTA diff --git a/core/ConCmdManager.h b/core/ConCmdManager.h index 2dac0234..e521dc70 100644 --- a/core/ConCmdManager.h +++ b/core/ConCmdManager.h @@ -34,7 +34,7 @@ #include "sm_globals.h" #include "sourcemm_api.h" -#include "ForwardSys.h" +#include #include #include #include diff --git a/core/ConVarManager.cpp b/core/ConVarManager.cpp index 07514749..ca8e8cb0 100644 --- a/core/ConVarManager.cpp +++ b/core/ConVarManager.cpp @@ -29,7 +29,6 @@ #include "ConVarManager.h" #include "HalfLife2.h" -#include "ForwardSys.h" #include "sm_srvcmds.h" #include "sm_stringutil.h" #include @@ -151,7 +150,7 @@ void ConVarManager::OnSourceModShutdown() handlesys->FreeHandle(pInfo->handle, &sec); if (pInfo->pChangeForward != NULL) { - g_Forwards.ReleaseForward(pInfo->pChangeForward); + forwardsys->ReleaseForward(pInfo->pChangeForward); } if (pInfo->sourceMod) { @@ -558,7 +557,7 @@ void ConVarManager::HookConVarChange(ConVar *pConVar, IPluginFunction *pFunction /* If forward does not exist, create it */ if (!pForward) { - pForward = g_Forwards.CreateForwardEx(NULL, ET_Ignore, 3, CONVARCHANGE_PARAMS); + pForward = forwardsys->CreateForwardEx(NULL, ET_Ignore, 3, CONVARCHANGE_PARAMS); pInfo->pChangeForward = pForward; } @@ -598,7 +597,7 @@ void ConVarManager::UnhookConVarChange(ConVar *pConVar, IPluginFunction *pFuncti !ConVarReentrancyGuard::IsCvarInChain(pConVar)) { /* Free this forward */ - g_Forwards.ReleaseForward(pForward); + forwardsys->ReleaseForward(pForward); pInfo->pChangeForward = NULL; } } diff --git a/core/ConsoleDetours.cpp b/core/ConsoleDetours.cpp index 27932b63..6c406666 100644 --- a/core/ConsoleDetours.cpp +++ b/core/ConsoleDetours.cpp @@ -579,7 +579,7 @@ ConsoleDetours::ConsoleDetours() : status(FeatureStatus_Unknown) void ConsoleDetours::OnSourceModAllInitialized() { - m_pForward = g_Forwards.CreateForwardEx("OnAnyCommand", ET_Hook, 3, NULL, Param_Cell, + m_pForward = forwardsys->CreateForwardEx("OnAnyCommand", ET_Hook, 3, NULL, Param_Cell, Param_String, Param_Cell); sharesys->AddCapabilityProvider(NULL, this, FEATURECAP_COMMANDLISTENER); } @@ -590,10 +590,10 @@ void ConsoleDetours::OnSourceModShutdown() !iter.empty(); iter.next()) { - g_Forwards.ReleaseForward(iter->value); + forwardsys->ReleaseForward(iter->value); } - g_Forwards.ReleaseForward(m_pForward); + forwardsys->ReleaseForward(m_pForward); s_GenericHooker.Disable(); } @@ -626,7 +626,7 @@ bool ConsoleDetours::AddListener(IPluginFunction *fun, const char *command) IChangeableForward *forward; if (!m_Listeners.retrieve(str, &forward)) { - forward = g_Forwards.CreateForwardEx(NULL, ET_Hook, 3, NULL, Param_Cell, + forward = forwardsys->CreateForwardEx(NULL, ET_Hook, 3, NULL, Param_Cell, Param_String, Param_Cell); m_Listeners.insert(str, forward); } diff --git a/core/ConsoleDetours.h b/core/ConsoleDetours.h index 349041d7..3bf9ae74 100644 --- a/core/ConsoleDetours.h +++ b/core/ConsoleDetours.h @@ -33,7 +33,7 @@ #include "sm_globals.h" #include "sourcemm_api.h" -#include "ForwardSys.h" +#include #include class ConsoleDetours : diff --git a/core/CoreConfig.cpp b/core/CoreConfig.cpp index 97993f0c..a79e4d67 100644 --- a/core/CoreConfig.cpp +++ b/core/CoreConfig.cpp @@ -38,7 +38,6 @@ #include "sm_stringutil.h" #include "LibrarySys.h" #include "Logger.h" -#include "ForwardSys.h" #include "frame_hooks.h" #include "logic_bridge.h" @@ -119,9 +118,9 @@ void CheckAndFinalizeConfigs() void CoreConfig::OnSourceModAllInitialized() { g_RootMenu.AddRootConsoleCommand("config", "Set core configuration options", this); - g_pOnServerCfg = g_Forwards.CreateForward("OnServerCfg", ET_Ignore, 0, NULL); - g_pOnConfigsExecuted = g_Forwards.CreateForward("OnConfigsExecuted", ET_Ignore, 0, NULL); - g_pOnAutoConfigsBuffered = g_Forwards.CreateForward("OnAutoConfigsBuffered", ET_Ignore, 0, NULL); + g_pOnServerCfg = forwardsys->CreateForward("OnServerCfg", ET_Ignore, 0, NULL); + g_pOnConfigsExecuted = forwardsys->CreateForward("OnConfigsExecuted", ET_Ignore, 0, NULL); + g_pOnAutoConfigsBuffered = forwardsys->CreateForward("OnAutoConfigsBuffered", ET_Ignore, 0, NULL); } CoreConfig::CoreConfig() @@ -135,9 +134,9 @@ CoreConfig::~CoreConfig() void CoreConfig::OnSourceModShutdown() { g_RootMenu.RemoveRootConsoleCommand("config", this); - g_Forwards.ReleaseForward(g_pOnServerCfg); - g_Forwards.ReleaseForward(g_pOnConfigsExecuted); - g_Forwards.ReleaseForward(g_pOnAutoConfigsBuffered); + forwardsys->ReleaseForward(g_pOnServerCfg); + forwardsys->ReleaseForward(g_pOnConfigsExecuted); + forwardsys->ReleaseForward(g_pOnAutoConfigsBuffered); if (g_pExecPtr != NULL) { diff --git a/core/EventManager.cpp b/core/EventManager.cpp index 7dd9b5ac..3d40709a 100644 --- a/core/EventManager.cpp +++ b/core/EventManager.cpp @@ -30,7 +30,6 @@ */ #include "EventManager.h" -#include "ForwardSys.h" #include "sm_stringutil.h" #include "logic_bridge.h" @@ -133,12 +132,12 @@ void EventManager::OnPluginUnloaded(IPlugin *plugin) { if (pHook->pPreHook) { - g_Forwards.ReleaseForward(pHook->pPreHook); + forwardsys->ReleaseForward(pHook->pPreHook); } if (pHook->pPostHook) { - g_Forwards.ReleaseForward(pHook->pPostHook); + forwardsys->ReleaseForward(pHook->pPostHook); } delete pHook; @@ -197,12 +196,12 @@ EventHookError EventManager::HookEvent(const char *name, IPluginFunction *pFunct if (mode == EventHookMode_Pre) { /* Create forward for a pre hook */ - pHook->pPreHook = g_Forwards.CreateForwardEx(NULL, ET_Hook, 3, GAMEEVENT_PARAMS); + pHook->pPreHook = forwardsys->CreateForwardEx(NULL, ET_Hook, 3, GAMEEVENT_PARAMS); /* Add to forward list */ pHook->pPreHook->AddFunction(pFunction); } else { /* Create forward for a post hook */ - pHook->pPostHook = g_Forwards.CreateForwardEx(NULL, ET_Ignore, 3, GAMEEVENT_PARAMS); + pHook->pPostHook = forwardsys->CreateForwardEx(NULL, ET_Ignore, 3, GAMEEVENT_PARAMS); /* Should we copy data from a pre hook to the post hook? */ pHook->postCopy = (mode == EventHookMode_Post); /* Add to forward list */ @@ -229,7 +228,7 @@ EventHookError EventManager::HookEvent(const char *name, IPluginFunction *pFunct /* Create pre hook forward if necessary */ if (!pHook->pPreHook) { - pHook->pPreHook = g_Forwards.CreateForwardEx(NULL, ET_Event, 3, GAMEEVENT_PARAMS); + pHook->pPreHook = forwardsys->CreateForwardEx(NULL, ET_Event, 3, GAMEEVENT_PARAMS); } /* Add plugin function to forward list */ @@ -238,7 +237,7 @@ EventHookError EventManager::HookEvent(const char *name, IPluginFunction *pFunct /* Create post hook forward if necessary */ if (!pHook->pPostHook) { - pHook->pPostHook = g_Forwards.CreateForwardEx(NULL, ET_Ignore, 3, GAMEEVENT_PARAMS); + pHook->pPostHook = forwardsys->CreateForwardEx(NULL, ET_Ignore, 3, GAMEEVENT_PARAMS); } /* If postCopy is false, then we may want to set it to true */ @@ -285,7 +284,7 @@ EventHookError EventManager::UnhookEvent(const char *name, IPluginFunction *pFun /* If forward's list contains 0 functions now, free it */ if ((*pEventForward)->GetFunctionCount() == 0) { - g_Forwards.ReleaseForward(*pEventForward); + forwardsys->ReleaseForward(*pEventForward); *pEventForward = NULL; } diff --git a/core/PlayerManager.cpp b/core/PlayerManager.cpp index f4250586..cf6e66a2 100644 --- a/core/PlayerManager.cpp +++ b/core/PlayerManager.cpp @@ -30,7 +30,6 @@ */ #include "PlayerManager.h" -#include "ForwardSys.h" #include "AdminCache.h" #include "ConCmdManager.h" #include "MenuStyle_Valve.h" @@ -159,20 +158,20 @@ void PlayerManager::OnSourceModAllInitialized() ParamType p1[] = {Param_Cell, Param_String, Param_Cell}; ParamType p2[] = {Param_Cell}; - m_clconnect = g_Forwards.CreateForward("OnClientConnect", ET_LowEvent, 3, p1); - m_clconnect_post = g_Forwards.CreateForward("OnClientConnected", ET_Ignore, 1, p2); - m_clputinserver = g_Forwards.CreateForward("OnClientPutInServer", ET_Ignore, 1, p2); - m_cldisconnect = g_Forwards.CreateForward("OnClientDisconnect", ET_Ignore, 1, p2); - m_cldisconnect_post = g_Forwards.CreateForward("OnClientDisconnect_Post", ET_Ignore, 1, p2); - m_clcommand = g_Forwards.CreateForward("OnClientCommand", ET_Hook, 2, NULL, Param_Cell, Param_Cell); - m_clinfochanged = g_Forwards.CreateForward("OnClientSettingsChanged", ET_Ignore, 1, p2); - m_clauth = g_Forwards.CreateForward("OnClientAuthorized", ET_Ignore, 2, NULL, Param_Cell, Param_String); - m_onActivate = g_Forwards.CreateForward("OnServerLoad", ET_Ignore, 0, NULL); - m_onActivate2 = g_Forwards.CreateForward("OnMapStart", ET_Ignore, 0, NULL); + m_clconnect = forwardsys->CreateForward("OnClientConnect", ET_LowEvent, 3, p1); + m_clconnect_post = forwardsys->CreateForward("OnClientConnected", ET_Ignore, 1, p2); + m_clputinserver = forwardsys->CreateForward("OnClientPutInServer", ET_Ignore, 1, p2); + m_cldisconnect = forwardsys->CreateForward("OnClientDisconnect", ET_Ignore, 1, p2); + m_cldisconnect_post = forwardsys->CreateForward("OnClientDisconnect_Post", ET_Ignore, 1, p2); + m_clcommand = forwardsys->CreateForward("OnClientCommand", ET_Hook, 2, NULL, Param_Cell, Param_Cell); + m_clinfochanged = forwardsys->CreateForward("OnClientSettingsChanged", ET_Ignore, 1, p2); + m_clauth = forwardsys->CreateForward("OnClientAuthorized", ET_Ignore, 2, NULL, Param_Cell, Param_String); + m_onActivate = forwardsys->CreateForward("OnServerLoad", ET_Ignore, 0, NULL); + m_onActivate2 = forwardsys->CreateForward("OnMapStart", ET_Ignore, 0, NULL); - PreAdminCheck = g_Forwards.CreateForward("OnClientPreAdminCheck", ET_Event, 1, p1); - PostAdminCheck = g_Forwards.CreateForward("OnClientPostAdminCheck", ET_Ignore, 1, p1); - PostAdminFilter = g_Forwards.CreateForward("OnClientPostAdminFilter", ET_Ignore, 1, p1); + PreAdminCheck = forwardsys->CreateForward("OnClientPreAdminCheck", ET_Event, 1, p1); + PostAdminCheck = forwardsys->CreateForward("OnClientPostAdminCheck", ET_Ignore, 1, p1); + PostAdminFilter = forwardsys->CreateForward("OnClientPostAdminFilter", ET_Ignore, 1, p1); m_bIsListenServer = !engine->IsDedicatedServer(); m_ListenClient = 0; @@ -197,20 +196,20 @@ void PlayerManager::OnSourceModShutdown() SH_REMOVE_HOOK(IServerGameDLL, ServerActivate, gamedll, SH_MEMBER(this, &PlayerManager::OnServerActivate), true); /* Release forwards */ - g_Forwards.ReleaseForward(m_clconnect); - g_Forwards.ReleaseForward(m_clconnect_post); - g_Forwards.ReleaseForward(m_clputinserver); - g_Forwards.ReleaseForward(m_cldisconnect); - g_Forwards.ReleaseForward(m_cldisconnect_post); - g_Forwards.ReleaseForward(m_clcommand); - g_Forwards.ReleaseForward(m_clinfochanged); - g_Forwards.ReleaseForward(m_clauth); - g_Forwards.ReleaseForward(m_onActivate); - g_Forwards.ReleaseForward(m_onActivate2); + forwardsys->ReleaseForward(m_clconnect); + forwardsys->ReleaseForward(m_clconnect_post); + forwardsys->ReleaseForward(m_clputinserver); + forwardsys->ReleaseForward(m_cldisconnect); + forwardsys->ReleaseForward(m_cldisconnect_post); + forwardsys->ReleaseForward(m_clcommand); + forwardsys->ReleaseForward(m_clinfochanged); + forwardsys->ReleaseForward(m_clauth); + forwardsys->ReleaseForward(m_onActivate); + forwardsys->ReleaseForward(m_onActivate2); - g_Forwards.ReleaseForward(PreAdminCheck); - g_Forwards.ReleaseForward(PostAdminCheck); - g_Forwards.ReleaseForward(PostAdminFilter); + forwardsys->ReleaseForward(PreAdminCheck); + forwardsys->ReleaseForward(PostAdminCheck); + forwardsys->ReleaseForward(PostAdminFilter); delete [] m_Players; diff --git a/core/TimerSys.cpp b/core/TimerSys.cpp index 77c1f28f..fbadcc40 100644 --- a/core/TimerSys.cpp +++ b/core/TimerSys.cpp @@ -31,7 +31,6 @@ #include #include "TimerSys.h" -#include "ForwardSys.h" #include "sourcemm_api.h" #include "frame_hooks.h" #include "ConVarManager.h" @@ -182,8 +181,8 @@ TimerSystem::~TimerSystem() void TimerSystem::OnSourceModAllInitialized() { sharesys->AddInterface(NULL, this); - m_pOnGameFrame = g_Forwards.CreateForward("OnGameFrame", ET_Ignore, 0, NULL); - m_pOnMapTimeLeftChanged = g_Forwards.CreateForward("OnMapTimeLeftChanged", ET_Ignore, 0, NULL); + m_pOnGameFrame = forwardsys->CreateForward("OnGameFrame", ET_Ignore, 0, NULL); + m_pOnMapTimeLeftChanged = forwardsys->CreateForward("OnMapTimeLeftChanged", ET_Ignore, 0, NULL); } void TimerSystem::OnSourceModGameInitialized() @@ -199,8 +198,8 @@ void TimerSystem::OnSourceModGameInitialized() void TimerSystem::OnSourceModShutdown() { SetMapTimer(NULL); - g_Forwards.ReleaseForward(m_pOnGameFrame); - g_Forwards.ReleaseForward(m_pOnMapTimeLeftChanged); + forwardsys->ReleaseForward(m_pOnGameFrame); + forwardsys->ReleaseForward(m_pOnMapTimeLeftChanged); } void TimerSystem::OnSourceModLevelEnd() diff --git a/core/logic/AMBuilder b/core/logic/AMBuilder index ddfc6e8e..db6f7842 100644 --- a/core/logic/AMBuilder +++ b/core/logic/AMBuilder @@ -63,6 +63,7 @@ files = [ 'DebugReporter.cpp', 'Database.cpp', 'smn_database.cpp', + 'ForwardSys.cpp', ] if AMBuild.target['platform'] == 'windows': files.append('thread/WinThreads.cpp') diff --git a/core/ForwardSys.cpp b/core/logic/ForwardSys.cpp similarity index 94% rename from core/ForwardSys.cpp rename to core/logic/ForwardSys.cpp index 3529dd7e..8fc489a0 100644 --- a/core/ForwardSys.cpp +++ b/core/logic/ForwardSys.cpp @@ -33,7 +33,8 @@ #include #include #include "ForwardSys.h" -#include "logic_bridge.h" +#include "DebugReporter.h" +#include "common_logic.h" CForwardManager g_Forwards; @@ -370,7 +371,7 @@ int CForward::Execute(cell_t *result, IForwardFilter *filter) if (err != SP_ERROR_NONE) { - logicore.GenerateError(func->GetParentContext(), + g_DbgReporter.GenerateError(func->GetParentContext(), func->GetFunctionID(), err, "Failed to push parameter while executing forward"); diff --git a/core/ForwardSys.h b/core/logic/ForwardSys.h similarity index 91% rename from core/ForwardSys.h rename to core/logic/ForwardSys.h index cf622063..4f826d98 100644 --- a/core/ForwardSys.h +++ b/core/logic/ForwardSys.h @@ -34,10 +34,10 @@ #include #include -#include "sm_globals.h" +#include "common_logic.h" #include #include -#include "sourcemod.h" +#include "ISourceMod.h" using namespace SourceHook; @@ -46,29 +46,6 @@ typedef List::iterator FuncIter; /* :TODO: a global name max define for sourcepawn, should mirror compiler's sNAMEMAX */ #define FORWARDS_NAME_MAX 64 -struct ByrefInfo -{ - unsigned int cells; - cell_t *orig_addr; - int flags; - int sz_flags; -}; - -struct FwdParamInfo -{ - cell_t val; - ByrefInfo byref; - ParamType pushedas; -}; - -class SourceMod::IForwardFilter -{ -public: - virtual void Preprocess(IPluginFunction *fun, FwdParamInfo *params) - { - } -}; - class FuncIteratorGuard { bool triggered; diff --git a/core/logic/common_logic.cpp b/core/logic/common_logic.cpp index 8a076e0e..effed0ed 100644 --- a/core/logic/common_logic.cpp +++ b/core/logic/common_logic.cpp @@ -48,6 +48,7 @@ #include "NativeOwner.h" #include "HandleSys.h" #include "ExtensionSys.h" +#include "ForwardSys.h" sm_core_t smcore; IHandleSys *handlesys = &g_HandleSys; @@ -60,7 +61,7 @@ IVEngineServer *engine; IShareSys *sharesys = &g_ShareSys; IRootConsole *rootmenu; IPluginManager *pluginsys = g_PluginSys.GetOldAPI(); -IForwardManager *forwardsys; +IForwardManager *forwardsys = &g_Forwards; ITimerSystem *timersys; ServerGlobals serverGlobals; IPlayerManager *playerhelpers; @@ -124,6 +125,7 @@ static sm_logic_t logic = &g_ShareSys, &g_Extensions, &g_HandleSys, + &g_Forwards, NULL, -1.0f }; @@ -140,7 +142,6 @@ static void logic_init(const sm_core_t* core, sm_logic_t* _logic) engine = core->engine; g_pSM = core->sm; rootmenu = core->rootmenu; - forwardsys = core->forwardsys; timersys = core->timersys; playerhelpers = core->playerhelpers; adminsys = core->adminsys; diff --git a/core/logic/intercom.h b/core/logic/intercom.h index 25f15dd2..fa4fb86e 100644 --- a/core/logic/intercom.h +++ b/core/logic/intercom.h @@ -41,6 +41,7 @@ #include #include #include +#include using namespace SourceMod; using namespace SourcePawn; @@ -50,7 +51,7 @@ using namespace SourceHook; * 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 - 24) +#define SM_LOGIC_MAGIC (0x0F47C0DE - 25) #if defined SM_LOGIC class IVEngineServer @@ -229,7 +230,6 @@ struct sm_core_t IVEngineServer *engine; IFileSystem *filesystem; IRootConsole *rootmenu; - IForwardManager *forwardsys; ITimerSystem *timersys; IPlayerManager *playerhelpers; IAdminSystem *adminsys; @@ -298,6 +298,7 @@ struct sm_logic_t IShareSys *sharesys; IExtensionSys *extsys; IHandleSys *handlesys; + IForwardManager *forwardsys; IdentityToken_t *core_ident; float sentinel; }; diff --git a/core/logic_bridge.cpp b/core/logic_bridge.cpp index 802568bb..0b883080 100644 --- a/core/logic_bridge.cpp +++ b/core/logic_bridge.cpp @@ -39,7 +39,6 @@ #include "sm_stringutil.h" #include "Logger.h" #include "sm_srvcmds.h" -#include "ForwardSys.h" #include "TimerSys.h" #include "logic_bridge.h" #include "PlayerManager.h" @@ -85,6 +84,7 @@ IScriptManager *scripts; IShareSys *sharesys; IExtensionSys *extsys; IHandleSys *handlesys; +IForwardManager *forwardsys; class VEngineServer_Logic : public IVEngineServer_Logic { @@ -372,7 +372,6 @@ static sm_core_t core_bridge = reinterpret_cast(&logic_engine), reinterpret_cast(&logic_filesystem), &g_RootMenu, - &g_Forwards, &g_Timers, &g_Players, &g_Admins, @@ -453,6 +452,7 @@ void InitLogicBridge() extsys = logicore.extsys; g_pCoreIdent = logicore.core_ident; handlesys = logicore.handlesys; + forwardsys = logicore.forwardsys; } bool StartLogicBridge(char *error, size_t maxlength) diff --git a/core/logic_bridge.h b/core/logic_bridge.h index 0fd0cdfc..981d80ee 100644 --- a/core/logic_bridge.h +++ b/core/logic_bridge.h @@ -46,5 +46,6 @@ extern IScriptManager *scripts; extern IShareSys *sharesys; extern IExtensionSys *extsys; extern IHandleSys *handlesys; +extern IForwardManager *forwardsys; #endif /* _INCLUDE_SOURCEMOD_LOGIC_BRIDGE_H_ */ diff --git a/core/smn_console.cpp b/core/smn_console.cpp index e7c00c92..1ec22b2f 100644 --- a/core/smn_console.cpp +++ b/core/smn_console.cpp @@ -30,6 +30,7 @@ */ #include "sm_globals.h" +#include "sourcemod.h" #include "HalfLife2.h" #include "sourcemm_api.h" #include "ConVarManager.h" diff --git a/core/smn_core.cpp b/core/smn_core.cpp index 1a569fbf..b19900d8 100644 --- a/core/smn_core.cpp +++ b/core/smn_core.cpp @@ -37,7 +37,6 @@ #include "sourcemod.h" #include "LibrarySys.h" #include "TimerSys.h" -#include "ForwardSys.h" #include "Logger.h" #include #include "logic_bridge.h" @@ -67,7 +66,7 @@ public: g_PlIter = handlesys->CreateType("PluginIterator", this, 0, NULL, NULL, g_pCoreIdent, NULL); - g_OnLogAction = g_Forwards.CreateForward("OnLogAction", + g_OnLogAction = forwardsys->CreateForward("OnLogAction", ET_Hook, 5, NULL, @@ -84,7 +83,7 @@ public: } void OnSourceModShutdown() { - g_Forwards.ReleaseForward(g_OnLogAction); + forwardsys->ReleaseForward(g_OnLogAction); handlesys->RemoveType(g_PlIter, g_pCoreIdent); } } g_CoreNativeHelpers; diff --git a/core/sourcemod.cpp b/core/sourcemod.cpp index caa5d2aa..6b393dfb 100644 --- a/core/sourcemod.cpp +++ b/core/sourcemod.cpp @@ -39,7 +39,6 @@ #include "AdminCache.h" #include "sm_stringutil.h" #include "PlayerManager.h" -#include "ForwardSys.h" #include "TimerSys.h" #include #include "frame_hooks.h" @@ -374,7 +373,7 @@ bool SourceModBase::LevelInit(char const *pMapName, char const *pMapEntities, ch if (!g_pOnMapEnd) { - g_pOnMapEnd = g_Forwards.CreateForward("OnMapEnd", ET_Ignore, 0, NULL); + g_pOnMapEnd = forwardsys->CreateForward("OnMapEnd", ET_Ignore, 0, NULL); } g_LevelEndBarrier = true; @@ -517,7 +516,7 @@ void SourceModBase::ShutdownServices() extsys->Shutdown(); if (g_pOnMapEnd) - g_Forwards.ReleaseForward(g_pOnMapEnd); + forwardsys->ReleaseForward(g_pOnMapEnd); /* Notify! */ SMGlobalClass *pBase = SMGlobalClass::head; diff --git a/public/IForwardSys.h b/public/IForwardSys.h index a9a8c935..577c1ea7 100644 --- a/public/IForwardSys.h +++ b/public/IForwardSys.h @@ -81,9 +81,52 @@ namespace SourceMod ET_Hook = 3, /**< Acts as a hook with the ResultTypes above, mid-Stops allowed, returns highest */ ET_LowEvent = 4, /**< Same as ET_Event except that it returns the lowest value */ }; + + #define SP_PARAMTYPE_ANY 0 + #define SP_PARAMFLAG_BYREF (1<<0) + #define SP_PARAMTYPE_CELL (1<<1) + #define SP_PARAMTYPE_FLOAT (2<<1) + #define SP_PARAMTYPE_STRING (3<<1)|SP_PARAMFLAG_BYREF + #define SP_PARAMTYPE_ARRAY (4<<1)|SP_PARAMFLAG_BYREF + #define SP_PARAMTYPE_VARARG (5<<1) - class IForward; - class IForwardFilter; + /** + * @brief Describes the various ways to pass parameters to plugins. + */ + enum ParamType + { + Param_Any = SP_PARAMTYPE_ANY, /**< Any data type can be pushed */ + Param_Cell = SP_PARAMTYPE_CELL, /**< Only basic cells can be pushed */ + Param_Float = SP_PARAMTYPE_FLOAT, /**< Only floats can be pushed */ + Param_String = SP_PARAMTYPE_STRING, /**< Only strings can be pushed */ + Param_Array = SP_PARAMTYPE_ARRAY, /**< Only arrays can be pushed */ + Param_VarArgs = SP_PARAMTYPE_VARARG, /**< Same as "..." in plugins, anything can be pushed, but it will always be byref */ + Param_CellByRef = SP_PARAMTYPE_CELL|SP_PARAMFLAG_BYREF, /**< Only a cell by reference can be pushed */ + Param_FloatByRef = SP_PARAMTYPE_FLOAT|SP_PARAMFLAG_BYREF, /**< Only a float by reference can be pushed */ + }; + + struct ByrefInfo + { + unsigned int cells; + cell_t *orig_addr; + int flags; + int sz_flags; + }; + + struct FwdParamInfo + { + cell_t val; + ByrefInfo byref; + ParamType pushedas; + }; + + class IForwardFilter + { + public: + virtual void Preprocess(IPluginFunction *fun, FwdParamInfo *params) + { + } + }; /** * @brief Unmanaged Forward, abstracts calling multiple functions as "forwards," or collections of functions. @@ -197,29 +240,6 @@ namespace SourceMod */ virtual bool RemoveFunction(IPluginContext *ctx, funcid_t index) =0; }; - - #define SP_PARAMTYPE_ANY 0 - #define SP_PARAMFLAG_BYREF (1<<0) - #define SP_PARAMTYPE_CELL (1<<1) - #define SP_PARAMTYPE_FLOAT (2<<1) - #define SP_PARAMTYPE_STRING (3<<1)|SP_PARAMFLAG_BYREF - #define SP_PARAMTYPE_ARRAY (4<<1)|SP_PARAMFLAG_BYREF - #define SP_PARAMTYPE_VARARG (5<<1) - - /** - * @brief Describes the various ways to pass parameters to plugins. - */ - enum ParamType - { - Param_Any = SP_PARAMTYPE_ANY, /**< Any data type can be pushed */ - Param_Cell = SP_PARAMTYPE_CELL, /**< Only basic cells can be pushed */ - Param_Float = SP_PARAMTYPE_FLOAT, /**< Only floats can be pushed */ - Param_String = SP_PARAMTYPE_STRING, /**< Only strings can be pushed */ - Param_Array = SP_PARAMTYPE_ARRAY, /**< Only arrays can be pushed */ - Param_VarArgs = SP_PARAMTYPE_VARARG, /**< Same as "..." in plugins, anything can be pushed, but it will always be byref */ - Param_CellByRef = SP_PARAMTYPE_CELL|SP_PARAMFLAG_BYREF, /**< Only a cell by reference can be pushed */ - Param_FloatByRef = SP_PARAMTYPE_FLOAT|SP_PARAMFLAG_BYREF, /**< Only a float by reference can be pushed */ - }; /** * @brief Provides functions for creating/destroying managed and unmanaged forwards.