diff --git a/core/Makefile b/core/Makefile
index 7226cf2c..25c5b9c9 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -22,7 +22,7 @@ OBJECTS = AdminCache.cpp CDataPack.cpp ConCmdManager.cpp ConVarManager.cpp CoreC
NativeOwner.cpp logic_bridge.cpp
OBJECTS += smn_admin.cpp smn_bitbuffer.cpp smn_console.cpp smn_core.cpp \
smn_datapacks.cpp smn_entities.cpp smn_events.cpp smn_fakenatives.cpp \
- smn_filesystem.cpp smn_functions.cpp smn_gameconfigs.cpp smn_halflife.cpp \
+ smn_filesystem.cpp smn_gameconfigs.cpp smn_halflife.cpp \
smn_handles.cpp smn_keyvalues.cpp smn_banning.cpp \
smn_lang.cpp smn_player.cpp smn_string.cpp smn_timers.cpp \
smn_usermsgs.cpp smn_menus.cpp smn_database.cpp smn_vector.cpp \
diff --git a/core/logic/Makefile b/core/logic/Makefile
index 8ef9c957..2808e72e 100644
--- a/core/logic/Makefile
+++ b/core/logic/Makefile
@@ -24,7 +24,8 @@ OBJECTS = \
TextParsers.cpp \
smn_textparse.cpp \
smn_adt_trie.cpp \
- Profiler.cpp
+ Profiler.cpp \
+ smn_functions.cpp
##############################################
### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
diff --git a/core/logic/common_logic.cpp b/core/logic/common_logic.cpp
index 3049a782..e7ca457d 100644
--- a/core/logic/common_logic.cpp
+++ b/core/logic/common_logic.cpp
@@ -47,6 +47,7 @@ IVEngineServer *engine;
IShareSys *sharesys;
IRootConsole *rootmenu;
IPluginManager *pluginsys;
+IForwardManager *forwardsys;
static sm_logic_t logic =
{
@@ -69,6 +70,7 @@ static void logic_init(const sm_core_t* core, sm_logic_t* _logic)
sharesys = core->sharesys;
rootmenu = core->rootmenu;
pluginsys = core->pluginsys;
+ forwardsys = core->forwardsys;
}
PLATFORM_EXTERN_C ITextParsers *get_textparsers()
diff --git a/core/logic/common_logic.h b/core/logic/common_logic.h
index 96e51ca7..986595ab 100644
--- a/core/logic/common_logic.h
+++ b/core/logic/common_logic.h
@@ -46,6 +46,7 @@ extern IVEngineServer *engine;
extern IShareSys *sharesys;
extern IRootConsole *rootmenu;
extern IPluginManager *pluginsys;
+extern IForwardManager *forwardsys;
#endif /* _INCLUDE_SOURCEMOD_COMMON_LOGIC_H_ */
diff --git a/core/logic/intercom.h b/core/logic/intercom.h
index b6d489bf..0f840e2e 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 - 1)
+#define SM_LOGIC_MAGIC (0x0F47C0DE - 2)
#if defined SM_LOGIC
class IVEngineServer
@@ -62,6 +62,7 @@ namespace SourceMod
class IThreader;
class IRootConsole;
class IPluginManager;
+ class IForwardManager;
}
class IVEngineServer;
@@ -78,6 +79,7 @@ struct sm_core_t
IShareSys *sharesys;
IRootConsole *rootmenu;
IPluginManager *pluginsys;
+ IForwardManager *forwardsys;
/* Functions */
void (*AddNatives)(sp_nativeinfo_t* nlist);
ConVar * (*FindConVar)(const char*);
diff --git a/core/logic/msvc9/logic.vcproj b/core/logic/msvc9/logic.vcproj
index 0ecf657c..1d53f5c1 100755
--- a/core/logic/msvc9/logic.vcproj
+++ b/core/logic/msvc9/logic.vcproj
@@ -184,6 +184,10 @@
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
+
+
diff --git a/core/smn_functions.cpp b/core/logic/smn_functions.cpp
similarity index 83%
rename from core/smn_functions.cpp
rename to core/logic/smn_functions.cpp
index 6feb6e49..29d22588 100644
--- a/core/smn_functions.cpp
+++ b/core/logic/smn_functions.cpp
@@ -29,10 +29,10 @@
* Version: $Id$
*/
-#include "sm_globals.h"
-#include "PluginSys.h"
-#include "ForwardSys.h"
-#include "HandleSys.h"
+#include "common_logic.h"
+#include
+#include
+#include
HandleType_t g_GlobalFwdType = 0;
HandleType_t g_PrivateFwdType = 0;
@@ -52,36 +52,36 @@ public:
HandleAccess sec;
/* Set GlobalFwd handle access security */
- g_HandleSys.InitAccessDefaults(NULL, &sec);
+ handlesys->InitAccessDefaults(NULL, &sec);
sec.access[HandleAccess_Read] = 0;
sec.access[HandleAccess_Clone] = HANDLE_RESTRICT_IDENTITY | HANDLE_RESTRICT_OWNER;
/* Create 'GlobalFwd' handle type */
- g_GlobalFwdType = g_HandleSys.CreateType("GlobalFwd", this, 0, NULL, &sec, g_pCoreIdent, NULL);
+ g_GlobalFwdType = handlesys->CreateType("GlobalFwd", this, 0, NULL, &sec, g_pCoreIdent, NULL);
/* Private forwards are cloneable */
sec.access[HandleAccess_Clone] = 0;
/* Create 'PrivateFwd' handle type */
- g_PrivateFwdType = g_HandleSys.CreateType("PrivateFwd", this, g_GlobalFwdType, NULL, &sec, g_pCoreIdent, NULL);
+ g_PrivateFwdType = handlesys->CreateType("PrivateFwd", this, g_GlobalFwdType, NULL, &sec, g_pCoreIdent, NULL);
}
void OnSourceModShutdown()
{
- g_HandleSys.RemoveType(g_PrivateFwdType, g_pCoreIdent);
- g_HandleSys.RemoveType(g_GlobalFwdType, g_pCoreIdent);
+ handlesys->RemoveType(g_PrivateFwdType, g_pCoreIdent);
+ handlesys->RemoveType(g_GlobalFwdType, g_pCoreIdent);
}
void OnHandleDestroy(HandleType_t type, void *object)
{
IForward *pForward = static_cast(object);
- g_Forwards.ReleaseForward(pForward);
+ forwardsys->ReleaseForward(pForward);
}
bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize)
{
- *pSize = sizeof(CForward) + (((IForward *)object)->GetFunctionCount() * 12);
+ *pSize = sizeof(IForward*) + (((IForward *)object)->GetFunctionCount() * 12);
return true;
}
} g_ForwardNativeHelpers;
@@ -112,9 +112,9 @@ static cell_t sm_GetFunctionByName(IPluginContext *pContext, const cell_t *param
if (hndl == 0)
{
- pPlugin = g_PluginSys.FindPluginByContext(pContext->GetContext());
+ pPlugin = pluginsys->FindPluginByContext(pContext->GetContext());
} else {
- pPlugin = g_PluginSys.PluginFromHandle(hndl, &err);
+ pPlugin = pluginsys->PluginFromHandle(hndl, &err);
if (!pPlugin)
{
@@ -155,9 +155,9 @@ static cell_t sm_CreateGlobalForward(IPluginContext *pContext, const cell_t *par
forwardParams[i - 3] = static_cast(*addr);
}
- IForward *pForward = g_Forwards.CreateForward(name, static_cast(params[2]), count - 2, forwardParams);
+ IForward *pForward = forwardsys->CreateForward(name, static_cast(params[2]), count - 2, forwardParams);
- return g_HandleSys.CreateHandle(g_GlobalFwdType, pForward, pContext->GetIdentity(), g_pCoreIdent, NULL);
+ return handlesys->CreateHandle(g_GlobalFwdType, pForward, pContext->GetIdentity(), g_pCoreIdent, NULL);
}
static cell_t sm_CreateForward(IPluginContext *pContext, const cell_t *params)
@@ -177,9 +177,9 @@ static cell_t sm_CreateForward(IPluginContext *pContext, const cell_t *params)
forwardParams[i - 2] = static_cast(*addr);
}
- IChangeableForward *pForward = g_Forwards.CreateForwardEx(NULL, static_cast(params[1]), count - 1, forwardParams);
+ IChangeableForward *pForward = forwardsys->CreateForwardEx(NULL, static_cast(params[1]), count - 1, forwardParams);
- return g_HandleSys.CreateHandle(g_PrivateFwdType, pForward, pContext->GetIdentity(), g_pCoreIdent, NULL);
+ return handlesys->CreateHandle(g_PrivateFwdType, pForward, pContext->GetIdentity(), g_pCoreIdent, NULL);
}
static cell_t sm_GetForwardFunctionCount(IPluginContext *pContext, const cell_t *params)
@@ -188,7 +188,7 @@ static cell_t sm_GetForwardFunctionCount(IPluginContext *pContext, const cell_t
HandleError err;
IForward *pForward;
- if ((err=g_HandleSys.ReadHandle(hndl, g_GlobalFwdType, NULL, (void **)&pForward))
+ if ((err=handlesys->ReadHandle(hndl, g_GlobalFwdType, NULL, (void **)&pForward))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid forward handle %x (error %d)", hndl, err);
@@ -205,7 +205,7 @@ static cell_t sm_AddToForward(IPluginContext *pContext, const cell_t *params)
IChangeableForward *pForward;
IPlugin *pPlugin;
- if ((err=g_HandleSys.ReadHandle(fwdHandle, g_PrivateFwdType, NULL, (void **)&pForward))
+ if ((err=handlesys->ReadHandle(fwdHandle, g_PrivateFwdType, NULL, (void **)&pForward))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid private forward handle %x (error %d)", fwdHandle, err);
@@ -213,9 +213,9 @@ static cell_t sm_AddToForward(IPluginContext *pContext, const cell_t *params)
if (plHandle == 0)
{
- pPlugin = g_PluginSys.FindPluginByContext(pContext->GetContext());
+ pPlugin = pluginsys->FindPluginByContext(pContext->GetContext());
} else {
- pPlugin = g_PluginSys.PluginFromHandle(plHandle, &err);
+ pPlugin = pluginsys->PluginFromHandle(plHandle, &err);
if (!pPlugin)
{
@@ -241,7 +241,7 @@ static cell_t sm_RemoveFromForward(IPluginContext *pContext, const cell_t *param
IChangeableForward *pForward;
IPlugin *pPlugin;
- if ((err=g_HandleSys.ReadHandle(fwdHandle, g_PrivateFwdType, NULL, (void **)&pForward))
+ if ((err=handlesys->ReadHandle(fwdHandle, g_PrivateFwdType, NULL, (void **)&pForward))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid private forward handle %x (error %d)", fwdHandle, err);
@@ -249,9 +249,9 @@ static cell_t sm_RemoveFromForward(IPluginContext *pContext, const cell_t *param
if (plHandle == 0)
{
- pPlugin = g_PluginSys.FindPluginByContext(pContext->GetContext());
+ pPlugin = pluginsys->FindPluginByContext(pContext->GetContext());
} else {
- pPlugin = g_PluginSys.PluginFromHandle(plHandle, &err);
+ pPlugin = pluginsys->PluginFromHandle(plHandle, &err);
if (!pPlugin)
{
@@ -277,7 +277,7 @@ static cell_t sm_RemoveAllFromForward(IPluginContext *pContext, const cell_t *pa
IChangeableForward *pForward;
IPlugin *pPlugin;
- if ((err=g_HandleSys.ReadHandle(fwdHandle, g_PrivateFwdType, NULL, (void **)&pForward))
+ if ((err=handlesys->ReadHandle(fwdHandle, g_PrivateFwdType, NULL, (void **)&pForward))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid private forward handle %x (error %d)", fwdHandle, err);
@@ -285,9 +285,9 @@ static cell_t sm_RemoveAllFromForward(IPluginContext *pContext, const cell_t *pa
if (plHandle == 0)
{
- pPlugin = g_PluginSys.FindPluginByContext(pContext->GetContext());
+ pPlugin = pluginsys->FindPluginByContext(pContext->GetContext());
} else {
- pPlugin = g_PluginSys.PluginFromHandle(plHandle, &err);
+ pPlugin = pluginsys->PluginFromHandle(plHandle, &err);
if (!pPlugin)
{
@@ -310,9 +310,9 @@ static cell_t sm_CallStartFunction(IPluginContext *pContext, const cell_t *param
if (hndl == 0)
{
- pPlugin = g_PluginSys.FindPluginByContext(pContext->GetContext());
+ pPlugin = pluginsys->FindPluginByContext(pContext->GetContext());
} else {
- pPlugin = g_PluginSys.PluginFromHandle(hndl, &err);
+ pPlugin = pluginsys->PluginFromHandle(hndl, &err);
if (!pPlugin)
{
@@ -344,7 +344,7 @@ static cell_t sm_CallStartForward(IPluginContext *pContext, const cell_t *params
hndl = static_cast(params[1]);
- if ((err=g_HandleSys.ReadHandle(hndl, g_GlobalFwdType, NULL, (void **)&pForward))
+ if ((err=handlesys->ReadHandle(hndl, g_GlobalFwdType, NULL, (void **)&pForward))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid forward handle %x (error %d)", hndl, err);
diff --git a/core/logic_bridge.cpp b/core/logic_bridge.cpp
index e6e8df2c..a6690fc4 100644
--- a/core/logic_bridge.cpp
+++ b/core/logic_bridge.cpp
@@ -42,6 +42,7 @@
#include "Logger.h"
#include "ShareSys.h"
#include "sm_srvcmds.h"
+#include "ForwardSys.h"
static ILibrary *g_pLogic = NULL;
static LogicInitFunction logic_init_fn;
@@ -95,6 +96,7 @@ static sm_core_t core_bridge =
&g_ShareSys,
&g_RootMenu,
&g_PluginSys,
+ &g_Forwards,
/* Functions */
add_natives,
find_convar,
diff --git a/core/msvc9/sourcemod_mm.vcproj b/core/msvc9/sourcemod_mm.vcproj
index 2d6e83f5..0131b59e 100644
--- a/core/msvc9/sourcemod_mm.vcproj
+++ b/core/msvc9/sourcemod_mm.vcproj
@@ -1930,10 +1930,6 @@
RelativePath="..\smn_filesystem.cpp"
>
-
-
diff --git a/public/IPluginSys.h b/public/IPluginSys.h
index e683dec3..54fdf6ed 100644
--- a/public/IPluginSys.h
+++ b/public/IPluginSys.h
@@ -1,8 +1,8 @@
/**
- * vim: set ts=4 :
+ * vim: set ts=4 sw=4 :
* =============================================================================
* SourceMod
- * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
+ * Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
@@ -38,10 +38,11 @@
*/
#include
+#include
#include
#define SMINTERFACE_PLUGINSYSTEM_NAME "IPluginManager"
-#define SMINTERFACE_PLUGINSYSTEM_VERSION 2
+#define SMINTERFACE_PLUGINSYSTEM_VERSION 3
/** Context user slot 3 is used Core for holding an IPluginContext pointer. */
#define SM_CONTEXTVAR_USER 3
@@ -353,7 +354,17 @@ namespace SourceMod
* @param listener Pointer to a listener.
*/
virtual void RemovePluginsListener(IPluginsListener *listener) =0;
+
+ /**
+ * @brief Converts a Handle to an IPlugin if possible.
+ *
+ * @param handle Handle.
+ * @param err Error, set on failure (otherwise undefined).
+ * @return IPlugin pointer, or NULL on failure.
+ */
+ virtual IPlugin *PluginFromHandle(Handle_t handle, HandleError *err) =0;
};
}
#endif //_INCLUDE_SOURCEMOD_PLUGINMNGR_INTERFACE_H_
+