From c1884912895fbca971712cb453f2d910a9a27c60 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 14 May 2010 21:06:06 -0700 Subject: [PATCH] Moved handle natives from core to logic (bug 4406 part 9, r=ds). --HG-- rename : core/smn_handles.cpp => core/logic/smn_handles.cpp --- core/AMBuilder | 1 - core/Makefile | 2 +- core/logic/AMBuilder | 1 + core/logic/Makefile | 1 + core/logic/intercom.h | 2 +- core/{ => logic}/smn_handles.cpp | 18 ++++++++++-------- public/IPluginSys.h | 9 ++++++++- 7 files changed, 22 insertions(+), 12 deletions(-) rename core/{ => logic}/smn_handles.cpp (85%) diff --git a/core/AMBuilder b/core/AMBuilder index 04180f3f..354291c9 100644 --- a/core/AMBuilder +++ b/core/AMBuilder @@ -56,7 +56,6 @@ for i in SM.sdkInfo: 'smn_halflife.cpp', 'PluginSys.cpp', 'smn_console.cpp', - 'smn_handles.cpp', 'UserMessages.cpp', 'Database.cpp', 'MenuManager.cpp', diff --git a/core/Makefile b/core/Makefile index c6978f36..bdedb0a1 100644 --- a/core/Makefile +++ b/core/Makefile @@ -25,7 +25,7 @@ OBJECTS = AdminCache.cpp CDataPack.cpp ConCmdManager.cpp ConVarManager.cpp CoreC OBJECTS += 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_gameconfigs.cpp smn_halflife.cpp \ - smn_handles.cpp smn_keyvalues.cpp smn_player.cpp \ + smn_keyvalues.cpp smn_player.cpp \ smn_usermsgs.cpp smn_menus.cpp smn_database.cpp smn_vector.cpp \ smn_hudtext.cpp smn_nextmap.cpp OBJECTS += ExtensionSys.cpp \ diff --git a/core/logic/AMBuilder b/core/logic/AMBuilder index 94742e28..2b937638 100644 --- a/core/logic/AMBuilder +++ b/core/logic/AMBuilder @@ -40,6 +40,7 @@ files = [ 'PhraseCollection.cpp', 'smn_lang.cpp', 'smn_string.cpp', + 'smn_handles.cpp', 'sm_crc32.cpp' ] if AMBuild.target['platform'] == 'windows': diff --git a/core/logic/Makefile b/core/logic/Makefile index 3366abf3..1e88c623 100644 --- a/core/logic/Makefile +++ b/core/logic/Makefile @@ -36,6 +36,7 @@ OBJECTS = \ PhraseCollection.cpp \ smn_lang.cpp \ smn_string.cpp \ + smn_handles.cpp \ smn_players.cpp ############################################## diff --git a/core/logic/intercom.h b/core/logic/intercom.h index da75227b..341cb104 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 - 12) +#define SM_LOGIC_MAGIC (0x0F47C0DE - 13) #if defined SM_LOGIC class IVEngineServer diff --git a/core/smn_handles.cpp b/core/logic/smn_handles.cpp similarity index 85% rename from core/smn_handles.cpp rename to core/logic/smn_handles.cpp index e4fb47cb..d0834594 100644 --- a/core/smn_handles.cpp +++ b/core/logic/smn_handles.cpp @@ -29,15 +29,17 @@ * Version: $Id$ */ -#include "sm_globals.h" -#include "HandleSys.h" -#include "PluginSys.h" +#include "common_logic.h" +#include +#include + +using namespace SourceMod; static cell_t sm_IsValidHandle(IPluginContext *pContext, const cell_t *params) { Handle_t hndl = static_cast(params[1]); - HandleError err = g_HandleSys.ReadHandle(hndl, 0, NULL, NULL); + HandleError err = handlesys->ReadHandle(hndl, 0, NULL, NULL); if (err != HandleError_Access && err != HandleError_None) @@ -56,7 +58,7 @@ static cell_t sm_CloseHandle(IPluginContext *pContext, const cell_t *params) sec.pIdentity = NULL; sec.pOwner = pContext->GetIdentity(); - HandleError err = g_HandleSys.FreeHandle(hndl, &sec); + HandleError err = handlesys->FreeHandle(hndl, &sec); if (err == HandleError_None) { @@ -80,7 +82,7 @@ static cell_t sm_CloneHandle(IPluginContext *pContext, const cell_t *params) pNewOwner = pContext->GetIdentity(); } else { Handle_t hPlugin = static_cast(params[2]); - IPlugin *pPlugin = g_PluginSys.PluginFromHandle(hPlugin, &err); + IPlugin *pPlugin = pluginsys->PluginFromHandle(hPlugin, &err); if (!pPlugin) { return pContext->ThrowNativeError("Plugin handle %x is invalid (error %d)", hndl, err); @@ -88,7 +90,7 @@ static cell_t sm_CloneHandle(IPluginContext *pContext, const cell_t *params) pNewOwner = pPlugin->GetIdentity(); } - err = g_HandleSys.CloneHandle(hndl, &new_hndl, pNewOwner, NULL); + err = handlesys->CloneHandle(hndl, &new_hndl, pNewOwner, NULL); if (err == HandleError_Access) { @@ -102,7 +104,7 @@ static cell_t sm_CloneHandle(IPluginContext *pContext, const cell_t *params) static cell_t sm_GetMyHandle(IPluginContext *pContext, const cell_t *params) { - CPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pContext->GetContext()); + IPlugin *pPlugin = pluginsys->FindPluginByContext(pContext->GetContext()); return pPlugin->GetMyHandle(); } diff --git a/public/IPluginSys.h b/public/IPluginSys.h index 1e92d9e4..bc3424aa 100644 --- a/public/IPluginSys.h +++ b/public/IPluginSys.h @@ -42,7 +42,7 @@ #include #define SMINTERFACE_PLUGINSYSTEM_NAME "IPluginManager" -#define SMINTERFACE_PLUGINSYSTEM_VERSION 4 +#define SMINTERFACE_PLUGINSYSTEM_VERSION 5 /** Context user slot 3 is used Core for holding an IPluginContext pointer. */ #define SM_CONTEXTVAR_USER 3 @@ -206,6 +206,13 @@ namespace SourceMod * @return Plugin's phrase collection. */ virtual IPhraseCollection *GetPhrases() =0; + + /** + * @brief Returns a plugin's handle. + * + * @return Plugin's handle. + */ + virtual Handle_t GetMyHandle() =0; };