Move scared guts of core into logic (bug 5680, r=fyren).

--HG--
rename : core/ExtensionSys.cpp => core/logic/ExtensionSys.cpp
rename : core/ExtensionSys.h => core/logic/ExtensionSys.h
rename : core/HandleSys.cpp => core/logic/HandleSys.cpp
rename : core/HandleSys.h => core/logic/HandleSys.h
rename : core/NativeInvoker.cpp => core/logic/NativeInvoker.cpp
rename : core/NativeInvoker.h => core/logic/NativeInvoker.h
rename : core/NativeOwner.cpp => core/logic/NativeOwner.cpp
rename : core/NativeOwner.h => core/logic/NativeOwner.h
rename : core/PluginSys.cpp => core/logic/PluginSys.cpp
rename : core/PluginSys.h => core/logic/PluginSys.h
rename : core/ShareSys.cpp => core/logic/ShareSys.cpp
rename : core/ShareSys.h => core/logic/ShareSys.h
rename : core/smn_fakenatives.cpp => core/logic/smn_fakenatives.cpp
rename : core/logic/AutoHandleRooter.h => public/AutoHandleRooter.h
This commit is contained in:
David Anderson 2013-03-29 11:37:29 -07:00
parent 502c6f0dae
commit 045ee262a8
71 changed files with 3973 additions and 1131 deletions

View File

@ -31,7 +31,7 @@
#include "ADTFactory.h" #include "ADTFactory.h"
#include "sm_globals.h" #include "sm_globals.h"
#include "ShareSys.h" #include "logic_bridge.h"
ADTFactory g_AdtFactory; ADTFactory g_AdtFactory;
@ -47,7 +47,7 @@ unsigned int ADTFactory::GetInterfaceVersion()
void ADTFactory::OnSourceModAllInitialized() void ADTFactory::OnSourceModAllInitialized()
{ {
g_ShareSys.AddInterface(NULL, this); sharesys->AddInterface(NULL, this);
} }
IBasicTrie *ADTFactory::CreateBasicTrie() IBasicTrie *ADTFactory::CreateBasicTrie()

View File

@ -50,7 +50,6 @@ for i in SM.sdkInfo:
files = [ files = [
'AdminCache.cpp', 'AdminCache.cpp',
'ExtensionSys.cpp',
'MenuStyle_Valve.cpp', 'MenuStyle_Valve.cpp',
'logic_bridge.cpp', 'logic_bridge.cpp',
'smn_entities.cpp', 'smn_entities.cpp',
@ -63,19 +62,16 @@ for i in SM.sdkInfo:
'sm_trie.cpp', 'sm_trie.cpp',
'CDataPack.cpp', 'CDataPack.cpp',
'frame_hooks.cpp', 'frame_hooks.cpp',
'NativeInvoker.cpp',
'smn_fakenatives.cpp', 'smn_fakenatives.cpp',
'smn_nextmap.cpp', 'smn_nextmap.cpp',
'sourcemm_api.cpp', 'sourcemm_api.cpp',
'ChatTriggers.cpp', 'ChatTriggers.cpp',
'NativeOwner.cpp',
'smn_player.cpp', 'smn_player.cpp',
'sourcemod.cpp', 'sourcemod.cpp',
'concmd_cleaner.cpp', 'concmd_cleaner.cpp',
'HalfLife2.cpp', 'HalfLife2.cpp',
'NextMap.cpp', 'NextMap.cpp',
'ConCmdManager.cpp', 'ConCmdManager.cpp',
'HandleSys.cpp',
'ConVarManager.cpp', 'ConVarManager.cpp',
'LibrarySys.cpp', 'LibrarySys.cpp',
'PlayerManager.cpp', 'PlayerManager.cpp',
@ -83,7 +79,6 @@ for i in SM.sdkInfo:
'CoreConfig.cpp', 'CoreConfig.cpp',
'Logger.cpp', 'Logger.cpp',
'smn_halflife.cpp', 'smn_halflife.cpp',
'PluginSys.cpp',
'smn_console.cpp', 'smn_console.cpp',
'UserMessages.cpp', 'UserMessages.cpp',
'Database.cpp', 'Database.cpp',
@ -92,7 +87,6 @@ for i in SM.sdkInfo:
'smn_hudtext.cpp', 'smn_hudtext.cpp',
'smn_usermsgs.cpp', 'smn_usermsgs.cpp',
'MenuStyle_Base.cpp', 'MenuStyle_Base.cpp',
'ShareSys.cpp',
'smn_database.cpp', 'smn_database.cpp',
'smn_keyvalues.cpp', 'smn_keyvalues.cpp',
'smn_vector.cpp', 'smn_vector.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 "ShareSys.h"
#include "ForwardSys.h" #include "ForwardSys.h"
#include "PlayerManager.h" #include "PlayerManager.h"
#include "ConCmdManager.h" #include "ConCmdManager.h"
@ -42,6 +41,7 @@
#include "sm_stringutil.h" #include "sm_stringutil.h"
#include "sourcemm_api.h" #include "sourcemm_api.h"
#include "sm_srvcmds.h" #include "sm_srvcmds.h"
#include "logic_bridge.h"
#define LEVEL_STATE_NONE 0 #define LEVEL_STATE_NONE 0
#define LEVEL_STATE_LEVELS 1 #define LEVEL_STATE_LEVELS 1
@ -294,7 +294,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 = g_Forwards.CreateForward("OnRebuildAdminCache", ET_Ignore, 1, NULL, Param_Cell);
g_ShareSys.AddInterface(NULL, this); sharesys->AddInterface(NULL, this);
} }
void AdminCache::OnSourceModLevelChange(const char *mapName) void AdminCache::OnSourceModLevelChange(const char *mapName)

View File

@ -73,13 +73,14 @@ ConCmdManager::~ConCmdManager()
void ConCmdManager::OnSourceModAllInitialized() void ConCmdManager::OnSourceModAllInitialized()
{ {
g_PluginSys.AddPluginsListener(this); scripts->AddPluginsListener(this);
g_RootMenu.AddRootConsoleCommand("cmds", "List console commands", this); g_RootMenu.AddRootConsoleCommand("cmds", "List console commands", this);
SH_ADD_HOOK(IServerGameClients, SetCommandClient, serverClients, SH_MEMBER(this, &ConCmdManager::SetCommandClient), false); SH_ADD_HOOK(IServerGameClients, SetCommandClient, serverClients, SH_MEMBER(this, &ConCmdManager::SetCommandClient), false);
} }
void ConCmdManager::OnSourceModShutdown() void ConCmdManager::OnSourceModShutdown()
{ {
scripts->RemovePluginsListener(this);
/* All commands should already be removed by the time we're done */ /* All commands should already be removed by the time we're done */
SH_REMOVE_HOOK(IServerGameClients, SetCommandClient, serverClients, SH_MEMBER(this, &ConCmdManager::SetCommandClient), false); SH_REMOVE_HOOK(IServerGameClients, SetCommandClient, serverClients, SH_MEMBER(this, &ConCmdManager::SetCommandClient), false);
g_RootMenu.RemoveRootConsoleCommand("cmds", this); g_RootMenu.RemoveRootConsoleCommand("cmds", this);
@ -109,7 +110,7 @@ void ConCmdManager::RemoveConCmds(List<CmdHook *> &cmdlist)
{ {
CmdHook *pHook = (*iter); CmdHook *pHook = (*iter);
IPluginContext *pContext = pHook->pf->GetParentContext(); IPluginContext *pContext = pHook->pf->GetParentContext();
IPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pContext->GetContext()); IPlugin *pPlugin = scripts->FindPluginByContext(pContext->GetContext());
CmdList *pList = NULL; CmdList *pList = NULL;
//gaben //gaben
@ -623,7 +624,7 @@ bool ConCmdManager::AddAdminCommand(IPluginFunction *pFunction,
/* Now add to the plugin */ /* Now add to the plugin */
CmdList *pList; CmdList *pList;
IPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pFunction->GetParentContext()->GetContext()); IPlugin *pPlugin = scripts->FindPluginByContext(pFunction->GetParentContext()->GetContext());
if (!pPlugin->GetProperty("CommandList", (void **)&pList)) if (!pPlugin->GetProperty("CommandList", (void **)&pList))
{ {
pList = new CmdList(); pList = new CmdList();
@ -663,7 +664,7 @@ bool ConCmdManager::AddServerCommand(IPluginFunction *pFunction,
/* Add to the plugin */ /* Add to the plugin */
CmdList *pList; CmdList *pList;
IPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pFunction->GetParentContext()->GetContext()); IPlugin *pPlugin = scripts->FindPluginByContext(pFunction->GetParentContext()->GetContext());
if (!pPlugin->GetProperty("CommandList", (void **)&pList)) if (!pPlugin->GetProperty("CommandList", (void **)&pList))
{ {
pList = new CmdList(); pList = new CmdList();
@ -915,7 +916,7 @@ void ConCmdManager::OnRootConsoleCommand(const char *cmdname, const CCommand &co
{ {
const char *text = command.Arg(2); const char *text = command.Arg(2);
CPlugin *pPlugin = g_PluginSys.FindPluginByConsoleArg(text); IPlugin *pPlugin = scripts->FindPluginByConsoleArg(text);
if (!pPlugin) if (!pPlugin)
{ {

View File

@ -29,13 +29,12 @@
#include "ConVarManager.h" #include "ConVarManager.h"
#include "HalfLife2.h" #include "HalfLife2.h"
#include "PluginSys.h"
#include "ForwardSys.h" #include "ForwardSys.h"
#include "HandleSys.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>
#include <sm_trie_tpl.h> #include <sm_trie_tpl.h>
#include "logic_bridge.h"
ConVarManager g_ConVarManager; ConVarManager g_ConVarManager;
@ -106,7 +105,7 @@ void ConVarManager::OnSourceModStartup(bool late)
sec.access[HandleAccess_Clone] = HANDLE_RESTRICT_IDENTITY | HANDLE_RESTRICT_OWNER; sec.access[HandleAccess_Clone] = HANDLE_RESTRICT_IDENTITY | HANDLE_RESTRICT_OWNER;
/* Create the 'ConVar' handle type */ /* Create the 'ConVar' handle type */
m_ConVarType = g_HandleSys.CreateType("ConVar", this, 0, NULL, &sec, g_pCoreIdent, NULL); m_ConVarType = handlesys->CreateType("ConVar", this, 0, NULL, &sec, g_pCoreIdent, NULL);
} }
void ConVarManager::OnSourceModAllInitialized() void ConVarManager::OnSourceModAllInitialized()
@ -128,7 +127,7 @@ void ConVarManager::OnSourceModAllInitialized()
SH_ADD_HOOK(ICvar, CallGlobalChangeCallback, icvar, SH_STATIC(OnConVarChanged), false); SH_ADD_HOOK(ICvar, CallGlobalChangeCallback, icvar, SH_STATIC(OnConVarChanged), false);
#endif #endif
g_PluginSys.AddPluginsListener(this); scripts->AddPluginsListener(this);
/* Add the 'convars' option to the 'sm' console command */ /* Add the 'convars' option to the 'sm' console command */
g_RootMenu.AddRootConsoleCommand("cvars", "View convars created by a plugin", this); g_RootMenu.AddRootConsoleCommand("cvars", "View convars created by a plugin", this);
@ -146,7 +145,7 @@ void ConVarManager::OnSourceModShutdown()
iter = m_ConVars.erase(iter); iter = m_ConVars.erase(iter);
g_HandleSys.FreeHandle(pInfo->handle, &sec); handlesys->FreeHandle(pInfo->handle, &sec);
if (pInfo->pChangeForward != NULL) if (pInfo->pChangeForward != NULL)
{ {
g_Forwards.ReleaseForward(pInfo->pChangeForward); g_Forwards.ReleaseForward(pInfo->pChangeForward);
@ -200,10 +199,10 @@ void ConVarManager::OnSourceModShutdown()
/* Remove the 'convars' option from the 'sm' console command */ /* Remove the 'convars' option from the 'sm' console command */
g_RootMenu.RemoveRootConsoleCommand("cvars", this); g_RootMenu.RemoveRootConsoleCommand("cvars", this);
g_PluginSys.RemovePluginsListener(this); scripts->RemovePluginsListener(this);
/* Remove the 'ConVar' handle type */ /* Remove the 'ConVar' handle type */
g_HandleSys.RemoveType(m_ConVarType, g_pCoreIdent); handlesys->RemoveType(m_ConVarType, g_pCoreIdent);
} }
/** /**
@ -269,7 +268,7 @@ void ConVarManager::OnUnlinkConCommandBase(ConCommandBase *pBase, const char *na
convar_cache.remove(name); convar_cache.remove(name);
/* Now make sure no plugins are referring to this pointer */ /* Now make sure no plugins are referring to this pointer */
IPluginIterator *pl_iter = g_PluginSys.GetPluginIterator(); IPluginIterator *pl_iter = scripts->GetPluginIterator();
while (pl_iter->MorePlugins()) while (pl_iter->MorePlugins())
{ {
IPlugin *pl = pl_iter->GetPlugin(); IPlugin *pl = pl_iter->GetPlugin();
@ -285,7 +284,7 @@ void ConVarManager::OnUnlinkConCommandBase(ConCommandBase *pBase, const char *na
} }
/* Free resources */ /* Free resources */
g_HandleSys.FreeHandle(pInfo->handle, &sec); handlesys->FreeHandle(pInfo->handle, &sec);
delete pInfo; delete pInfo;
} }
@ -337,7 +336,7 @@ void ConVarManager::OnRootConsoleCommand(const char *cmdname, const CCommand &co
} }
/* Get plugin object */ /* Get plugin object */
CPlugin *plugin = g_PluginSys.FindPluginByConsoleArg(arg); IPlugin *plugin = scripts->FindPluginByConsoleArg(arg);
if (!plugin) if (!plugin)
{ {
@ -418,7 +417,7 @@ Handle_t ConVarManager::CreateConVar(IPluginContext *pContext, const char *name,
pInfo->pVar = pConVar; pInfo->pVar = pConVar;
/* If we don't, then create a new handle from the convar */ /* If we don't, then create a new handle from the convar */
hndl = g_HandleSys.CreateHandle(m_ConVarType, pInfo, NULL, g_pCoreIdent, NULL); hndl = handlesys->CreateHandle(m_ConVarType, pInfo, NULL, g_pCoreIdent, NULL);
if (hndl == BAD_HANDLE) if (hndl == BAD_HANDLE)
{ {
delete pInfo; delete pInfo;
@ -449,7 +448,7 @@ Handle_t ConVarManager::CreateConVar(IPluginContext *pContext, const char *name,
pInfo->pChangeForward = NULL; pInfo->pChangeForward = NULL;
/* Create a handle from the new convar */ /* Create a handle from the new convar */
hndl = g_HandleSys.CreateHandle(m_ConVarType, pInfo, NULL, g_pCoreIdent, NULL); hndl = handlesys->CreateHandle(m_ConVarType, pInfo, NULL, g_pCoreIdent, NULL);
if (hndl == BAD_HANDLE) if (hndl == BAD_HANDLE)
{ {
delete pInfo; delete pInfo;
@ -500,7 +499,7 @@ Handle_t ConVarManager::FindConVar(const char *name)
pInfo->pVar = pConVar; pInfo->pVar = pConVar;
/* If we don't have a handle, then create a new one */ /* If we don't have a handle, then create a new one */
hndl = g_HandleSys.CreateHandle(m_ConVarType, pInfo, NULL, g_pCoreIdent, NULL); hndl = handlesys->CreateHandle(m_ConVarType, pInfo, NULL, g_pCoreIdent, NULL);
if (hndl == BAD_HANDLE) if (hndl == BAD_HANDLE)
{ {
delete pInfo; delete pInfo;
@ -639,7 +638,7 @@ void ConVarManager::AddConVarToPluginList(IPluginContext *pContext, const ConVar
bool inserted = false; bool inserted = false;
const char *orig = pConVar->GetName(); const char *orig = pConVar->GetName();
IPlugin *plugin = g_PluginSys.FindPluginByContext(pContext->GetContext()); IPlugin *plugin = scripts->FindPluginByContext(pContext->GetContext());
/* Check plugin for an existing convar list */ /* Check plugin for an existing convar list */
if (!plugin->GetProperty("ConVarList", (void **)&pConVarList)) if (!plugin->GetProperty("ConVarList", (void **)&pConVarList))
@ -772,7 +771,7 @@ HandleError ConVarManager::ReadConVarHandle(Handle_t hndl, ConVar **pVar)
ConVarInfo *pInfo; ConVarInfo *pInfo;
HandleError error; HandleError error;
if ((error = g_HandleSys.ReadHandle(hndl, m_ConVarType, NULL, (void **)&pInfo)) != HandleError_None) if ((error = handlesys->ReadHandle(hndl, m_ConVarType, NULL, (void **)&pInfo)) != HandleError_None)
{ {
return error; return error;
} }

View File

@ -49,7 +49,7 @@
#include "ConCmdManager.h" #include "ConCmdManager.h"
#include "HalfLife2.h" #include "HalfLife2.h"
#include "ConCommandBaseIterator.h" #include "ConCommandBaseIterator.h"
#include "ShareSys.h" #include "logic_bridge.h"
#if defined PLATFORM_POSIX #if defined PLATFORM_POSIX
# include <dlfcn.h> # include <dlfcn.h>
@ -576,7 +576,7 @@ void ConsoleDetours::OnSourceModAllInitialized()
{ {
m_pForward = g_Forwards.CreateForwardEx("OnAnyCommand", ET_Hook, 3, NULL, Param_Cell, m_pForward = g_Forwards.CreateForwardEx("OnAnyCommand", ET_Hook, 3, NULL, Param_Cell,
Param_String, Param_Cell); Param_String, Param_Cell);
g_ShareSys.AddCapabilityProvider(NULL, this, FEATURECAP_COMMANDLISTENER); sharesys->AddCapabilityProvider(NULL, this, FEATURECAP_COMMANDLISTENER);
} }
void ConsoleDetours::OnSourceModShutdown() void ConsoleDetours::OnSourceModShutdown()

View File

@ -38,9 +38,9 @@
#include "sm_stringutil.h" #include "sm_stringutil.h"
#include "LibrarySys.h" #include "LibrarySys.h"
#include "Logger.h" #include "Logger.h"
#include "PluginSys.h"
#include "ForwardSys.h" #include "ForwardSys.h"
#include "frame_hooks.h" #include "frame_hooks.h"
#include "logic_bridge.h"
#ifdef PLATFORM_WINDOWS #ifdef PLATFORM_WINDOWS
ConVar sm_corecfgfile("sm_corecfgfile", "addons\\sourcemod\\configs\\core.cfg", 0, "SourceMod core configuration file"); ConVar sm_corecfgfile("sm_corecfgfile", "addons\\sourcemod\\configs\\core.cfg", 0, "SourceMod core configuration file");
@ -321,7 +321,7 @@ inline bool IsPathSepChar(char c)
#endif #endif
} }
bool SM_ExecuteConfig(CPlugin *pl, AutoConfig *cfg, bool can_create) bool SM_ExecuteConfig(IPlugin *pl, AutoConfig *cfg, bool can_create)
{ {
bool will_create = false; bool will_create = false;
@ -500,10 +500,10 @@ void SM_DoSingleExecFwds(IPluginContext *ctx)
void SM_ConfigsExecuted_Plugin(unsigned int serial) void SM_ConfigsExecuted_Plugin(unsigned int serial)
{ {
IPluginIterator *iter = g_PluginSys.GetPluginIterator(); IPluginIterator *iter = scripts->GetPluginIterator();
while (iter->MorePlugins()) while (iter->MorePlugins())
{ {
CPlugin *plugin = (CPlugin *)(iter->GetPlugin()); IPlugin *plugin = iter->GetPlugin();
if (plugin->GetSerial() == serial) if (plugin->GetSerial() == serial)
{ {
SM_DoSingleExecFwds(plugin->GetBaseContext()); SM_DoSingleExecFwds(plugin->GetBaseContext());
@ -516,7 +516,7 @@ void SM_ConfigsExecuted_Plugin(unsigned int serial)
void SM_ExecuteForPlugin(IPluginContext *ctx) void SM_ExecuteForPlugin(IPluginContext *ctx)
{ {
CPlugin *plugin = (CPlugin *)g_PluginSys.GetPluginByCtx(ctx->GetContext()); SMPlugin *plugin = scripts->FindPluginByContext(ctx->GetContext());
unsigned int num = plugin->GetConfigCount(); unsigned int num = plugin->GetConfigCount();
if (!num) if (!num)
@ -545,19 +545,18 @@ void SM_ExecuteAllConfigs()
engine->ServerCommand("exec sourcemod/sourcemod.cfg\n"); engine->ServerCommand("exec sourcemod/sourcemod.cfg\n");
IPluginIterator *iter = g_PluginSys.GetPluginIterator(); CVector<SMPlugin *> plugins;
while (iter->MorePlugins()) scripts->ListPlugins(&plugins);
for (size_t i = 0; i < plugins.size(); i++)
{ {
CPlugin *plugin = (CPlugin *)(iter->GetPlugin()); SMPlugin *plugin = plugins[i];
unsigned int num = plugin->GetConfigCount(); unsigned int num = plugin->GetConfigCount();
bool can_create = true; bool can_create = true;
for (unsigned int i=0; i<num; i++) for (unsigned int i=0; i<num; i++)
{ {
can_create = SM_ExecuteConfig(plugin, plugin->GetConfig(i), can_create); can_create = SM_ExecuteConfig(plugin, plugin->GetConfig(i), can_create);
} }
iter->NextPlugin();
} }
iter->Release();
g_bGotServerStart = true; g_bGotServerStart = true;
CheckAndFinalizeConfigs(); CheckAndFinalizeConfigs();

View File

@ -30,14 +30,12 @@
*/ */
#include "Database.h" #include "Database.h"
#include "HandleSys.h"
#include "ShareSys.h"
#include "sourcemod.h" #include "sourcemod.h"
#include "sm_stringutil.h" #include "sm_stringutil.h"
#include "Logger.h" #include "Logger.h"
#include "ExtensionSys.h"
#include <stdlib.h> #include <stdlib.h>
#include <IThreader.h> #include <IThreader.h>
#include "logic_bridge.h"
#define DBPARSE_LEVEL_NONE 0 #define DBPARSE_LEVEL_NONE 0
#define DBPARSE_LEVEL_MAIN 1 #define DBPARSE_LEVEL_MAIN 1
@ -55,14 +53,14 @@ void DBManager::OnSourceModAllInitialized()
{ {
HandleAccess sec; HandleAccess sec;
g_HandleSys.InitAccessDefaults(NULL, &sec); handlesys->InitAccessDefaults(NULL, &sec);
sec.access[HandleAccess_Delete] |= HANDLE_RESTRICT_IDENTITY; sec.access[HandleAccess_Delete] |= HANDLE_RESTRICT_IDENTITY;
sec.access[HandleAccess_Clone] |= HANDLE_RESTRICT_IDENTITY; sec.access[HandleAccess_Clone] |= HANDLE_RESTRICT_IDENTITY;
m_DriverType = g_HandleSys.CreateType("IDriver", this, 0, NULL, &sec, g_pCoreIdent, NULL); m_DriverType = handlesys->CreateType("IDriver", this, 0, NULL, &sec, g_pCoreIdent, NULL);
m_DatabaseType = g_HandleSys.CreateType("IDatabase", this, 0, NULL, NULL, g_pCoreIdent, NULL); m_DatabaseType = handlesys->CreateType("IDatabase", this, 0, NULL, NULL, g_pCoreIdent, NULL);
g_ShareSys.AddInterface(NULL, this); sharesys->AddInterface(NULL, this);
g_SourceMod.BuildPath(Path_SM, m_Filename, sizeof(m_Filename), "configs/databases.cfg"); g_SourceMod.BuildPath(Path_SM, m_Filename, sizeof(m_Filename), "configs/databases.cfg");
@ -70,7 +68,7 @@ void DBManager::OnSourceModAllInitialized()
m_pThinkLock = g_pThreader->MakeMutex(); m_pThinkLock = g_pThreader->MakeMutex();
m_pQueueLock = g_pThreader->MakeMutex(); m_pQueueLock = g_pThreader->MakeMutex();
g_PluginSys.AddPluginsListener(this); scripts->AddPluginsListener(this);
} }
void DBManager::OnSourceModLevelChange(const char *mapName) void DBManager::OnSourceModLevelChange(const char *mapName)
@ -98,12 +96,12 @@ void DBManager::OnSourceModLevelChange(const char *mapName)
void DBManager::OnSourceModShutdown() void DBManager::OnSourceModShutdown()
{ {
KillWorkerThread(); KillWorkerThread();
g_PluginSys.RemovePluginsListener(this); scripts->RemovePluginsListener(this);
m_pConfigLock->DestroyThis(); m_pConfigLock->DestroyThis();
m_pThinkLock->DestroyThis(); m_pThinkLock->DestroyThis();
m_pQueueLock->DestroyThis(); m_pQueueLock->DestroyThis();
g_HandleSys.RemoveType(m_DatabaseType, g_pCoreIdent); handlesys->RemoveType(m_DatabaseType, g_pCoreIdent);
g_HandleSys.RemoveType(m_DriverType, g_pCoreIdent); handlesys->RemoveType(m_DriverType, g_pCoreIdent);
ClearConfigs(); ClearConfigs();
} }
@ -125,7 +123,7 @@ void DBManager::OnHandleDestroy(HandleType_t type, void *object)
return; return;
} }
if (g_HandleSys.TypeCheck(type, m_DatabaseType)) if (handlesys->TypeCheck(type, m_DatabaseType))
{ {
IDatabase *pdb = (IDatabase *)object; IDatabase *pdb = (IDatabase *)object;
pdb->Close(); pdb->Close();
@ -402,7 +400,7 @@ Handle_t DBManager::CreateHandle(DBHandleType dtype, void *ptr, IdentityToken_t
return BAD_HANDLE; return BAD_HANDLE;
} }
return g_HandleSys.CreateHandle(type, ptr, pToken, g_pCoreIdent, NULL); return handlesys->CreateHandle(type, ptr, pToken, g_pCoreIdent, NULL);
} }
HandleError DBManager::ReadHandle(Handle_t hndl, DBHandleType dtype, void **ptr) HandleError DBManager::ReadHandle(Handle_t hndl, DBHandleType dtype, void **ptr)
@ -420,13 +418,13 @@ HandleError DBManager::ReadHandle(Handle_t hndl, DBHandleType dtype, void **ptr)
HandleSecurity sec(NULL, g_pCoreIdent); HandleSecurity sec(NULL, g_pCoreIdent);
return g_HandleSys.ReadHandle(hndl, type, &sec, ptr); return handlesys->ReadHandle(hndl, type, &sec, ptr);
} }
HandleError DBManager::ReleaseHandle(Handle_t hndl, DBHandleType type, IdentityToken_t *token) HandleError DBManager::ReleaseHandle(Handle_t hndl, DBHandleType type, IdentityToken_t *token)
{ {
HandleSecurity sec(token, g_pCoreIdent); HandleSecurity sec(token, g_pCoreIdent);
return g_HandleSys.FreeHandle(hndl, &sec); return handlesys->FreeHandle(hndl, &sec);
} }
unsigned int DBManager::GetDriverCount() unsigned int DBManager::GetDriverCount()
@ -485,7 +483,7 @@ IDBDriver *DBManager::FindOrLoadDriver(const char *name)
char filename[PLATFORM_MAX_PATH]; char filename[PLATFORM_MAX_PATH];
UTIL_Format(filename, sizeof(filename), "dbi.%s.ext", name); UTIL_Format(filename, sizeof(filename), "dbi.%s.ext", name);
IExtension *pExt = g_Extensions.LoadAutoExtension(filename); IExtension *pExt = extsys->LoadAutoExtension(filename);
if (!pExt || !pExt->IsLoaded() || m_drivers.size() <= last_size) if (!pExt || !pExt->IsLoaded() || m_drivers.size() <= last_size)
{ {
return NULL; return NULL;
@ -729,6 +727,6 @@ const char *DBManager::GetDefaultDriverName()
void DBManager::AddDependency(IExtension *myself, IDBDriver *driver) void DBManager::AddDependency(IExtension *myself, IDBDriver *driver)
{ {
g_Extensions.AddRawDependency(myself, driver->GetIdentity(), driver); extsys->AddRawDependency(myself, driver->GetIdentity(), driver);
} }

View File

@ -40,8 +40,8 @@
#include <ITextParsers.h> #include <ITextParsers.h>
#include "sm_memtable.h" #include "sm_memtable.h"
#include <IThreader.h> #include <IThreader.h>
#include <IPluginSys.h>
#include "sm_simple_prioqueue.h" #include "sm_simple_prioqueue.h"
#include "PluginSys.h"
using namespace SourceHook; using namespace SourceHook;

View File

@ -31,9 +31,8 @@
#include "EventManager.h" #include "EventManager.h"
#include "ForwardSys.h" #include "ForwardSys.h"
#include "HandleSys.h"
#include "PluginSys.h"
#include "sm_stringutil.h" #include "sm_stringutil.h"
#include "logic_bridge.h"
EventManager g_EventManager; EventManager g_EventManager;
@ -90,7 +89,7 @@ void EventManager::OnSourceModAllInitialized()
sec.access[HandleAccess_Clone] = HANDLE_RESTRICT_IDENTITY | HANDLE_RESTRICT_OWNER; sec.access[HandleAccess_Clone] = HANDLE_RESTRICT_IDENTITY | HANDLE_RESTRICT_OWNER;
/* Create the 'GameEvent' handle type */ /* Create the 'GameEvent' handle type */
m_EventType = g_HandleSys.CreateType("GameEvent", this, 0, NULL, &sec, g_pCoreIdent, NULL); m_EventType = handlesys->CreateType("GameEvent", this, 0, NULL, &sec, g_pCoreIdent, NULL);
} }
void EventManager::OnSourceModShutdown() void EventManager::OnSourceModShutdown()
@ -100,7 +99,7 @@ void EventManager::OnSourceModShutdown()
SH_REMOVE_HOOK(IGameEventManager2, FireEvent, gameevents, SH_MEMBER(this, &EventManager::OnFireEvent_Post), true); SH_REMOVE_HOOK(IGameEventManager2, FireEvent, gameevents, SH_MEMBER(this, &EventManager::OnFireEvent_Post), true);
/* Remove the 'GameEvent' handle type */ /* Remove the 'GameEvent' handle type */
g_HandleSys.RemoveType(m_EventType, g_pCoreIdent); handlesys->RemoveType(m_EventType, g_pCoreIdent);
/* Remove ourselves as listener for events */ /* Remove ourselves as listener for events */
gameevents->RemoveListener(this); gameevents->RemoveListener(this);
@ -187,7 +186,7 @@ EventHookError EventManager::HookEvent(const char *name, IPluginFunction *pFunct
if (!sm_trie_retrieve(m_EventHooks, name, (void **)&pHook)) if (!sm_trie_retrieve(m_EventHooks, name, (void **)&pHook))
{ {
EventHookList *pHookList; EventHookList *pHookList;
IPlugin *plugin = g_PluginSys.GetPluginByCtx(pFunction->GetParentContext()->GetContext()); IPlugin *plugin = scripts->FindPluginByContext(pFunction->GetParentContext()->GetContext());
/* Check plugin for an existing EventHook list */ /* Check plugin for an existing EventHook list */
if (!plugin->GetProperty("EventHooks", (void **)&pHookList)) if (!plugin->GetProperty("EventHooks", (void **)&pHookList))
@ -300,7 +299,7 @@ EventHookError EventManager::UnhookEvent(const char *name, IPluginFunction *pFun
/* If reference count is now 0, free hook structure */ /* If reference count is now 0, free hook structure */
EventHookList *pHookList; EventHookList *pHookList;
IPlugin *plugin = g_PluginSys.GetPluginByCtx(pFunction->GetParentContext()->GetContext()); IPlugin *plugin = scripts->FindPluginByContext(pFunction->GetParentContext()->GetContext());
/* Get plugin's event hook list */ /* Get plugin's event hook list */
if (!plugin->GetProperty("EventHooks", (void**)&pHookList)) if (!plugin->GetProperty("EventHooks", (void**)&pHookList))
@ -411,7 +410,7 @@ bool EventManager::OnFireEvent(IGameEvent *pEvent, bool bDontBroadcast)
{ {
EventInfo info(pEvent, NULL); EventInfo info(pEvent, NULL);
HandleSecurity sec(NULL, g_pCoreIdent); HandleSecurity sec(NULL, g_pCoreIdent);
Handle_t hndl = g_HandleSys.CreateHandle(m_EventType, &info, NULL, g_pCoreIdent, NULL); Handle_t hndl = handlesys->CreateHandle(m_EventType, &info, NULL, g_pCoreIdent, NULL);
info.bDontBroadcast = bDontBroadcast; info.bDontBroadcast = bDontBroadcast;
@ -424,7 +423,7 @@ bool EventManager::OnFireEvent(IGameEvent *pEvent, bool bDontBroadcast)
broadcast = info.bDontBroadcast; broadcast = info.bDontBroadcast;
g_HandleSys.FreeHandle(hndl, &sec); handlesys->FreeHandle(hndl, &sec);
} }
if (pHook->postCopy) if (pHook->postCopy)
@ -476,7 +475,7 @@ bool EventManager::OnFireEvent_Post(IGameEvent *pEvent, bool bDontBroadcast)
info.bDontBroadcast = bDontBroadcast; info.bDontBroadcast = bDontBroadcast;
info.pEvent = m_EventCopies.front(); info.pEvent = m_EventCopies.front();
info.pOwner = NULL; info.pOwner = NULL;
hndl = g_HandleSys.CreateHandle(m_EventType, &info, NULL, g_pCoreIdent, NULL); hndl = handlesys->CreateHandle(m_EventType, &info, NULL, g_pCoreIdent, NULL);
pForward->PushCell(hndl); pForward->PushCell(hndl);
} else { } else {
@ -491,7 +490,7 @@ bool EventManager::OnFireEvent_Post(IGameEvent *pEvent, bool bDontBroadcast)
{ {
/* Free handle */ /* Free handle */
HandleSecurity sec(NULL, g_pCoreIdent); HandleSecurity sec(NULL, g_pCoreIdent);
g_HandleSys.FreeHandle(hndl, &sec); handlesys->FreeHandle(hndl, &sec);
/* Free event structure */ /* Free event structure */
gameevents->FreeEvent(info.pEvent); gameevents->FreeEvent(info.pEvent);

View File

@ -33,8 +33,6 @@
#include <stdarg.h> #include <stdarg.h>
#include <string.h> #include <string.h>
#include "ForwardSys.h" #include "ForwardSys.h"
#include "PluginSys.h"
#include "ShareSys.h"
#include "logic_bridge.h" #include "logic_bridge.h"
CForwardManager g_Forwards; CForwardManager g_Forwards;
@ -63,8 +61,8 @@ CForwardManager::~CForwardManager()
void CForwardManager::OnSourceModAllInitialized() void CForwardManager::OnSourceModAllInitialized()
{ {
g_PluginSys.AddPluginsListener(this); scripts->AddPluginsListener(this);
g_ShareSys.AddInterface(NULL, this); sharesys->AddInterface(NULL, this);
} }
IForward *CForwardManager::CreateForward(const char *name, ExecType et, unsigned int num_params, const ParamType *types, ...) IForward *CForwardManager::CreateForward(const char *name, ExecType et, unsigned int num_params, const ParamType *types, ...)
@ -79,7 +77,7 @@ IForward *CForwardManager::CreateForward(const char *name, ExecType et, unsigned
if (fwd) if (fwd)
{ {
g_PluginSys.AddFunctionsToForward(name, fwd); scripts->AddFunctionsToForward(name, fwd);
m_managed.push_back(fwd); m_managed.push_back(fwd);
} }

View File

@ -51,12 +51,12 @@
typedef ICommandLine *(*FakeGetCommandLine)(); typedef ICommandLine *(*FakeGetCommandLine)();
#if defined _WIN32 #if defined _WIN32
#define TIER0_NAME "tier0.dll" #define TIER0_NAME "tier0.dll"
#define VSTDLIB_NAME "vstdlib.dll" #define VSTDLIB_NAME "vstdlib.dll"
#elif defined __APPLE__ #elif defined __APPLE__
#define TIER0_NAME "libtier0.dylib" #define TIER0_NAME "libtier0.dylib"
#define VSTDLIB_NAME "libvstdlib.dylib" #define VSTDLIB_NAME "libvstdlib.dylib"
#elif defined __linux__ #elif defined __linux__
#if SOURCE_ENGINE == SE_ORANGEBOXVALVE || SOURCE_ENGINE == SE_CSS #if SOURCE_ENGINE == SE_ORANGEBOXVALVE || SOURCE_ENGINE == SE_CSS
#define TIER0_NAME "libtier0_srv.so" #define TIER0_NAME "libtier0_srv.so"
@ -67,7 +67,7 @@ typedef ICommandLine *(*FakeGetCommandLine)();
#else #else
#define TIER0_NAME "tier0_i486.so" #define TIER0_NAME "tier0_i486.so"
#define VSTDLIB_NAME "vstdlib_i486.so" #define VSTDLIB_NAME "vstdlib_i486.so"
#endif #endif
#endif #endif
CHalfLife2 g_HL2; CHalfLife2 g_HL2;
@ -157,7 +157,7 @@ void CHalfLife2::OnSourceModAllInitialized()
m_HinTextMsg = g_UserMsgs.GetMessageIndex("HintText"); m_HinTextMsg = g_UserMsgs.GetMessageIndex("HintText");
m_SayTextMsg = g_UserMsgs.GetMessageIndex("SayText"); m_SayTextMsg = g_UserMsgs.GetMessageIndex("SayText");
m_VGUIMenu = g_UserMsgs.GetMessageIndex("VGUIMenu"); m_VGUIMenu = g_UserMsgs.GetMessageIndex("VGUIMenu");
g_ShareSys.AddInterface(NULL, this); sharesys->AddInterface(NULL, this);
} }
void CHalfLife2::OnSourceModAllInitialized_Post() void CHalfLife2::OnSourceModAllInitialized_Post()
@ -241,44 +241,44 @@ void CHalfLife2::InitCommandLine()
if (!g_LibSys.IsPathFile(path)) if (!g_LibSys.IsPathFile(path))
{ {
g_Logger.LogError("Could not find path for: " TIER0_NAME); g_Logger.LogError("Could not find path for: " TIER0_NAME);
return; return;
} }
ILibrary *lib = g_LibSys.OpenLibrary(path, error, sizeof(error)); ILibrary *lib = g_LibSys.OpenLibrary(path, error, sizeof(error));
m_pGetCommandLine = lib->GetSymbolAddress("CommandLine_Tier0"); m_pGetCommandLine = lib->GetSymbolAddress("CommandLine_Tier0");
/* '_Tier0' dropped on Alien Swarm version */ /* '_Tier0' dropped on Alien Swarm version */
if (m_pGetCommandLine == NULL) if (m_pGetCommandLine == NULL)
{ {
m_pGetCommandLine = lib->GetSymbolAddress("CommandLine"); m_pGetCommandLine = lib->GetSymbolAddress("CommandLine");
} }
if (m_pGetCommandLine == NULL) if (m_pGetCommandLine == NULL)
{ {
/* We probably have a Ship engine. */ /* We probably have a Ship engine. */
lib->CloseLibrary(); lib->CloseLibrary();
g_SourceMod.BuildPath(Path_Game, path, sizeof(path), "../bin/" VSTDLIB_NAME); g_SourceMod.BuildPath(Path_Game, path, sizeof(path), "../bin/" VSTDLIB_NAME);
if (!g_LibSys.IsPathFile(path)) if (!g_LibSys.IsPathFile(path))
{ {
g_Logger.LogError("Could not find path for: " VSTDLIB_NAME); g_Logger.LogError("Could not find path for: " VSTDLIB_NAME);
return; return;
} }
if ((lib = g_LibSys.OpenLibrary(path, error, sizeof(error))) == NULL) if ((lib = g_LibSys.OpenLibrary(path, error, sizeof(error))) == NULL)
{ {
g_Logger.LogError("Could not load %s: %s", path, error); g_Logger.LogError("Could not load %s: %s", path, error);
return; return;
} }
m_pGetCommandLine = lib->GetSymbolAddress("CommandLine"); m_pGetCommandLine = lib->GetSymbolAddress("CommandLine");
if (m_pGetCommandLine == NULL) if (m_pGetCommandLine == NULL)
{ {
g_Logger.LogError("Could not locate any command line functionality"); g_Logger.LogError("Could not locate any command line functionality");
} }
lib->CloseLibrary(); lib->CloseLibrary();
} }
} }

View File

@ -544,13 +544,20 @@ void Logger::DisableLogging()
} }
void Logger::LogFatal(const char *msg, ...) void Logger::LogFatal(const char *msg, ...)
{
va_list ap;
va_start(ap, msg);
LogFatalEx(msg, ap);
va_end(ap);
}
void Logger::LogFatalEx(const char *msg, va_list ap)
{ {
/* :TODO: make this print all pretty-like /* :TODO: make this print all pretty-like
* In fact, the pretty log printing function should be abstracted. * In fact, the pretty log printing function should be abstracted.
* It's already implemented twice which is bad. * It's already implemented twice which is bad.
*/ */
va_list ap;
char path[PLATFORM_MAX_PATH]; char path[PLATFORM_MAX_PATH];
g_SourceMod.BuildPath(Path_Game, path, sizeof(path), "sourcemod_fatal.log"); g_SourceMod.BuildPath(Path_Game, path, sizeof(path), "sourcemod_fatal.log");
@ -559,9 +566,7 @@ void Logger::LogFatal(const char *msg, ...)
if (fp) if (fp)
{ {
m_Active = true; m_Active = true;
va_start(ap, msg);
LogToOpenFileEx(fp, msg, ap); LogToOpenFileEx(fp, msg, ap);
va_end(ap);
m_Active = false; m_Active = false;
fclose(fp); fclose(fp);
} }

View File

@ -78,6 +78,7 @@ public:
void LogError(const char *msg, ...); void LogError(const char *msg, ...);
void LogErrorEx(const char *msg, va_list ap); void LogErrorEx(const char *msg, va_list ap);
void LogFatal(const char *msg, ...); void LogFatal(const char *msg, ...);
void LogFatalEx(const char *msg, va_list ap);
void LogToOpenFile(FILE *fp, const char *msg, ...); void LogToOpenFile(FILE *fp, const char *msg, ...);
void LogToOpenFileEx(FILE *fp, const char *msg, va_list ap); void LogToOpenFileEx(FILE *fp, const char *msg, va_list ap);
/* This version does not print to console, and is thus thread-safe */ /* This version does not print to console, and is thus thread-safe */

View File

@ -38,8 +38,6 @@
#include "sourcemm_api.h" #include "sourcemm_api.h"
#include "PlayerManager.h" #include "PlayerManager.h"
#include "MenuStyle_Valve.h" #include "MenuStyle_Valve.h"
#include "ShareSys.h"
#include "HandleSys.h"
#include "sourcemm_api.h" #include "sourcemm_api.h"
#include "logic_bridge.h" #include "logic_bridge.h"
@ -56,24 +54,24 @@ MenuManager::MenuManager()
void MenuManager::OnSourceModAllInitialized() void MenuManager::OnSourceModAllInitialized()
{ {
g_ShareSys.AddInterface(NULL, this); sharesys->AddInterface(NULL, this);
HandleAccess access; HandleAccess access;
g_HandleSys.InitAccessDefaults(NULL, &access); handlesys->InitAccessDefaults(NULL, &access);
/* Deny cloning to menus */ /* Deny cloning to menus */
access.access[HandleAccess_Clone] = HANDLE_RESTRICT_OWNER|HANDLE_RESTRICT_IDENTITY; access.access[HandleAccess_Clone] = HANDLE_RESTRICT_OWNER|HANDLE_RESTRICT_IDENTITY;
m_MenuType = g_HandleSys.CreateType("IBaseMenu", this, 0, NULL, &access, g_pCoreIdent, NULL); m_MenuType = handlesys->CreateType("IBaseMenu", this, 0, NULL, &access, g_pCoreIdent, NULL);
/* Also deny deletion to styles */ /* Also deny deletion to styles */
access.access[HandleAccess_Delete] = HANDLE_RESTRICT_OWNER|HANDLE_RESTRICT_IDENTITY; access.access[HandleAccess_Delete] = HANDLE_RESTRICT_OWNER|HANDLE_RESTRICT_IDENTITY;
m_StyleType = g_HandleSys.CreateType("IMenuStyle", this, 0, NULL, &access, g_pCoreIdent, NULL); m_StyleType = handlesys->CreateType("IMenuStyle", this, 0, NULL, &access, g_pCoreIdent, NULL);
} }
void MenuManager::OnSourceModAllShutdown() void MenuManager::OnSourceModAllShutdown()
{ {
g_HandleSys.RemoveType(m_MenuType, g_pCoreIdent); handlesys->RemoveType(m_MenuType, g_pCoreIdent);
g_HandleSys.RemoveType(m_StyleType, g_pCoreIdent); handlesys->RemoveType(m_StyleType, g_pCoreIdent);
} }
void MenuManager::OnHandleDestroy(HandleType_t type, void *object) void MenuManager::OnHandleDestroy(HandleType_t type, void *object)
@ -112,7 +110,7 @@ Handle_t MenuManager::CreateMenuHandle(IBaseMenu *menu, IdentityToken_t *pOwner)
return BAD_HANDLE; return BAD_HANDLE;
} }
return g_HandleSys.CreateHandle(m_MenuType, menu, pOwner, g_pCoreIdent, NULL); return handlesys->CreateHandle(m_MenuType, menu, pOwner, g_pCoreIdent, NULL);
} }
Handle_t MenuManager::CreateStyleHandle(IMenuStyle *style) Handle_t MenuManager::CreateStyleHandle(IMenuStyle *style)
@ -122,7 +120,7 @@ Handle_t MenuManager::CreateStyleHandle(IMenuStyle *style)
return BAD_HANDLE; return BAD_HANDLE;
} }
return g_HandleSys.CreateHandle(m_StyleType, style, g_pCoreIdent, g_pCoreIdent, NULL); return handlesys->CreateHandle(m_StyleType, style, g_pCoreIdent, g_pCoreIdent, NULL);
} }
HandleError MenuManager::ReadMenuHandle(Handle_t handle, IBaseMenu **menu) HandleError MenuManager::ReadMenuHandle(Handle_t handle, IBaseMenu **menu)
@ -132,7 +130,7 @@ HandleError MenuManager::ReadMenuHandle(Handle_t handle, IBaseMenu **menu)
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
sec.pOwner = NULL; sec.pOwner = NULL;
return g_HandleSys.ReadHandle(handle, m_MenuType, &sec, (void **)menu); return handlesys->ReadHandle(handle, m_MenuType, &sec, (void **)menu);
} }
HandleError MenuManager::ReadStyleHandle(Handle_t handle, IMenuStyle **style) HandleError MenuManager::ReadStyleHandle(Handle_t handle, IMenuStyle **style)
@ -142,7 +140,7 @@ HandleError MenuManager::ReadStyleHandle(Handle_t handle, IMenuStyle **style)
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
sec.pOwner = g_pCoreIdent; sec.pOwner = g_pCoreIdent;
return g_HandleSys.ReadHandle(handle, m_StyleType, &sec, (void **)style); return handlesys->ReadHandle(handle, m_StyleType, &sec, (void **)style);
} }
bool MenuManager::SetDefaultStyle(IMenuStyle *style) bool MenuManager::SetDefaultStyle(IMenuStyle *style)

View File

@ -34,11 +34,12 @@
#include "MenuStyle_Base.h" #include "MenuStyle_Base.h"
#include "PlayerManager.h" #include "PlayerManager.h"
#include "MenuManager.h" #include "MenuManager.h"
#include "HandleSys.h"
#include "CellRecipientFilter.h" #include "CellRecipientFilter.h"
#if defined MENU_DEBUG #if defined MENU_DEBUG
#include "Logger.h" #include "Logger.h"
#endif #endif
#include "logic_bridge.h"
#include "AutoHandleRooter.h"
BaseMenuStyle::BaseMenuStyle() : m_WatchList(256), m_hHandle(BAD_HANDLE) BaseMenuStyle::BaseMenuStyle() : m_WatchList(256), m_hHandle(BAD_HANDLE)
{ {
@ -818,7 +819,7 @@ void CBaseMenu::InternalDelete()
m_hHandle = BAD_HANDLE; m_hHandle = BAD_HANDLE;
m_bDeleting = true; m_bDeleting = true;
g_HandleSys.FreeHandle(hndl, &sec); handlesys->FreeHandle(hndl, &sec);
} }
m_pHandler->OnMenuDestroy(this); m_pHandler->OnMenuDestroy(this);

View File

@ -31,7 +31,6 @@
#include "PlayerManager.h" #include "PlayerManager.h"
#include "ForwardSys.h" #include "ForwardSys.h"
#include "ShareSys.h"
#include "AdminCache.h" #include "AdminCache.h"
#include "ConCmdManager.h" #include "ConCmdManager.h"
#include "MenuStyle_Valve.h" #include "MenuStyle_Valve.h"
@ -45,7 +44,6 @@
#include <inetchannel.h> #include <inetchannel.h>
#include <iclient.h> #include <iclient.h>
#include <IGameConfigs.h> #include <IGameConfigs.h>
#include "ExtensionSys.h"
#include <sourcemod_version.h> #include <sourcemod_version.h>
#include "ConsoleDetours.h" #include "ConsoleDetours.h"
#include "logic_bridge.h" #include "logic_bridge.h"
@ -141,7 +139,7 @@ void PlayerManager::OnSourceModAllInitialized()
SH_ADD_HOOK(IServerGameClients, ClientSettingsChanged, serverClients, SH_MEMBER(this, &PlayerManager::OnClientSettingsChanged), true); SH_ADD_HOOK(IServerGameClients, ClientSettingsChanged, serverClients, SH_MEMBER(this, &PlayerManager::OnClientSettingsChanged), true);
SH_ADD_HOOK(IServerGameDLL, ServerActivate, gamedll, SH_MEMBER(this, &PlayerManager::OnServerActivate), true); SH_ADD_HOOK(IServerGameDLL, ServerActivate, gamedll, SH_MEMBER(this, &PlayerManager::OnServerActivate), true);
g_ShareSys.AddInterface(NULL, this); sharesys->AddInterface(NULL, this);
ParamType p1[] = {Param_Cell, Param_String, Param_Cell}; ParamType p1[] = {Param_Cell, Param_String, Param_Cell};
ParamType p2[] = {Param_Cell}; ParamType p2[] = {Param_Cell};
@ -278,11 +276,11 @@ void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int cl
g_NumPlayersToAuth = &m_AuthQueue[0]; g_NumPlayersToAuth = &m_AuthQueue[0];
} }
g_PluginSys.SyncMaxClients(m_maxClients); scripts->SyncMaxClients(m_maxClients);
g_OnMapStarted = true; g_OnMapStarted = true;
g_Extensions.CallOnCoreMapStart(pEdictList, edictCount, m_maxClients); extsys->CallOnCoreMapStart(pEdictList, edictCount, m_maxClients);
m_onActivate->Execute(NULL); m_onActivate->Execute(NULL);
m_onActivate2->Execute(NULL); m_onActivate2->Execute(NULL);
@ -779,6 +777,173 @@ void ClientConsolePrint(edict_t *e, const char *fmt, ...)
engine->ClientPrintf(e, buffer); engine->ClientPrintf(e, buffer);
} }
void ListExtensionsToClient(CPlayer *player, const CCommand &args)
{
char buffer[256];
unsigned int id = 0;
unsigned int start = 0;
CVector<IExtension *> extensions;
extsys->ListExtensions(&extensions);
if (!extensions.size())
{
ClientConsolePrint(player->GetEdict(), "[SM] No extensions found.");
return;
}
if (args.ArgC() > 2)
{
start = atoi(args.Arg(2));
}
SourceHook::CVector<IExtension *>::iterator iter;
for (iter = extensions.begin();
iter != extensions.end();
iter++)
{
IExtension *ext = (*iter);
char error[255];
if (!ext->IsRunning(error, sizeof(error)))
{
continue;
}
id++;
if (id < start)
{
continue;
}
if (id - start > 10)
{
break;
}
IExtensionInterface *api = ext->GetAPI();
const char *name = api->GetExtensionName();
const char *version = api->GetExtensionVerString();
const char *author = api->GetExtensionAuthor();
const char *description = api->GetExtensionDescription();
size_t len = UTIL_Format(buffer, sizeof(buffer), " \"%s\"", name);
if (version != NULL && version[0])
{
len += UTIL_Format(&buffer[len], sizeof(buffer)-len, " (%s)", version);
}
if (author != NULL && author[0])
{
len += UTIL_Format(&buffer[len], sizeof(buffer)-len, " by %s", author);
}
if (description != NULL && description[0])
{
len += UTIL_Format(&buffer[len], sizeof(buffer)-len, ": %s", description);
}
ClientConsolePrint(player->GetEdict(), "%s", buffer);
}
for (; iter != extensions.end(); iter++)
{
char error[255];
if ((*iter)->IsRunning(error, sizeof(error)))
{
break;
}
}
if (iter != extensions.end())
{
ClientConsolePrint(player->GetEdict(), "To see more, type \"sm exts %d\"", id);
}
}
void ListPluginsToClient(CPlayer *player, const CCommand &args)
{
char buffer[256];
unsigned int id = 0;
edict_t *e = player->GetEdict();
unsigned int start = 0;
CVector<SMPlugin *> plugins;
scripts->ListPlugins(&plugins);
if (!plugins.size())
{
ClientConsolePrint(e, "[SM] No plugins found.");
return;
}
if (args.ArgC() > 2)
{
start = atoi(args.Arg(2));
}
SourceHook::List<SMPlugin *> m_FailList;
CVector<SMPlugin *>::iterator iter = plugins.begin();
for (; iter != plugins.end(); iter++)
{
SMPlugin *pl = *iter;
if (pl->GetStatus() != Plugin_Running)
{
continue;
}
/* Count valid plugins */
id++;
if (id < start)
{
continue;
}
if (id - start > 10)
{
break;
}
size_t len;
const sm_plugininfo_t *info = pl->GetPublicInfo();
len = UTIL_Format(buffer, sizeof(buffer), " \"%s\"", (IS_STR_FILLED(info->name)) ? info->name : pl->GetFilename());
if (IS_STR_FILLED(info->version))
{
len += UTIL_Format(&buffer[len], sizeof(buffer)-len, " (%s)", info->version);
}
if (IS_STR_FILLED(info->author))
{
UTIL_Format(&buffer[len], sizeof(buffer)-len, " by %s", info->author);
}
else
{
UTIL_Format(&buffer[len], sizeof(buffer)-len, " %s", pl->GetFilename());
}
ClientConsolePrint(e, "%s", buffer);
}
/* See if we can get more plugins */
for (; iter != plugins.end(); iter++)
{
if ((*iter)->GetStatus() == Plugin_Running)
{
break;
}
}
/* Do we actually have more plugins? */
if (iter != plugins.end())
{
ClientConsolePrint(e, "To see more, type \"sm plugins %d\"", id);
}
}
#if SOURCE_ENGINE >= SE_ORANGEBOX #if SOURCE_ENGINE >= SE_ORANGEBOX
void PlayerManager::OnClientCommand(edict_t *pEntity, const CCommand &args) void PlayerManager::OnClientCommand(edict_t *pEntity, const CCommand &args)
{ {
@ -800,12 +965,12 @@ void PlayerManager::OnClientCommand(edict_t *pEntity)
{ {
if (args.ArgC() > 1 && strcmp(args.Arg(1), "plugins") == 0) if (args.ArgC() > 1 && strcmp(args.Arg(1), "plugins") == 0)
{ {
g_PluginSys.ListPluginsToClient(pPlayer, args); ListPluginsToClient(pPlayer, args);
RETURN_META(MRES_SUPERCEDE); RETURN_META(MRES_SUPERCEDE);
} }
else if (args.ArgC() > 1 && strcmp(args.Arg(1), "exts") == 0) else if (args.ArgC() > 1 && strcmp(args.Arg(1), "exts") == 0)
{ {
g_Extensions.ListExtensionsToClient(pPlayer, args); ListExtensionsToClient(pPlayer, args);
RETURN_META(MRES_SUPERCEDE); RETURN_META(MRES_SUPERCEDE);
} }
else if (args.ArgC() > 1 && strcmp(args.Arg(1), "credits") == 0) else if (args.ArgC() > 1 && strcmp(args.Arg(1), "credits") == 0)
@ -1641,9 +1806,9 @@ void CPlayer::SetAuthString(const char *steamid)
m_AuthID.assign(steamid); m_AuthID.assign(steamid);
} }
// Ensure a valid AuthString is set before calling. // Ensure a valid AuthString is set before calling.
void CPlayer::Authorize() void CPlayer::Authorize()
{ {
m_IsAuthorized = true; m_IsAuthorized = true;
} }
@ -1690,9 +1855,9 @@ const char *CPlayer::GetIPAddress()
const char *CPlayer::GetAuthString(bool validated) const char *CPlayer::GetAuthString(bool validated)
{ {
if (validated && !IsAuthStringValidated()) if (validated && !IsAuthStringValidated())
{ {
return NULL; return NULL;
} }
return m_AuthID.c_str(); return m_AuthID.c_str();
@ -1752,15 +1917,15 @@ bool CPlayer::IsAuthorized()
return m_IsAuthorized; return m_IsAuthorized;
} }
bool CPlayer::IsAuthStringValidated() bool CPlayer::IsAuthStringValidated()
{ {
#if SOURCE_ENGINE >= SE_ORANGEBOX #if SOURCE_ENGINE >= SE_ORANGEBOX
if (g_Players.m_bAuthstringValidation && !g_HL2.IsLANServer()) if (g_Players.m_bAuthstringValidation && !g_HL2.IsLANServer())
{ {
return engine->IsClientFullyAuthenticated(m_pEdict); return engine->IsClientFullyAuthenticated(m_pEdict);
} }
#endif #endif
return true; return true;
} }

View File

@ -35,6 +35,7 @@
#include "sourcemm_api.h" #include "sourcemm_api.h"
#include "frame_hooks.h" #include "frame_hooks.h"
#include "ConVarManager.h" #include "ConVarManager.h"
#include "logic_bridge.h"
#define TIMER_MIN_ACCURACY 0.1 #define TIMER_MIN_ACCURACY 0.1
@ -180,7 +181,7 @@ TimerSystem::~TimerSystem()
void TimerSystem::OnSourceModAllInitialized() void TimerSystem::OnSourceModAllInitialized()
{ {
g_ShareSys.AddInterface(NULL, this); sharesys->AddInterface(NULL, this);
m_pOnGameFrame = g_Forwards.CreateForward("OnGameFrame", ET_Ignore, 0, NULL); m_pOnGameFrame = g_Forwards.CreateForward("OnGameFrame", ET_Ignore, 0, NULL);
m_pOnMapTimeLeftChanged = g_Forwards.CreateForward("OnMapTimeLeftChanged", ET_Ignore, 0, NULL); m_pOnMapTimeLeftChanged = g_Forwards.CreateForward("OnMapTimeLeftChanged", ET_Ignore, 0, NULL);
} }

View File

@ -32,11 +32,11 @@
#ifndef _INCLUDE_SOURCEMOD_CTIMERSYS_H_ #ifndef _INCLUDE_SOURCEMOD_CTIMERSYS_H_
#define _INCLUDE_SOURCEMOD_CTIMERSYS_H_ #define _INCLUDE_SOURCEMOD_CTIMERSYS_H_
#include "ShareSys.h"
#include <ITimerSystem.h> #include <ITimerSystem.h>
#include <sh_stack.h> #include <sh_stack.h>
#include <sh_list.h> #include <sh_list.h>
#include "sourcemm_api.h" #include "sourcemm_api.h"
#include "sm_globals.h"
using namespace SourceHook; using namespace SourceHook;
using namespace SourceMod; using namespace SourceMod;

View File

@ -31,6 +31,7 @@
#include "UserMessages.h" #include "UserMessages.h"
#include "sm_stringutil.h" #include "sm_stringutil.h"
#include "logic_bridge.h"
#if SOURCE_ENGINE == SE_DOTA #if SOURCE_ENGINE == SE_DOTA
#include <dota_usermessage_helpers.h> #include <dota_usermessage_helpers.h>
@ -91,7 +92,7 @@ void UserMessages::OnSourceModStartup(bool late)
void UserMessages::OnSourceModAllInitialized() void UserMessages::OnSourceModAllInitialized()
{ {
g_ShareSys.AddInterface(NULL, this); sharesys->AddInterface(NULL, this);
} }
void UserMessages::OnSourceModAllShutdown() void UserMessages::OnSourceModAllShutdown()

View File

@ -32,12 +32,14 @@
#ifndef _INCLUDE_SOURCEMOD_CUSERMESSAGES_H_ #ifndef _INCLUDE_SOURCEMOD_CUSERMESSAGES_H_
#define _INCLUDE_SOURCEMOD_CUSERMESSAGES_H_ #define _INCLUDE_SOURCEMOD_CUSERMESSAGES_H_
#include "ShareSys.h"
#include <IUserMessages.h> #include <IUserMessages.h>
#include "sourcemm_api.h" #include "sourcemm_api.h"
#include "sm_trie.h" #include "sm_trie.h"
#include "sm_stringutil.h" #include "sm_stringutil.h"
#include "CellRecipientFilter.h" #include "CellRecipientFilter.h"
#include "sm_globals.h"
#include <sh_list.h>
#include <sh_stack.h>
using namespace SourceHook; using namespace SourceHook;
using namespace SourceMod; using namespace SourceMod;

View File

@ -38,6 +38,7 @@
#include "CoreConfig.h" #include "CoreConfig.h"
#include <sm_queue.h> #include <sm_queue.h>
#include <IThreader.h> #include <IThreader.h>
#include "sourcemod.h"
static IMutex *frame_mutex; static IMutex *frame_mutex;
static Queue<FrameAction> *frame_queue; static Queue<FrameAction> *frame_queue;

View File

@ -47,9 +47,16 @@ files = [
'smn_handles.cpp', 'smn_handles.cpp',
'smn_datapacks.cpp', 'smn_datapacks.cpp',
'smn_gameconfigs.cpp', 'smn_gameconfigs.cpp',
'smn_fakenatives.cpp',
'GameConfigs.cpp', 'GameConfigs.cpp',
'sm_crc32.cpp', 'sm_crc32.cpp',
'smn_profiler.cpp', 'smn_profiler.cpp',
'ShareSys.cpp',
'PluginSys.cpp',
'HandleSys.cpp',
'NativeOwner.cpp',
'NativeInvoker.cpp',
'ExtensionSys.cpp',
'DebugReporter.cpp' 'DebugReporter.cpp'
] ]
if AMBuild.target['platform'] == 'windows': if AMBuild.target['platform'] == 'windows':

View File

@ -31,13 +31,10 @@
#include <stdlib.h> #include <stdlib.h>
#include "ExtensionSys.h" #include "ExtensionSys.h"
#include "LibrarySys.h" #include <ILibrarySys.h>
#include "ShareSys.h" #include <ISourceMod.h>
#include "Logger.h" #include "common_logic.h"
#include "sourcemm_api.h" #include "PluginSys.h"
#include "sm_srvcmds.h"
#include "sm_stringutil.h"
#include "PlayerManager.h"
CExtensionManager g_Extensions; CExtensionManager g_Extensions;
IdentityType_t g_ExtType; IdentityType_t g_ExtType;
@ -51,7 +48,7 @@ void CExtension::Initialize(const char *filename, const char *path)
m_File.assign(filename); m_File.assign(filename);
m_Path.assign(path); m_Path.assign(path);
char real_name[PLATFORM_MAX_PATH]; char real_name[PLATFORM_MAX_PATH];
g_LibSys.GetFileFromPath(real_name, sizeof(real_name), m_Path.c_str()); libsys->GetFileFromPath(real_name, sizeof(real_name), m_Path.c_str());
m_RealFile.assign(real_name); m_RealFile.assign(real_name);
} }
@ -107,29 +104,29 @@ CLocalExtension::CLocalExtension(const char *filename)
} }
/* Zeroth, see if there is an engine specific build in the new place. */ /* Zeroth, see if there is an engine specific build in the new place. */
g_SourceMod.BuildPath(Path_SM, g_pSM->BuildPath(Path_SM,
path, path,
PLATFORM_MAX_PATH, PLATFORM_MAX_PATH,
"extensions/%s." GAMEFIX "." PLATFORM_LIB_EXT, "extensions/%s." GAMEFIX "." PLATFORM_LIB_EXT,
filename); filename);
if (g_LibSys.IsPathFile(path)) if (libsys->IsPathFile(path))
{ {
goto found; goto found;
} }
/* First see if there is an engine specific build! */ /* First see if there is an engine specific build! */
g_SourceMod.BuildPath(Path_SM, g_pSM->BuildPath(Path_SM,
path, path,
PLATFORM_MAX_PATH, PLATFORM_MAX_PATH,
"extensions/auto." GAMEFIX "/%s." PLATFORM_LIB_EXT, "extensions/auto." GAMEFIX "/%s." PLATFORM_LIB_EXT,
filename); filename);
/* Try the "normal" version */ /* Try the "normal" version */
if (!g_LibSys.IsPathFile(path)) if (!libsys->IsPathFile(path))
{ {
normal: normal:
g_SourceMod.BuildPath(Path_SM, g_pSM->BuildPath(Path_SM,
path, path,
PLATFORM_MAX_PATH, PLATFORM_MAX_PATH,
"extensions/%s." PLATFORM_LIB_EXT, "extensions/%s." PLATFORM_LIB_EXT,
@ -159,7 +156,7 @@ bool CRemoteExtension::Load(char *error, size_t maxlength)
bool CLocalExtension::Load(char *error, size_t maxlength) bool CLocalExtension::Load(char *error, size_t maxlength)
{ {
m_pLib = g_LibSys.OpenLibrary(m_Path.c_str(), error, maxlength); m_pLib = libsys->OpenLibrary(m_Path.c_str(), error, maxlength);
if (m_pLib == NULL) if (m_pLib == NULL)
{ {
@ -191,24 +188,10 @@ bool CLocalExtension::Load(char *error, size_t maxlength)
/* Load as MM:S */ /* Load as MM:S */
if (m_pAPI->IsMetamodExtension()) if (m_pAPI->IsMetamodExtension())
{ {
bool already; bool ok;
m_PlId = g_pMMPlugins->Load(m_Path.c_str(), g_PLID, already, error, maxlength); m_PlId = smcore.LoadMMSPlugin(m_Path.c_str(), &ok, error, maxlength);
// Check the plugin didn't refuse load if (!m_PlId || !ok)
Pl_Status status;
#ifndef METAMOD_PLAPI_VERSION
const char *file;
PluginId source;
#endif
if (!m_PlId || (
#ifndef METAMOD_PLAPI_VERSION
g_pMMPlugins->Query(m_PlId, file, status, source)
#else
g_pMMPlugins->Query(m_PlId, NULL, &status, NULL)
#endif
&& status < Pl_Paused))
{ {
m_pLib->CloseLibrary(); m_pLib->CloseLibrary();
m_pLib = NULL; m_pLib = NULL;
@ -223,8 +206,7 @@ bool CLocalExtension::Load(char *error, size_t maxlength)
{ {
if (m_PlId) if (m_PlId)
{ {
char dummy[255]; smcore.UnloadMMSPlugin(m_PlId);
g_pMMPlugins->Unload(m_PlId, true, dummy, sizeof(dummy));
m_PlId = 0; m_PlId = 0;
} }
} }
@ -245,8 +227,7 @@ void CLocalExtension::Unload()
{ {
if (m_pAPI != NULL && m_PlId) if (m_pAPI != NULL && m_PlId)
{ {
char temp_buffer[255]; smcore.UnloadMMSPlugin(m_PlId);
g_pMMPlugins->Unload(m_PlId, true, temp_buffer, sizeof(temp_buffer));
m_PlId = 0; m_PlId = 0;
} }
@ -309,7 +290,7 @@ bool CExtension::PerformAPICheck(char *error, size_t maxlength)
bool CExtension::Load(char *error, size_t maxlength) bool CExtension::Load(char *error, size_t maxlength)
{ {
CreateIdentity(); CreateIdentity();
if (!m_pAPI->OnExtensionLoad(this, &g_ShareSys, error, maxlength, !g_SourceMod.IsMapLoading())) if (!m_pAPI->OnExtensionLoad(this, &g_ShareSys, error, maxlength, !smcore.IsMapLoading()))
{ {
DestroyIdentity(); DestroyIdentity();
return false; return false;
@ -317,7 +298,7 @@ bool CExtension::Load(char *error, size_t maxlength)
else else
{ {
/* Check if we're past load time */ /* Check if we're past load time */
if (!g_SourceMod.IsMapLoading()) if (!smcore.IsMapLoading())
{ {
m_pAPI->OnExtensionsAllLoaded(); m_pAPI->OnExtensionsAllLoaded();
} }
@ -527,14 +508,13 @@ void CExtension::AddLibrary(const char *library)
void CExtensionManager::OnSourceModAllInitialized() void CExtensionManager::OnSourceModAllInitialized()
{ {
g_ExtType = g_ShareSys.CreateIdentType("EXTENSION"); g_ExtType = g_ShareSys.CreateIdentType("EXTENSION");
g_PluginSys.AddPluginsListener(this); pluginsys->AddPluginsListener(this);
g_RootMenu.AddRootConsoleCommand("exts", "Manage extensions", this);
g_ShareSys.AddInterface(NULL, this); g_ShareSys.AddInterface(NULL, this);
} }
void CExtensionManager::OnSourceModShutdown() void CExtensionManager::OnSourceModShutdown()
{ {
g_RootMenu.RemoveRootConsoleCommand("exts", this); pluginsys->RemovePluginsListener(this);
g_ShareSys.DestroyIdentType(g_ExtType); g_ShareSys.DestroyIdentType(g_ExtType);
} }
@ -552,9 +532,9 @@ void CExtensionManager::TryAutoload()
{ {
char path[PLATFORM_MAX_PATH]; char path[PLATFORM_MAX_PATH];
g_SourceMod.BuildPath(Path_SM, path, sizeof(path), "extensions"); g_pSM->BuildPath(Path_SM, path, sizeof(path), "extensions");
IDirectory *pDir = g_LibSys.OpenDirectory(path); IDirectory *pDir = libsys->OpenDirectory(path);
if (!pDir) if (!pDir)
{ {
return; return;
@ -585,7 +565,7 @@ void CExtensionManager::TryAutoload()
} }
char file[PLATFORM_MAX_PATH]; char file[PLATFORM_MAX_PATH];
len = UTIL_Format(file, sizeof(file), "%s", lfile); len = smcore.Format(file, sizeof(file), "%s", lfile);
strcpy(&file[len - 9], ".ext"); strcpy(&file[len - 9], ".ext");
LoadAutoExtension(file); LoadAutoExtension(file);
@ -594,16 +574,16 @@ void CExtensionManager::TryAutoload()
} }
} }
IExtension *CExtensionManager::LoadAutoExtension(const char *path, bool bErrorOnMissing) IExtension *CExtensionManager::LoadAutoExtension(const char *path)
{ {
/* Remove platform extension if it's there. Compat hack. */ /* Remove platform extension if it's there. Compat hack. */
const char *ext = g_LibSys.GetFileExtension(path); const char *ext = libsys->GetFileExtension(path);
if (strcmp(ext, PLATFORM_LIB_EXT) == 0) if (strcmp(ext, PLATFORM_LIB_EXT) == 0)
{ {
char path2[PLATFORM_MAX_PATH]; char path2[PLATFORM_MAX_PATH];
UTIL_Format(path2, sizeof(path2), "%s", path); smcore.Format(path2, sizeof(path2), "%s", path);
path2[strlen(path) - strlen(PLATFORM_LIB_EXT) - 1] = '\0'; path2[strlen(path) - strlen(PLATFORM_LIB_EXT) - 1] = '\0';
return LoadAutoExtension(path2, bErrorOnMissing); return LoadAutoExtension(path);
} }
IExtension *pAlready; IExtension *pAlready;
@ -622,11 +602,7 @@ IExtension *CExtensionManager::LoadAutoExtension(const char *path, bool bErrorOn
if (!p->Load(error, sizeof(error)) || !p->IsLoaded()) if (!p->Load(error, sizeof(error)) || !p->IsLoaded())
{ {
if (bErrorOnMissing || g_LibSys.IsPathFile(p->GetPath())) smcore.LogError("[SM] Unable to load extension \"%s\": %s", path, error);
{
g_Logger.LogError("[SM] Unable to load extension \"%s\": %s", path, error);
}
p->SetError(error); p->SetError(error);
} }
@ -640,7 +616,7 @@ IExtension *CExtensionManager::FindExtensionByFile(const char *file)
/* Chomp off the path */ /* Chomp off the path */
char lookup[PLATFORM_MAX_PATH]; char lookup[PLATFORM_MAX_PATH];
g_LibSys.GetFileFromPath(lookup, sizeof(lookup), file); libsys->GetFileFromPath(lookup, sizeof(lookup), file);
for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++) for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
{ {
@ -689,11 +665,11 @@ IExtension *CExtensionManager::FindExtensionByName(const char *ext)
IExtension *CExtensionManager::LoadExtension(const char *file, char *error, size_t maxlength) IExtension *CExtensionManager::LoadExtension(const char *file, char *error, size_t maxlength)
{ {
/* Remove platform extension if it's there. Compat hack. */ /* Remove platform extension if it's there. Compat hack. */
const char *ext = g_LibSys.GetFileExtension(file); const char *ext = libsys->GetFileExtension(file);
if (strcmp(ext, PLATFORM_LIB_EXT) == 0) if (strcmp(ext, PLATFORM_LIB_EXT) == 0)
{ {
char path2[PLATFORM_MAX_PATH]; char path2[PLATFORM_MAX_PATH];
UTIL_Format(path2, sizeof(path2), "%s", file); smcore.Format(path2, sizeof(path2), "%s", file);
path2[strlen(file) - strlen(PLATFORM_LIB_EXT) - 1] = '\0'; path2[strlen(file) - strlen(PLATFORM_LIB_EXT) - 1] = '\0';
return LoadExtension(path2, error, maxlength); return LoadExtension(path2, error, maxlength);
} }
@ -755,11 +731,11 @@ void CExtensionManager::AddInterface(IExtension *pOwner, SMInterface *pInterface
pExt->AddInterface(pInterface); pExt->AddInterface(pInterface);
} }
void CExtensionManager::BindChildPlugin( IExtension *pParent, CPlugin *pPlugin ) void CExtensionManager::BindChildPlugin(IExtension *pParent, SMPlugin *pPlugin)
{ {
CExtension *pExt = (CExtension *)pParent; CExtension *pExt = (CExtension *)pParent;
pExt->AddPlugin(pPlugin); pExt->AddPlugin(static_cast<CPlugin *>(pPlugin));
} }
void CExtensionManager::OnPluginDestroyed(IPlugin *plugin) void CExtensionManager::OnPluginDestroyed(IPlugin *plugin)
@ -768,7 +744,7 @@ void CExtensionManager::OnPluginDestroyed(IPlugin *plugin)
for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++) for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
{ {
(*iter)->DropRefsTo((CPlugin *)plugin); (*iter)->DropRefsTo(static_cast<CPlugin *>(plugin));
} }
} }
@ -828,7 +804,7 @@ bool CExtensionManager::UnloadExtension(IExtension *_pExt)
while (p_iter != pExt->m_Dependents.end()) while (p_iter != pExt->m_Dependents.end())
{ {
/* We have to manually unlink ourselves here, since we're no longer being managed */ /* We have to manually unlink ourselves here, since we're no longer being managed */
g_PluginSys.UnloadPlugin((*p_iter)); scripts->UnloadPlugin((*p_iter));
p_iter = pExt->m_Dependents.erase(p_iter); p_iter = pExt->m_Dependents.erase(p_iter);
} }
@ -837,7 +813,7 @@ bool CExtensionManager::UnloadExtension(IExtension *_pExt)
s_iter != pExt->m_Libraries.end(); s_iter != pExt->m_Libraries.end();
s_iter++) s_iter++)
{ {
g_PluginSys.OnLibraryAction((*s_iter).c_str(), LibraryAction_Removed); scripts->OnLibraryAction((*s_iter).c_str(), LibraryAction_Removed);
} }
/* Notify and/or unload all dependencies */ /* Notify and/or unload all dependencies */
@ -955,10 +931,10 @@ void CExtensionManager::AddDependency(IExtension *pSource, const char *file, boo
void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const CCommand &command) void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const CCommand &command)
{ {
int argcount = command.ArgC(); int argcount = smcore.Argc(command);
if (argcount >= 3) if (argcount >= 3)
{ {
const char *cmd = command.Arg(2); const char *cmd = smcore.Arg(command, 2);
if (strcmp(cmd, "list") == 0) if (strcmp(cmd, "list") == 0)
{ {
List<CExtension *>::iterator iter; List<CExtension *>::iterator iter;
@ -968,17 +944,17 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const CCommand
{ {
case 1: case 1:
{ {
g_RootMenu.ConsolePrint("[SM] Displaying 1 extension:"); rootmenu->ConsolePrint("[SM] Displaying 1 extension:");
break; break;
} }
case 0: case 0:
{ {
g_RootMenu.ConsolePrint("[SM] No extensions are loaded."); rootmenu->ConsolePrint("[SM] No extensions are loaded.");
break; break;
} }
default: default:
{ {
g_RootMenu.ConsolePrint("[SM] Displaying %d extensions:", m_Libs.size()); rootmenu->ConsolePrint("[SM] Displaying %d extensions:", m_Libs.size());
break; break;
} }
} }
@ -990,7 +966,7 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const CCommand
char error[255]; char error[255];
if (!pExt->IsRunning(error, sizeof(error))) if (!pExt->IsRunning(error, sizeof(error)))
{ {
g_RootMenu.ConsolePrint("[%02d] <FAILED> file \"%s\": %s", num, pExt->GetFilename(), error); rootmenu->ConsolePrint("[%02d] <FAILED> file \"%s\": %s", num, pExt->GetFilename(), error);
} }
else else
{ {
@ -998,10 +974,10 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const CCommand
const char *name = pAPI->GetExtensionName(); const char *name = pAPI->GetExtensionName();
const char *version = pAPI->GetExtensionVerString(); const char *version = pAPI->GetExtensionVerString();
const char *descr = pAPI->GetExtensionDescription(); const char *descr = pAPI->GetExtensionDescription();
g_RootMenu.ConsolePrint("[%02d] %s (%s): %s", num, name, version, descr); rootmenu->ConsolePrint("[%02d] %s (%s): %s", num, name, version, descr);
} }
} else { } else {
g_RootMenu.ConsolePrint("[%02d] <FAILED> file \"%s\": %s", num, pExt->GetFilename(), pExt->m_Error.c_str()); rootmenu->ConsolePrint("[%02d] <FAILED> file \"%s\": %s", num, pExt->GetFilename(), pExt->m_Error.c_str());
} }
} }
return; return;
@ -1010,29 +986,29 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const CCommand
{ {
if (argcount < 4) if (argcount < 4)
{ {
g_RootMenu.ConsolePrint("[SM] Usage: sm exts load <file>"); rootmenu->ConsolePrint("[SM] Usage: sm exts load <file>");
return; return;
} }
const char *filename = command.Arg(3); const char *filename = smcore.Arg(command, 3);
char path[PLATFORM_MAX_PATH]; char path[PLATFORM_MAX_PATH];
char error[256]; char error[256];
UTIL_Format(path, sizeof(path), "%s%s%s", filename, !strstr(filename, ".ext") ? ".ext" : "", smcore.Format(path, sizeof(path), "%s%s%s", filename, !strstr(filename, ".ext") ? ".ext" : "",
!strstr(filename, "." PLATFORM_LIB_EXT) ? "." PLATFORM_LIB_EXT : ""); !strstr(filename, "." PLATFORM_LIB_EXT) ? "." PLATFORM_LIB_EXT : "");
if (FindExtensionByFile(path) != NULL) if (FindExtensionByFile(path) != NULL)
{ {
g_RootMenu.ConsolePrint("[SM] Extension %s is already loaded.", path); rootmenu->ConsolePrint("[SM] Extension %s is already loaded.", path);
return; return;
} }
if (LoadExtension(path, error, sizeof(error))) if (LoadExtension(path, error, sizeof(error)))
{ {
g_RootMenu.ConsolePrint("[SM] Loaded extension %s successfully.", path); rootmenu->ConsolePrint("[SM] Loaded extension %s successfully.", path);
} else } else
{ {
g_RootMenu.ConsolePrint("[SM] Extension %s failed to load: %s", path, error); rootmenu->ConsolePrint("[SM] Extension %s failed to load: %s", path, error);
} }
return; return;
@ -1041,27 +1017,27 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const CCommand
{ {
if (argcount < 4) if (argcount < 4)
{ {
g_RootMenu.ConsolePrint("[SM] Usage: sm exts info <#>"); rootmenu->ConsolePrint("[SM] Usage: sm exts info <#>");
return; return;
} }
const char *sId = command.Arg(3); const char *sId = smcore.Arg(command, 3);
unsigned int id = atoi(sId); unsigned int id = atoi(sId);
if (id <= 0) if (id <= 0)
{ {
g_RootMenu.ConsolePrint("[SM] Usage: sm exts info <#>"); rootmenu->ConsolePrint("[SM] Usage: sm exts info <#>");
return; return;
} }
if (m_Libs.size() == 0) if (m_Libs.size() == 0)
{ {
g_RootMenu.ConsolePrint("[SM] No extensions are loaded."); rootmenu->ConsolePrint("[SM] No extensions are loaded.");
return; return;
} }
if (id > m_Libs.size()) if (id > m_Libs.size())
{ {
g_RootMenu.ConsolePrint("[SM] No extension was found with id %d.", id); rootmenu->ConsolePrint("[SM] No extension was found with id %d.", id);
return; return;
} }
@ -1079,44 +1055,44 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const CCommand
/* This should never happen */ /* This should never happen */
if (!pExt) if (!pExt)
{ {
g_RootMenu.ConsolePrint("[SM] No extension was found with id %d.", id); rootmenu->ConsolePrint("[SM] No extension was found with id %d.", id);
return; return;
} }
if (!pExt->IsLoaded()) if (!pExt->IsLoaded())
{ {
g_RootMenu.ConsolePrint(" File: %s", pExt->GetFilename()); rootmenu->ConsolePrint(" File: %s", pExt->GetFilename());
g_RootMenu.ConsolePrint(" Loaded: No (%s)", pExt->m_Error.c_str()); rootmenu->ConsolePrint(" Loaded: No (%s)", pExt->m_Error.c_str());
} }
else else
{ {
char error[255]; char error[255];
if (!pExt->IsRunning(error, sizeof(error))) if (!pExt->IsRunning(error, sizeof(error)))
{ {
g_RootMenu.ConsolePrint(" File: %s", pExt->GetFilename()); rootmenu->ConsolePrint(" File: %s", pExt->GetFilename());
g_RootMenu.ConsolePrint(" Loaded: Yes"); rootmenu->ConsolePrint(" Loaded: Yes");
g_RootMenu.ConsolePrint(" Running: No (%s)", error); rootmenu->ConsolePrint(" Running: No (%s)", error);
} }
else else
{ {
IExtensionInterface *pAPI = pExt->GetAPI(); IExtensionInterface *pAPI = pExt->GetAPI();
g_RootMenu.ConsolePrint(" File: %s", pExt->GetFilename()); rootmenu->ConsolePrint(" File: %s", pExt->GetFilename());
g_RootMenu.ConsolePrint(" Loaded: Yes (version %s)", pAPI->GetExtensionVerString()); rootmenu->ConsolePrint(" Loaded: Yes (version %s)", pAPI->GetExtensionVerString());
g_RootMenu.ConsolePrint(" Name: %s (%s)", pAPI->GetExtensionName(), pAPI->GetExtensionDescription()); rootmenu->ConsolePrint(" Name: %s (%s)", pAPI->GetExtensionName(), pAPI->GetExtensionDescription());
g_RootMenu.ConsolePrint(" Author: %s (%s)", pAPI->GetExtensionAuthor(), pAPI->GetExtensionURL()); rootmenu->ConsolePrint(" Author: %s (%s)", pAPI->GetExtensionAuthor(), pAPI->GetExtensionURL());
g_RootMenu.ConsolePrint(" Binary info: API version %d (compiled %s)", pAPI->GetExtensionVersion(), pAPI->GetExtensionDateString()); rootmenu->ConsolePrint(" Binary info: API version %d (compiled %s)", pAPI->GetExtensionVersion(), pAPI->GetExtensionDateString());
if (pExt->IsExternal()) if (pExt->IsExternal())
{ {
g_RootMenu.ConsolePrint(" Method: Loaded by Metamod:Source, attached to SourceMod"); rootmenu->ConsolePrint(" Method: Loaded by Metamod:Source, attached to SourceMod");
} }
else if (pAPI->IsMetamodExtension()) else if (pAPI->IsMetamodExtension())
{ {
g_RootMenu.ConsolePrint(" Method: Loaded by SourceMod, attached to Metamod:Source"); rootmenu->ConsolePrint(" Method: Loaded by SourceMod, attached to Metamod:Source");
} }
else else
{ {
g_RootMenu.ConsolePrint(" Method: Loaded by SourceMod"); rootmenu->ConsolePrint(" Method: Loaded by SourceMod");
} }
} }
} }
@ -1126,33 +1102,33 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const CCommand
{ {
if (argcount < 4) if (argcount < 4)
{ {
g_RootMenu.ConsolePrint("[SM] Usage: sm exts unload <#> [code]"); rootmenu->ConsolePrint("[SM] Usage: sm exts unload <#> [code]");
return; return;
} }
const char *arg = command.Arg(3); const char *arg = smcore.Arg(command, 3);
unsigned int num = atoi(arg); unsigned int num = atoi(arg);
CExtension *pExt = FindByOrder(num); CExtension *pExt = FindByOrder(num);
if (!pExt) if (!pExt)
{ {
g_RootMenu.ConsolePrint("[SM] Extension number %d was not found.", num); rootmenu->ConsolePrint("[SM] Extension number %d was not found.", num);
return; return;
} }
if (argcount > 4 && pExt->unload_code) if (argcount > 4 && pExt->unload_code)
{ {
const char *unload = command.Arg(4); const char *unload = smcore.Arg(command, 4);
if (pExt->unload_code == (unsigned)atoi(unload)) if (pExt->unload_code == (unsigned)atoi(unload))
{ {
char filename[PLATFORM_MAX_PATH]; char filename[PLATFORM_MAX_PATH];
snprintf(filename, PLATFORM_MAX_PATH, "%s", pExt->GetFilename()); snprintf(filename, PLATFORM_MAX_PATH, "%s", pExt->GetFilename());
UnloadExtension(pExt); UnloadExtension(pExt);
g_RootMenu.ConsolePrint("[SM] Extension %s is now unloaded.", filename); rootmenu->ConsolePrint("[SM] Extension %s is now unloaded.", filename);
} }
else else
{ {
g_RootMenu.ConsolePrint("[SM] Please try again, the correct unload code is \"%d\"", pExt->unload_code); rootmenu->ConsolePrint("[SM] Please try again, the correct unload code is \"%d\"", pExt->unload_code);
} }
return; return;
} }
@ -1163,7 +1139,7 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const CCommand
char filename[PLATFORM_MAX_PATH]; char filename[PLATFORM_MAX_PATH];
snprintf(filename, PLATFORM_MAX_PATH, "%s", pExt->GetFilename()); snprintf(filename, PLATFORM_MAX_PATH, "%s", pExt->GetFilename());
UnloadExtension(pExt); UnloadExtension(pExt);
g_RootMenu.ConsolePrint("[SM] Extension %s is now unloaded.", filename); rootmenu->ConsolePrint("[SM] Extension %s is now unloaded.", filename);
return; return;
} }
else else
@ -1171,7 +1147,7 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const CCommand
List<CPlugin *> plugins; List<CPlugin *> plugins;
if (pExt->m_ChildDeps.size()) if (pExt->m_ChildDeps.size())
{ {
g_RootMenu.ConsolePrint("[SM] Unloading %s will unload the following extensions: ", pExt->GetFilename()); rootmenu->ConsolePrint("[SM] Unloading %s will unload the following extensions: ", pExt->GetFilename());
List<CExtension *>::iterator iter; List<CExtension *>::iterator iter;
CExtension *pOther; CExtension *pOther;
/* Get list of all extensions */ /* Get list of all extensions */
@ -1196,7 +1172,7 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const CCommand
/* Will our dependent care? */ /* Will our dependent care? */
if (!pExt->GetAPI()->QueryInterfaceDrop((*i_iter).iface)) if (!pExt->GetAPI()->QueryInterfaceDrop((*i_iter).iface))
{ {
g_RootMenu.ConsolePrint(" -> %s", pExt->GetFilename()); rootmenu->ConsolePrint(" -> %s", pExt->GetFilename());
/* Add to plugin unload list */ /* Add to plugin unload list */
List<CPlugin *>::iterator p_iter; List<CPlugin *>::iterator p_iter;
for (p_iter=pOther->m_Dependents.begin(); for (p_iter=pOther->m_Dependents.begin();
@ -1214,7 +1190,7 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const CCommand
} }
if (pExt->m_Dependents.size()) if (pExt->m_Dependents.size())
{ {
g_RootMenu.ConsolePrint("[SM] Unloading %s will unload the following plugins: ", pExt->GetFilename()); rootmenu->ConsolePrint("[SM] Unloading %s will unload the following plugins: ", pExt->GetFilename());
List<CPlugin *>::iterator iter; List<CPlugin *>::iterator iter;
CPlugin *pPlugin; CPlugin *pPlugin;
for (iter = pExt->m_Dependents.begin(); iter != pExt->m_Dependents.end(); iter++) for (iter = pExt->m_Dependents.begin(); iter != pExt->m_Dependents.end(); iter++)
@ -1228,13 +1204,13 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const CCommand
for (iter = plugins.begin(); iter != plugins.end(); iter++) for (iter = plugins.begin(); iter != plugins.end(); iter++)
{ {
pPlugin = (*iter); pPlugin = (*iter);
g_RootMenu.ConsolePrint(" -> %s", pPlugin->GetFilename()); rootmenu->ConsolePrint(" -> %s", pPlugin->GetFilename());
} }
} }
srand(static_cast<int>(time(NULL))); srand(static_cast<int>(time(NULL)));
pExt->unload_code = (rand() % 877) + 123; //123 to 999 pExt->unload_code = (rand() % 877) + 123; //123 to 999
g_RootMenu.ConsolePrint("[SM] To verify unloading %s, please use the following: ", pExt->GetFilename()); rootmenu->ConsolePrint("[SM] To verify unloading %s, please use the following: ", pExt->GetFilename());
g_RootMenu.ConsolePrint("[SM] sm exts unload %d %d", num, pExt->unload_code); rootmenu->ConsolePrint("[SM] sm exts unload %d %d", num, pExt->unload_code);
return; return;
} }
@ -1243,17 +1219,17 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const CCommand
{ {
if (argcount < 4) if (argcount < 4)
{ {
g_RootMenu.ConsolePrint("[SM] Usage: sm exts reload <#>"); rootmenu->ConsolePrint("[SM] Usage: sm exts reload <#>");
return; return;
} }
const char *arg = command.Arg(3); const char *arg = smcore.Arg(command, 3);
unsigned int num = atoi(arg); unsigned int num = atoi(arg);
CExtension *pExt = FindByOrder(num); CExtension *pExt = FindByOrder(num);
if (!pExt) if (!pExt)
{ {
g_RootMenu.ConsolePrint("[SM] Extension number %d was not found.", num); rootmenu->ConsolePrint("[SM] Extension number %d was not found.", num);
return; return;
} }
@ -1266,18 +1242,18 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const CCommand
if (pExt->Reload(error, sizeof(error))) if (pExt->Reload(error, sizeof(error)))
{ {
g_RootMenu.ConsolePrint("[SM] Extension %s is now reloaded.", filename); rootmenu->ConsolePrint("[SM] Extension %s is now reloaded.", filename);
} }
else else
{ {
g_RootMenu.ConsolePrint("[SM] Extension %s failed to reload: %s", filename, error); rootmenu->ConsolePrint("[SM] Extension %s failed to reload: %s", filename, error);
} }
return; return;
} }
else else
{ {
g_RootMenu.ConsolePrint("[SM] Extension %s is not loaded.", pExt->GetFilename()); rootmenu->ConsolePrint("[SM] Extension %s is not loaded.", pExt->GetFilename());
return; return;
} }
@ -1285,100 +1261,12 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const CCommand
} }
} }
g_RootMenu.ConsolePrint("SourceMod Extensions Menu:"); rootmenu->ConsolePrint("SourceMod Extensions Menu:");
g_RootMenu.DrawGenericOption("info", "Extra extension information"); rootmenu->DrawGenericOption("info", "Extra extension information");
g_RootMenu.DrawGenericOption("list", "List extensions"); rootmenu->DrawGenericOption("list", "List extensions");
g_RootMenu.DrawGenericOption("load", "Load an extension"); rootmenu->DrawGenericOption("load", "Load an extension");
g_RootMenu.DrawGenericOption("reload", "Reload an extension"); rootmenu->DrawGenericOption("reload", "Reload an extension");
g_RootMenu.DrawGenericOption("unload", "Unload an extension"); rootmenu->DrawGenericOption("unload", "Unload an extension");
}
void CExtensionManager::ListExtensionsToClient(CPlayer *player, const CCommand &args)
{
char buffer[256];
int numExtensions = m_Libs.size();
edict_t *edict = player->GetEdict();
unsigned int id = 0;
unsigned int start = 0;
if (!numExtensions)
{
ClientConsolePrint(edict, "[SM] No extensions found.");
return;
}
if (args.ArgC() > 2)
{
start = atoi(args.Arg(2));
}
CExtension *ext;
SourceHook::List<CExtension *>::iterator iter;
for (iter = m_Libs.begin();
iter != m_Libs.end();
iter++)
{
ext = (*iter);
char error[255];
if (!ext->IsRunning(error, sizeof(error)))
{
continue;
}
id++;
if (id < start)
{
continue;
}
if (id - start > 10)
{
break;
}
IExtensionInterface *api = ext->GetAPI();
const char *name = api->GetExtensionName();
const char *version = api->GetExtensionVerString();
const char *author = api->GetExtensionAuthor();
const char *description = api->GetExtensionDescription();
size_t len = UTIL_Format(buffer, sizeof(buffer), " \"%s\"", name);
if (version != NULL && IS_STR_FILLED(version))
{
len += UTIL_Format(&buffer[len], sizeof(buffer)-len, " (%s)", version);
}
if (author != NULL && IS_STR_FILLED(author))
{
len += UTIL_Format(&buffer[len], sizeof(buffer)-len, " by %s", author);
}
if (description != NULL && IS_STR_FILLED(description))
{
len += UTIL_Format(&buffer[len], sizeof(buffer)-len, ": %s", description);
}
ClientConsolePrint(edict, "%s", buffer);
}
while (iter != m_Libs.end())
{
char error[255];
if ((*iter)->IsRunning(error, sizeof(error)))
{
break;
}
}
if (iter != m_Libs.end())
{
ClientConsolePrint(edict, "To see more, type \"sm exts %d\"", id);
}
} }
CExtension *CExtensionManager::GetExtensionFromIdent(IdentityToken_t *ptr) CExtension *CExtensionManager::GetExtensionFromIdent(IdentityToken_t *ptr)
@ -1403,7 +1291,7 @@ void CExtensionManager::AddLibrary(IExtension *pSource, const char *library)
{ {
CExtension *pExt = (CExtension *)pSource; CExtension *pExt = (CExtension *)pSource;
pExt->AddLibrary(library); pExt->AddLibrary(library);
g_PluginSys.OnLibraryAction(library, LibraryAction_Added); scripts->OnLibraryAction(library, LibraryAction_Added);
} }
bool CExtensionManager::LibraryExists(const char *library) bool CExtensionManager::LibraryExists(const char *library)
@ -1473,6 +1361,14 @@ void CExtensionManager::CallOnCoreMapStart(edict_t *pEdictList, int edictCount,
} }
} }
void CExtensionManager::ListExtensions(CVector<IExtension *> *list)
{
for (List<CExtension *>::iterator iter = m_Libs.begin(); iter != m_Libs.end(); iter++)
{
list->push_back(*iter);
}
}
bool CLocalExtension::IsSameFile(const char *file) bool CLocalExtension::IsSameFile(const char *file)
{ {
/* Only care about the shortened name. */ /* Only care about the shortened name. */

View File

@ -37,13 +37,11 @@
#include <sh_list.h> #include <sh_list.h>
#include <sh_string.h> #include <sh_string.h>
#include <sm_trie_tpl.h> #include <sm_trie_tpl.h>
#include "sm_globals.h" #include "common_logic.h"
#include "ShareSys.h"
#include <ISmmAPI.h>
#include <IPluginSys.h> #include <IPluginSys.h>
#include <IRootConsoleMenu.h> #include <IRootConsoleMenu.h>
#include "PluginSys.h"
#include "NativeOwner.h" #include "NativeOwner.h"
#include "ShareSys.h"
class CPlayer; class CPlayer;
@ -120,7 +118,7 @@ public:
bool IsExternal(); bool IsExternal();
bool IsSameFile(const char *file); bool IsSameFile(const char *file);
private: private:
PluginId m_PlId; int m_PlId;
ILibrary *m_pLib; ILibrary *m_pLib;
}; };
@ -138,10 +136,9 @@ public:
}; };
class CExtensionManager : class CExtensionManager :
public IExtensionManager, public IExtensionSys,
public SMGlobalClass, public SMGlobalClass,
public IPluginsListener, public IPluginsListener
public IRootConsoleCommand
{ {
public: public:
CExtensionManager(); CExtensionManager();
@ -166,10 +163,10 @@ public: //IPluginsListener
public: //IRootConsoleCommand public: //IRootConsoleCommand
void OnRootConsoleCommand(const char *cmdname, const CCommand &command); void OnRootConsoleCommand(const char *cmdname, const CCommand &command);
public: public:
IExtension *LoadAutoExtension(const char *path, bool bErrorOnMissing=true); IExtension *LoadAutoExtension(const char *path);
void BindDependency(IExtension *pOwner, IfaceInfo *pInfo); void BindDependency(IExtension *pOwner, IfaceInfo *pInfo);
void AddInterface(IExtension *pOwner, SMInterface *pInterface); void AddInterface(IExtension *pOwner, SMInterface *pInterface);
void BindChildPlugin(IExtension *pParent, CPlugin *pPlugin); void BindChildPlugin(IExtension *pParent, SMPlugin *pPlugin);
void MarkAllLoaded(); void MarkAllLoaded();
void AddDependency(IExtension *pSource, const char *file, bool required, bool autoload); void AddDependency(IExtension *pSource, const char *file, bool required, bool autoload);
void TryAutoload(); void TryAutoload();
@ -177,8 +174,7 @@ public:
bool LibraryExists(const char *library); bool LibraryExists(const char *library);
void CallOnCoreMapStart(edict_t *pEdictList, int edictCount, int clientMax); void CallOnCoreMapStart(edict_t *pEdictList, int edictCount, int clientMax);
void AddRawDependency(IExtension *ext, IdentityToken_t *other, void *iface); void AddRawDependency(IExtension *ext, IdentityToken_t *other, void *iface);
public: void ListExtensions(CVector<IExtension *> *list);
void ListExtensionsToClient(CPlayer *player, const CCommand &args);
public: public:
CExtension *GetExtensionFromIdent(IdentityToken_t *ptr); CExtension *GetExtensionFromIdent(IdentityToken_t *ptr);
void Shutdown(); void Shutdown();

View File

@ -30,13 +30,11 @@
*/ */
#include "HandleSys.h" #include "HandleSys.h"
#include "ShareSys.h"
#include "PluginSys.h"
#include "ExtensionSys.h"
#include "Logger.h"
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
#include "sm_stringutil.h" #include "common_logic.h"
#include "ShareSys.h"
#include "ExtensionSys.h"
HandleSystem g_HandleSys; HandleSystem g_HandleSys;
@ -60,7 +58,6 @@ HandleSystem::HandleSystem()
m_Types = new QHandleType[HANDLESYS_TYPEARRAY_SIZE]; m_Types = new QHandleType[HANDLESYS_TYPEARRAY_SIZE];
memset(m_Types, 0, sizeof(QHandleType) * HANDLESYS_TYPEARRAY_SIZE); memset(m_Types, 0, sizeof(QHandleType) * HANDLESYS_TYPEARRAY_SIZE);
m_TypeLookup = sm_trie_create();
m_strtab = new BaseStringTable(512); m_strtab = new BaseStringTable(512);
m_TypeTail = 0; m_TypeTail = 0;
@ -70,7 +67,6 @@ HandleSystem::~HandleSystem()
{ {
delete [] m_Handles; delete [] m_Handles;
delete [] m_Types; delete [] m_Types;
sm_trie_destroy(m_TypeLookup);
delete m_strtab; delete m_strtab;
} }
@ -145,7 +141,7 @@ HandleType_t HandleSystem::CreateType(const char *name,
if (name && name[0] != '\0') if (name && name[0] != '\0')
{ {
if (sm_trie_retrieve(m_TypeLookup, name, NULL)) if (m_TypeLookup.retrieve(name))
{ {
if (err) if (err)
{ {
@ -213,7 +209,7 @@ HandleType_t HandleSystem::CreateType(const char *name,
if (name && name[0] != '\0') if (name && name[0] != '\0')
{ {
pType->nameIdx = m_strtab->AddString(name); pType->nameIdx = m_strtab->AddString(name);
sm_trie_insert(m_TypeLookup, name, (void *)pType); m_TypeLookup.insert(name, pType);
} else { } else {
pType->nameIdx = -1; pType->nameIdx = -1;
} }
@ -245,14 +241,14 @@ HandleType_t HandleSystem::CreateType(const char *name,
bool HandleSystem::FindHandleType(const char *name, HandleType_t *type) bool HandleSystem::FindHandleType(const char *name, HandleType_t *type)
{ {
QHandleType *_type; QHandleType **typepp = m_TypeLookup.retrieve(name);
if (!sm_trie_retrieve(m_TypeLookup, name, (void **)&_type)) if (!typepp)
{ {
return false; return false;
} }
unsigned int offset = _type - m_Types; unsigned int offset = *typepp - m_Types;
if (type) if (type)
{ {
@ -660,13 +656,13 @@ void HandleSystem::GetHandleUnchecked(Handle_t hndl, QHandle *& pHandle, unsigne
HandleError HandleSystem::FreeHandle(QHandle *pHandle, unsigned int index) HandleError HandleSystem::FreeHandle(QHandle *pHandle, unsigned int index)
{ {
if (pHandle->is_destroying) if (pHandle->is_destroying)
{ {
/* Someone tried to free this recursively. /* Someone tried to free this recursively.
* We'll just ignore this safely. * We'll just ignore this safely.
*/ */
return HandleError_None; return HandleError_None;
} }
QHandleType *pType = &m_Types[pHandle->type]; QHandleType *pType = &m_Types[pHandle->type];
@ -691,9 +687,9 @@ HandleError HandleSystem::FreeHandle(QHandle *pHandle, unsigned int index)
/* Type should be the same but do this anyway... */ /* Type should be the same but do this anyway... */
pType = &m_Types[pMaster->type]; pType = &m_Types[pMaster->type];
pMaster->is_destroying = true; pMaster->is_destroying = true;
if (pMaster->object) if (pMaster->object)
{ {
pType->dispatch->OnHandleDestroy(pMaster->type, pMaster->object); pType->dispatch->OnHandleDestroy(pMaster->type, pMaster->object);
} }
ReleasePrimHandle(master); ReleasePrimHandle(master);
} }
@ -708,9 +704,9 @@ HandleError HandleSystem::FreeHandle(QHandle *pHandle, unsigned int index)
if (--pHandle->refcount == 0) if (--pHandle->refcount == 0)
{ {
pHandle->is_destroying = true; pHandle->is_destroying = true;
if (pHandle->object) if (pHandle->object)
{ {
pType->dispatch->OnHandleDestroy(pHandle->type, pHandle->object); pType->dispatch->OnHandleDestroy(pHandle->type, pHandle->object);
} }
ReleasePrimHandle(index); ReleasePrimHandle(index);
} else { } else {
@ -945,7 +941,7 @@ bool HandleSystem::RemoveType(HandleType_t type, IdentityToken_t *ident)
const char *typeName; const char *typeName;
typeName = m_strtab->GetString(pType->nameIdx); typeName = m_strtab->GetString(pType->nameIdx);
sm_trie_delete(m_TypeLookup, typeName); m_TypeLookup.remove(typeName);
} }
return true; return true;
@ -980,12 +976,12 @@ bool HandleSystem::InitAccessDefaults(TypeAccess *pTypeAccess, HandleAccess *pHa
} }
#define HANDLE_LOG_VERY_BAD(message, ...) \ #define HANDLE_LOG_VERY_BAD(message, ...) \
g_Logger.LogFatal(message, ##__VA_ARGS__); \ smcore.LogFatal(message, ##__VA_ARGS__); \
g_Logger.LogError(message, ##__VA_ARGS__); smcore.LogError(message, ##__VA_ARGS__);
bool HandleSystem::TryAndFreeSomeHandles() bool HandleSystem::TryAndFreeSomeHandles()
{ {
IPluginIterator *pl_iter = g_PluginSys.GetPluginIterator(); IPluginIterator *pl_iter = scripts->GetPluginIterator();
IPlugin *highest_owner = NULL; IPlugin *highest_owner = NULL;
unsigned int highest_handle_count = 0; unsigned int highest_handle_count = 0;
@ -1034,7 +1030,7 @@ bool HandleSystem::TryAndFreeSomeHandles()
highest_owner->GetBaseContext()->ThrowNativeErrorEx(SP_ERROR_MEMACCESS, "Memory leak"); highest_owner->GetBaseContext()->ThrowNativeErrorEx(SP_ERROR_MEMACCESS, "Memory leak");
return g_PluginSys.UnloadPlugin(highest_owner); return scripts->UnloadPlugin(highest_owner);
} }
void HandleSystem::Dump(HANDLE_REPORTER rep) void HandleSystem::Dump(HANDLE_REPORTER rep)
@ -1059,20 +1055,20 @@ void HandleSystem::Dump(HANDLE_REPORTER rep)
{ {
owner = "CORE"; owner = "CORE";
} }
else if (pOwner == g_PluginSys.GetIdentity()) else if (pOwner == scripts->GetIdentity())
{ {
owner = "PLUGINSYS"; owner = "PLUGINSYS";
} }
else else
{ {
CExtension *ext = g_Extensions.GetExtensionFromIdent(pOwner); IExtension *ext = g_Extensions.GetExtensionFromIdent(pOwner);
if (ext) if (ext)
{ {
owner = ext->GetFilename(); owner = ext->GetFilename();
} }
else else
{ {
CPlugin *pPlugin = g_PluginSys.GetPluginFromIdentity(pOwner); SMPlugin *pPlugin = scripts->FindPluginByIdentity(pOwner);
if (pPlugin) if (pPlugin)
{ {
owner = pPlugin->GetFilename(); owner = pPlugin->GetFilename();
@ -1094,21 +1090,21 @@ void HandleSystem::Dump(HANDLE_REPORTER rep)
type = m_strtab->GetString(pType->nameIdx); type = m_strtab->GetString(pType->nameIdx);
} }
if ((parentIdx = m_Handles[i].clone) != 0) if ((parentIdx = m_Handles[i].clone) != 0)
{ {
if (m_Handles[parentIdx].refcount > 0) if (m_Handles[parentIdx].refcount > 0)
{ {
size = 0; size = 0;
bresult = true; bresult = true;
} }
else else
{ {
bresult = pType->dispatch->GetHandleApproxSize(m_Handles[parentIdx].type, m_Handles[parentIdx].object, &size); bresult = pType->dispatch->GetHandleApproxSize(m_Handles[parentIdx].type, m_Handles[parentIdx].object, &size);
} }
} }
else else
{ {
bresult = pType->dispatch->GetHandleApproxSize(m_Handles[i].type, m_Handles[i].object, &size); bresult = pType->dispatch->GetHandleApproxSize(m_Handles[i].type, m_Handles[i].object, &size);
} }
if (pType->dispatch->GetDispatchVersion() < HANDLESYS_MEMUSAGE_MIN_VERSION if (pType->dispatch->GetDispatchVersion() < HANDLESYS_MEMUSAGE_MIN_VERSION
@ -1119,7 +1115,7 @@ void HandleSystem::Dump(HANDLE_REPORTER rep)
else else
{ {
char buffer[32]; char buffer[32];
UTIL_Format(buffer, sizeof(buffer), "%d", size); smcore.Format(buffer, sizeof(buffer), "%d", size);
rep("0x%08x\t%-20.20s\t%-20.20s\t%-10.10s", index, owner, type, buffer); rep("0x%08x\t%-20.20s\t%-20.20s\t%-10.10s", index, owner, type, buffer);
total_size += size; total_size += size;
} }

View File

@ -34,10 +34,9 @@
#include <IHandleSys.h> #include <IHandleSys.h>
#include <stdio.h> #include <stdio.h>
#include "sm_globals.h" #include <sm_trie_tpl.h>
#include "sm_trie.h"
#include "sourcemod.h"
#include "sm_memtable.h" #include "sm_memtable.h"
#include "common_logic.h"
#define HANDLESYS_MAX_HANDLES (1<<14) #define HANDLESYS_MAX_HANDLES (1<<14)
#define HANDLESYS_MAX_TYPES (1<<9) #define HANDLESYS_MAX_TYPES (1<<9)
@ -217,7 +216,7 @@ protected:
private: private:
QHandle *m_Handles; QHandle *m_Handles;
QHandleType *m_Types; QHandleType *m_Types;
Trie *m_TypeLookup; KTrie<QHandleType *> m_TypeLookup;
unsigned int m_TypeTail; unsigned int m_TypeTail;
unsigned int m_FreeTypes; unsigned int m_FreeTypes;
unsigned int m_HandleTail; unsigned int m_HandleTail;

View File

@ -54,7 +54,7 @@ unsigned int NativeInterface::GetInterfaceVersion()
void NativeInterface::OnSourceModAllInitialized() void NativeInterface::OnSourceModAllInitialized()
{ {
g_ShareSys.AddInterface(NULL, &g_NInvoke); sharesys->AddInterface(NULL, &g_NInvoke);
} }
IPluginRuntime *NativeInterface::CreateRuntime(const char *name, size_t bytes) IPluginRuntime *NativeInterface::CreateRuntime(const char *name, size_t bytes)

View File

@ -32,8 +32,12 @@
#ifndef _INCLUDE_SOURCEMOD_NATIVE_INVOKER_H_ #ifndef _INCLUDE_SOURCEMOD_NATIVE_INVOKER_H_
#define _INCLUDE_SOURCEMOD_NATIVE_INVOKER_H_ #define _INCLUDE_SOURCEMOD_NATIVE_INVOKER_H_
#include "sm_globals.h" #include <sp_vm_api.h>
#include <INativeInvoker.h> #include <INativeInvoker.h>
#include "common_logic.h"
using namespace SourceMod;
using namespace SourcePawn;
struct ParamInfo struct ParamInfo
{ {

View File

@ -1,3 +1,33 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourcePawn
* Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#include "NativeOwner.h" #include "NativeOwner.h"
#include "ShareSys.h" #include "ShareSys.h"
#include "PluginSys.h" #include "PluginSys.h"
@ -41,7 +71,7 @@ void CNativeOwner::AddNatives(const sp_nativeinfo_t *natives)
} }
} }
void CNativeOwner::PropogateMarkSerial(unsigned int serial) void CNativeOwner::PropagateMarkSerial(unsigned int serial)
{ {
CNativeOwner *pOwner; CNativeOwner *pOwner;
List<CPlugin *>::iterator iter; List<CPlugin *>::iterator iter;

View File

@ -3,25 +3,28 @@
#include <sp_vm_types.h> #include <sp_vm_types.h>
#include <sh_list.h> #include <sh_list.h>
#include "common_logic.h"
class CPlugin;
struct NativeEntry; struct NativeEntry;
class CPlugin;
using namespace SourceMod;
struct WeakNative struct WeakNative
{ {
WeakNative(CPlugin *plugin, uint32_t index) : WeakNative(IPlugin *plugin, uint32_t index) :
pl(plugin), idx(index), entry(NULL) pl(plugin), idx(index), entry(NULL)
{ {
pl = plugin; pl = plugin;
idx = index; idx = index;
} }
WeakNative(CPlugin *plugin, uint32_t index, NativeEntry *pEntry) : WeakNative(IPlugin *plugin, uint32_t index, NativeEntry *pEntry) :
pl(plugin), idx(index), entry(pEntry) pl(plugin), idx(index), entry(pEntry)
{ {
pl = plugin; pl = plugin;
idx = index; idx = index;
} }
CPlugin *pl; IPlugin *pl;
uint32_t idx; uint32_t idx;
NativeEntry *entry; NativeEntry *entry;
}; };
@ -39,7 +42,7 @@ public:
public: public:
void SetMarkSerial(unsigned int serial); void SetMarkSerial(unsigned int serial);
unsigned int GetMarkSerial(); unsigned int GetMarkSerial();
void PropogateMarkSerial(unsigned int serial); void PropagateMarkSerial(unsigned int serial);
public: public:
void AddDependent(CPlugin *pPlugin); void AddDependent(CPlugin *pPlugin);
void AddWeakRef(const WeakNative & ref); void AddWeakRef(const WeakNative & ref);
@ -56,4 +59,6 @@ protected:
List<NativeEntry *> m_ReplacedNatives; List<NativeEntry *> m_ReplacedNatives;
}; };
extern CNativeOwner g_CoreNatives;
#endif //_INCLUDE_SOURCEMOD_NATIVE_OWNER_H_ #endif //_INCLUDE_SOURCEMOD_NATIVE_OWNER_H_

File diff suppressed because it is too large Load Diff

View File

@ -42,19 +42,9 @@
#include <sh_stack.h> #include <sh_stack.h>
#include <sh_vector.h> #include <sh_vector.h>
#include <sh_string.h> #include <sh_string.h>
#include "sm_globals.h" #include "common_logic.h"
#include "sm_trie.h" #include <sm_trie_tpl.h>
#include "sourcemod.h"
#include <IRootConsoleMenu.h> #include <IRootConsoleMenu.h>
#if SOURCE_ENGINE >= SE_ALIENSWARM
#include "convar_sm_swarm.h"
#elif SOURCE_ENGINE >= SE_LEFT4DEAD
#include "convar_sm_l4d.h"
#elif SOURCE_ENGINE >= SE_ORANGEBOX
#include "convar_sm_ob.h"
#else
#include "convar_sm.h"
#endif
#include "ITranslator.h" #include "ITranslator.h"
#include "IGameConfigs.h" #include "IGameConfigs.h"
#include "NativeOwner.h" #include "NativeOwner.h"
@ -130,23 +120,8 @@ enum APLRes
APLRes_SilentFailure APLRes_SilentFailure
}; };
enum LibraryAction
{
LibraryAction_Removed,
LibraryAction_Added
};
struct AutoConfig
{
String autocfg;
String folder;
bool create;
};
class CPlugin;
class CPlugin : class CPlugin :
public IPlugin, public SMPlugin,
public CNativeOwner public CNativeOwner
{ {
friend class CPluginManager; friend class CPluginManager;
@ -173,6 +148,9 @@ public:
bool GetProperty(const char *prop, void **ptr, bool remove=false); bool GetProperty(const char *prop, void **ptr, bool remove=false);
void DropEverything(); void DropEverything();
SourcePawn::IPluginRuntime *GetRuntime(); SourcePawn::IPluginRuntime *GetRuntime();
CNativeOwner *ToNativeOwner() {
return this;
}
public: public:
/** /**
* Creates a plugin object with default values. * Creates a plugin object with default values.
@ -276,7 +254,7 @@ private:
IPhraseCollection *m_pPhrases; IPhraseCollection *m_pPhrases;
List<String> m_RequiredLibs; List<String> m_RequiredLibs;
List<String> m_Libraries; List<String> m_Libraries;
Trie *m_pProps; KTrie<void *> m_pProps;
bool m_FakeNativesMissing; bool m_FakeNativesMissing;
bool m_LibraryMissing; bool m_LibraryMissing;
CVector<AutoConfig *> m_configs; CVector<AutoConfig *> m_configs;
@ -289,7 +267,7 @@ private:
}; };
class CPluginManager : class CPluginManager :
public IPluginManager, public IScriptManager,
public SMGlobalClass, public SMGlobalClass,
public IHandleTypeDispatch, public IHandleTypeDispatch,
public IRootConsoleCommand public IRootConsoleCommand
@ -316,7 +294,7 @@ public:
List<CPlugin *>::iterator current; List<CPlugin *>::iterator current;
}; };
friend class CPluginManager::CPluginIterator; friend class CPluginManager::CPluginIterator;
public: //IPluginManager public: //IScriptManager
IPlugin *LoadPlugin(const char *path, IPlugin *LoadPlugin(const char *path,
bool debug, bool debug,
PluginType type, PluginType type,
@ -329,6 +307,25 @@ public: //IPluginManager
IPluginIterator *GetPluginIterator(); IPluginIterator *GetPluginIterator();
void AddPluginsListener(IPluginsListener *listener); void AddPluginsListener(IPluginsListener *listener);
void RemovePluginsListener(IPluginsListener *listener); void RemovePluginsListener(IPluginsListener *listener);
void LoadAll(const char *config_path, const char *plugins_path);
void RefreshAll();
SMPlugin *FindPluginByOrder(unsigned num) {
return GetPluginByOrder(num);
}
SMPlugin *FindPluginByIdentity(IdentityToken_t *ident) {
return GetPluginFromIdentity(ident);
}
SMPlugin *FindPluginByContext(IPluginContext *ctx) {
return GetPluginByCtx(ctx->GetContext());
}
SMPlugin *FindPluginByContext(sp_context_t *ctx) {
return GetPluginByCtx(ctx);
}
SMPlugin *FindPluginByConsoleArg(const char *text);
SMPlugin *FindPluginByHandle(Handle_t hndl, HandleError *errp) {
return static_cast<SMPlugin *>(PluginFromHandle(hndl, errp));
}
void ListPlugins(CVector<SMPlugin *> *plugins);
public: //SMGlobalClass public: //SMGlobalClass
void OnSourceModAllInitialized(); void OnSourceModAllInitialized();
void OnSourceModShutdown(); void OnSourceModShutdown();
@ -388,11 +385,6 @@ public:
*/ */
const char *GetStatusText(PluginStatus status); const char *GetStatusText(PluginStatus status);
/**
* Reload or update plugins on level shutdown.
*/
void ReloadOrUnloadPlugins();
/** /**
* Add public functions from all running or paused * Add public functions from all running or paused
* plugins to the specified forward if the names match. * plugins to the specified forward if the names match.
@ -416,8 +408,6 @@ public:
void UnloadAll(); void UnloadAll();
CPlugin *FindPluginByConsoleArg(const char *arg);
void SyncMaxClients(int max_clients); void SyncMaxClients(int max_clients);
void ListPluginsToClient(CPlayer *player, const CCommand &args); void ListPluginsToClient(CPlayer *player, const CCommand &args);
@ -462,13 +452,14 @@ public:
{ {
return m_MyIdent; return m_MyIdent;
} }
IPluginManager *GetOldAPI();
private: private:
void TryRefreshDependencies(CPlugin *pOther); void TryRefreshDependencies(CPlugin *pOther);
private: private:
List<IPluginsListener *> m_listeners; List<IPluginsListener *> m_listeners;
List<CPlugin *> m_plugins; List<CPlugin *> m_plugins;
CStack<CPluginManager::CPluginIterator *> m_iters; CStack<CPluginManager::CPluginIterator *> m_iters;
Trie *m_LoadLookup; KTrie<CPlugin *> m_LoadLookup;
bool m_AllPluginsLoaded; bool m_AllPluginsLoaded;
IdentityToken_t *m_MyIdent; IdentityToken_t *m_MyIdent;

View File

@ -30,11 +30,11 @@
*/ */
#include "ShareSys.h" #include "ShareSys.h"
#include "HandleSys.h"
#include "ExtensionSys.h" #include "ExtensionSys.h"
#include "LibrarySys.h" #include <ILibrarySys.h>
#include "common_logic.h"
#include "PluginSys.h" #include "PluginSys.h"
#include "sm_stringutil.h" #include "HandleSys.h"
ShareSystem g_ShareSys; ShareSystem g_ShareSys;
static unsigned int g_mark_serial = 0; static unsigned int g_mark_serial = 0;
@ -61,36 +61,36 @@ void ShareSystem::Initialize()
{ {
TypeAccess sec; TypeAccess sec;
g_HandleSys.InitAccessDefaults(&sec, NULL); handlesys->InitAccessDefaults(&sec, NULL);
sec.ident = GetIdentRoot(); sec.ident = GetIdentRoot();
m_TypeRoot = g_HandleSys.CreateType("Identity", this, 0, &sec, NULL, NULL, NULL); m_TypeRoot = handlesys->CreateType("Identity", this, 0, &sec, NULL, NULL, NULL);
m_IfaceType = g_HandleSys.CreateType("Interface", this, 0, NULL, NULL, GetIdentRoot(), NULL); m_IfaceType = handlesys->CreateType("Interface", this, 0, NULL, NULL, GetIdentRoot(), NULL);
/* Initialize our static identity handle */ /* Initialize our static identity handle */
m_IdentRoot.ident = g_HandleSys.CreateHandle(m_TypeRoot, NULL, NULL, GetIdentRoot(), NULL); m_IdentRoot.ident = handlesys->CreateHandle(m_TypeRoot, NULL, NULL, GetIdentRoot(), NULL);
/* Add the Handle System and others... they are too innocent and pure to do it themselves */ /* Add the Handle System and others... they are too innocent and pure to do it themselves */
AddInterface(NULL, &g_HandleSys); AddInterface(NULL, handlesys);
AddInterface(NULL, &g_LibSys); AddInterface(NULL, libsys);
} }
void ShareSystem::OnSourceModShutdown() void ShareSystem::OnSourceModShutdown()
{ {
if (m_CoreType) if (m_CoreType)
{ {
g_HandleSys.RemoveType(m_CoreType, GetIdentRoot()); handlesys->RemoveType(m_CoreType, GetIdentRoot());
} }
g_HandleSys.RemoveType(m_IfaceType, GetIdentRoot()); handlesys->RemoveType(m_IfaceType, GetIdentRoot());
g_HandleSys.RemoveType(m_TypeRoot, GetIdentRoot()); handlesys->RemoveType(m_TypeRoot, GetIdentRoot());
} }
IdentityType_t ShareSystem::FindIdentType(const char *name) IdentityType_t ShareSystem::FindIdentType(const char *name)
{ {
HandleType_t type; HandleType_t type;
if (g_HandleSys.FindHandleType(name, &type)) if (handlesys->FindHandleType(name, &type))
{ {
if (g_HandleSys.TypeCheck(type, m_TypeRoot)) if (g_HandleSys.TypeCheck(type, m_TypeRoot))
{ {
@ -108,7 +108,7 @@ IdentityType_t ShareSystem::CreateIdentType(const char *name)
return 0; return 0;
} }
return g_HandleSys.CreateType(name, this, m_TypeRoot, NULL, NULL, GetIdentRoot(), NULL); return handlesys->CreateType(name, this, m_TypeRoot, NULL, NULL, GetIdentRoot(), NULL);
} }
void ShareSystem::OnHandleDestroy(HandleType_t type, void *object) void ShareSystem::OnHandleDestroy(HandleType_t type, void *object)
@ -217,13 +217,13 @@ void ShareSystem::DestroyIdentity(IdentityToken_t *identity)
sec.pOwner = GetIdentRoot(); sec.pOwner = GetIdentRoot();
sec.pIdentity = GetIdentRoot(); sec.pIdentity = GetIdentRoot();
g_HandleSys.FreeHandle(identity->ident, &sec); handlesys->FreeHandle(identity->ident, &sec);
delete identity; delete identity;
} }
void ShareSystem::DestroyIdentType(IdentityType_t type) void ShareSystem::DestroyIdentType(IdentityType_t type)
{ {
g_HandleSys.RemoveType(type, GetIdentRoot()); handlesys->RemoveType(type, GetIdentRoot());
} }
void ShareSystem::RemoveInterfaces(IExtension *pExtension) void ShareSystem::RemoveInterfaces(IExtension *pExtension)
@ -268,7 +268,7 @@ void ShareSystem::OverrideNatives(IExtension *myself, const sp_nativeinfo_t *nat
continue; continue;
} }
if (pEntry->owner != g_pCoreNatives) if (pEntry->owner != &g_CoreNatives)
{ {
continue; continue;
} }
@ -308,7 +308,7 @@ void ShareSystem::BindNativesToPlugin(CPlugin *pPlugin, bool bCoreOnly)
/* Generate a new serial ID, mark our dependencies with it. */ /* Generate a new serial ID, mark our dependencies with it. */
g_mark_serial++; g_mark_serial++;
pPlugin->PropogateMarkSerial(g_mark_serial); pPlugin->PropagateMarkSerial(g_mark_serial);
native_count = pContext->GetNativesNum(); native_count = pContext->GetNativesNum();
for (i = 0; i < native_count; i++) for (i = 0; i < native_count; i++)
@ -338,7 +338,7 @@ void ShareSystem::BindNativesToPlugin(CPlugin *pPlugin, bool bCoreOnly)
continue; continue;
} }
if (bCoreOnly && pEntry->owner != g_pCoreNatives) if (bCoreOnly && pEntry->owner != &g_CoreNatives)
{ {
continue; continue;
} }
@ -394,7 +394,7 @@ void ShareSystem::BindNativeToPlugin(CPlugin *pPlugin,
native->pfn = pEntry->func; native->pfn = pEntry->func;
/* We don't bother with dependency crap if the owner is Core. */ /* We don't bother with dependency crap if the owner is Core. */
if (pEntry->owner != g_pCoreNatives) if (pEntry->owner != &g_CoreNatives)
{ {
/* The native is optional, this is a special case */ /* The native is optional, this is a special case */
if ((native->flags & SP_NTVFLAG_OPTIONAL) == SP_NTVFLAG_OPTIONAL) if ((native->flags & SP_NTVFLAG_OPTIONAL) == SP_NTVFLAG_OPTIONAL)
@ -416,7 +416,7 @@ void ShareSystem::BindNativeToPlugin(CPlugin *pPlugin,
* If it has, it means this relationship has already occurred, * If it has, it means this relationship has already occurred,
* and there is no reason to do it again. * and there is no reason to do it again.
*/ */
if (pEntry->owner != pPlugin if (pEntry->owner != pPlugin->ToNativeOwner()
&& pEntry->owner->GetMarkSerial() != g_mark_serial) && pEntry->owner->GetMarkSerial() != g_mark_serial)
{ {
/* This has not been marked as a dependency yet */ /* This has not been marked as a dependency yet */
@ -516,7 +516,7 @@ NativeEntry *ShareSystem::AddFakeNative(IPluginFunction *pFunc, const char *name
pFake->call = pFunc; pFake->call = pFunc;
pFake->ctx = pFunc->GetParentContext(); pFake->ctx = pFunc->GetParentContext();
strncopy(pFake->name, name, sizeof(pFake->name)); smcore.strncopy(pFake->name, name, sizeof(pFake->name));
pEntry->fake = pFake; pEntry->fake = pFake;
pEntry->func = gate; pEntry->func = gate;

View File

@ -36,8 +36,7 @@
#include <IHandleSys.h> #include <IHandleSys.h>
#include <sh_list.h> #include <sh_list.h>
#include <sm_trie_tpl.h> #include <sm_trie_tpl.h>
#include "sm_globals.h" #include "common_logic.h"
#include "sourcemod.h"
using namespace SourceHook; using namespace SourceHook;
@ -62,8 +61,8 @@ struct IfaceInfo
}; };
class CNativeOwner; class CNativeOwner;
class CPlugin;
struct NativeEntry; struct NativeEntry;
class CPlugin;
struct ReplaceNative struct ReplaceNative
{ {

View File

@ -43,18 +43,23 @@
#include "Translator.h" #include "Translator.h"
#include "GameConfigs.h" #include "GameConfigs.h"
#include "DebugReporter.h" #include "DebugReporter.h"
#include "PluginSys.h"
#include "ShareSys.h"
#include "NativeOwner.h"
#include "HandleSys.h"
#include "ExtensionSys.h"
sm_core_t smcore; sm_core_t smcore;
IHandleSys *handlesys; IHandleSys *handlesys = &g_HandleSys;
IdentityToken_t *g_pCoreIdent; IdentityToken_t *g_pCoreIdent;
SMGlobalClass *SMGlobalClass::head = NULL; SMGlobalClass *SMGlobalClass::head = NULL;
ISourceMod *g_pSM; ISourceMod *g_pSM;
ILibrarySys *libsys; ILibrarySys *libsys;
ITextParsers *textparser = &g_TextParser; ITextParsers *textparser = &g_TextParser;
IVEngineServer *engine; IVEngineServer *engine;
IShareSys *sharesys; IShareSys *sharesys = &g_ShareSys;
IRootConsole *rootmenu; IRootConsole *rootmenu;
IPluginManager *pluginsys; IPluginManager *pluginsys = g_PluginSys.GetOldAPI();
IForwardManager *forwardsys; IForwardManager *forwardsys;
ITimerSystem *timersys; ITimerSystem *timersys;
ServerGlobals serverGlobals; ServerGlobals serverGlobals;
@ -63,6 +68,8 @@ IAdminSystem *adminsys;
IGameHelpers *gamehelpers; IGameHelpers *gamehelpers;
ISourcePawnEngine *g_pSourcePawn; ISourcePawnEngine *g_pSourcePawn;
ISourcePawnEngine2 *g_pSourcePawn2; ISourcePawnEngine2 *g_pSourcePawn2;
CNativeOwner g_CoreNatives;
IScriptManager *scripts = &g_PluginSys;
static void AddCorePhraseFile(const char *filename) static void AddCorePhraseFile(const char *filename)
{ {
@ -85,6 +92,16 @@ static void GenerateError(IPluginContext *ctx, cell_t idx, int err, const char *
va_end(ap); va_end(ap);
} }
static void AddNatives(sp_nativeinfo_t *natives)
{
g_CoreNatives.AddNatives(natives);
}
static void DumpHandles(void (*dumpfn)(const char *fmt, ...))
{
g_HandleSys.Dump(dumpfn);
}
static sm_logic_t logic = static sm_logic_t logic =
{ {
NULL, NULL,
@ -100,7 +117,15 @@ static sm_logic_t logic =
GetCoreGameConfig, GetCoreGameConfig,
OnLogPrint, OnLogPrint,
&g_DbgReporter, &g_DbgReporter,
GenerateError GenerateError,
AddNatives,
DumpHandles,
&g_PluginSys,
&g_ShareSys,
&g_Extensions,
&g_HandleSys,
NULL,
-1.0f
}; };
static void logic_init(const sm_core_t* core, sm_logic_t* _logic) static void logic_init(const sm_core_t* core, sm_logic_t* _logic)
@ -111,14 +136,10 @@ static void logic_init(const sm_core_t* core, sm_logic_t* _logic)
memcpy(_logic, &logic, sizeof(sm_logic_t)); memcpy(_logic, &logic, sizeof(sm_logic_t));
memcpy(&serverGlobals, core->serverGlobals, sizeof(ServerGlobals)); memcpy(&serverGlobals, core->serverGlobals, sizeof(ServerGlobals));
handlesys = core->handlesys;
libsys = core->libsys; libsys = core->libsys;
engine = core->engine; engine = core->engine;
g_pCoreIdent = core->core_ident;
g_pSM = core->sm; g_pSM = core->sm;
sharesys = core->sharesys;
rootmenu = core->rootmenu; rootmenu = core->rootmenu;
pluginsys = core->pluginsys;
forwardsys = core->forwardsys; forwardsys = core->forwardsys;
timersys = core->timersys; timersys = core->timersys;
playerhelpers = core->playerhelpers; playerhelpers = core->playerhelpers;
@ -126,6 +147,11 @@ static void logic_init(const sm_core_t* core, sm_logic_t* _logic)
gamehelpers = core->gamehelpers; gamehelpers = core->gamehelpers;
g_pSourcePawn = *core->spe1; g_pSourcePawn = *core->spe1;
g_pSourcePawn2 = *core->spe2; g_pSourcePawn2 = *core->spe2;
g_ShareSys.Initialize();
g_pCoreIdent = g_ShareSys.CreateCoreIdentity();
_logic->core_ident = g_pCoreIdent;
} }
PLATFORM_EXTERN_C ITextParsers *get_textparsers() PLATFORM_EXTERN_C ITextParsers *get_textparsers()
@ -145,7 +171,7 @@ PLATFORM_EXTERN_C LogicInitFunction logic_load(uint32_t magic)
void CoreNativesToAdd::OnSourceModAllInitialized() void CoreNativesToAdd::OnSourceModAllInitialized()
{ {
smcore.AddNatives(m_NativeList); g_CoreNatives.AddNatives(m_NativeList);
} }
/* Overload a few things to prevent libstdc++ linking */ /* Overload a few things to prevent libstdc++ linking */

View File

@ -52,6 +52,7 @@ extern ServerGlobals serverGlobals;
extern IPlayerManager *playerhelpers; extern IPlayerManager *playerhelpers;
extern IAdminSystem *adminsys; extern IAdminSystem *adminsys;
extern IGameHelpers *gamehelpers; extern IGameHelpers *gamehelpers;
extern IScriptManager *scripts;
#endif /* _INCLUDE_SOURCEMOD_COMMON_LOGIC_H_ */ #endif /* _INCLUDE_SOURCEMOD_COMMON_LOGIC_H_ */

View File

@ -29,20 +29,27 @@
* Version: $Id$ * Version: $Id$
*/ */
#include <sp_vm_api.h>
#include <IHandleSys.h>
#include <IShareSys.h>
#ifndef _INCLUDE_SOURCEMOD_INTERCOM_H_ #ifndef _INCLUDE_SOURCEMOD_INTERCOM_H_
#define _INCLUDE_SOURCEMOD_INTERCOM_H_ #define _INCLUDE_SOURCEMOD_INTERCOM_H_
#include <sp_vm_api.h>
#include <IHandleSys.h>
#include <IShareSys.h>
#include <IPluginSys.h>
#include <sh_string.h>
#include <sp_vm_api.h>
#include <sh_vector.h>
#include <IExtensionSys.h>
using namespace SourceMod; using namespace SourceMod;
using namespace SourcePawn;
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 - 18) #define SM_LOGIC_MAGIC (0x0F47C0DE - 19)
#if defined SM_LOGIC #if defined SM_LOGIC
class IVEngineServer class IVEngineServer
@ -75,6 +82,12 @@ namespace SourceMod
class IVEngineServer; class IVEngineServer;
class ConVar; class ConVar;
class SMGlobalClass;
namespace SourceMod
{
class IChangeableForward;
}
struct ServerGlobals struct ServerGlobals
{ {
@ -83,17 +96,79 @@ struct ServerGlobals
float *frametime; float *frametime;
}; };
struct AutoConfig
{
SourceHook::String autocfg;
SourceHook::String folder;
bool create;
};
enum LibraryAction
{
LibraryAction_Removed,
LibraryAction_Added
};
class CNativeOwner;
class SMPlugin : public IPlugin
{
public:
virtual size_t GetConfigCount() = 0;
virtual AutoConfig *GetConfig(size_t i) = 0;
virtual void AddLibrary(const char *name) = 0;
virtual void AddConfig(bool create, const char *cfg, const char *folder) = 0;
virtual void SetErrorState(PluginStatus status, const char *fmt, ...) = 0;
};
class IScriptManager
{
public:
virtual void LoadAll(const char *config_path, const char *plugins_path) = 0;
virtual void RefreshAll() = 0;
virtual void Shutdown() = 0;
virtual IdentityToken_t *GetIdentity() = 0;
virtual void SyncMaxClients(int maxClients) = 0;
virtual void AddPluginsListener(IPluginsListener *listener) = 0;
virtual void RemovePluginsListener(IPluginsListener *listener) = 0;
virtual IPluginIterator *GetPluginIterator() = 0;
virtual void OnLibraryAction(const char *name, LibraryAction action) = 0;
virtual bool LibraryExists(const char *name) = 0;
virtual SMPlugin *FindPluginByOrder(unsigned num) = 0;
virtual SMPlugin *FindPluginByIdentity(IdentityToken_t *ident) = 0;
virtual SMPlugin *FindPluginByContext(IPluginContext *ctx) = 0;
virtual SMPlugin *FindPluginByContext(sp_context_t *ctx) = 0;
virtual SMPlugin *FindPluginByConsoleArg(const char *text) = 0;
virtual SMPlugin *FindPluginByHandle(Handle_t hndl, HandleError *errp) = 0;
virtual bool UnloadPlugin(IPlugin *plugin) = 0;
virtual void ListPlugins(CVector<SMPlugin *> *plugins) = 0;
virtual void AddFunctionsToForward(const char *name, IChangeableForward *fwd) = 0;
};
class IExtensionSys : public IExtensionManager
{
public:
virtual IExtension *LoadAutoExtension(const char *name) = 0;
virtual void TryAutoload() = 0;
virtual void Shutdown() = 0;
virtual IExtension *FindExtensionByFile(const char *name) = 0;
virtual bool LibraryExists(const char *name) = 0;
virtual void CallOnCoreMapStart(edict_t *edictList, int edictCount, int maxClients) = 0;
virtual IExtension *GetExtensionFromIdent(IdentityToken_t *token) = 0;
virtual void BindChildPlugin(IExtension *ext, SMPlugin *plugin) = 0;
virtual void AddRawDependency(IExtension *myself, IdentityToken_t *token, void *iface) = 0;
virtual void ListExtensions(CVector<IExtension *> *list) = 0;
};
class CCommand;
struct sm_core_t struct sm_core_t
{ {
/* Objects */ /* Objects */
IHandleSys *handlesys;
IdentityToken_t *core_ident;
ISourceMod *sm; ISourceMod *sm;
ILibrarySys *libsys; ILibrarySys *libsys;
IVEngineServer *engine; IVEngineServer *engine;
IShareSys *sharesys;
IRootConsole *rootmenu; IRootConsole *rootmenu;
IPluginManager *pluginsys;
IForwardManager *forwardsys; IForwardManager *forwardsys;
ITimerSystem *timersys; ITimerSystem *timersys;
IPlayerManager *playerhelpers; IPlayerManager *playerhelpers;
@ -102,11 +177,11 @@ struct sm_core_t
ISourcePawnEngine **spe1; ISourcePawnEngine **spe1;
ISourcePawnEngine2 **spe2; ISourcePawnEngine2 **spe2;
/* Functions */ /* Functions */
void (*AddNatives)(sp_nativeinfo_t* nlist);
ConVar * (*FindConVar)(const char*); ConVar * (*FindConVar)(const char*);
unsigned int (*strncopy)(char*, const char*, size_t); unsigned int (*strncopy)(char*, const char*, size_t);
char * (*TrimWhitespace)(char *, size_t &); char * (*TrimWhitespace)(char *, size_t &);
void (*LogError)(const char*, ...); void (*LogError)(const char*, ...);
void (*LogFatal)(const char*, ...);
void (*Log)(const char*, ...); void (*Log)(const char*, ...);
void (*LogToFile)(FILE *fp, const char*, ...); void (*LogToFile)(FILE *fp, const char*, ...);
void (*LogToGame)(const char *message); void (*LogToGame)(const char *message);
@ -122,6 +197,15 @@ struct sm_core_t
const char * (*GetSourceEngineName)(); const char * (*GetSourceEngineName)();
bool (*SymbolsAreHidden)(); bool (*SymbolsAreHidden)();
const char * (*GetCoreConfigValue)(const char*); const char * (*GetCoreConfigValue)(const char*);
bool (*IsMapLoading)();
bool (*IsMapRunning)();
int (*Argc)(const CCommand &args);
const char * (*Arg)(const CCommand &args, int arg);
int (*LoadMMSPlugin)(const char *file, bool *ok, char *error, size_t maxlength);
void (*UnloadMMSPlugin)(int id);
void (*DoGlobalPluginLoads)();
bool (*AreConfigsExecuted)();
void (*ExecuteConfigs)(IPluginContext *ctx);
/* Data */ /* Data */
ServerGlobals *serverGlobals; ServerGlobals *serverGlobals;
void * serverFactory; void * serverFactory;
@ -145,6 +229,14 @@ struct sm_logic_t
bool (*OnLogPrint)(const char *msg); // true to supercede bool (*OnLogPrint)(const char *msg); // true to supercede
IDebugListener *debugger; IDebugListener *debugger;
void (*GenerateError)(IPluginContext *, cell_t, int, const char *, ...); void (*GenerateError)(IPluginContext *, cell_t, int, const char *, ...);
void (*AddNatives)(sp_nativeinfo_t *natives);
void (*DumpHandles)(void (*dumpfn)(const char *fmt, ...));
IScriptManager *scripts;
IShareSys *sharesys;
IExtensionSys *extsys;
IHandleSys *handlesys;
IdentityToken_t *core_ident;
float sentinel;
}; };
typedef void (*LogicInitFunction)(const sm_core_t *core, sm_logic_t *logic); typedef void (*LogicInitFunction)(const sm_core_t *core, sm_logic_t *logic);
@ -152,4 +244,3 @@ typedef LogicInitFunction (*LogicLoadFunction)(uint32_t magic);
typedef ITextParsers *(*GetITextParsers)(); typedef ITextParsers *(*GetITextParsers)();
#endif /* _INCLUDE_SOURCEMOD_INTERCOM_H_ */ #endif /* _INCLUDE_SOURCEMOD_INTERCOM_H_ */

View File

@ -113,10 +113,17 @@
<ItemGroup> <ItemGroup>
<ClCompile Include="..\common_logic.cpp" /> <ClCompile Include="..\common_logic.cpp" />
<ClCompile Include="..\DebugReporter.cpp" /> <ClCompile Include="..\DebugReporter.cpp" />
<ClCompile Include="..\ExtensionSys.cpp" />
<ClCompile Include="..\GameConfigs.cpp" /> <ClCompile Include="..\GameConfigs.cpp" />
<ClCompile Include="..\HandleSys.cpp" />
<ClCompile Include="..\MemoryUtils.cpp" /> <ClCompile Include="..\MemoryUtils.cpp" />
<ClCompile Include="..\NativeInvoker.cpp" />
<ClCompile Include="..\NativeOwner.cpp" />
<ClCompile Include="..\PhraseCollection.cpp" /> <ClCompile Include="..\PhraseCollection.cpp" />
<ClCompile Include="..\PluginSys.cpp" />
<ClCompile Include="..\Profiler.cpp" /> <ClCompile Include="..\Profiler.cpp" />
<ClCompile Include="..\ShareSys.cpp" />
<ClCompile Include="..\smn_fakenatives.cpp" />
<ClCompile Include="..\smn_filesystem.cpp" /> <ClCompile Include="..\smn_filesystem.cpp" />
<ClCompile Include="..\sm_crc32.cpp" /> <ClCompile Include="..\sm_crc32.cpp" />
<ClCompile Include="..\smn_admin.cpp" /> <ClCompile Include="..\smn_admin.cpp" />
@ -151,12 +158,17 @@
<ClInclude Include="..\AutoHandleRooter.h" /> <ClInclude Include="..\AutoHandleRooter.h" />
<ClInclude Include="..\CellArray.h" /> <ClInclude Include="..\CellArray.h" />
<ClInclude Include="..\common_logic.h" /> <ClInclude Include="..\common_logic.h" />
<ClInclude Include="..\ExtensionSys.h" />
<ClInclude Include="..\GameConfigs.h" /> <ClInclude Include="..\GameConfigs.h" />
<ClInclude Include="..\intercom.h" /> <ClInclude Include="..\intercom.h" />
<ClInclude Include="..\MemoryUtils.h" /> <ClInclude Include="..\MemoryUtils.h" />
<ClInclude Include="..\MersenneTwister.h" /> <ClInclude Include="..\MersenneTwister.h" />
<ClInclude Include="..\NativeInvoker.h" />
<ClInclude Include="..\NativeOwner.h" />
<ClInclude Include="..\PhraseCollection.h" /> <ClInclude Include="..\PhraseCollection.h" />
<ClInclude Include="..\PluginSys.h" />
<ClInclude Include="..\Profiler.h" /> <ClInclude Include="..\Profiler.h" />
<ClInclude Include="..\ShareSys.h" />
<ClInclude Include="..\sm_crc32.h" /> <ClInclude Include="..\sm_crc32.h" />
<ClInclude Include="..\sm_memtable.h" /> <ClInclude Include="..\sm_memtable.h" />
<ClInclude Include="..\sm_symtable.h" /> <ClInclude Include="..\sm_symtable.h" />
@ -168,9 +180,6 @@
<ClInclude Include="..\thread\WinThreads.h" /> <ClInclude Include="..\thread\WinThreads.h" />
<ClInclude Include="..\Translator.h" /> <ClInclude Include="..\Translator.h" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\version.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>

View File

@ -123,6 +123,27 @@
<ClCompile Include="..\smn_filesystem.cpp"> <ClCompile Include="..\smn_filesystem.cpp">
<Filter>Natives</Filter> <Filter>Natives</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\smn_fakenatives.cpp">
<Filter>Natives</Filter>
</ClCompile>
<ClCompile Include="..\ExtensionSys.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\ShareSys.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\PluginSys.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\NativeInvoker.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\NativeOwner.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\HandleSys.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\CellArray.h"> <ClInclude Include="..\CellArray.h">
@ -191,10 +212,20 @@
<ClInclude Include="..\..\..\public\sm_platform.h"> <ClInclude Include="..\..\..\public\sm_platform.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
</ItemGroup> <ClInclude Include="..\ExtensionSys.h">
<ItemGroup> <Filter>Header Files</Filter>
<ResourceCompile Include="..\version.rc"> </ClInclude>
<Filter>Resource Files</Filter> <ClInclude Include="..\NativeInvoker.h">
</ResourceCompile> <Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\NativeOwner.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\PluginSys.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\ShareSys.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -31,11 +31,11 @@
#include <sh_list.h> #include <sh_list.h>
#include <sh_string.h> #include <sh_string.h>
#include "sm_trie.h" #include <sm_trie_tpl.h>
#include "sm_globals.h" #include <ISourceMod.h>
#include "common_logic.h"
#include "ShareSys.h"
#include "PluginSys.h" #include "PluginSys.h"
#include "sourcemod.h"
#include "sm_stringutil.h"
using namespace SourceHook; using namespace SourceHook;
@ -139,11 +139,10 @@ static cell_t ThrowNativeError(IPluginContext *pContext, const cell_t *params)
return pContext->ThrowNativeError("Not called from inside a native function"); return pContext->ThrowNativeError("Not called from inside a native function");
} }
g_SourceMod.SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE); g_pSM->SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE);
char buffer[512]; char buffer[512];
g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2);
g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2);
if (pContext->GetLastNativeError() != SP_ERROR_NONE) if (pContext->GetLastNativeError() != SP_ERROR_NONE)
{ {
@ -427,7 +426,7 @@ static cell_t FormatNativeString(IPluginContext *pContext, const cell_t *params)
size_t maxlen = (size_t)params[4]; size_t maxlen = (size_t)params[4];
/* Do the format */ /* Do the format */
size_t written = atcprintf(output_buffer, maxlen, format_buffer, s_curcaller, s_curparams, &var_param); size_t written = smcore.atcprintf(output_buffer, maxlen, format_buffer, s_curcaller, s_curparams, &var_param);
cell_t *addr; cell_t *addr;
pContext->LocalToPhysAddr(params[5], &addr); pContext->LocalToPhysAddr(params[5], &addr);

View File

@ -34,8 +34,8 @@
#include <IPlayerHelpers.h> #include <IPlayerHelpers.h>
#include <sh_string.h> #include <sh_string.h>
#include <sh_list.h> #include <sh_list.h>
#include "AutoHandleRooter.h"
#include "CellArray.h" #include "CellArray.h"
#include "AutoHandleRooter.h"
using namespace SourceHook; using namespace SourceHook;
using namespace SourceMod; using namespace SourceMod;

View File

@ -33,14 +33,11 @@
#include "sourcemod.h" #include "sourcemod.h"
#include "sourcemm_api.h" #include "sourcemm_api.h"
#include "sm_globals.h" #include "sm_globals.h"
#include "NativeOwner.h"
#include "sm_autonatives.h" #include "sm_autonatives.h"
#include "logic/intercom.h" #include "logic/intercom.h"
#include "LibrarySys.h" #include "LibrarySys.h"
#include "HandleSys.h"
#include "sm_stringutil.h" #include "sm_stringutil.h"
#include "Logger.h" #include "Logger.h"
#include "ShareSys.h"
#include "sm_srvcmds.h" #include "sm_srvcmds.h"
#include "ForwardSys.h" #include "ForwardSys.h"
#include "TimerSys.h" #include "TimerSys.h"
@ -49,6 +46,15 @@
#include "AdminCache.h" #include "AdminCache.h"
#include "HalfLife2.h" #include "HalfLife2.h"
#include "CoreConfig.h" #include "CoreConfig.h"
#if SOURCE_ENGINE >= SE_ALIENSWARM
#include "convar_sm_swarm.h"
#elif SOURCE_ENGINE >= SE_LEFT4DEAD
#include "convar_sm_l4d.h"
#elif SOURCE_ENGINE >= SE_ORANGEBOX
#include "convar_sm_ob.h"
#else
#include "convar_sm.h"
#endif
#if defined _WIN32 #if defined _WIN32
#define MATCHMAKINGDS_SUFFIX "" #define MATCHMAKINGDS_SUFFIX ""
@ -72,13 +78,17 @@ IThreader *g_pThreader;
ITextParsers *textparsers; ITextParsers *textparsers;
sm_logic_t logicore; sm_logic_t logicore;
ITranslator *translator; ITranslator *translator;
IScriptManager *scripts;
IShareSys *sharesys;
IExtensionSys *extsys;
IHandleSys *handlesys;
class VEngineServer_Logic : public IVEngineServer_Logic class VEngineServer_Logic : public IVEngineServer_Logic
{ {
public: public:
virtual bool IsMapValid(const char *map) virtual bool IsMapValid(const char *map)
{ {
return engine->IsMapValid(map); return !!engine->IsMapValid(map);
} }
virtual void ServerCommand(const char *cmd) virtual void ServerCommand(const char *cmd)
@ -89,11 +99,6 @@ public:
static VEngineServer_Logic logic_engine; static VEngineServer_Logic logic_engine;
static void add_natives(sp_nativeinfo_t *natives)
{
g_pCoreNatives->AddNatives(natives);
}
static ConVar *find_convar(const char *name) static ConVar *find_convar(const char *name)
{ {
return icvar->FindVar(name); return icvar->FindVar(name);
@ -108,6 +113,15 @@ static void log_error(const char *fmt, ...)
va_end(ap); va_end(ap);
} }
static void log_fatal(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
g_Logger.LogFatalEx(fmt, ap);
va_end(ap);
}
static void log_message(const char *fmt, ...) static void log_message(const char *fmt, ...)
{ {
va_list ap; va_list ap;
@ -206,21 +220,78 @@ static bool symbols_are_hidden()
static const char* get_core_config_value(const char* key) static const char* get_core_config_value(const char* key)
{ {
return g_CoreConfig.GetCoreConfigValue(key); return g_CoreConfig.GetCoreConfigValue(key);
} }
static bool is_map_loading()
{
return g_SourceMod.IsMapLoading();
}
static bool is_map_running()
{
return g_SourceMod.IsMapRunning();
}
int read_cmd_argc(const CCommand &args)
{
return args.ArgC();
}
static const char *read_cmd_arg(const CCommand &args, int arg)
{
return args.Arg(arg);
}
static int load_mms_plugin(const char *file, bool *ok, char *error, size_t maxlength)
{
bool ignore_already;
PluginId id = g_pMMPlugins->Load(file, g_PLID, ignore_already, error, maxlength);
Pl_Status status;
#ifndef METAMOD_PLAPI_VERSION
const char *file;
PluginId source;
#endif
if (!id || (
#ifndef METAMOD_PLAPI_VERSION
g_pMMPlugins->Query(id, file, status, source)
#else
g_pMMPlugins->Query(id, NULL, &status, NULL)
#endif
&& status < Pl_Paused))
{
*ok = false;
}
else
{
*ok = true;
}
return id;
}
static void unload_mms_plugin(int id)
{
char ignore[255];
g_pMMPlugins->Unload(id, true, ignore, sizeof(ignore));
}
void do_global_plugin_loads()
{
g_SourceMod.DoGlobalPluginLoads();
}
static ServerGlobals serverGlobals; static ServerGlobals serverGlobals;
static sm_core_t core_bridge = static sm_core_t core_bridge =
{ {
/* Objects */ /* Objects */
&g_HandleSys,
NULL,
&g_SourceMod, &g_SourceMod,
&g_LibSys, &g_LibSys,
reinterpret_cast<IVEngineServer*>(&logic_engine), reinterpret_cast<IVEngineServer*>(&logic_engine),
&g_ShareSys,
&g_RootMenu, &g_RootMenu,
&g_PluginSys,
&g_Forwards, &g_Forwards,
&g_Timers, &g_Timers,
&g_Players, &g_Players,
@ -229,11 +300,11 @@ static sm_core_t core_bridge =
&g_pSourcePawn, &g_pSourcePawn,
&g_pSourcePawn2, &g_pSourcePawn2,
/* Functions */ /* Functions */
add_natives,
find_convar, find_convar,
strncopy, strncopy,
UTIL_TrimWhitespace, UTIL_TrimWhitespace,
log_error, log_error,
log_fatal,
log_message, log_message,
log_to_file, log_to_file,
log_to_game, log_to_game,
@ -248,6 +319,15 @@ static sm_core_t core_bridge =
get_source_engine_name, get_source_engine_name,
symbols_are_hidden, symbols_are_hidden,
get_core_config_value, get_core_config_value,
is_map_loading,
is_map_running,
read_cmd_argc,
read_cmd_arg,
load_mms_plugin,
unload_mms_plugin,
do_global_plugin_loads,
SM_AreConfigsExecuted,
SM_ExecuteForPlugin,
&serverGlobals &serverGlobals
}; };
@ -257,7 +337,6 @@ void InitLogicBridge()
serverGlobals.frametime = &gpGlobals->frametime; serverGlobals.frametime = &gpGlobals->frametime;
serverGlobals.interval_per_tick = &gpGlobals->interval_per_tick; serverGlobals.interval_per_tick = &gpGlobals->interval_per_tick;
core_bridge.core_ident = g_pCoreIdent;
core_bridge.engineFactory = (void *)g_SMAPI->GetEngineFactory(false); core_bridge.engineFactory = (void *)g_SMAPI->GetEngineFactory(false);
core_bridge.serverFactory = (void *)g_SMAPI->GetServerFactory(false); core_bridge.serverFactory = (void *)g_SMAPI->GetServerFactory(false);
@ -286,6 +365,11 @@ void InitLogicBridge()
g_pThreader = logicore.threader; g_pThreader = logicore.threader;
g_pSourcePawn2->SetProfiler(logicore.profiler); g_pSourcePawn2->SetProfiler(logicore.profiler);
translator = logicore.translator; translator = logicore.translator;
scripts = logicore.scripts;
sharesys = logicore.sharesys;
extsys = logicore.extsys;
g_pCoreIdent = logicore.core_ident;
handlesys = logicore.handlesys;
} }
bool StartLogicBridge(char *error, size_t maxlength) bool StartLogicBridge(char *error, size_t maxlength)

View File

@ -42,6 +42,9 @@ struct sm_logic_t;
extern sm_logic_t logicore; extern sm_logic_t logicore;
extern ITranslator *translator; extern ITranslator *translator;
extern IGameConfig *g_pGameConf; extern IGameConfig *g_pGameConf;
extern IScriptManager *scripts;
extern IShareSys *sharesys;
extern IExtensionSys *extsys;
extern IHandleSys *handlesys;
#endif /* _INCLUDE_SOURCEMOD_LOGIC_BRIDGE_H_ */ #endif /* _INCLUDE_SOURCEMOD_LOGIC_BRIDGE_H_ */

View File

@ -2098,11 +2098,9 @@
</ClCompile> </ClCompile>
<ClCompile Include="..\Database.cpp" /> <ClCompile Include="..\Database.cpp" />
<ClCompile Include="..\EventManager.cpp" /> <ClCompile Include="..\EventManager.cpp" />
<ClCompile Include="..\ExtensionSys.cpp" />
<ClCompile Include="..\ForwardSys.cpp" /> <ClCompile Include="..\ForwardSys.cpp" />
<ClCompile Include="..\frame_hooks.cpp" /> <ClCompile Include="..\frame_hooks.cpp" />
<ClCompile Include="..\HalfLife2.cpp" /> <ClCompile Include="..\HalfLife2.cpp" />
<ClCompile Include="..\HandleSys.cpp" />
<ClCompile Include="..\LibrarySys.cpp" /> <ClCompile Include="..\LibrarySys.cpp" />
<ClCompile Include="..\Logger.cpp" /> <ClCompile Include="..\Logger.cpp" />
<ClCompile Include="..\logic_bridge.cpp" /> <ClCompile Include="..\logic_bridge.cpp" />
@ -2111,12 +2109,8 @@
<ClCompile Include="..\MenuStyle_Radio.cpp" /> <ClCompile Include="..\MenuStyle_Radio.cpp" />
<ClCompile Include="..\MenuStyle_Valve.cpp" /> <ClCompile Include="..\MenuStyle_Valve.cpp" />
<ClCompile Include="..\MenuVoting.cpp" /> <ClCompile Include="..\MenuVoting.cpp" />
<ClCompile Include="..\NativeInvoker.cpp" />
<ClCompile Include="..\NativeOwner.cpp" />
<ClCompile Include="..\NextMap.cpp" /> <ClCompile Include="..\NextMap.cpp" />
<ClCompile Include="..\PlayerManager.cpp" /> <ClCompile Include="..\PlayerManager.cpp" />
<ClCompile Include="..\PluginSys.cpp" />
<ClCompile Include="..\ShareSys.cpp" />
<ClCompile Include="..\smn_protobuf.cpp"> <ClCompile Include="..\smn_protobuf.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='CrazyDebug - Alien Swarm|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='CrazyDebug - Alien Swarm|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='CrazyDebug - Bloody Good Time|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='CrazyDebug - Bloody Good Time|Win32'">true</ExcludedFromBuild>
@ -2170,7 +2164,6 @@
<ClCompile Include="..\smn_database.cpp" /> <ClCompile Include="..\smn_database.cpp" />
<ClCompile Include="..\smn_entities.cpp" /> <ClCompile Include="..\smn_entities.cpp" />
<ClCompile Include="..\smn_events.cpp" /> <ClCompile Include="..\smn_events.cpp" />
<ClCompile Include="..\smn_fakenatives.cpp" />
<ClCompile Include="..\smn_halflife.cpp" /> <ClCompile Include="..\smn_halflife.cpp" />
<ClCompile Include="..\smn_hudtext.cpp" /> <ClCompile Include="..\smn_hudtext.cpp" />
<ClCompile Include="..\smn_keyvalues.cpp" /> <ClCompile Include="..\smn_keyvalues.cpp" />
@ -2308,11 +2301,9 @@
<ClInclude Include="..\CoreConfig.h" /> <ClInclude Include="..\CoreConfig.h" />
<ClInclude Include="..\Database.h" /> <ClInclude Include="..\Database.h" />
<ClInclude Include="..\EventManager.h" /> <ClInclude Include="..\EventManager.h" />
<ClInclude Include="..\ExtensionSys.h" />
<ClInclude Include="..\ForwardSys.h" /> <ClInclude Include="..\ForwardSys.h" />
<ClInclude Include="..\frame_hooks.h" /> <ClInclude Include="..\frame_hooks.h" />
<ClInclude Include="..\HalfLife2.h" /> <ClInclude Include="..\HalfLife2.h" />
<ClInclude Include="..\HandleSys.h" />
<ClInclude Include="..\LibrarySys.h" /> <ClInclude Include="..\LibrarySys.h" />
<ClInclude Include="..\Logger.h" /> <ClInclude Include="..\Logger.h" />
<ClInclude Include="..\logic_bridge.h" /> <ClInclude Include="..\logic_bridge.h" />
@ -2321,12 +2312,8 @@
<ClInclude Include="..\MenuStyle_Radio.h" /> <ClInclude Include="..\MenuStyle_Radio.h" />
<ClInclude Include="..\MenuStyle_Valve.h" /> <ClInclude Include="..\MenuStyle_Valve.h" />
<ClInclude Include="..\MenuVoting.h" /> <ClInclude Include="..\MenuVoting.h" />
<ClInclude Include="..\NativeInvoker.h" />
<ClInclude Include="..\NativeOwner.h" />
<ClInclude Include="..\NextMap.h" /> <ClInclude Include="..\NextMap.h" />
<ClInclude Include="..\PlayerManager.h" /> <ClInclude Include="..\PlayerManager.h" />
<ClInclude Include="..\PluginSys.h" />
<ClInclude Include="..\ShareSys.h" />
<ClInclude Include="..\sm_autonatives.h" /> <ClInclude Include="..\sm_autonatives.h" />
<ClInclude Include="..\sm_fastlink.h" /> <ClInclude Include="..\sm_fastlink.h" />
<ClInclude Include="..\sm_globals.h" /> <ClInclude Include="..\sm_globals.h" />

View File

@ -69,9 +69,6 @@
<ClCompile Include="..\EventManager.cpp"> <ClCompile Include="..\EventManager.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\ExtensionSys.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\ForwardSys.cpp"> <ClCompile Include="..\ForwardSys.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
@ -81,9 +78,6 @@
<ClCompile Include="..\HalfLife2.cpp"> <ClCompile Include="..\HalfLife2.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\HandleSys.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\LibrarySys.cpp"> <ClCompile Include="..\LibrarySys.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
@ -108,24 +102,12 @@
<ClCompile Include="..\MenuVoting.cpp"> <ClCompile Include="..\MenuVoting.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\NativeInvoker.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\NativeOwner.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\NextMap.cpp"> <ClCompile Include="..\NextMap.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\PlayerManager.cpp"> <ClCompile Include="..\PlayerManager.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\PluginSys.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\ShareSys.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\sm_autonatives.cpp"> <ClCompile Include="..\sm_autonatives.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
@ -168,9 +150,6 @@
<ClCompile Include="..\smn_events.cpp"> <ClCompile Include="..\smn_events.cpp">
<Filter>Natives</Filter> <Filter>Natives</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\smn_fakenatives.cpp">
<Filter>Natives</Filter>
</ClCompile>
<ClCompile Include="..\smn_halflife.cpp"> <ClCompile Include="..\smn_halflife.cpp">
<Filter>Natives</Filter> <Filter>Natives</Filter>
</ClCompile> </ClCompile>
@ -251,9 +230,6 @@
<ClInclude Include="..\EventManager.h"> <ClInclude Include="..\EventManager.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\ExtensionSys.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\ForwardSys.h"> <ClInclude Include="..\ForwardSys.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
@ -263,9 +239,6 @@
<ClInclude Include="..\HalfLife2.h"> <ClInclude Include="..\HalfLife2.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\HandleSys.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\LibrarySys.h"> <ClInclude Include="..\LibrarySys.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
@ -290,24 +263,12 @@
<ClInclude Include="..\MenuVoting.h"> <ClInclude Include="..\MenuVoting.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\NativeInvoker.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\NativeOwner.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\NextMap.h"> <ClInclude Include="..\NextMap.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\PlayerManager.h"> <ClInclude Include="..\PlayerManager.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\PluginSys.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\ShareSys.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\sm_autonatives.h"> <ClInclude Include="..\sm_autonatives.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>

View File

@ -0,0 +1,95 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sourcemod_mm", "sourcemod_mm.vcxproj", "{E39527CD-7CAB-4420-97CC-DA1B93B260BC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
CrazyDebug - Alien Swarm|Win32 = CrazyDebug - Alien Swarm|Win32
CrazyDebug - CS GO|Win32 = CrazyDebug - CS GO|Win32
CrazyDebug - Dark Messiah|Win32 = CrazyDebug - Dark Messiah|Win32
CrazyDebug - Episode 1|Win32 = CrazyDebug - Episode 1|Win32
CrazyDebug - Left 4 Dead 2|Win32 = CrazyDebug - Left 4 Dead 2|Win32
CrazyDebug - Left 4 Dead|Win32 = CrazyDebug - Left 4 Dead|Win32
CrazyDebug - Old Metamod|Win32 = CrazyDebug - Old Metamod|Win32
CrazyDebug - Orange Box Valve|Win32 = CrazyDebug - Orange Box Valve|Win32
CrazyDebug - Orange Box|Win32 = CrazyDebug - Orange Box|Win32
Debug - Alien Swarm|Win32 = Debug - Alien Swarm|Win32
Debug - CS GO|Win32 = Debug - CS GO|Win32
Debug - Dark Messiah|Win32 = Debug - Dark Messiah|Win32
Debug - Episode 1|Win32 = Debug - Episode 1|Win32
Debug - Left 4 Dead 2|Win32 = Debug - Left 4 Dead 2|Win32
Debug - Left 4 Dead|Win32 = Debug - Left 4 Dead|Win32
Debug - Old Metamod|Win32 = Debug - Old Metamod|Win32
Debug - Orange Box Valve|Win32 = Debug - Orange Box Valve|Win32
Debug - Orange Box|Win32 = Debug - Orange Box|Win32
Release - Alien Swarm|Win32 = Release - Alien Swarm|Win32
Release - CS GO|Win32 = Release - CS GO|Win32
Release - Dark Messiah|Win32 = Release - Dark Messiah|Win32
Release - Episode 1|Win32 = Release - Episode 1|Win32
Release - Left 4 Dead 2|Win32 = Release - Left 4 Dead 2|Win32
Release - Left 4 Dead|Win32 = Release - Left 4 Dead|Win32
Release - Old Metamod|Win32 = Release - Old Metamod|Win32
Release - Orange Box Valve|Win32 = Release - Orange Box Valve|Win32
Release - Orange Box|Win32 = Release - Orange Box|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Alien Swarm|Win32.ActiveCfg = CrazyDebug - Alien Swarm|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Alien Swarm|Win32.Build.0 = CrazyDebug - Alien Swarm|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - CS GO|Win32.ActiveCfg = CrazyDebug - CS GO|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - CS GO|Win32.Build.0 = CrazyDebug - CS GO|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Dark Messiah|Win32.ActiveCfg = CrazyDebug - Dark Messiah|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Dark Messiah|Win32.Build.0 = CrazyDebug - Dark Messiah|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Episode 1|Win32.ActiveCfg = CrazyDebug - Episode 1|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Episode 1|Win32.Build.0 = CrazyDebug - Episode 1|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Left 4 Dead 2|Win32.ActiveCfg = CrazyDebug - Left 4 Dead 2|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Left 4 Dead 2|Win32.Build.0 = CrazyDebug - Left 4 Dead 2|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Left 4 Dead|Win32.ActiveCfg = CrazyDebug - Left 4 Dead|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Left 4 Dead|Win32.Build.0 = CrazyDebug - Left 4 Dead|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Old Metamod|Win32.ActiveCfg = CrazyDebug - Old Metamod|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Old Metamod|Win32.Build.0 = CrazyDebug - Old Metamod|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Orange Box Valve|Win32.ActiveCfg = CrazyDebug - Orange Box Valve|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Orange Box Valve|Win32.Build.0 = CrazyDebug - Orange Box Valve|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Orange Box|Win32.ActiveCfg = CrazyDebug - Orange Box|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.CrazyDebug - Orange Box|Win32.Build.0 = CrazyDebug - Orange Box|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Alien Swarm|Win32.ActiveCfg = Debug - Alien Swarm|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Alien Swarm|Win32.Build.0 = Debug - Alien Swarm|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - CS GO|Win32.ActiveCfg = Debug - CS GO|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - CS GO|Win32.Build.0 = Debug - CS GO|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Dark Messiah|Win32.ActiveCfg = Debug - Dark Messiah|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Dark Messiah|Win32.Build.0 = Debug - Dark Messiah|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Episode 1|Win32.ActiveCfg = Debug - Episode 1|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Episode 1|Win32.Build.0 = Debug - Episode 1|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Left 4 Dead 2|Win32.ActiveCfg = Debug - Left 4 Dead 2|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Left 4 Dead 2|Win32.Build.0 = Debug - Left 4 Dead 2|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Left 4 Dead|Win32.ActiveCfg = Debug - Left 4 Dead|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Left 4 Dead|Win32.Build.0 = Debug - Left 4 Dead|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Old Metamod|Win32.ActiveCfg = Debug - Old Metamod|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Old Metamod|Win32.Build.0 = Debug - Old Metamod|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Orange Box Valve|Win32.ActiveCfg = Debug - Orange Box Valve|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Orange Box Valve|Win32.Build.0 = Debug - Orange Box Valve|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Orange Box|Win32.ActiveCfg = Debug - Orange Box|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Debug - Orange Box|Win32.Build.0 = Debug - Orange Box|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Alien Swarm|Win32.ActiveCfg = Release - Alien Swarm|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Alien Swarm|Win32.Build.0 = Release - Alien Swarm|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - CS GO|Win32.ActiveCfg = Release - CS GO|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - CS GO|Win32.Build.0 = Release - CS GO|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Dark Messiah|Win32.ActiveCfg = Release - Dark Messiah|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Dark Messiah|Win32.Build.0 = Release - Dark Messiah|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Episode 1|Win32.ActiveCfg = Release - Episode 1|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Episode 1|Win32.Build.0 = Release - Episode 1|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Left 4 Dead 2|Win32.ActiveCfg = Release - Left 4 Dead 2|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Left 4 Dead 2|Win32.Build.0 = Release - Left 4 Dead 2|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Left 4 Dead|Win32.ActiveCfg = Release - Left 4 Dead|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Left 4 Dead|Win32.Build.0 = Release - Left 4 Dead|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Old Metamod|Win32.ActiveCfg = Release - Old Metamod|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Old Metamod|Win32.Build.0 = Release - Old Metamod|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Orange Box Valve|Win32.ActiveCfg = Release - Orange Box Valve|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Orange Box Valve|Win32.Build.0 = Release - Orange Box Valve|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Orange Box|Win32.ActiveCfg = Release - Orange Box|Win32
{E39527CD-7CAB-4420-97CC-DA1B93B260BC}.Release - Orange Box|Win32.Build.0 = Release - Orange Box|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

File diff suppressed because it is too large Load Diff

View File

@ -30,14 +30,9 @@
*/ */
#include "sm_autonatives.h" #include "sm_autonatives.h"
#include "PluginSys.h" #include "logic_bridge.h"
#include "NativeOwner.h"
CNativeOwner g_CoreNatives;
CNativeOwner *g_pCoreNatives = &g_CoreNatives;
void CoreNativesToAdd::OnSourceModAllInitialized() void CoreNativesToAdd::OnSourceModAllInitialized()
{ {
g_CoreNatives.AddNatives(m_NativeList); logicore.AddNatives(m_NativeList);
} }

View File

@ -50,8 +50,4 @@ public:
sp_nativeinfo_t *m_NativeList; sp_nativeinfo_t *m_NativeList;
}; };
class CNativeOwner;
extern CNativeOwner *g_pCoreNatives;
#endif //_INCLUDE_SOURCEMOD_CORE_AUTONATIVES_H_ #endif //_INCLUDE_SOURCEMOD_CORE_AUTONATIVES_H_

View File

@ -32,10 +32,9 @@
#include "sm_srvcmds.h" #include "sm_srvcmds.h"
#include <sourcemod_version.h> #include <sourcemod_version.h>
#include "sm_stringutil.h" #include "sm_stringutil.h"
#include "HandleSys.h"
#include "CoreConfig.h" #include "CoreConfig.h"
#include "ConVarManager.h" #include "ConVarManager.h"
#include "ShareSys.h" #include "logic_bridge.h"
RootConsoleMenu g_RootMenu; RootConsoleMenu g_RootMenu;
@ -71,7 +70,7 @@ void RootConsoleMenu::OnSourceModStartup(bool late)
void RootConsoleMenu::OnSourceModAllInitialized() void RootConsoleMenu::OnSourceModAllInitialized()
{ {
g_ShareSys.AddInterface(NULL, this); sharesys->AddInterface(NULL, this);
} }
void RootConsoleMenu::OnSourceModShutdown() void RootConsoleMenu::OnSourceModShutdown()
@ -406,14 +405,14 @@ CON_COMMAND(sm_dump_handles, "Dumps Handle usage to a file for finding Handle le
} }
g_pHndlLog = fp; g_pHndlLog = fp;
g_HandleSys.Dump(write_handles_to_log); logicore.DumpHandles(write_handles_to_log);
g_pHndlLog = NULL; g_pHndlLog = NULL;
fclose(fp); fclose(fp);
} }
else else
{ {
g_HandleSys.Dump(write_handles_to_game); logicore.DumpHandles(write_handles_to_game);
} }
} }

View File

@ -34,7 +34,6 @@
#include "sourcemod.h" #include "sourcemod.h"
#include <IRootConsoleMenu.h> #include <IRootConsoleMenu.h>
#include "PluginSys.h"
#include "sourcemm_api.h" #include "sourcemm_api.h"
#include <sh_list.h> #include <sh_list.h>
#include <sh_string.h> #include <sh_string.h>

View File

@ -32,11 +32,12 @@
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h> #include <ctype.h>
#include <stdarg.h> #include <stdarg.h>
#include <ITextParsers.h>
#include "sm_stringutil.h" #include "sm_stringutil.h"
#include "Logger.h" #include "Logger.h"
#include "PluginSys.h"
#include "PlayerManager.h" #include "PlayerManager.h"
#include "logic_bridge.h" #include "logic_bridge.h"
#include "sourcemod.h"
#define LADJUST 0x00000004 /* left adjustment */ #define LADJUST 0x00000004 /* left adjustment */
#define ZEROPAD 0x00000080 /* zero (as opposed to blank) pad */ #define ZEROPAD 0x00000080 /* zero (as opposed to blank) pad */
@ -72,7 +73,7 @@ size_t Translate(char *buffer,
unsigned int langid; unsigned int langid;
*error = false; *error = false;
Translation pTrans; Translation pTrans;
CPlugin *pl = (CPlugin *)g_PluginSys.FindPluginByContext(pCtx->GetContext()); IPlugin *pl = scripts->FindPluginByContext(pCtx->GetContext());
unsigned int max_params = 0; unsigned int max_params = 0;
IPhraseCollection *pPhrases; IPhraseCollection *pPhrases;

View File

@ -34,11 +34,12 @@
#ifndef USE_PROTOBUF_USERMESSAGES #ifndef USE_PROTOBUF_USERMESSAGES
#include "sourcemod.h" #include "sourcemod.h"
#include "HandleSys.h"
#include <bitbuf.h> #include <bitbuf.h>
#include <vector.h> #include <vector.h>
#include <HalfLife2.h> #include <HalfLife2.h>
#include "smn_usermsgs.h" #include "smn_usermsgs.h"
#include "sourcemod.h"
#include "logic_bridge.h"
static cell_t smn_BfWriteBool(IPluginContext *pCtx, const cell_t *params) static cell_t smn_BfWriteBool(IPluginContext *pCtx, const cell_t *params)
{ {
@ -50,7 +51,7 @@ static cell_t smn_BfWriteBool(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_WrBitBufType, &sec, (void **)&pBitBuf)) if ((herr=handlesys->ReadHandle(hndl, g_WrBitBufType, &sec, (void **)&pBitBuf))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr);
@ -71,7 +72,7 @@ static cell_t smn_BfWriteByte(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_WrBitBufType, &sec, (void **)&pBitBuf)) if ((herr=handlesys->ReadHandle(hndl, g_WrBitBufType, &sec, (void **)&pBitBuf))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr);
@ -92,7 +93,7 @@ static cell_t smn_BfWriteChar(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_WrBitBufType, &sec, (void **)&pBitBuf)) if ((herr=handlesys->ReadHandle(hndl, g_WrBitBufType, &sec, (void **)&pBitBuf))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr);
@ -113,7 +114,7 @@ static cell_t smn_BfWriteShort(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_WrBitBufType, &sec, (void **)&pBitBuf)) if ((herr=handlesys->ReadHandle(hndl, g_WrBitBufType, &sec, (void **)&pBitBuf))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr);
@ -134,7 +135,7 @@ static cell_t smn_BfWriteWord(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_WrBitBufType, &sec, (void **)&pBitBuf)) if ((herr=handlesys->ReadHandle(hndl, g_WrBitBufType, &sec, (void **)&pBitBuf))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr);
@ -155,7 +156,7 @@ static cell_t smn_BfWriteNum(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_WrBitBufType, &sec, (void **)&pBitBuf)) if ((herr=handlesys->ReadHandle(hndl, g_WrBitBufType, &sec, (void **)&pBitBuf))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr);
@ -176,7 +177,7 @@ static cell_t smn_BfWriteFloat(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_WrBitBufType, &sec, (void **)&pBitBuf)) if ((herr=handlesys->ReadHandle(hndl, g_WrBitBufType, &sec, (void **)&pBitBuf))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr);
@ -198,7 +199,7 @@ static cell_t smn_BfWriteString(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_WrBitBufType, &sec, (void **)&pBitBuf)) if ((herr=handlesys->ReadHandle(hndl, g_WrBitBufType, &sec, (void **)&pBitBuf))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr);
@ -226,7 +227,7 @@ static cell_t smn_BfWriteEntity(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_WrBitBufType, &sec, (void **)&pBitBuf)) if ((herr=handlesys->ReadHandle(hndl, g_WrBitBufType, &sec, (void **)&pBitBuf))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr);
@ -254,7 +255,7 @@ static cell_t smn_BfWriteAngle(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_WrBitBufType, &sec, (void **)&pBitBuf)) if ((herr=handlesys->ReadHandle(hndl, g_WrBitBufType, &sec, (void **)&pBitBuf))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr);
@ -275,7 +276,7 @@ static cell_t smn_BfWriteCoord(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_WrBitBufType, &sec, (void **)&pBitBuf)) if ((herr=handlesys->ReadHandle(hndl, g_WrBitBufType, &sec, (void **)&pBitBuf))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr);
@ -296,7 +297,7 @@ static cell_t smn_BfWriteVecCoord(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_WrBitBufType, &sec, (void **)&pBitBuf)) if ((herr=handlesys->ReadHandle(hndl, g_WrBitBufType, &sec, (void **)&pBitBuf))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr);
@ -320,7 +321,7 @@ static cell_t smn_BfWriteVecNormal(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_WrBitBufType, &sec, (void **)&pBitBuf)) if ((herr=handlesys->ReadHandle(hndl, g_WrBitBufType, &sec, (void **)&pBitBuf))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr);
@ -344,7 +345,7 @@ static cell_t smn_BfWriteAngles(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_WrBitBufType, &sec, (void **)&pBitBuf)) if ((herr=handlesys->ReadHandle(hndl, g_WrBitBufType, &sec, (void **)&pBitBuf))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr);
@ -368,7 +369,7 @@ static cell_t smn_BfReadBool(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_RdBitBufType, &sec, (void **)&pBitBuf)) if ((herr=handlesys->ReadHandle(hndl, g_RdBitBufType, &sec, (void **)&pBitBuf))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr);
@ -387,7 +388,7 @@ static cell_t smn_BfReadByte(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_RdBitBufType, &sec, (void **)&pBitBuf)) if ((herr=handlesys->ReadHandle(hndl, g_RdBitBufType, &sec, (void **)&pBitBuf))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr);
@ -406,7 +407,7 @@ static cell_t smn_BfReadChar(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_RdBitBufType, &sec, (void **)&pBitBuf)) if ((herr=handlesys->ReadHandle(hndl, g_RdBitBufType, &sec, (void **)&pBitBuf))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr);
@ -425,7 +426,7 @@ static cell_t smn_BfReadShort(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_RdBitBufType, &sec, (void **)&pBitBuf)) if ((herr=handlesys->ReadHandle(hndl, g_RdBitBufType, &sec, (void **)&pBitBuf))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr);
@ -444,7 +445,7 @@ static cell_t smn_BfReadWord(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_RdBitBufType, &sec, (void **)&pBitBuf)) if ((herr=handlesys->ReadHandle(hndl, g_RdBitBufType, &sec, (void **)&pBitBuf))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr);
@ -463,7 +464,7 @@ static cell_t smn_BfReadNum(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_RdBitBufType, &sec, (void **)&pBitBuf)) if ((herr=handlesys->ReadHandle(hndl, g_RdBitBufType, &sec, (void **)&pBitBuf))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr);
@ -482,7 +483,7 @@ static cell_t smn_BfReadFloat(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_RdBitBufType, &sec, (void **)&pBitBuf)) if ((herr=handlesys->ReadHandle(hndl, g_RdBitBufType, &sec, (void **)&pBitBuf))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr);
@ -503,7 +504,7 @@ static cell_t smn_BfReadString(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_RdBitBufType, &sec, (void **)&pBitBuf)) if ((herr=handlesys->ReadHandle(hndl, g_RdBitBufType, &sec, (void **)&pBitBuf))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr);
@ -530,7 +531,7 @@ static cell_t smn_BfReadEntity(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_RdBitBufType, &sec, (void **)&pBitBuf)) if ((herr=handlesys->ReadHandle(hndl, g_RdBitBufType, &sec, (void **)&pBitBuf))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr);
@ -551,7 +552,7 @@ static cell_t smn_BfReadAngle(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_RdBitBufType, &sec, (void **)&pBitBuf)) if ((herr=handlesys->ReadHandle(hndl, g_RdBitBufType, &sec, (void **)&pBitBuf))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr);
@ -570,7 +571,7 @@ static cell_t smn_BfReadCoord(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_RdBitBufType, &sec, (void **)&pBitBuf)) if ((herr=handlesys->ReadHandle(hndl, g_RdBitBufType, &sec, (void **)&pBitBuf))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr);
@ -589,7 +590,7 @@ static cell_t smn_BfReadVecCoord(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_RdBitBufType, &sec, (void **)&pBitBuf)) if ((herr=handlesys->ReadHandle(hndl, g_RdBitBufType, &sec, (void **)&pBitBuf))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr);
@ -618,7 +619,7 @@ static cell_t smn_BfReadVecNormal(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_RdBitBufType, &sec, (void **)&pBitBuf)) if ((herr=handlesys->ReadHandle(hndl, g_RdBitBufType, &sec, (void **)&pBitBuf))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr);
@ -647,7 +648,7 @@ static cell_t smn_BfReadAngles(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_RdBitBufType, &sec, (void **)&pBitBuf)) if ((herr=handlesys->ReadHandle(hndl, g_RdBitBufType, &sec, (void **)&pBitBuf))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr);
@ -676,7 +677,7 @@ static cell_t smn_BfGetNumBytesLeft(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_RdBitBufType, &sec, (void **)&pBitBuf)) if ((herr=handlesys->ReadHandle(hndl, g_RdBitBufType, &sec, (void **)&pBitBuf))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid bit buffer handle %x (error %d)", hndl, herr);

View File

@ -32,10 +32,8 @@
#include "sm_globals.h" #include "sm_globals.h"
#include "HalfLife2.h" #include "HalfLife2.h"
#include "sourcemm_api.h" #include "sourcemm_api.h"
#include "HandleSys.h"
#include "ConVarManager.h" #include "ConVarManager.h"
#include "ConCmdManager.h" #include "ConCmdManager.h"
#include "PluginSys.h"
#include "sm_stringutil.h" #include "sm_stringutil.h"
#include "PlayerManager.h" #include "PlayerManager.h"
#include "ChatTriggers.h" #include "ChatTriggers.h"
@ -47,6 +45,7 @@
#include "Logger.h" #include "Logger.h"
#include "ConsoleDetours.h" #include "ConsoleDetours.h"
#include "ConCommandBaseIterator.h" #include "ConCommandBaseIterator.h"
#include "logic_bridge.h"
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_DOTA #if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_DOTA
#include <netmessages.pb.h> #include <netmessages.pb.h>
@ -88,13 +87,13 @@ public:
{ {
HandleAccess access; HandleAccess access;
g_HandleSys.InitAccessDefaults(NULL, &access); handlesys->InitAccessDefaults(NULL, &access);
htConCmdIter = g_HandleSys.CreateType("ConCmdIter", this, 0, NULL, &access, g_pCoreIdent, NULL); htConCmdIter = handlesys->CreateType("ConCmdIter", this, 0, NULL, &access, g_pCoreIdent, NULL);
access.access[HandleAccess_Clone] = HANDLE_RESTRICT_OWNER | HANDLE_RESTRICT_IDENTITY; access.access[HandleAccess_Clone] = HANDLE_RESTRICT_OWNER | HANDLE_RESTRICT_IDENTITY;
hCmdIterType = g_HandleSys.CreateType("CmdIter", this, 0, NULL, &access, g_pCoreIdent, NULL); hCmdIterType = handlesys->CreateType("CmdIter", this, 0, NULL, &access, g_pCoreIdent, NULL);
} }
virtual void OnHandleDestroy(HandleType_t type, void *object) virtual void OnHandleDestroy(HandleType_t type, void *object)
{ {
@ -726,7 +725,7 @@ static cell_t sm_RegConsoleCmd(IPluginContext *pContext, const cell_t *params)
return pContext->ThrowNativeError("Invalid function id (%X)", params[2]); return pContext->ThrowNativeError("Invalid function id (%X)", params[2]);
} }
CPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pContext->GetContext()); IPlugin *pPlugin = scripts->FindPluginByContext(pContext->GetContext());
const char *group = pPlugin->GetFilename(); const char *group = pPlugin->GetFilename();
if (!g_ConCmds.AddAdminCommand(pFunction, name, group, 0, help, params[4])) if (!g_ConCmds.AddAdminCommand(pFunction, name, group, 0, help, params[4]))
{ {
@ -757,7 +756,7 @@ static cell_t sm_RegAdminCmd(IPluginContext *pContext, const cell_t *params)
if (group[0] == '\0') if (group[0] == '\0')
{ {
CPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pContext->GetContext()); IPlugin *pPlugin = scripts->FindPluginByContext(pContext->GetContext());
group = pPlugin->GetFilename(); group = pPlugin->GetFilename();
} }
@ -1211,7 +1210,7 @@ static cell_t GetCommandIterator(IPluginContext *pContext, const cell_t *params)
GlobCmdIter *iter = new GlobCmdIter; GlobCmdIter *iter = new GlobCmdIter;
iter->started = false; iter->started = false;
Handle_t hndl = g_HandleSys.CreateHandle(hCmdIterType, iter, pContext->GetIdentity(), g_pCoreIdent, NULL); Handle_t hndl = handlesys->CreateHandle(hCmdIterType, iter, pContext->GetIdentity(), g_pCoreIdent, NULL);
if (hndl == BAD_HANDLE) if (hndl == BAD_HANDLE)
{ {
delete iter; delete iter;
@ -1226,7 +1225,7 @@ static cell_t ReadCommandIterator(IPluginContext *pContext, const cell_t *params
HandleError err; HandleError err;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err = g_HandleSys.ReadHandle(params[1], hCmdIterType, &sec, (void **)&iter)) if ((err = handlesys->ReadHandle(params[1], hCmdIterType, &sec, (void **)&iter))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid GlobCmdIter Handle %x", params[1]); return pContext->ThrowNativeError("Invalid GlobCmdIter Handle %x", params[1]);
@ -1365,7 +1364,7 @@ static cell_t FindFirstConCommand(IPluginContext *pContext, const cell_t *params
pContext->StringToLocalUTF8(params[5], params[6], (desc && desc[0]) ? desc : "", NULL); pContext->StringToLocalUTF8(params[5], params[6], (desc && desc[0]) ? desc : "", NULL);
} }
if ((hndl = g_HandleSys.CreateHandle(htConCmdIter, pIter, pContext->GetIdentity(), g_pCoreIdent, NULL)) if ((hndl = handlesys->CreateHandle(htConCmdIter, pIter, pContext->GetIdentity(), g_pCoreIdent, NULL))
== BAD_HANDLE) == BAD_HANDLE)
{ {
delete pIter; delete pIter;
@ -1384,7 +1383,7 @@ static cell_t FindNextConCommand(IPluginContext *pContext, const cell_t *params)
const ConCommandBase *pConCmd; const ConCommandBase *pConCmd;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err = g_HandleSys.ReadHandle(params[1], htConCmdIter, &sec, (void **)&pIter)) != HandleError_None) if ((err = handlesys->ReadHandle(params[1], htConCmdIter, &sec, (void **)&pIter)) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid Handle %x (error %d)", params[1], err); return pContext->ThrowNativeError("Invalid Handle %x (error %d)", params[1], err);
} }

View File

@ -35,15 +35,13 @@
#include "sm_stringutil.h" #include "sm_stringutil.h"
#include "sm_globals.h" #include "sm_globals.h"
#include "sourcemod.h" #include "sourcemod.h"
#include "PluginSys.h"
#include "HandleSys.h"
#include "LibrarySys.h" #include "LibrarySys.h"
#include "TimerSys.h" #include "TimerSys.h"
#include "ForwardSys.h" #include "ForwardSys.h"
#include "Logger.h" #include "Logger.h"
#include "ExtensionSys.h"
#include <sm_trie_tpl.h> #include <sm_trie_tpl.h>
#include <sh_memory.h> #include <sh_memory.h>
#include "logic_bridge.h"
#if defined PLATFORM_WINDOWS #if defined PLATFORM_WINDOWS
#include <windows.h> #include <windows.h>
@ -65,10 +63,10 @@ public:
void OnSourceModAllInitialized() void OnSourceModAllInitialized()
{ {
HandleAccess hacc; HandleAccess hacc;
g_HandleSys.InitAccessDefaults(NULL, &hacc); handlesys->InitAccessDefaults(NULL, &hacc);
hacc.access[HandleAccess_Clone] = HANDLE_RESTRICT_IDENTITY|HANDLE_RESTRICT_OWNER; hacc.access[HandleAccess_Clone] = HANDLE_RESTRICT_IDENTITY|HANDLE_RESTRICT_OWNER;
g_PlIter = g_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 = g_Forwards.CreateForward("OnLogAction",
ET_Hook, ET_Hook,
@ -88,7 +86,7 @@ public:
void OnSourceModShutdown() void OnSourceModShutdown()
{ {
g_Forwards.ReleaseForward(g_OnLogAction); g_Forwards.ReleaseForward(g_OnLogAction);
g_HandleSys.RemoveType(g_PlIter, g_pCoreIdent); handlesys->RemoveType(g_PlIter, g_pCoreIdent);
} }
} g_CoreNativeHelpers; } g_CoreNativeHelpers;
@ -114,7 +112,7 @@ void LogAction(Handle_t hndl, int type, int client, int target, const char *mess
if (type == 2) if (type == 2)
{ {
HandleError err; HandleError err;
IPlugin *pPlugin = g_PluginSys.PluginFromHandle(hndl, &err); IPlugin *pPlugin = scripts->FindPluginByHandle(hndl, &err);
if (pPlugin) if (pPlugin)
{ {
logtag = pPlugin->GetFilename(); logtag = pPlugin->GetFilename();
@ -197,9 +195,9 @@ static cell_t FormatTime(IPluginContext *pContext, const cell_t *params)
static cell_t GetPluginIterator(IPluginContext *pContext, const cell_t *params) static cell_t GetPluginIterator(IPluginContext *pContext, const cell_t *params)
{ {
IPluginIterator *iter = g_PluginSys.GetPluginIterator(); IPluginIterator *iter = scripts->GetPluginIterator();
Handle_t hndl = g_HandleSys.CreateHandle(g_PlIter, iter, pContext->GetIdentity(), g_pCoreIdent, NULL); Handle_t hndl = handlesys->CreateHandle(g_PlIter, iter, pContext->GetIdentity(), g_pCoreIdent, NULL);
if (hndl == BAD_HANDLE) if (hndl == BAD_HANDLE)
{ {
@ -219,7 +217,7 @@ static cell_t MorePlugins(IPluginContext *pContext, const cell_t *params)
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
sec.pOwner = pContext->GetIdentity(); sec.pOwner = pContext->GetIdentity();
if ((err=g_HandleSys.ReadHandle(hndl, g_PlIter, &sec, (void **)&pIter)) != HandleError_None) if ((err=handlesys->ReadHandle(hndl, g_PlIter, &sec, (void **)&pIter)) != HandleError_None)
{ {
return pContext->ThrowNativeError("Could not read Handle %x (error %d)", hndl, err); return pContext->ThrowNativeError("Could not read Handle %x (error %d)", hndl, err);
} }
@ -237,12 +235,12 @@ static cell_t ReadPlugin(IPluginContext *pContext, const cell_t *params)
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
sec.pOwner = pContext->GetIdentity(); sec.pOwner = pContext->GetIdentity();
if ((err=g_HandleSys.ReadHandle(hndl, g_PlIter, &sec, (void **)&pIter)) != HandleError_None) if ((err=handlesys->ReadHandle(hndl, g_PlIter, &sec, (void **)&pIter)) != HandleError_None)
{ {
return pContext->ThrowNativeError("Could not read Handle %x (error %d)", hndl, err); return pContext->ThrowNativeError("Could not read Handle %x (error %d)", hndl, err);
} }
CPlugin *pPlugin = (CPlugin *)pIter->GetPlugin(); IPlugin *pPlugin = pIter->GetPlugin();
if (!pPlugin) if (!pPlugin)
{ {
return BAD_HANDLE; return BAD_HANDLE;
@ -253,14 +251,14 @@ static cell_t ReadPlugin(IPluginContext *pContext, const cell_t *params)
return pPlugin->GetMyHandle(); return pPlugin->GetMyHandle();
} }
CPlugin *GetPluginFromHandle(IPluginContext *pContext, Handle_t hndl) IPlugin *GetPluginFromHandle(IPluginContext *pContext, Handle_t hndl)
{ {
if (hndl == BAD_HANDLE) if (hndl == BAD_HANDLE)
{ {
return g_PluginSys.GetPluginByCtx(pContext->GetContext()); return scripts->FindPluginByContext(pContext->GetContext());
} else { } else {
HandleError err; HandleError err;
CPlugin *pPlugin = (CPlugin *)g_PluginSys.PluginFromHandle(hndl, &err); IPlugin *pPlugin = scripts->FindPluginByHandle(hndl, &err);
if (!pPlugin) if (!pPlugin)
{ {
pContext->ThrowNativeError("Could not read Handle %x (error %d)", hndl, err); pContext->ThrowNativeError("Could not read Handle %x (error %d)", hndl, err);
@ -271,7 +269,7 @@ CPlugin *GetPluginFromHandle(IPluginContext *pContext, Handle_t hndl)
static cell_t GetPluginStatus(IPluginContext *pContext, const cell_t *params) static cell_t GetPluginStatus(IPluginContext *pContext, const cell_t *params)
{ {
CPlugin *pPlugin = GetPluginFromHandle(pContext, params[1]); IPlugin *pPlugin = GetPluginFromHandle(pContext, params[1]);
if (!pPlugin) if (!pPlugin)
{ {
return 0; return 0;
@ -282,7 +280,7 @@ static cell_t GetPluginStatus(IPluginContext *pContext, const cell_t *params)
static cell_t GetPluginFilename(IPluginContext *pContext, const cell_t *params) static cell_t GetPluginFilename(IPluginContext *pContext, const cell_t *params)
{ {
CPlugin *pPlugin = GetPluginFromHandle(pContext, params[1]); IPlugin *pPlugin = GetPluginFromHandle(pContext, params[1]);
if (!pPlugin) if (!pPlugin)
{ {
return 0; return 0;
@ -295,7 +293,7 @@ static cell_t GetPluginFilename(IPluginContext *pContext, const cell_t *params)
static cell_t IsPluginDebugging(IPluginContext *pContext, const cell_t *params) static cell_t IsPluginDebugging(IPluginContext *pContext, const cell_t *params)
{ {
CPlugin *pPlugin = GetPluginFromHandle(pContext, params[1]); IPlugin *pPlugin = GetPluginFromHandle(pContext, params[1]);
if (!pPlugin) if (!pPlugin)
{ {
return 0; return 0;
@ -316,7 +314,7 @@ enum PluginInfo
static cell_t GetPluginInfo(IPluginContext *pContext, const cell_t *params) static cell_t GetPluginInfo(IPluginContext *pContext, const cell_t *params)
{ {
CPlugin *pPlugin = GetPluginFromHandle(pContext, params[1]); IPlugin *pPlugin = GetPluginFromHandle(pContext, params[1]);
if (!pPlugin) if (!pPlugin)
{ {
return 0; return 0;
@ -373,10 +371,10 @@ static cell_t GetPluginInfo(IPluginContext *pContext, const cell_t *params)
static cell_t SetFailState(IPluginContext *pContext, const cell_t *params) static cell_t SetFailState(IPluginContext *pContext, const cell_t *params)
{ {
char *str; char *str;
CPlugin *pPlugin; SMPlugin *pPlugin;
pContext->LocalToString(params[1], &str); pContext->LocalToString(params[1], &str);
pPlugin = g_PluginSys.GetPluginByCtx(pContext->GetContext()); pPlugin = scripts->FindPluginByContext(pContext->GetContext());
if (params[0] == 1) if (params[0] == 1)
{ {
@ -425,7 +423,7 @@ static cell_t GetSysTickCount(IPluginContext *pContext, const cell_t *params)
static cell_t AutoExecConfig(IPluginContext *pContext, const cell_t *params) static cell_t AutoExecConfig(IPluginContext *pContext, const cell_t *params)
{ {
CPlugin *plugin = g_PluginSys.GetPluginByCtx(pContext->GetContext()); SMPlugin *plugin = scripts->FindPluginByContext(pContext->GetContext());
char *cfg, *folder; char *cfg, *folder;
pContext->LocalToString(params[2], &cfg); pContext->LocalToString(params[2], &cfg);
@ -476,12 +474,11 @@ static cell_t MarkNativeAsOptional(IPluginContext *pContext, const cell_t *param
static cell_t RegPluginLibrary(IPluginContext *pContext, const cell_t *params) static cell_t RegPluginLibrary(IPluginContext *pContext, const cell_t *params)
{ {
char *name; char *name;
CPlugin *pl = g_PluginSys.GetPluginByCtx(pContext->GetContext()); SMPlugin *pl = scripts->FindPluginByContext(pContext->GetContext());
pContext->LocalToString(params[1], &name); pContext->LocalToString(params[1], &name);
pl->AddLibrary(name); pl->AddLibrary(name);
return 1; return 1;
} }
@ -495,12 +492,12 @@ static cell_t LibraryExists(IPluginContext *pContext, const cell_t *params)
return 1; return 1;
} }
if (g_PluginSys.LibraryExists(str)) if (scripts->LibraryExists(str))
{ {
return 1; return 1;
} }
if (g_Extensions.LibraryExists(str)) if (extsys->LibraryExists(str))
{ {
return 1; return 1;
} }
@ -519,7 +516,7 @@ static cell_t sm_LogAction(IPluginContext *pContext, const cell_t *params)
return 0; return 0;
} }
CPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pContext->GetContext()); IPlugin *pPlugin = scripts->FindPluginByContext(pContext->GetContext());
LogAction(pPlugin->GetMyHandle(), 2, params[1], params[2], buffer); LogAction(pPlugin->GetMyHandle(), 2, params[1], params[2], buffer);
@ -550,7 +547,7 @@ static cell_t LogToFile(IPluginContext *pContext, const cell_t *params)
return 0; return 0;
} }
CPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pContext->GetContext()); IPlugin *pPlugin = scripts->FindPluginByContext(pContext->GetContext());
g_Logger.LogToOpenFile(fp, "[%s] %s", pPlugin->GetFilename(), buffer); g_Logger.LogToOpenFile(fp, "[%s] %s", pPlugin->GetFilename(), buffer);
@ -595,7 +592,7 @@ static cell_t GetExtensionFileStatus(IPluginContext *pContext, const cell_t *par
char *str; char *str;
pContext->LocalToString(params[1], &str); pContext->LocalToString(params[1], &str);
IExtension *pExtension = g_Extensions.FindExtensionByFile(str); IExtension *pExtension = extsys->FindExtensionByFile(str);
if (!pExtension) if (!pExtension)
{ {
@ -619,7 +616,7 @@ static cell_t GetExtensionFileStatus(IPluginContext *pContext, const cell_t *par
static cell_t FindPluginByNumber(IPluginContext *pContext, const cell_t *params) static cell_t FindPluginByNumber(IPluginContext *pContext, const cell_t *params)
{ {
CPlugin *pPlugin = g_PluginSys.GetPluginByOrder(params[1]); IPlugin *pPlugin = scripts->FindPluginByOrder(params[1]);
if (pPlugin == NULL) if (pPlugin == NULL)
{ {
@ -641,7 +638,7 @@ static cell_t GetFeatureStatus(IPluginContext *pContext, const cell_t *params)
pContext->LocalToString(params[2], &name); pContext->LocalToString(params[2], &name);
return g_ShareSys.TestFeature(pContext->GetRuntime(),type, name); return sharesys->TestFeature(pContext->GetRuntime(), type, name);
} }
static cell_t RequireFeature(IPluginContext *pContext, const cell_t *params) static cell_t RequireFeature(IPluginContext *pContext, const cell_t *params)
@ -651,12 +648,12 @@ static cell_t RequireFeature(IPluginContext *pContext, const cell_t *params)
pContext->LocalToString(params[2], &name); pContext->LocalToString(params[2], &name);
if (g_ShareSys.TestFeature(pContext->GetRuntime(),type, name) != FeatureStatus_Available) if (sharesys->TestFeature(pContext->GetRuntime(), type, name) != FeatureStatus_Available)
{ {
char buffer[255]; char buffer[255];
char *msg = buffer; char *msg = buffer;
char default_message[255]; char default_message[255];
CPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pContext->GetContext()); SMPlugin *pPlugin = scripts->FindPluginByContext(pContext->GetContext());
g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 3); g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 3);
if (pContext->GetLastNativeError() != SP_ERROR_NONE || buffer[0] == '\0') if (pContext->GetLastNativeError() != SP_ERROR_NONE || buffer[0] == '\0')

View File

@ -30,11 +30,11 @@
*/ */
#include "sm_globals.h" #include "sm_globals.h"
#include "HandleSys.h"
#include "Database.h" #include "Database.h"
#include "ExtensionSys.h"
#include "PluginSys.h"
#include "sm_stringutil.h" #include "sm_stringutil.h"
#include "logic_bridge.h"
#include "KeyValues.h"
#include "sourcemod.h"
HandleType_t hStmtType; HandleType_t hStmtType;
@ -55,22 +55,22 @@ public:
HandleAccess acc; HandleAccess acc;
/* Disable cloning */ /* Disable cloning */
g_HandleSys.InitAccessDefaults(NULL, &acc); handlesys->InitAccessDefaults(NULL, &acc);
acc.access[HandleAccess_Clone] = HANDLE_RESTRICT_OWNER|HANDLE_RESTRICT_IDENTITY; acc.access[HandleAccess_Clone] = HANDLE_RESTRICT_OWNER|HANDLE_RESTRICT_IDENTITY;
TypeAccess tacc; TypeAccess tacc;
g_HandleSys.InitAccessDefaults(&tacc, NULL); handlesys->InitAccessDefaults(&tacc, NULL);
tacc.ident = g_pCoreIdent; tacc.ident = g_pCoreIdent;
hCombinedQueryType = g_HandleSys.CreateType("IQuery", this, 0, &tacc, &acc, g_pCoreIdent, NULL); hCombinedQueryType = handlesys->CreateType("IQuery", this, 0, &tacc, &acc, g_pCoreIdent, NULL);
hStmtType = g_HandleSys.CreateType("IPreparedQuery", this, 0, &tacc, &acc, g_pCoreIdent, NULL); hStmtType = handlesys->CreateType("IPreparedQuery", this, 0, &tacc, &acc, g_pCoreIdent, NULL);
} }
virtual void OnSourceModShutdown() virtual void OnSourceModShutdown()
{ {
g_HandleSys.RemoveType(hStmtType, g_pCoreIdent); handlesys->RemoveType(hStmtType, g_pCoreIdent);
g_HandleSys.RemoveType(hCombinedQueryType, g_pCoreIdent); handlesys->RemoveType(hCombinedQueryType, g_pCoreIdent);
} }
virtual void OnHandleDestroy(HandleType_t type, void *object) virtual void OnHandleDestroy(HandleType_t type, void *object)
@ -97,9 +97,9 @@ inline HandleError ReadQueryHndl(Handle_t hndl, IPluginContext *pContext, IQuery
HandleError ret; HandleError ret;
if ((ret = g_HandleSys.ReadHandle(hndl, hStmtType, &sec, (void **)query)) != HandleError_None) if ((ret = handlesys->ReadHandle(hndl, hStmtType, &sec, (void **)query)) != HandleError_None)
{ {
ret = g_HandleSys.ReadHandle(hndl, hCombinedQueryType, &sec, (void **)&c); ret = handlesys->ReadHandle(hndl, hCombinedQueryType, &sec, (void **)&c);
if (ret == HandleError_None) if (ret == HandleError_None)
{ {
*query = c->query; *query = c->query;
@ -115,7 +115,7 @@ inline HandleError ReadQueryAndDbHndl(Handle_t hndl, IPluginContext *pContext, I
sec.pOwner = pContext->GetIdentity(); sec.pOwner = pContext->GetIdentity();
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
HandleError ret = g_HandleSys.ReadHandle(hndl, hCombinedQueryType, &sec, (void **)&c); HandleError ret = handlesys->ReadHandle(hndl, hCombinedQueryType, &sec, (void **)&c);
if (ret == HandleError_None) if (ret == HandleError_None)
{ {
*query = c->query; *query = c->query;
@ -130,7 +130,7 @@ inline HandleError ReadStmtHndl(Handle_t hndl, IPluginContext *pContext, IPrepar
sec.pOwner = pContext->GetIdentity(); sec.pOwner = pContext->GetIdentity();
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
return g_HandleSys.ReadHandle(hndl, hStmtType, &sec, (void **)query); return handlesys->ReadHandle(hndl, hStmtType, &sec, (void **)query);
} }
inline HandleError ReadDbOrStmtHndl(Handle_t hndl, IPluginContext *pContext, IDatabase **db, IPreparedQuery **query) inline HandleError ReadDbOrStmtHndl(Handle_t hndl, IPluginContext *pContext, IDatabase **db, IPreparedQuery **query)
@ -149,7 +149,7 @@ class TQueryOp : public IDBThreadOperation
public: public:
TQueryOp(IDatabase *db, IPluginFunction *pf, const char *query, cell_t data) : TQueryOp(IDatabase *db, IPluginFunction *pf, const char *query, cell_t data) :
m_pDatabase(db), m_pFunction(pf), m_Query(query), m_Data(data), m_pDatabase(db), m_pFunction(pf), m_Query(query), m_Data(data),
me(g_PluginSys.GetPluginByCtx(pf->GetParentContext()->GetContext())), me(scripts->FindPluginByContext(pf->GetParentContext()->GetContext())),
m_pQuery(NULL) m_pQuery(NULL)
{ {
/* We always increase the reference count because this is potentially /* We always increase the reference count because this is potentially
@ -163,9 +163,9 @@ public:
*/ */
HandleSecurity sec(me->GetIdentity(), g_pCoreIdent); HandleSecurity sec(me->GetIdentity(), g_pCoreIdent);
HandleAccess access; HandleAccess access;
g_HandleSys.InitAccessDefaults(NULL, &access); handlesys->InitAccessDefaults(NULL, &access);
access.access[HandleAccess_Delete] = HANDLE_RESTRICT_IDENTITY|HANDLE_RESTRICT_OWNER; access.access[HandleAccess_Delete] = HANDLE_RESTRICT_IDENTITY|HANDLE_RESTRICT_OWNER;
m_MyHandle = g_HandleSys.CreateHandleEx(g_DBMan.GetDatabaseType(), m_MyHandle = handlesys->CreateHandleEx(g_DBMan.GetDatabaseType(),
db, db,
&sec, &sec,
&access, &access,
@ -182,7 +182,7 @@ public:
if (m_MyHandle != BAD_HANDLE) if (m_MyHandle != BAD_HANDLE)
{ {
HandleSecurity sec(me->GetIdentity(), g_pCoreIdent); HandleSecurity sec(me->GetIdentity(), g_pCoreIdent);
g_HandleSys.FreeHandle(m_MyHandle, &sec); handlesys->FreeHandle(m_MyHandle, &sec);
} else { } else {
/* Otherwise, there is an open ref to the db */ /* Otherwise, there is an open ref to the db */
m_pDatabase->Close(); m_pDatabase->Close();
@ -219,7 +219,7 @@ public:
/* Create a Handle for our query */ /* Create a Handle for our query */
HandleSecurity sec(me->GetIdentity(), g_pCoreIdent); HandleSecurity sec(me->GetIdentity(), g_pCoreIdent);
HandleAccess access; HandleAccess access;
g_HandleSys.InitAccessDefaults(NULL, &access); handlesys->InitAccessDefaults(NULL, &access);
access.access[HandleAccess_Delete] = HANDLE_RESTRICT_IDENTITY|HANDLE_RESTRICT_OWNER; access.access[HandleAccess_Delete] = HANDLE_RESTRICT_IDENTITY|HANDLE_RESTRICT_OWNER;
Handle_t qh = BAD_HANDLE; Handle_t qh = BAD_HANDLE;
@ -230,7 +230,7 @@ public:
c->query = m_pQuery; c->query = m_pQuery;
c->db = m_pDatabase; c->db = m_pDatabase;
qh = g_HandleSys.CreateHandle(hCombinedQueryType, c, me->GetIdentity(), g_pCoreIdent, NULL); qh = handlesys->CreateHandle(hCombinedQueryType, c, me->GetIdentity(), g_pCoreIdent, NULL);
if (qh != BAD_HANDLE) if (qh != BAD_HANDLE)
{ {
m_pQuery = NULL; m_pQuery = NULL;
@ -248,7 +248,7 @@ public:
if (qh != BAD_HANDLE) if (qh != BAD_HANDLE)
{ {
g_HandleSys.FreeHandle(qh, &sec); handlesys->FreeHandle(qh, &sec);
} }
} }
void Destroy() void Destroy()
@ -260,7 +260,7 @@ private:
IPluginFunction *m_pFunction; IPluginFunction *m_pFunction;
String m_Query; String m_Query;
cell_t m_Data; cell_t m_Data;
CPlugin *me; IPlugin *me;
IQuery *m_pQuery; IQuery *m_pQuery;
char error[255]; char error[255];
Handle_t m_MyHandle; Handle_t m_MyHandle;
@ -277,7 +277,7 @@ public:
m_Data = data; m_Data = data;
error[0] = '\0'; error[0] = '\0';
strncopy(dbname, _dbname, sizeof(dbname)); strncopy(dbname, _dbname, sizeof(dbname));
me = g_PluginSys.GetPluginByCtx(m_pFunction->GetParentContext()->GetContext()); me = scripts->FindPluginByContext(m_pFunction->GetParentContext()->GetContext());
} }
IdentityToken_t *GetOwner() IdentityToken_t *GetOwner()
{ {
@ -336,7 +336,7 @@ public:
delete this; delete this;
} }
private: private:
CPlugin *me; IPlugin *me;
IPluginFunction *m_pFunction; IPluginFunction *m_pFunction;
IDBDriver *m_pDriver; IDBDriver *m_pDriver;
IDatabase *m_pDatabase; IDatabase *m_pDatabase;
@ -369,10 +369,10 @@ static cell_t SQL_Connect(IPluginContext *pContext, const cell_t *params)
} }
/* HACK! Add us to the dependency list */ /* HACK! Add us to the dependency list */
CExtension *pExt = g_Extensions.GetExtensionFromIdent(driver->GetIdentity()); IExtension *pExt = extsys->GetExtensionFromIdent(driver->GetIdentity());
if (pExt) if (pExt)
{ {
g_Extensions.BindChildPlugin(pExt, g_PluginSys.GetPluginByCtx(pContext->GetContext())); extsys->BindChildPlugin(pExt, scripts->FindPluginByContext(pContext->GetContext()));
} }
return hndl; return hndl;
@ -427,15 +427,15 @@ static cell_t SQL_TConnect(IPluginContext *pContext, const cell_t *params)
} }
/* HACK! Add us to the dependency list */ /* HACK! Add us to the dependency list */
CExtension *pExt = g_Extensions.GetExtensionFromIdent(driver->GetIdentity()); IExtension *pExt = extsys->GetExtensionFromIdent(driver->GetIdentity());
if (pExt) if (pExt)
{ {
g_Extensions.BindChildPlugin(pExt, g_PluginSys.GetPluginByCtx(pContext->GetContext())); extsys->BindChildPlugin(pExt, scripts->FindPluginByContext(pContext->GetContext()));
} }
/* Finally, add to the thread if we can */ /* Finally, add to the thread if we can */
TConnectOp *op = new TConnectOp(pf, driver, conf, params[3]); TConnectOp *op = new TConnectOp(pf, driver, conf, params[3]);
CPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pContext->GetContext()); IPlugin *pPlugin = scripts->FindPluginByContext(pContext->GetContext());
if (pPlugin->GetProperty("DisallowDBThreads", NULL) if (pPlugin->GetProperty("DisallowDBThreads", NULL)
|| !g_DBMan.AddToThreadQueue(op, PrioQueue_High)) || !g_DBMan.AddToThreadQueue(op, PrioQueue_High))
{ {
@ -498,10 +498,10 @@ static cell_t SQL_ConnectEx(IPluginContext *pContext, const cell_t *params)
} }
/* HACK! Add us to the dependency list */ /* HACK! Add us to the dependency list */
CExtension *pExt = g_Extensions.GetExtensionFromIdent(driver->GetIdentity()); IExtension *pExt = extsys->GetExtensionFromIdent(driver->GetIdentity());
if (pExt) if (pExt)
{ {
g_Extensions.BindChildPlugin(pExt, g_PluginSys.GetPluginByCtx(pContext->GetContext())); extsys->BindChildPlugin(pExt, scripts->FindPluginByContext(pContext->GetContext()));
} }
return hndl; return hndl;
@ -741,7 +741,7 @@ static cell_t SQL_Query(IPluginContext *pContext, const cell_t *params)
CombinedQuery *c = new CombinedQuery; CombinedQuery *c = new CombinedQuery;
c->query = qr; c->query = qr;
c->db = db; c->db = db;
Handle_t hndl = g_HandleSys.CreateHandle(hCombinedQueryType, c, pContext->GetIdentity(), g_pCoreIdent, NULL); Handle_t hndl = handlesys->CreateHandle(hCombinedQueryType, c, pContext->GetIdentity(), g_pCoreIdent, NULL);
if (hndl == BAD_HANDLE) if (hndl == BAD_HANDLE)
{ {
qr->Destroy(); qr->Destroy();
@ -786,7 +786,7 @@ static cell_t SQL_TQuery(IPluginContext *pContext, const cell_t *params)
level = PrioQueue_Low; level = PrioQueue_Low;
} }
CPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pContext->GetContext()); IPlugin *pPlugin = scripts->FindPluginByContext(pContext->GetContext());
TQueryOp *op = new TQueryOp(db, pf, query, data); TQueryOp *op = new TQueryOp(db, pf, query, data);
if (pPlugin->GetProperty("DisallowDBThreads", NULL) if (pPlugin->GetProperty("DisallowDBThreads", NULL)
@ -856,7 +856,7 @@ static cell_t SQL_PrepareQuery(IPluginContext *pContext, const cell_t *params)
return BAD_HANDLE; return BAD_HANDLE;
} }
Handle_t hndl = g_HandleSys.CreateHandle(hStmtType, qr, pContext->GetIdentity(), g_pCoreIdent, NULL); Handle_t hndl = handlesys->CreateHandle(hStmtType, qr, pContext->GetIdentity(), g_pCoreIdent, NULL);
if (hndl == BAD_HANDLE) if (hndl == BAD_HANDLE)
{ {
qr->Destroy(); qr->Destroy();
@ -1398,10 +1398,10 @@ static cell_t SQL_ConnectCustom(IPluginContext *pContext, const cell_t *params)
} }
/* HACK! Add us to the dependency list */ /* HACK! Add us to the dependency list */
CExtension *pExt = g_Extensions.GetExtensionFromIdent(driver->GetIdentity()); IExtension *pExt = extsys->GetExtensionFromIdent(driver->GetIdentity());
if (pExt) if (pExt)
{ {
g_Extensions.BindChildPlugin(pExt, g_PluginSys.GetPluginByCtx(pContext->GetContext())); extsys->BindChildPlugin(pExt, scripts->FindPluginByContext(pContext->GetContext()));
} }
return hndl; return hndl;

View File

@ -31,8 +31,8 @@
#include "sm_globals.h" #include "sm_globals.h"
#include "sourcemm_api.h" #include "sourcemm_api.h"
#include "HandleSys.h"
#include "EventManager.h" #include "EventManager.h"
#include "logic_bridge.h"
static cell_t sm_HookEvent(IPluginContext *pContext, const cell_t *params) static cell_t sm_HookEvent(IPluginContext *pContext, const cell_t *params)
{ {
@ -113,7 +113,7 @@ static cell_t sm_CreateEvent(IPluginContext *pContext, const cell_t *params)
if (pInfo) if (pInfo)
{ {
return g_HandleSys.CreateHandle(g_EventManager.GetHandleType(), pInfo, pContext->GetIdentity(), g_pCoreIdent, NULL); return handlesys->CreateHandle(g_EventManager.GetHandleType(), pInfo, pContext->GetIdentity(), g_pCoreIdent, NULL);
} }
return BAD_HANDLE; return BAD_HANDLE;
@ -125,7 +125,7 @@ static cell_t sm_FireEvent(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
EventInfo *pInfo; EventInfo *pInfo;
if ((err=g_HandleSys.ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo)) if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err); return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
@ -141,7 +141,7 @@ static cell_t sm_FireEvent(IPluginContext *pContext, const cell_t *params)
/* Free handle on game event */ /* Free handle on game event */
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
g_HandleSys.FreeHandle(hndl, &sec); handlesys->FreeHandle(hndl, &sec);
return 1; return 1;
} }
@ -152,7 +152,7 @@ static cell_t sm_CancelCreatedEvent(IPluginContext *pContext, const cell_t *para
HandleError err; HandleError err;
EventInfo *pInfo; EventInfo *pInfo;
if ((err=g_HandleSys.ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo)) if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err); return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
@ -168,7 +168,7 @@ static cell_t sm_CancelCreatedEvent(IPluginContext *pContext, const cell_t *para
/* Free handle on game event */ /* Free handle on game event */
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent); HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
g_HandleSys.FreeHandle(hndl, &sec); handlesys->FreeHandle(hndl, &sec);
return 1; return 1;
} }
@ -179,7 +179,7 @@ static cell_t sm_GetEventName(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
EventInfo *pInfo; EventInfo *pInfo;
if ((err=g_HandleSys.ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo)) if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err); return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
@ -196,7 +196,7 @@ static cell_t sm_GetEventBool(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
EventInfo *pInfo; EventInfo *pInfo;
if ((err=g_HandleSys.ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo)) if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err); return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
@ -214,7 +214,7 @@ static cell_t sm_GetEventInt(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
EventInfo *pInfo; EventInfo *pInfo;
if ((err=g_HandleSys.ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo)) if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err); return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
@ -232,7 +232,7 @@ static cell_t sm_GetEventFloat(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
EventInfo *pInfo; EventInfo *pInfo;
if ((err=g_HandleSys.ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo)) if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err); return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
@ -252,7 +252,7 @@ static cell_t sm_GetEventString(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
EventInfo *pInfo; EventInfo *pInfo;
if ((err=g_HandleSys.ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo)) if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err); return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
@ -272,7 +272,7 @@ static cell_t sm_SetEventBool(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
EventInfo *pInfo; EventInfo *pInfo;
if ((err=g_HandleSys.ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo)) if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err); return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
@ -292,7 +292,7 @@ static cell_t sm_SetEventInt(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
EventInfo *pInfo; EventInfo *pInfo;
if ((err=g_HandleSys.ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo)) if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err); return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
@ -312,7 +312,7 @@ static cell_t sm_SetEventFloat(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
EventInfo *pInfo; EventInfo *pInfo;
if ((err=g_HandleSys.ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo)) if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err); return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
@ -333,7 +333,7 @@ static cell_t sm_SetEventString(IPluginContext *pContext, const cell_t *params)
HandleError err; HandleError err;
EventInfo *pInfo; EventInfo *pInfo;
if ((err=g_HandleSys.ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo)) if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err); return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
@ -354,7 +354,7 @@ static cell_t sm_SetEventBroadcast(IPluginContext *pContext, const cell_t *param
HandleError err; HandleError err;
EventInfo *pInfo; EventInfo *pInfo;
if ((err=g_HandleSys.ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo)) if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err); return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);

View File

@ -32,7 +32,6 @@
#include "sm_globals.h" #include "sm_globals.h"
#include "sourcemod.h" #include "sourcemod.h"
#include "sourcemm_api.h" #include "sourcemm_api.h"
#include "HandleSys.h"
#include "PlayerManager.h" #include "PlayerManager.h"
#include "HalfLife2.h" #include "HalfLife2.h"

View File

@ -34,8 +34,8 @@
#include "UserMessages.h" #include "UserMessages.h"
#include "TimerSys.h" #include "TimerSys.h"
#include "PlayerManager.h" #include "PlayerManager.h"
#include "HandleSys.h"
#include "logic_bridge.h" #include "logic_bridge.h"
#include "sourcemod.h"
#if SOURCE_ENGINE == SE_DOTA #if SOURCE_ENGINE == SE_DOTA
#include <game/shared/protobuf/usermessages.pb.h> #include <game/shared/protobuf/usermessages.pb.h>
@ -101,7 +101,7 @@ public:
} }
m_PlayerHuds = new player_chaninfo_t[256+1]; m_PlayerHuds = new player_chaninfo_t[256+1];
m_hHudSyncObj = g_HandleSys.CreateType("HudSyncObj", this, 0, NULL, NULL, g_pCoreIdent, NULL); m_hHudSyncObj = handlesys->CreateType("HudSyncObj", this, 0, NULL, NULL, g_pCoreIdent, NULL);
g_Players.AddClientListener(this); g_Players.AddClientListener(this);
} }
@ -114,7 +114,7 @@ public:
} }
delete [] m_PlayerHuds; delete [] m_PlayerHuds;
g_HandleSys.RemoveType(m_hHudSyncObj, g_pCoreIdent); handlesys->RemoveType(m_hHudSyncObj, g_pCoreIdent);
g_Players.RemoveClientListener(this); g_Players.RemoveClientListener(this);
} }
@ -154,7 +154,7 @@ public:
sec = HandleSecurity(pIdent, g_pCoreIdent); sec = HandleSecurity(pIdent, g_pCoreIdent);
if ((hndl = g_HandleSys.CreateHandleEx(m_hHudSyncObj, obj, &sec, NULL, &err)) if ((hndl = handlesys->CreateHandleEx(m_hHudSyncObj, obj, &sec, NULL, &err))
== BAD_HANDLE) == BAD_HANDLE)
{ {
delete obj; delete obj;
@ -168,7 +168,7 @@ public:
hud_syncobj_t **pObj) hud_syncobj_t **pObj)
{ {
HandleSecurity sec(pOwner, g_pCoreIdent); HandleSecurity sec(pOwner, g_pCoreIdent);
return g_HandleSys.ReadHandle(hndl, m_hHudSyncObj, &sec, (void **)pObj); return handlesys->ReadHandle(hndl, m_hHudSyncObj, &sec, (void **)pObj);
} }
unsigned int AutoSelectChannel(unsigned int client) unsigned int AutoSelectChannel(unsigned int client)

View File

@ -32,10 +32,10 @@
#include "sourcemod.h" #include "sourcemod.h"
#include "sourcemm_api.h" #include "sourcemm_api.h"
#include "sm_stringutil.h" #include "sm_stringutil.h"
#include "HandleSys.h"
#include "HalfLife2.h" #include "HalfLife2.h"
#include <KeyValues.h> #include <KeyValues.h>
#include "utlbuffer.h" #include "utlbuffer.h"
#include "logic_bridge.h"
HandleType_t g_KeyValueType; HandleType_t g_KeyValueType;
@ -52,11 +52,11 @@ class KeyValueNatives :
public: public:
void OnSourceModAllInitialized() void OnSourceModAllInitialized()
{ {
g_KeyValueType = g_HandleSys.CreateType("KeyValues", this, 0, NULL, NULL, g_pCoreIdent, NULL); g_KeyValueType = handlesys->CreateType("KeyValues", this, 0, NULL, NULL, g_pCoreIdent, NULL);
} }
void OnSourceModShutdown() void OnSourceModShutdown()
{ {
g_HandleSys.RemoveType(g_KeyValueType, g_pCoreIdent); handlesys->RemoveType(g_KeyValueType, g_pCoreIdent);
g_KeyValueType = 0; g_KeyValueType = 0;
} }
void OnHandleDestroy(HandleType_t type, void *object) void OnHandleDestroy(HandleType_t type, void *object)
@ -100,7 +100,7 @@ KeyValues *SourceModBase::ReadKeyValuesHandle(Handle_t hndl, HandleError *err, b
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None) != HandleError_None)
{ {
if (err) if (err)
@ -128,7 +128,7 @@ static cell_t smn_KvSetString(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
@ -153,7 +153,7 @@ static cell_t smn_KvSetNum(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
@ -177,7 +177,7 @@ static cell_t smn_KvSetUInt64(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
@ -205,7 +205,7 @@ static cell_t smn_KvSetFloat(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
@ -229,7 +229,7 @@ static cell_t smn_KvSetColor(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
@ -254,7 +254,7 @@ static cell_t smn_KvSetVector(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
@ -283,7 +283,7 @@ static cell_t smn_KvGetString(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
@ -310,7 +310,7 @@ static cell_t smn_KvGetNum(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
@ -335,7 +335,7 @@ static cell_t smn_KvGetFloat(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
@ -360,7 +360,7 @@ static cell_t smn_KvGetColor(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
@ -394,7 +394,7 @@ static cell_t smn_KvGetUInt64(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
@ -423,7 +423,7 @@ static cell_t smn_KvGetVector(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
@ -501,7 +501,7 @@ static cell_t smn_CreateKeyValues(IPluginContext *pCtx, const cell_t *params)
pStk->pBase = new KeyValues(name, is_empty ? NULL : firstkey, (is_empty||(firstvalue[0]=='\0')) ? NULL : firstvalue); pStk->pBase = new KeyValues(name, is_empty ? NULL : firstkey, (is_empty||(firstvalue[0]=='\0')) ? NULL : firstvalue);
pStk->pCurRoot.push(pStk->pBase); pStk->pCurRoot.push(pStk->pBase);
return g_HandleSys.CreateHandle(g_KeyValueType, pStk, pCtx->GetIdentity(), g_pCoreIdent, NULL); return handlesys->CreateHandle(g_KeyValueType, pStk, pCtx->GetIdentity(), g_pCoreIdent, NULL);
} }
static cell_t smn_KvJumpToKey(IPluginContext *pCtx, const cell_t *params) static cell_t smn_KvJumpToKey(IPluginContext *pCtx, const cell_t *params)
@ -515,7 +515,7 @@ static cell_t smn_KvJumpToKey(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
@ -544,7 +544,7 @@ static cell_t smn_KvJumpToKeySymbol(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
@ -571,7 +571,7 @@ static cell_t smn_KvGotoFirstSubKey(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
@ -605,7 +605,7 @@ static cell_t smn_KvGotoNextKey(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
@ -638,7 +638,7 @@ static cell_t smn_KvGoBack(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
@ -663,7 +663,7 @@ static cell_t smn_KvRewind(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
@ -687,7 +687,7 @@ static cell_t smn_KvGetSectionName(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
@ -715,7 +715,7 @@ static cell_t smn_KvSetSectionName(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
@ -740,7 +740,7 @@ static cell_t smn_KvGetDataType(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
@ -762,7 +762,7 @@ static cell_t smn_KeyValuesToFile(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
@ -785,7 +785,7 @@ static cell_t smn_FileToKeyValues(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
@ -807,7 +807,7 @@ static cell_t smn_KvSetEscapeSequences(IPluginContext *pCtx, const cell_t *param
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
@ -828,7 +828,7 @@ static cell_t smn_KvNodesInStack(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
@ -847,7 +847,7 @@ static cell_t smn_KvDeleteThis(IPluginContext *pContext, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); return pContext->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
@ -901,7 +901,7 @@ static cell_t smn_KvDeleteKey(IPluginContext *pContext, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); return pContext->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
@ -938,7 +938,7 @@ static cell_t smn_KvSavePosition(IPluginContext *pContext, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); return pContext->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
@ -966,12 +966,12 @@ static cell_t smn_CopySubkeys(IPluginContext *pContext, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl_copied, g_KeyValueType, &sec, (void **)&pStk_copied)) if ((herr=handlesys->ReadHandle(hndl_copied, g_KeyValueType, &sec, (void **)&pStk_copied))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid key value handle %x (error %d)", hndl_copied, herr); return pContext->ThrowNativeError("Invalid key value handle %x (error %d)", hndl_copied, herr);
} }
if ((herr=g_HandleSys.ReadHandle(hndl_parent, g_KeyValueType, &sec, (void **)&pStk_parent)) if ((herr=handlesys->ReadHandle(hndl_parent, g_KeyValueType, &sec, (void **)&pStk_parent))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid key value handle %x (error %d)", hndl_parent, herr); return pContext->ThrowNativeError("Invalid key value handle %x (error %d)", hndl_parent, herr);
@ -994,7 +994,7 @@ static cell_t smn_GetNameSymbol(IPluginContext *pContext, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); return pContext->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
@ -1028,7 +1028,7 @@ static cell_t smn_FindKeyById(IPluginContext *pContext, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None) != HandleError_None)
{ {
return pContext->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); return pContext->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
@ -1056,7 +1056,7 @@ static cell_t smn_KvGetSectionSymbol(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = NULL; sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None) != HandleError_None)
{ {
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);

View File

@ -34,8 +34,6 @@
#include "MenuManager.h" #include "MenuManager.h"
#include "MenuStyle_Valve.h" #include "MenuStyle_Valve.h"
#include "MenuStyle_Radio.h" #include "MenuStyle_Radio.h"
#include "HandleSys.h"
#include "PluginSys.h"
#include "PlayerManager.h" #include "PlayerManager.h"
#include "sm_stringutil.h" #include "sm_stringutil.h"
#include "sourcemm_api.h" #include "sourcemm_api.h"
@ -44,6 +42,7 @@
#endif #endif
#include "ChatTriggers.h" #include "ChatTriggers.h"
#include "logic_bridge.h" #include "logic_bridge.h"
#include "sourcemod.h"
#if defined CreateMenu #if defined CreateMenu
#undef CreateMenu #undef CreateMenu
@ -126,15 +125,16 @@ class MenuNativeHelpers :
public: public:
virtual void OnSourceModAllInitialized() virtual void OnSourceModAllInitialized()
{ {
m_PanelType = g_HandleSys.CreateType("IMenuPanel", this, 0, NULL, NULL, g_pCoreIdent, NULL); m_PanelType = handlesys->CreateType("IMenuPanel", this, 0, NULL, NULL, g_pCoreIdent, NULL);
m_TempPanelType = g_HandleSys.CreateType("TempIMenuPanel", this, m_PanelType, NULL, NULL, g_pCoreIdent, NULL); m_TempPanelType = handlesys->CreateType("TempIMenuPanel", this, m_PanelType, NULL, NULL, g_pCoreIdent, NULL);
g_PluginSys.AddPluginsListener(this); scripts->AddPluginsListener(this);
} }
virtual void OnSourceModShutdown() virtual void OnSourceModShutdown()
{ {
g_HandleSys.RemoveType(m_TempPanelType, g_pCoreIdent); scripts->RemovePluginsListener(this);
g_HandleSys.RemoveType(m_PanelType, g_pCoreIdent); handlesys->RemoveType(m_TempPanelType, g_pCoreIdent);
handlesys->RemoveType(m_PanelType, g_pCoreIdent);
while (!m_FreePanelHandlers.empty()) while (!m_FreePanelHandlers.empty())
{ {
@ -208,7 +208,7 @@ public:
m_FreePanelHandlers.pop(); m_FreePanelHandlers.pop();
} }
handler->m_pFunc = pFunction; handler->m_pFunc = pFunction;
handler->m_pPlugin = g_PluginSys.GetPluginByCtx(pFunction->GetParentContext()->GetContext()); handler->m_pPlugin = scripts->FindPluginByContext(pFunction->GetParentContext()->GetContext());
return handler; return handler;
} }
@ -311,14 +311,14 @@ void CMenuHandler::OnMenuDisplay(IBaseMenu *menu, int client, IMenuPanel *panel)
sec.pOwner = m_pBasic->GetParentContext()->GetIdentity(); sec.pOwner = m_pBasic->GetParentContext()->GetIdentity();
HandleAccess access; HandleAccess access;
g_HandleSys.InitAccessDefaults(NULL, &access); handlesys->InitAccessDefaults(NULL, &access);
access.access[HandleAccess_Delete] = HANDLE_RESTRICT_IDENTITY|HANDLE_RESTRICT_OWNER; access.access[HandleAccess_Delete] = HANDLE_RESTRICT_IDENTITY|HANDLE_RESTRICT_OWNER;
Handle_t hndl = g_HandleSys.CreateHandleEx(g_MenuHelpers.GetTempPanelType(), panel, &sec, &access, NULL); Handle_t hndl = handlesys->CreateHandleEx(g_MenuHelpers.GetTempPanelType(), panel, &sec, &access, NULL);
DoAction(menu, MenuAction_Display, client, hndl); DoAction(menu, MenuAction_Display, client, hndl);
g_HandleSys.FreeHandle(hndl, &sec); handlesys->FreeHandle(hndl, &sec);
} }
} }
@ -570,7 +570,7 @@ bool CMenuHandler::OnSetHandlerOption(const char *option, const void *data)
inline Handle_t MakePanelHandle(IMenuPanel *panel, IPluginContext *pContext) inline Handle_t MakePanelHandle(IMenuPanel *panel, IPluginContext *pContext)
{ {
return g_HandleSys.CreateHandle(g_MenuHelpers.GetPanelType(), panel, pContext->GetIdentity(), g_pCoreIdent, NULL); return handlesys->CreateHandle(g_MenuHelpers.GetPanelType(), panel, pContext->GetIdentity(), g_pCoreIdent, NULL);
} }
inline HandleError ReadPanelHandle(Handle_t hndl, IMenuPanel **panel) inline HandleError ReadPanelHandle(Handle_t hndl, IMenuPanel **panel)
@ -578,7 +578,7 @@ inline HandleError ReadPanelHandle(Handle_t hndl, IMenuPanel **panel)
HandleSecurity sec; HandleSecurity sec;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
sec.pOwner = NULL; sec.pOwner = NULL;
return g_HandleSys.ReadHandle(hndl, g_MenuHelpers.GetPanelType(), &sec, (void **)panel); return handlesys->ReadHandle(hndl, g_MenuHelpers.GetPanelType(), &sec, (void **)panel);
} }
inline IMenuStyle *GetStyleFromCell(cell_t cell) inline IMenuStyle *GetStyleFromCell(cell_t cell)

View File

@ -47,7 +47,7 @@
sec.pOwner = NULL; \ sec.pOwner = NULL; \
sec.pIdentity = g_pCoreIdent; \ sec.pIdentity = g_pCoreIdent; \
\ \
if ((herr=g_HandleSys.ReadHandle(hndl, g_ProtobufType, &sec, (void **)&msg)) \ if ((herr=handlesys->ReadHandle(hndl, g_ProtobufType, &sec, (void **)&msg)) \
!= HandleError_None) \ != HandleError_None) \
{ \ { \
return pCtx->ThrowNativeError("Invalid protobuf message handle %x (error %d)", hndl, herr); \ return pCtx->ThrowNativeError("Invalid protobuf message handle %x (error %d)", hndl, herr); \
@ -872,7 +872,7 @@ static cell_t smn_PbReadMessage(IPluginContext *pCtx, const cell_t *params)
return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str()); return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str());
} }
Handle_t outHndl = g_HandleSys.CreateHandle(g_ProtobufType, new SMProtobufMessage(innerMsg), NULL, g_pCoreIdent, NULL); Handle_t outHndl = handlesys->CreateHandle(g_ProtobufType, new SMProtobufMessage(innerMsg), NULL, g_pCoreIdent, NULL);
msg->AddChildHandle(outHndl); msg->AddChildHandle(outHndl);
return outHndl; return outHndl;
@ -889,7 +889,7 @@ static cell_t smn_PbReadRepeatedMessage(IPluginContext *pCtx, const cell_t *para
return pCtx->ThrowNativeError("Invalid field \"%s\"[%d] for message \"%s\"", strField, params[3], msg->GetProtobufMessage()->GetTypeName().c_str()); return pCtx->ThrowNativeError("Invalid field \"%s\"[%d] for message \"%s\"", strField, params[3], msg->GetProtobufMessage()->GetTypeName().c_str());
} }
Handle_t outHndl = g_HandleSys.CreateHandle(g_ProtobufType, new SMProtobufMessage(const_cast<protobuf::Message *>(innerMsg)), NULL, g_pCoreIdent, NULL); Handle_t outHndl = handlesys->CreateHandle(g_ProtobufType, new SMProtobufMessage(const_cast<protobuf::Message *>(innerMsg)), NULL, g_pCoreIdent, NULL);
msg->AddChildHandle(outHndl); msg->AddChildHandle(outHndl);
return outHndl; return outHndl;
@ -906,7 +906,7 @@ static cell_t smn_PbAddMessage(IPluginContext *pCtx, const cell_t *params)
return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str()); return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str());
} }
Handle_t outHndl = g_HandleSys.CreateHandle(g_ProtobufType, new SMProtobufMessage(innerMsg), NULL, g_pCoreIdent, NULL); Handle_t outHndl = handlesys->CreateHandle(g_ProtobufType, new SMProtobufMessage(innerMsg), NULL, g_pCoreIdent, NULL);
msg->AddChildHandle(outHndl); msg->AddChildHandle(outHndl);
return outHndl; return outHndl;

View File

@ -29,10 +29,9 @@
* Version: $Id$ * Version: $Id$
*/ */
#include "HandleSys.h"
#include "PluginSys.h"
#include "PlayerManager.h" #include "PlayerManager.h"
#include "smn_usermsgs.h" #include "smn_usermsgs.h"
#include "logic_bridge.h"
#ifdef USE_PROTOBUF_USERMESSAGES #ifdef USE_PROTOBUF_USERMESSAGES
#include "UserMessagePBHelpers.h" #include "UserMessagePBHelpers.h"
#endif #endif
@ -89,19 +88,19 @@ void UsrMessageNatives::OnSourceModAllInitialized()
{ {
HandleAccess sec; HandleAccess sec;
g_HandleSys.InitAccessDefaults(NULL, &sec); handlesys->InitAccessDefaults(NULL, &sec);
sec.access[HandleAccess_Delete] = HANDLE_RESTRICT_IDENTITY; sec.access[HandleAccess_Delete] = HANDLE_RESTRICT_IDENTITY;
#ifdef USE_PROTOBUF_USERMESSAGES #ifdef USE_PROTOBUF_USERMESSAGES
g_ProtobufType = g_HandleSys.CreateType("ProtobufUM", this, 0, NULL, NULL, g_pCoreIdent, NULL); g_ProtobufType = handlesys->CreateType("ProtobufUM", this, 0, NULL, NULL, g_pCoreIdent, NULL);
#else #else
g_WrBitBufType = g_HandleSys.CreateType("BitBufWriter", this, 0, NULL, NULL, g_pCoreIdent, NULL); g_WrBitBufType = handlesys->CreateType("BitBufWriter", this, 0, NULL, NULL, g_pCoreIdent, NULL);
g_RdBitBufType = g_HandleSys.CreateType("BitBufReader", this, 0, NULL, &sec, g_pCoreIdent, NULL); g_RdBitBufType = handlesys->CreateType("BitBufReader", this, 0, NULL, &sec, g_pCoreIdent, NULL);
g_ReadBufHandle = g_HandleSys.CreateHandle(g_RdBitBufType, &g_ReadBitBuf, NULL, g_pCoreIdent, NULL); g_ReadBufHandle = handlesys->CreateHandle(g_RdBitBufType, &g_ReadBitBuf, NULL, g_pCoreIdent, NULL);
#endif #endif
g_PluginSys.AddPluginsListener(this); scripts->AddPluginsListener(this);
} }
void UsrMessageNatives::OnSourceModShutdown() void UsrMessageNatives::OnSourceModShutdown()
@ -110,14 +109,14 @@ void UsrMessageNatives::OnSourceModShutdown()
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
#ifdef USE_PROTOBUF_USERMESSAGES #ifdef USE_PROTOBUF_USERMESSAGES
g_HandleSys.RemoveType(g_ProtobufType, g_pCoreIdent); handlesys->RemoveType(g_ProtobufType, g_pCoreIdent);
g_ProtobufType = 0; g_ProtobufType = 0;
#else #else
g_HandleSys.FreeHandle(g_ReadBufHandle, &sec); handlesys->FreeHandle(g_ReadBufHandle, &sec);
g_HandleSys.RemoveType(g_WrBitBufType, g_pCoreIdent); handlesys->RemoveType(g_WrBitBufType, g_pCoreIdent);
g_HandleSys.RemoveType(g_RdBitBufType, g_pCoreIdent); handlesys->RemoveType(g_RdBitBufType, g_pCoreIdent);
g_WrBitBufType = 0; g_WrBitBufType = 0;
g_RdBitBufType = 0; g_RdBitBufType = 0;
@ -169,7 +168,7 @@ MsgListenerWrapper *UsrMessageNatives::CreateListener(IPluginContext *pCtx)
{ {
MsgWrapperList *pList; MsgWrapperList *pList;
MsgListenerWrapper *pListener; MsgListenerWrapper *pListener;
IPlugin *pl = g_PluginSys.FindPluginByContext(pCtx->GetContext()); IPlugin *pl = scripts->FindPluginByContext(pCtx->GetContext());
if (m_FreeListeners.empty()) if (m_FreeListeners.empty())
{ {
@ -195,7 +194,7 @@ bool UsrMessageNatives::FindListener(int msgid, IPluginContext *pCtx, IPluginFun
MsgWrapperList *pList; MsgWrapperList *pList;
MsgWrapperIter _iter; MsgWrapperIter _iter;
MsgListenerWrapper *pListener; MsgListenerWrapper *pListener;
IPlugin *pl = g_PluginSys.FindPluginByContext(pCtx->GetContext()); IPlugin *pl = scripts->FindPluginByContext(pCtx->GetContext());
if (!pl->GetProperty("MsgListeners", reinterpret_cast<void **>(&pList))) if (!pl->GetProperty("MsgListeners", reinterpret_cast<void **>(&pList)))
{ {
@ -221,7 +220,7 @@ bool UsrMessageNatives::DeleteListener(IPluginContext *pCtx, MsgWrapperIter iter
{ {
MsgWrapperList *pList; MsgWrapperList *pList;
MsgListenerWrapper *pListener; MsgListenerWrapper *pListener;
IPlugin *pl = g_PluginSys.FindPluginByContext(pCtx->GetContext()); IPlugin *pl = scripts->FindPluginByContext(pCtx->GetContext());
if (!pl->GetProperty("MsgListeners", reinterpret_cast<void **>(&pList))) if (!pl->GetProperty("MsgListeners", reinterpret_cast<void **>(&pList)))
{ {
@ -311,7 +310,7 @@ void MsgListenerWrapper::OnUserMessage(int msg_id, bf_write *bf, IRecipientFilte
size_t size = _FillInPlayers(g_MsgPlayers, pFilter); size_t size = _FillInPlayers(g_MsgPlayers, pFilter);
#ifdef USE_PROTOBUF_USERMESSAGES #ifdef USE_PROTOBUF_USERMESSAGES
hndl = g_HandleSys.CreateHandle(g_ProtobufType, new SMProtobufMessage(msg), NULL, g_pCoreIdent, NULL); hndl = handlesys->CreateHandle(g_ProtobufType, new SMProtobufMessage(msg), NULL, g_pCoreIdent, NULL);
#else #else
g_ReadBitBuf.StartReading(bf->GetBasePointer(), bf->GetNumBytesWritten()); g_ReadBitBuf.StartReading(bf->GetBasePointer(), bf->GetNumBytesWritten());
hndl = g_ReadBufHandle; hndl = g_ReadBufHandle;
@ -328,7 +327,7 @@ void MsgListenerWrapper::OnUserMessage(int msg_id, bf_write *bf, IRecipientFilte
#ifdef USE_PROTOBUF_USERMESSAGES #ifdef USE_PROTOBUF_USERMESSAGES
HandleSecurity sec; HandleSecurity sec;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
g_HandleSys.FreeHandle(hndl, &sec); handlesys->FreeHandle(hndl, &sec);
#endif #endif
} }
@ -343,7 +342,7 @@ ResultType MsgListenerWrapper::InterceptUserMessage(int msg_id, bf_write *bf, IR
size_t size = _FillInPlayers(g_MsgPlayers, pFilter); size_t size = _FillInPlayers(g_MsgPlayers, pFilter);
#ifdef USE_PROTOBUF_USERMESSAGES #ifdef USE_PROTOBUF_USERMESSAGES
hndl = g_HandleSys.CreateHandle(g_ProtobufType, new SMProtobufMessage(msg), NULL, g_pCoreIdent, NULL); hndl = handlesys->CreateHandle(g_ProtobufType, new SMProtobufMessage(msg), NULL, g_pCoreIdent, NULL);
#else #else
g_ReadBitBuf.StartReading(bf->GetBasePointer(), bf->GetNumBytesWritten()); g_ReadBitBuf.StartReading(bf->GetBasePointer(), bf->GetNumBytesWritten());
hndl = g_ReadBufHandle; hndl = g_ReadBufHandle;
@ -360,7 +359,7 @@ ResultType MsgListenerWrapper::InterceptUserMessage(int msg_id, bf_write *bf, IR
#ifdef USE_PROTOBUF_USERMESSAGES #ifdef USE_PROTOBUF_USERMESSAGES
HandleSecurity sec; HandleSecurity sec;
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
g_HandleSys.FreeHandle(hndl, &sec); handlesys->FreeHandle(hndl, &sec);
#endif #endif
return static_cast<ResultType>(res); return static_cast<ResultType>(res);
@ -455,7 +454,7 @@ static cell_t smn_StartMessage(IPluginContext *pCtx, const cell_t *params)
return pCtx->ThrowNativeError("Unable to execute a new message while in hook"); return pCtx->ThrowNativeError("Unable to execute a new message while in hook");
} }
g_CurMsgHandle = g_HandleSys.CreateHandle(g_ProtobufType, new SMProtobufMessage(msg), pCtx->GetIdentity(), g_pCoreIdent, NULL); g_CurMsgHandle = handlesys->CreateHandle(g_ProtobufType, new SMProtobufMessage(msg), pCtx->GetIdentity(), g_pCoreIdent, NULL);
#else #else
bf_write *pBitBuf = g_UserMsgs.StartBitBufMessage(msgid, cl_array, numClients, params[4]); bf_write *pBitBuf = g_UserMsgs.StartBitBufMessage(msgid, cl_array, numClients, params[4]);
if (!pBitBuf) if (!pBitBuf)
@ -463,7 +462,7 @@ static cell_t smn_StartMessage(IPluginContext *pCtx, const cell_t *params)
return pCtx->ThrowNativeError("Unable to execute a new message while in hook"); return pCtx->ThrowNativeError("Unable to execute a new message while in hook");
} }
g_CurMsgHandle = g_HandleSys.CreateHandle(g_WrBitBufType, pBitBuf, pCtx->GetIdentity(), g_pCoreIdent, NULL); g_CurMsgHandle = handlesys->CreateHandle(g_WrBitBufType, pBitBuf, pCtx->GetIdentity(), g_pCoreIdent, NULL);
#endif #endif
g_IsMsgInExec = true; g_IsMsgInExec = true;
@ -514,7 +513,7 @@ static cell_t smn_StartMessageEx(IPluginContext *pCtx, const cell_t *params)
return pCtx->ThrowNativeError("Unable to execute a new message while in hook"); return pCtx->ThrowNativeError("Unable to execute a new message while in hook");
} }
g_CurMsgHandle = g_HandleSys.CreateHandle(g_ProtobufType, new SMProtobufMessage(msg), pCtx->GetIdentity(), g_pCoreIdent, NULL); g_CurMsgHandle = handlesys->CreateHandle(g_ProtobufType, new SMProtobufMessage(msg), pCtx->GetIdentity(), g_pCoreIdent, NULL);
#else #else
bf_write *pBitBuf = g_UserMsgs.StartBitBufMessage(msgid, cl_array, numClients, params[4]); bf_write *pBitBuf = g_UserMsgs.StartBitBufMessage(msgid, cl_array, numClients, params[4]);
if (!pBitBuf) if (!pBitBuf)
@ -522,7 +521,7 @@ static cell_t smn_StartMessageEx(IPluginContext *pCtx, const cell_t *params)
return pCtx->ThrowNativeError("Unable to execute a new message while in hook"); return pCtx->ThrowNativeError("Unable to execute a new message while in hook");
} }
g_CurMsgHandle = g_HandleSys.CreateHandle(g_WrBitBufType, pBitBuf, pCtx->GetIdentity(), g_pCoreIdent, NULL); g_CurMsgHandle = handlesys->CreateHandle(g_WrBitBufType, pBitBuf, pCtx->GetIdentity(), g_pCoreIdent, NULL);
#endif #endif
g_IsMsgInExec = true; g_IsMsgInExec = true;
@ -542,7 +541,7 @@ static cell_t smn_EndMessage(IPluginContext *pCtx, const cell_t *params)
sec.pOwner = pCtx->GetIdentity(); sec.pOwner = pCtx->GetIdentity();
sec.pIdentity = g_pCoreIdent; sec.pIdentity = g_pCoreIdent;
g_HandleSys.FreeHandle(g_CurMsgHandle, &sec); handlesys->FreeHandle(g_CurMsgHandle, &sec);
g_IsMsgInExec = false; g_IsMsgInExec = false;

View File

@ -33,9 +33,9 @@
#include "sourcemm_api.h" #include "sourcemm_api.h"
#include <sourcemod_version.h> #include <sourcemod_version.h>
#include "Logger.h" #include "Logger.h"
#include "ExtensionSys.h"
#include "concmd_cleaner.h" #include "concmd_cleaner.h"
#include "compat_wrappers.h" #include "compat_wrappers.h"
#include "logic_bridge.h"
SourceMod_Core g_SourceMod_Core; SourceMod_Core g_SourceMod_Core;
IVEngineServer *engine = NULL; IVEngineServer *engine = NULL;
@ -231,7 +231,7 @@ void *SourceMod_Core::OnMetamodQuery(const char *iface, int *ret)
if (strcmp(iface, SOURCEMOD_INTERFACE_EXTENSIONS) == 0) if (strcmp(iface, SOURCEMOD_INTERFACE_EXTENSIONS) == 0)
{ {
ptr = (IExtensionManager *)&g_Extensions; ptr = extsys;
} }
if (ret != NULL) if (ret != NULL)

View File

@ -34,11 +34,8 @@
#include "sourcemm_api.h" #include "sourcemm_api.h"
#include "LibrarySys.h" #include "LibrarySys.h"
#include <sh_string.h> #include <sh_string.h>
#include "PluginSys.h"
#include "ShareSys.h"
#include "CoreConfig.h" #include "CoreConfig.h"
#include "Logger.h" #include "Logger.h"
#include "ExtensionSys.h"
#include "AdminCache.h" #include "AdminCache.h"
#include "sm_stringutil.h" #include "sm_stringutil.h"
#include "PlayerManager.h" #include "PlayerManager.h"
@ -263,11 +260,6 @@ void SourceModBase::StartSourceMod(bool late)
enginePatch = SH_GET_CALLCLASS(engine); enginePatch = SH_GET_CALLCLASS(engine);
gamedllPatch = SH_GET_CALLCLASS(gamedll); gamedllPatch = SH_GET_CALLCLASS(gamedll);
g_ShareSys.Initialize();
/* Make the global core identity */
g_pCoreIdent = g_ShareSys.CreateCoreIdentity();
InitLogicBridge(); InitLogicBridge();
/* Notify! */ /* Notify! */
@ -296,7 +288,7 @@ void SourceModBase::StartSourceMod(bool late)
} }
/* Add us now... */ /* Add us now... */
g_ShareSys.AddInterface(NULL, this); sharesys->AddInterface(NULL, this);
/* We're loaded! */ /* We're loaded! */
g_Loaded = true; g_Loaded = true;
@ -311,7 +303,7 @@ void SourceModBase::StartSourceMod(bool late)
const char *disabled = GetCoreConfigValue("DisableAutoUpdate"); const char *disabled = GetCoreConfigValue("DisableAutoUpdate");
if (disabled == NULL || strcasecmp(disabled, "yes") != 0) if (disabled == NULL || strcasecmp(disabled, "yes") != 0)
{ {
g_Extensions.LoadAutoExtension("updater.ext." PLATFORM_LIB_EXT); extsys->LoadAutoExtension("updater.ext." PLATFORM_LIB_EXT);
} }
} }
@ -383,7 +375,7 @@ void SourceModBase::LevelShutdown()
if (m_ExecPluginReload) if (m_ExecPluginReload)
{ {
g_PluginSys.ReloadOrUnloadPlugins(); scripts->RefreshAll();
m_ExecPluginReload = false; m_ExecPluginReload = false;
} }
} }
@ -406,7 +398,7 @@ void SourceModBase::DoGlobalPluginLoads()
"plugins"); "plugins");
/* Load any auto extensions */ /* Load any auto extensions */
g_Extensions.TryAutoload(); extsys->TryAutoload();
/* Fire the extensions ready message */ /* Fire the extensions ready message */
g_SMAPI->MetaFactory(SOURCEMOD_NOTICE_EXTENSIONS, NULL, NULL); g_SMAPI->MetaFactory(SOURCEMOD_NOTICE_EXTENSIONS, NULL, NULL);
@ -417,23 +409,10 @@ void SourceModBase::DoGlobalPluginLoads()
{ {
char path[PLATFORM_MAX_PATH]; char path[PLATFORM_MAX_PATH];
UTIL_Format(path, sizeof(path), "%s.ext." PLATFORM_LIB_EXT, game_ext); UTIL_Format(path, sizeof(path), "%s.ext." PLATFORM_LIB_EXT, game_ext);
g_Extensions.LoadAutoExtension(path); extsys->LoadAutoExtension(path);
} }
/* Run the first pass */ scripts->LoadAll(config_path, plugins_path);
g_PluginSys.LoadAll_FirstPass(config_path, plugins_path);
/* Mark any extensions as loaded */
g_Extensions.MarkAllLoaded();
/* No modules yet, it's safe to call this from here */
g_PluginSys.LoadAll_SecondPass();
/* Re-mark any extensions as loaded */
g_Extensions.MarkAllLoaded();
/* Call OnAllPluginsLoaded */
g_PluginSys.AllPluginsLoaded();
} }
size_t SourceModBase::BuildPath(PathType type, char *buffer, size_t maxlength, const char *format, ...) size_t SourceModBase::BuildPath(PathType type, char *buffer, size_t maxlength, const char *format, ...)
@ -484,10 +463,10 @@ void SourceModBase::CloseSourceMod()
LevelShutdown(); LevelShutdown();
/* Unload plugins */ /* Unload plugins */
g_PluginSys.Shutdown(); scripts->Shutdown();
/* Unload extensions */ /* Unload extensions */
g_Extensions.Shutdown(); extsys->Shutdown();
SH_REMOVE_HOOK(IServerGameDLL, LevelInit, gamedll, SH_MEMBER(this, &SourceModBase::LevelInit), false); SH_REMOVE_HOOK(IServerGameDLL, LevelInit, gamedll, SH_MEMBER(this, &SourceModBase::LevelInit), false);

View File

@ -32,7 +32,6 @@
#ifndef _INCLUDE_SOURCEMOD_AUTO_HANDLE_ROOTER_H_ #ifndef _INCLUDE_SOURCEMOD_AUTO_HANDLE_ROOTER_H_
#define _INCLUDE_SOURCEMOD_AUTO_HANDLE_ROOTER_H_ #define _INCLUDE_SOURCEMOD_AUTO_HANDLE_ROOTER_H_
#include "common_logic.h"
#include <IHandleSys.h> #include <IHandleSys.h>
class AutoHandleRooter class AutoHandleRooter

View File

@ -132,8 +132,10 @@ namespace SourceMod
* *
* Note: This is bumped when IShareSys is changed, because IShareSys * Note: This is bumped when IShareSys is changed, because IShareSys
* itself is not versioned. * itself is not versioned.
*
* V6 - added TestFeature() to IShareSys.
*/ */
#define SMINTERFACE_EXTENSIONAPI_VERSION 5 #define SMINTERFACE_EXTENSIONAPI_VERSION 6
/** /**
* @brief The interface an extension must expose. * @brief The interface an extension must expose.

View File

@ -52,7 +52,7 @@
#include <sp_vm_types.h> #include <sp_vm_types.h>
#define SMINTERFACE_HANDLESYSTEM_NAME "IHandleSys" #define SMINTERFACE_HANDLESYSTEM_NAME "IHandleSys"
#define SMINTERFACE_HANDLESYSTEM_VERSION 4 #define SMINTERFACE_HANDLESYSTEM_VERSION 5
/** Specifies no Identity */ /** Specifies no Identity */
#define DEFAULT_IDENTITY NULL #define DEFAULT_IDENTITY NULL
@ -364,6 +364,15 @@ namespace SourceMod
* @return A new Handle_t, or 0 on failure. * @return A new Handle_t, or 0 on failure.
*/ */
virtual Handle_t FastCloneHandle(Handle_t hndl) =0; virtual Handle_t FastCloneHandle(Handle_t hndl) =0;
/**
* @brief Type checks two handles.
*
* @param given Type to test.
* @param actual Type to check for.
* @return True if "given" is a subtype of "actual", false otherwise.
*/
virtual bool TypeCheck(HandleType_t given, HandleType_t actual) = 0;
}; };
} }

View File

@ -43,7 +43,7 @@
namespace SourceMod namespace SourceMod
{ {
#define SMINTERFACE_LIBRARYSYS_NAME "ILibrarySys" #define SMINTERFACE_LIBRARYSYS_NAME "ILibrarySys"
#define SMINTERFACE_LIBRARYSYS_VERSION 4 #define SMINTERFACE_LIBRARYSYS_VERSION 5
enum FileTimeType enum FileTimeType
{ {
@ -223,6 +223,16 @@ namespace SourceMod
* @return True on success, false on failure. * @return True on success, false on failure.
*/ */
virtual bool FileTime(const char *path, FileTimeType type, time_t *pTime) =0; virtual bool FileTime(const char *path, FileTimeType type, time_t *pTime) =0;
/**
* @brief Retrieve the file component of the given path.
*
* @param buffer Output buffer.
* @param maxlength Length of the output buffer.
* @param path Path to search for a filename.
* @return Number of bytes written to buffer, not including the null terminator.
*/
virtual size_t GetFileFromPath(char *buffer, size_t maxlength, const char *path) =0;
}; };
} }

View File

@ -38,7 +38,7 @@
*/ */
#include <sp_vm_types.h> #include <sp_vm_types.h>
#include <sp_vm_api.h>
namespace SourceMod namespace SourceMod
{ {
@ -278,6 +278,19 @@ namespace SourceMod
virtual void DropCapabilityProvider(IExtension *myself, virtual void DropCapabilityProvider(IExtension *myself,
IFeatureProvider *provider, IFeatureProvider *provider,
const char *name) =0; const char *name) =0;
/**
* Tests for a feature.
*
* @param rt Plugin to test.
* @param type Feature type.
* @param name Feature name.
* @return Feature status.
*/
virtual FeatureStatus TestFeature(SourcePawn::IPluginRuntime *rt,
FeatureType type,
const char *name) =0;
}; };
} }