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
This commit is contained in:
Nicholas Hastings 2013-10-09 08:43:08 -04:00
parent 1d1b5d1c6d
commit 1ba6b2653a
22 changed files with 127 additions and 133 deletions

View File

@ -61,7 +61,6 @@ for i in SM.sdkInfo:
'logic_bridge.cpp', 'logic_bridge.cpp',
'smn_entities.cpp', 'smn_entities.cpp',
'sm_stringutil.cpp', 'sm_stringutil.cpp',
'ForwardSys.cpp',
'MenuVoting.cpp', 'MenuVoting.cpp',
'smn_events.cpp', 'smn_events.cpp',
'smn_menus.cpp', 'smn_menus.cpp',

View File

@ -33,7 +33,6 @@
#include <assert.h> #include <assert.h>
#include <ITextParsers.h> #include <ITextParsers.h>
#include "AdminCache.h" #include "AdminCache.h"
#include "ForwardSys.h"
#include "PlayerManager.h" #include "PlayerManager.h"
#include "ConCmdManager.h" #include "ConCmdManager.h"
#include "Logger.h" #include "Logger.h"
@ -276,7 +275,7 @@ void AdminCache::OnSourceModStartup(bool late)
void AdminCache::OnSourceModAllInitialized() 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); sharesys->AddInterface(NULL, this);
} }
@ -303,7 +302,7 @@ void AdminCache::OnSourceModLevelChange(const char *mapName)
void AdminCache::OnSourceModShutdown() void AdminCache::OnSourceModShutdown()
{ {
g_Forwards.ReleaseForward(m_pCacheFwd); forwardsys->ReleaseForward(m_pCacheFwd);
m_pCacheFwd = NULL; m_pCacheFwd = NULL;
} }

View File

@ -108,10 +108,10 @@ ConfigResult ChatTriggers::OnSourceModConfigChanged(const char *key,
void ChatTriggers::OnSourceModAllInitialized() void ChatTriggers::OnSourceModAllInitialized()
{ {
m_pShouldFloodBlock = g_Forwards.CreateForward("OnClientFloodCheck", ET_Event, 1, NULL, Param_Cell); m_pShouldFloodBlock = forwardsys->CreateForward("OnClientFloodCheck", ET_Event, 1, NULL, Param_Cell);
m_pDidFloodBlock = g_Forwards.CreateForward("OnClientFloodResult", ET_Event, 2, NULL, Param_Cell, Param_Cell); m_pDidFloodBlock = forwardsys->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 = forwardsys->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_pOnClientSayCmd_Post = forwardsys->CreateForward("OnClientSayCommand_Post", ET_Ignore, 3, NULL, Param_Cell, Param_String, Param_String);
} }
void ChatTriggers::OnSourceModAllInitialized_Post() void ChatTriggers::OnSourceModAllInitialized_Post()
@ -186,10 +186,10 @@ void ChatTriggers::OnSourceModShutdown()
} }
#endif #endif
g_Forwards.ReleaseForward(m_pShouldFloodBlock); forwardsys->ReleaseForward(m_pShouldFloodBlock);
g_Forwards.ReleaseForward(m_pDidFloodBlock); forwardsys->ReleaseForward(m_pDidFloodBlock);
g_Forwards.ReleaseForward(m_pOnClientSayCmd); forwardsys->ReleaseForward(m_pOnClientSayCmd);
g_Forwards.ReleaseForward(m_pOnClientSayCmd_Post); forwardsys->ReleaseForward(m_pOnClientSayCmd_Post);
} }
#if SOURCE_ENGINE == SE_DOTA #if SOURCE_ENGINE == SE_DOTA

View File

@ -34,7 +34,7 @@
#include "sm_globals.h" #include "sm_globals.h"
#include "sourcemm_api.h" #include "sourcemm_api.h"
#include "ForwardSys.h" #include <IForwardSys.h>
#include <sh_list.h> #include <sh_list.h>
#include <sh_string.h> #include <sh_string.h>
#include <IRootConsoleMenu.h> #include <IRootConsoleMenu.h>

View File

@ -29,7 +29,6 @@
#include "ConVarManager.h" #include "ConVarManager.h"
#include "HalfLife2.h" #include "HalfLife2.h"
#include "ForwardSys.h"
#include "sm_srvcmds.h" #include "sm_srvcmds.h"
#include "sm_stringutil.h" #include "sm_stringutil.h"
#include <sh_vector.h> #include <sh_vector.h>
@ -151,7 +150,7 @@ void ConVarManager::OnSourceModShutdown()
handlesys->FreeHandle(pInfo->handle, &sec); handlesys->FreeHandle(pInfo->handle, &sec);
if (pInfo->pChangeForward != NULL) if (pInfo->pChangeForward != NULL)
{ {
g_Forwards.ReleaseForward(pInfo->pChangeForward); forwardsys->ReleaseForward(pInfo->pChangeForward);
} }
if (pInfo->sourceMod) if (pInfo->sourceMod)
{ {
@ -558,7 +557,7 @@ void ConVarManager::HookConVarChange(ConVar *pConVar, IPluginFunction *pFunction
/* If forward does not exist, create it */ /* If forward does not exist, create it */
if (!pForward) if (!pForward)
{ {
pForward = g_Forwards.CreateForwardEx(NULL, ET_Ignore, 3, CONVARCHANGE_PARAMS); pForward = forwardsys->CreateForwardEx(NULL, ET_Ignore, 3, CONVARCHANGE_PARAMS);
pInfo->pChangeForward = pForward; pInfo->pChangeForward = pForward;
} }
@ -598,7 +597,7 @@ void ConVarManager::UnhookConVarChange(ConVar *pConVar, IPluginFunction *pFuncti
!ConVarReentrancyGuard::IsCvarInChain(pConVar)) !ConVarReentrancyGuard::IsCvarInChain(pConVar))
{ {
/* Free this forward */ /* Free this forward */
g_Forwards.ReleaseForward(pForward); forwardsys->ReleaseForward(pForward);
pInfo->pChangeForward = NULL; pInfo->pChangeForward = NULL;
} }
} }

View File

@ -579,7 +579,7 @@ ConsoleDetours::ConsoleDetours() : status(FeatureStatus_Unknown)
void ConsoleDetours::OnSourceModAllInitialized() 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); Param_String, Param_Cell);
sharesys->AddCapabilityProvider(NULL, this, FEATURECAP_COMMANDLISTENER); sharesys->AddCapabilityProvider(NULL, this, FEATURECAP_COMMANDLISTENER);
} }
@ -590,10 +590,10 @@ void ConsoleDetours::OnSourceModShutdown()
!iter.empty(); !iter.empty();
iter.next()) iter.next())
{ {
g_Forwards.ReleaseForward(iter->value); forwardsys->ReleaseForward(iter->value);
} }
g_Forwards.ReleaseForward(m_pForward); forwardsys->ReleaseForward(m_pForward);
s_GenericHooker.Disable(); s_GenericHooker.Disable();
} }
@ -626,7 +626,7 @@ bool ConsoleDetours::AddListener(IPluginFunction *fun, const char *command)
IChangeableForward *forward; IChangeableForward *forward;
if (!m_Listeners.retrieve(str, &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); Param_String, Param_Cell);
m_Listeners.insert(str, forward); m_Listeners.insert(str, forward);
} }

View File

@ -33,7 +33,7 @@
#include "sm_globals.h" #include "sm_globals.h"
#include "sourcemm_api.h" #include "sourcemm_api.h"
#include "ForwardSys.h" #include <IForwardSys.h>
#include <sm_stringhashmap.h> #include <sm_stringhashmap.h>
class ConsoleDetours : class ConsoleDetours :

View File

@ -38,7 +38,6 @@
#include "sm_stringutil.h" #include "sm_stringutil.h"
#include "LibrarySys.h" #include "LibrarySys.h"
#include "Logger.h" #include "Logger.h"
#include "ForwardSys.h"
#include "frame_hooks.h" #include "frame_hooks.h"
#include "logic_bridge.h" #include "logic_bridge.h"
@ -119,9 +118,9 @@ void CheckAndFinalizeConfigs()
void CoreConfig::OnSourceModAllInitialized() void CoreConfig::OnSourceModAllInitialized()
{ {
g_RootMenu.AddRootConsoleCommand("config", "Set core configuration options", this); g_RootMenu.AddRootConsoleCommand("config", "Set core configuration options", this);
g_pOnServerCfg = g_Forwards.CreateForward("OnServerCfg", ET_Ignore, 0, NULL); g_pOnServerCfg = forwardsys->CreateForward("OnServerCfg", ET_Ignore, 0, NULL);
g_pOnConfigsExecuted = g_Forwards.CreateForward("OnConfigsExecuted", ET_Ignore, 0, NULL); g_pOnConfigsExecuted = forwardsys->CreateForward("OnConfigsExecuted", ET_Ignore, 0, NULL);
g_pOnAutoConfigsBuffered = g_Forwards.CreateForward("OnAutoConfigsBuffered", ET_Ignore, 0, NULL); g_pOnAutoConfigsBuffered = forwardsys->CreateForward("OnAutoConfigsBuffered", ET_Ignore, 0, NULL);
} }
CoreConfig::CoreConfig() CoreConfig::CoreConfig()
@ -135,9 +134,9 @@ CoreConfig::~CoreConfig()
void CoreConfig::OnSourceModShutdown() void CoreConfig::OnSourceModShutdown()
{ {
g_RootMenu.RemoveRootConsoleCommand("config", this); g_RootMenu.RemoveRootConsoleCommand("config", this);
g_Forwards.ReleaseForward(g_pOnServerCfg); forwardsys->ReleaseForward(g_pOnServerCfg);
g_Forwards.ReleaseForward(g_pOnConfigsExecuted); forwardsys->ReleaseForward(g_pOnConfigsExecuted);
g_Forwards.ReleaseForward(g_pOnAutoConfigsBuffered); forwardsys->ReleaseForward(g_pOnAutoConfigsBuffered);
if (g_pExecPtr != NULL) if (g_pExecPtr != NULL)
{ {

View File

@ -30,7 +30,6 @@
*/ */
#include "EventManager.h" #include "EventManager.h"
#include "ForwardSys.h"
#include "sm_stringutil.h" #include "sm_stringutil.h"
#include "logic_bridge.h" #include "logic_bridge.h"
@ -133,12 +132,12 @@ void EventManager::OnPluginUnloaded(IPlugin *plugin)
{ {
if (pHook->pPreHook) if (pHook->pPreHook)
{ {
g_Forwards.ReleaseForward(pHook->pPreHook); forwardsys->ReleaseForward(pHook->pPreHook);
} }
if (pHook->pPostHook) if (pHook->pPostHook)
{ {
g_Forwards.ReleaseForward(pHook->pPostHook); forwardsys->ReleaseForward(pHook->pPostHook);
} }
delete pHook; delete pHook;
@ -197,12 +196,12 @@ EventHookError EventManager::HookEvent(const char *name, IPluginFunction *pFunct
if (mode == EventHookMode_Pre) if (mode == EventHookMode_Pre)
{ {
/* Create forward for a pre hook */ /* 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 */ /* Add to forward list */
pHook->pPreHook->AddFunction(pFunction); pHook->pPreHook->AddFunction(pFunction);
} else { } else {
/* Create forward for a post hook */ /* 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? */ /* Should we copy data from a pre hook to the post hook? */
pHook->postCopy = (mode == EventHookMode_Post); pHook->postCopy = (mode == EventHookMode_Post);
/* Add to forward list */ /* Add to forward list */
@ -229,7 +228,7 @@ EventHookError EventManager::HookEvent(const char *name, IPluginFunction *pFunct
/* Create pre hook forward if necessary */ /* Create pre hook forward if necessary */
if (!pHook->pPreHook) 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 */ /* Add plugin function to forward list */
@ -238,7 +237,7 @@ EventHookError EventManager::HookEvent(const char *name, IPluginFunction *pFunct
/* Create post hook forward if necessary */ /* Create post hook forward if necessary */
if (!pHook->pPostHook) 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 */ /* 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 forward's list contains 0 functions now, free it */
if ((*pEventForward)->GetFunctionCount() == 0) if ((*pEventForward)->GetFunctionCount() == 0)
{ {
g_Forwards.ReleaseForward(*pEventForward); forwardsys->ReleaseForward(*pEventForward);
*pEventForward = NULL; *pEventForward = NULL;
} }

View File

@ -30,7 +30,6 @@
*/ */
#include "PlayerManager.h" #include "PlayerManager.h"
#include "ForwardSys.h"
#include "AdminCache.h" #include "AdminCache.h"
#include "ConCmdManager.h" #include "ConCmdManager.h"
#include "MenuStyle_Valve.h" #include "MenuStyle_Valve.h"
@ -159,20 +158,20 @@ void PlayerManager::OnSourceModAllInitialized()
ParamType p1[] = {Param_Cell, Param_String, Param_Cell}; ParamType p1[] = {Param_Cell, Param_String, Param_Cell};
ParamType p2[] = {Param_Cell}; ParamType p2[] = {Param_Cell};
m_clconnect = g_Forwards.CreateForward("OnClientConnect", ET_LowEvent, 3, p1); m_clconnect = forwardsys->CreateForward("OnClientConnect", ET_LowEvent, 3, p1);
m_clconnect_post = g_Forwards.CreateForward("OnClientConnected", ET_Ignore, 1, p2); m_clconnect_post = forwardsys->CreateForward("OnClientConnected", ET_Ignore, 1, p2);
m_clputinserver = g_Forwards.CreateForward("OnClientPutInServer", ET_Ignore, 1, p2); m_clputinserver = forwardsys->CreateForward("OnClientPutInServer", ET_Ignore, 1, p2);
m_cldisconnect = g_Forwards.CreateForward("OnClientDisconnect", ET_Ignore, 1, p2); m_cldisconnect = forwardsys->CreateForward("OnClientDisconnect", ET_Ignore, 1, p2);
m_cldisconnect_post = g_Forwards.CreateForward("OnClientDisconnect_Post", ET_Ignore, 1, p2); m_cldisconnect_post = forwardsys->CreateForward("OnClientDisconnect_Post", ET_Ignore, 1, p2);
m_clcommand = g_Forwards.CreateForward("OnClientCommand", ET_Hook, 2, NULL, Param_Cell, Param_Cell); m_clcommand = forwardsys->CreateForward("OnClientCommand", ET_Hook, 2, NULL, Param_Cell, Param_Cell);
m_clinfochanged = g_Forwards.CreateForward("OnClientSettingsChanged", ET_Ignore, 1, p2); m_clinfochanged = forwardsys->CreateForward("OnClientSettingsChanged", ET_Ignore, 1, p2);
m_clauth = g_Forwards.CreateForward("OnClientAuthorized", ET_Ignore, 2, NULL, Param_Cell, Param_String); m_clauth = forwardsys->CreateForward("OnClientAuthorized", ET_Ignore, 2, NULL, Param_Cell, Param_String);
m_onActivate = g_Forwards.CreateForward("OnServerLoad", ET_Ignore, 0, NULL); m_onActivate = forwardsys->CreateForward("OnServerLoad", ET_Ignore, 0, NULL);
m_onActivate2 = g_Forwards.CreateForward("OnMapStart", ET_Ignore, 0, NULL); m_onActivate2 = forwardsys->CreateForward("OnMapStart", ET_Ignore, 0, NULL);
PreAdminCheck = g_Forwards.CreateForward("OnClientPreAdminCheck", ET_Event, 1, p1); PreAdminCheck = forwardsys->CreateForward("OnClientPreAdminCheck", ET_Event, 1, p1);
PostAdminCheck = g_Forwards.CreateForward("OnClientPostAdminCheck", ET_Ignore, 1, p1); PostAdminCheck = forwardsys->CreateForward("OnClientPostAdminCheck", ET_Ignore, 1, p1);
PostAdminFilter = g_Forwards.CreateForward("OnClientPostAdminFilter", ET_Ignore, 1, p1); PostAdminFilter = forwardsys->CreateForward("OnClientPostAdminFilter", ET_Ignore, 1, p1);
m_bIsListenServer = !engine->IsDedicatedServer(); m_bIsListenServer = !engine->IsDedicatedServer();
m_ListenClient = 0; m_ListenClient = 0;
@ -197,20 +196,20 @@ void PlayerManager::OnSourceModShutdown()
SH_REMOVE_HOOK(IServerGameDLL, ServerActivate, gamedll, SH_MEMBER(this, &PlayerManager::OnServerActivate), true); SH_REMOVE_HOOK(IServerGameDLL, ServerActivate, gamedll, SH_MEMBER(this, &PlayerManager::OnServerActivate), true);
/* Release forwards */ /* Release forwards */
g_Forwards.ReleaseForward(m_clconnect); forwardsys->ReleaseForward(m_clconnect);
g_Forwards.ReleaseForward(m_clconnect_post); forwardsys->ReleaseForward(m_clconnect_post);
g_Forwards.ReleaseForward(m_clputinserver); forwardsys->ReleaseForward(m_clputinserver);
g_Forwards.ReleaseForward(m_cldisconnect); forwardsys->ReleaseForward(m_cldisconnect);
g_Forwards.ReleaseForward(m_cldisconnect_post); forwardsys->ReleaseForward(m_cldisconnect_post);
g_Forwards.ReleaseForward(m_clcommand); forwardsys->ReleaseForward(m_clcommand);
g_Forwards.ReleaseForward(m_clinfochanged); forwardsys->ReleaseForward(m_clinfochanged);
g_Forwards.ReleaseForward(m_clauth); forwardsys->ReleaseForward(m_clauth);
g_Forwards.ReleaseForward(m_onActivate); forwardsys->ReleaseForward(m_onActivate);
g_Forwards.ReleaseForward(m_onActivate2); forwardsys->ReleaseForward(m_onActivate2);
g_Forwards.ReleaseForward(PreAdminCheck); forwardsys->ReleaseForward(PreAdminCheck);
g_Forwards.ReleaseForward(PostAdminCheck); forwardsys->ReleaseForward(PostAdminCheck);
g_Forwards.ReleaseForward(PostAdminFilter); forwardsys->ReleaseForward(PostAdminFilter);
delete [] m_Players; delete [] m_Players;

View File

@ -31,7 +31,6 @@
#include <time.h> #include <time.h>
#include "TimerSys.h" #include "TimerSys.h"
#include "ForwardSys.h"
#include "sourcemm_api.h" #include "sourcemm_api.h"
#include "frame_hooks.h" #include "frame_hooks.h"
#include "ConVarManager.h" #include "ConVarManager.h"
@ -182,8 +181,8 @@ TimerSystem::~TimerSystem()
void TimerSystem::OnSourceModAllInitialized() void TimerSystem::OnSourceModAllInitialized()
{ {
sharesys->AddInterface(NULL, this); sharesys->AddInterface(NULL, this);
m_pOnGameFrame = g_Forwards.CreateForward("OnGameFrame", ET_Ignore, 0, NULL); m_pOnGameFrame = forwardsys->CreateForward("OnGameFrame", ET_Ignore, 0, NULL);
m_pOnMapTimeLeftChanged = g_Forwards.CreateForward("OnMapTimeLeftChanged", ET_Ignore, 0, NULL); m_pOnMapTimeLeftChanged = forwardsys->CreateForward("OnMapTimeLeftChanged", ET_Ignore, 0, NULL);
} }
void TimerSystem::OnSourceModGameInitialized() void TimerSystem::OnSourceModGameInitialized()
@ -199,8 +198,8 @@ void TimerSystem::OnSourceModGameInitialized()
void TimerSystem::OnSourceModShutdown() void TimerSystem::OnSourceModShutdown()
{ {
SetMapTimer(NULL); SetMapTimer(NULL);
g_Forwards.ReleaseForward(m_pOnGameFrame); forwardsys->ReleaseForward(m_pOnGameFrame);
g_Forwards.ReleaseForward(m_pOnMapTimeLeftChanged); forwardsys->ReleaseForward(m_pOnMapTimeLeftChanged);
} }
void TimerSystem::OnSourceModLevelEnd() void TimerSystem::OnSourceModLevelEnd()

View File

@ -63,6 +63,7 @@ files = [
'DebugReporter.cpp', 'DebugReporter.cpp',
'Database.cpp', 'Database.cpp',
'smn_database.cpp', 'smn_database.cpp',
'ForwardSys.cpp',
] ]
if AMBuild.target['platform'] == 'windows': if AMBuild.target['platform'] == 'windows':
files.append('thread/WinThreads.cpp') files.append('thread/WinThreads.cpp')

View File

@ -33,7 +33,8 @@
#include <stdarg.h> #include <stdarg.h>
#include <string.h> #include <string.h>
#include "ForwardSys.h" #include "ForwardSys.h"
#include "logic_bridge.h" #include "DebugReporter.h"
#include "common_logic.h"
CForwardManager g_Forwards; CForwardManager g_Forwards;
@ -370,7 +371,7 @@ int CForward::Execute(cell_t *result, IForwardFilter *filter)
if (err != SP_ERROR_NONE) if (err != SP_ERROR_NONE)
{ {
logicore.GenerateError(func->GetParentContext(), g_DbgReporter.GenerateError(func->GetParentContext(),
func->GetFunctionID(), func->GetFunctionID(),
err, err,
"Failed to push parameter while executing forward"); "Failed to push parameter while executing forward");

View File

@ -34,10 +34,10 @@
#include <IForwardSys.h> #include <IForwardSys.h>
#include <IPluginSys.h> #include <IPluginSys.h>
#include "sm_globals.h" #include "common_logic.h"
#include <sh_list.h> #include <sh_list.h>
#include <sh_stack.h> #include <sh_stack.h>
#include "sourcemod.h" #include "ISourceMod.h"
using namespace SourceHook; using namespace SourceHook;
@ -46,29 +46,6 @@ typedef List<IPluginFunction *>::iterator FuncIter;
/* :TODO: a global name max define for sourcepawn, should mirror compiler's sNAMEMAX */ /* :TODO: a global name max define for sourcepawn, should mirror compiler's sNAMEMAX */
#define FORWARDS_NAME_MAX 64 #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 class FuncIteratorGuard
{ {
bool triggered; bool triggered;

View File

@ -48,6 +48,7 @@
#include "NativeOwner.h" #include "NativeOwner.h"
#include "HandleSys.h" #include "HandleSys.h"
#include "ExtensionSys.h" #include "ExtensionSys.h"
#include "ForwardSys.h"
sm_core_t smcore; sm_core_t smcore;
IHandleSys *handlesys = &g_HandleSys; IHandleSys *handlesys = &g_HandleSys;
@ -60,7 +61,7 @@ IVEngineServer *engine;
IShareSys *sharesys = &g_ShareSys; IShareSys *sharesys = &g_ShareSys;
IRootConsole *rootmenu; IRootConsole *rootmenu;
IPluginManager *pluginsys = g_PluginSys.GetOldAPI(); IPluginManager *pluginsys = g_PluginSys.GetOldAPI();
IForwardManager *forwardsys; IForwardManager *forwardsys = &g_Forwards;
ITimerSystem *timersys; ITimerSystem *timersys;
ServerGlobals serverGlobals; ServerGlobals serverGlobals;
IPlayerManager *playerhelpers; IPlayerManager *playerhelpers;
@ -124,6 +125,7 @@ static sm_logic_t logic =
&g_ShareSys, &g_ShareSys,
&g_Extensions, &g_Extensions,
&g_HandleSys, &g_HandleSys,
&g_Forwards,
NULL, NULL,
-1.0f -1.0f
}; };
@ -140,7 +142,6 @@ static void logic_init(const sm_core_t* core, sm_logic_t* _logic)
engine = core->engine; engine = core->engine;
g_pSM = core->sm; g_pSM = core->sm;
rootmenu = core->rootmenu; rootmenu = core->rootmenu;
forwardsys = core->forwardsys;
timersys = core->timersys; timersys = core->timersys;
playerhelpers = core->playerhelpers; playerhelpers = core->playerhelpers;
adminsys = core->adminsys; adminsys = core->adminsys;

View File

@ -41,6 +41,7 @@
#include <sp_vm_api.h> #include <sp_vm_api.h>
#include <sh_vector.h> #include <sh_vector.h>
#include <IExtensionSys.h> #include <IExtensionSys.h>
#include <IForwardSys.h>
using namespace SourceMod; using namespace SourceMod;
using namespace SourcePawn; using namespace SourcePawn;
@ -50,7 +51,7 @@ using namespace SourceHook;
* Add 1 to the RHS of this expression to bump the intercom file * Add 1 to the RHS of this expression to bump the intercom file
* This is to prevent mismatching core/logic binaries * This is to prevent mismatching core/logic binaries
*/ */
#define SM_LOGIC_MAGIC (0x0F47C0DE - 24) #define SM_LOGIC_MAGIC (0x0F47C0DE - 25)
#if defined SM_LOGIC #if defined SM_LOGIC
class IVEngineServer class IVEngineServer
@ -229,7 +230,6 @@ struct sm_core_t
IVEngineServer *engine; IVEngineServer *engine;
IFileSystem *filesystem; IFileSystem *filesystem;
IRootConsole *rootmenu; IRootConsole *rootmenu;
IForwardManager *forwardsys;
ITimerSystem *timersys; ITimerSystem *timersys;
IPlayerManager *playerhelpers; IPlayerManager *playerhelpers;
IAdminSystem *adminsys; IAdminSystem *adminsys;
@ -298,6 +298,7 @@ struct sm_logic_t
IShareSys *sharesys; IShareSys *sharesys;
IExtensionSys *extsys; IExtensionSys *extsys;
IHandleSys *handlesys; IHandleSys *handlesys;
IForwardManager *forwardsys;
IdentityToken_t *core_ident; IdentityToken_t *core_ident;
float sentinel; float sentinel;
}; };

View File

@ -39,7 +39,6 @@
#include "sm_stringutil.h" #include "sm_stringutil.h"
#include "Logger.h" #include "Logger.h"
#include "sm_srvcmds.h" #include "sm_srvcmds.h"
#include "ForwardSys.h"
#include "TimerSys.h" #include "TimerSys.h"
#include "logic_bridge.h" #include "logic_bridge.h"
#include "PlayerManager.h" #include "PlayerManager.h"
@ -85,6 +84,7 @@ IScriptManager *scripts;
IShareSys *sharesys; IShareSys *sharesys;
IExtensionSys *extsys; IExtensionSys *extsys;
IHandleSys *handlesys; IHandleSys *handlesys;
IForwardManager *forwardsys;
class VEngineServer_Logic : public IVEngineServer_Logic class VEngineServer_Logic : public IVEngineServer_Logic
{ {
@ -372,7 +372,6 @@ static sm_core_t core_bridge =
reinterpret_cast<IVEngineServer*>(&logic_engine), reinterpret_cast<IVEngineServer*>(&logic_engine),
reinterpret_cast<IFileSystem*>(&logic_filesystem), reinterpret_cast<IFileSystem*>(&logic_filesystem),
&g_RootMenu, &g_RootMenu,
&g_Forwards,
&g_Timers, &g_Timers,
&g_Players, &g_Players,
&g_Admins, &g_Admins,
@ -453,6 +452,7 @@ void InitLogicBridge()
extsys = logicore.extsys; extsys = logicore.extsys;
g_pCoreIdent = logicore.core_ident; g_pCoreIdent = logicore.core_ident;
handlesys = logicore.handlesys; handlesys = logicore.handlesys;
forwardsys = logicore.forwardsys;
} }
bool StartLogicBridge(char *error, size_t maxlength) bool StartLogicBridge(char *error, size_t maxlength)

View File

@ -46,5 +46,6 @@ extern IScriptManager *scripts;
extern IShareSys *sharesys; extern IShareSys *sharesys;
extern IExtensionSys *extsys; extern IExtensionSys *extsys;
extern IHandleSys *handlesys; extern IHandleSys *handlesys;
extern IForwardManager *forwardsys;
#endif /* _INCLUDE_SOURCEMOD_LOGIC_BRIDGE_H_ */ #endif /* _INCLUDE_SOURCEMOD_LOGIC_BRIDGE_H_ */

View File

@ -30,6 +30,7 @@
*/ */
#include "sm_globals.h" #include "sm_globals.h"
#include "sourcemod.h"
#include "HalfLife2.h" #include "HalfLife2.h"
#include "sourcemm_api.h" #include "sourcemm_api.h"
#include "ConVarManager.h" #include "ConVarManager.h"

View File

@ -37,7 +37,6 @@
#include "sourcemod.h" #include "sourcemod.h"
#include "LibrarySys.h" #include "LibrarySys.h"
#include "TimerSys.h" #include "TimerSys.h"
#include "ForwardSys.h"
#include "Logger.h" #include "Logger.h"
#include <sh_memory.h> #include <sh_memory.h>
#include "logic_bridge.h" #include "logic_bridge.h"
@ -67,7 +66,7 @@ public:
g_PlIter = handlesys->CreateType("PluginIterator", this, 0, NULL, NULL, g_pCoreIdent, NULL); 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, ET_Hook,
5, 5,
NULL, NULL,
@ -84,7 +83,7 @@ public:
} }
void OnSourceModShutdown() void OnSourceModShutdown()
{ {
g_Forwards.ReleaseForward(g_OnLogAction); forwardsys->ReleaseForward(g_OnLogAction);
handlesys->RemoveType(g_PlIter, g_pCoreIdent); handlesys->RemoveType(g_PlIter, g_pCoreIdent);
} }
} g_CoreNativeHelpers; } g_CoreNativeHelpers;

View File

@ -39,7 +39,6 @@
#include "AdminCache.h" #include "AdminCache.h"
#include "sm_stringutil.h" #include "sm_stringutil.h"
#include "PlayerManager.h" #include "PlayerManager.h"
#include "ForwardSys.h"
#include "TimerSys.h" #include "TimerSys.h"
#include <IGameConfigs.h> #include <IGameConfigs.h>
#include "frame_hooks.h" #include "frame_hooks.h"
@ -374,7 +373,7 @@ bool SourceModBase::LevelInit(char const *pMapName, char const *pMapEntities, ch
if (!g_pOnMapEnd) 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; g_LevelEndBarrier = true;
@ -517,7 +516,7 @@ void SourceModBase::ShutdownServices()
extsys->Shutdown(); extsys->Shutdown();
if (g_pOnMapEnd) if (g_pOnMapEnd)
g_Forwards.ReleaseForward(g_pOnMapEnd); forwardsys->ReleaseForward(g_pOnMapEnd);
/* Notify! */ /* Notify! */
SMGlobalClass *pBase = SMGlobalClass::head; SMGlobalClass *pBase = SMGlobalClass::head;

View File

@ -81,9 +81,52 @@ namespace SourceMod
ET_Hook = 3, /**< Acts as a hook with the ResultTypes above, mid-Stops allowed, returns highest */ 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 */ 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. * @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; 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. * @brief Provides functions for creating/destroying managed and unmanaged forwards.