core/smn_core.cpp
changeset 3872 4c93f74cae51
parent 3474 467e6dbfa288
child 4073 56283c919b7b
     1.1 --- a/core/smn_core.cpp	Fri Mar 29 12:28:02 2013 -0400
     1.2 +++ b/core/smn_core.cpp	Fri Mar 29 11:37:29 2013 -0700
     1.3 @@ -35,15 +35,13 @@
     1.4  #include "sm_stringutil.h"
     1.5  #include "sm_globals.h"
     1.6  #include "sourcemod.h"
     1.7 -#include "PluginSys.h"
     1.8 -#include "HandleSys.h"
     1.9  #include "LibrarySys.h"
    1.10  #include "TimerSys.h"
    1.11  #include "ForwardSys.h"
    1.12  #include "Logger.h"
    1.13 -#include "ExtensionSys.h"
    1.14  #include <sm_trie_tpl.h>
    1.15  #include <sh_memory.h>
    1.16 +#include "logic_bridge.h"
    1.17  
    1.18  #if defined PLATFORM_WINDOWS
    1.19  #include <windows.h>
    1.20 @@ -65,10 +63,10 @@
    1.21  	void OnSourceModAllInitialized()
    1.22  	{
    1.23  		HandleAccess hacc;
    1.24 -		g_HandleSys.InitAccessDefaults(NULL,  &hacc);
    1.25 +		handlesys->InitAccessDefaults(NULL,  &hacc);
    1.26  		hacc.access[HandleAccess_Clone] = HANDLE_RESTRICT_IDENTITY|HANDLE_RESTRICT_OWNER;
    1.27  
    1.28 -		g_PlIter = g_HandleSys.CreateType("PluginIterator", this, 0, NULL, NULL, g_pCoreIdent, NULL);
    1.29 +		g_PlIter = handlesys->CreateType("PluginIterator", this, 0, NULL, NULL, g_pCoreIdent, NULL);
    1.30  
    1.31  		g_OnLogAction = g_Forwards.CreateForward("OnLogAction", 
    1.32  			ET_Hook, 
    1.33 @@ -88,7 +86,7 @@
    1.34  	void OnSourceModShutdown()
    1.35  	{
    1.36  		g_Forwards.ReleaseForward(g_OnLogAction);
    1.37 -		g_HandleSys.RemoveType(g_PlIter, g_pCoreIdent);
    1.38 +		handlesys->RemoveType(g_PlIter, g_pCoreIdent);
    1.39  	}
    1.40  } g_CoreNativeHelpers;
    1.41  
    1.42 @@ -114,7 +112,7 @@
    1.43  	if (type == 2)
    1.44  	{
    1.45  		HandleError err;
    1.46 -		IPlugin *pPlugin = g_PluginSys.PluginFromHandle(hndl, &err);
    1.47 +		IPlugin *pPlugin = scripts->FindPluginByHandle(hndl, &err);
    1.48  		if (pPlugin)
    1.49  		{
    1.50  			logtag = pPlugin->GetFilename();
    1.51 @@ -197,9 +195,9 @@
    1.52  
    1.53  static cell_t GetPluginIterator(IPluginContext *pContext, const cell_t *params)
    1.54  {
    1.55 -	IPluginIterator *iter = g_PluginSys.GetPluginIterator();
    1.56 +	IPluginIterator *iter = scripts->GetPluginIterator();
    1.57  
    1.58 -	Handle_t hndl = g_HandleSys.CreateHandle(g_PlIter, iter, pContext->GetIdentity(), g_pCoreIdent, NULL);
    1.59 +	Handle_t hndl = handlesys->CreateHandle(g_PlIter, iter, pContext->GetIdentity(), g_pCoreIdent, NULL);
    1.60  
    1.61  	if (hndl == BAD_HANDLE)
    1.62  	{
    1.63 @@ -219,7 +217,7 @@
    1.64  	sec.pIdentity = g_pCoreIdent;
    1.65  	sec.pOwner = pContext->GetIdentity();
    1.66  
    1.67 -	if ((err=g_HandleSys.ReadHandle(hndl, g_PlIter, &sec, (void **)&pIter)) != HandleError_None)
    1.68 +	if ((err=handlesys->ReadHandle(hndl, g_PlIter, &sec, (void **)&pIter)) != HandleError_None)
    1.69  	{
    1.70  		return pContext->ThrowNativeError("Could not read Handle %x (error %d)", hndl, err);
    1.71  	}
    1.72 @@ -237,12 +235,12 @@
    1.73  	sec.pIdentity = g_pCoreIdent;
    1.74  	sec.pOwner = pContext->GetIdentity();
    1.75  
    1.76 -	if ((err=g_HandleSys.ReadHandle(hndl, g_PlIter, &sec, (void **)&pIter)) != HandleError_None)
    1.77 +	if ((err=handlesys->ReadHandle(hndl, g_PlIter, &sec, (void **)&pIter)) != HandleError_None)
    1.78  	{
    1.79  		return pContext->ThrowNativeError("Could not read Handle %x (error %d)", hndl, err);
    1.80  	}
    1.81  
    1.82 -	CPlugin *pPlugin = (CPlugin *)pIter->GetPlugin();
    1.83 +	IPlugin *pPlugin = pIter->GetPlugin();
    1.84  	if (!pPlugin)
    1.85  	{
    1.86  		return BAD_HANDLE;
    1.87 @@ -253,14 +251,14 @@
    1.88  	return pPlugin->GetMyHandle();
    1.89  }
    1.90  
    1.91 -CPlugin *GetPluginFromHandle(IPluginContext *pContext, Handle_t hndl)
    1.92 +IPlugin *GetPluginFromHandle(IPluginContext *pContext, Handle_t hndl)
    1.93  {
    1.94  	if (hndl == BAD_HANDLE)
    1.95  	{
    1.96 -		return g_PluginSys.GetPluginByCtx(pContext->GetContext());
    1.97 +		return scripts->FindPluginByContext(pContext->GetContext());
    1.98  	} else {
    1.99  		HandleError err;
   1.100 -		CPlugin *pPlugin = (CPlugin *)g_PluginSys.PluginFromHandle(hndl, &err);
   1.101 +		IPlugin *pPlugin = scripts->FindPluginByHandle(hndl, &err);
   1.102  		if (!pPlugin)
   1.103  		{
   1.104  			pContext->ThrowNativeError("Could not read Handle %x (error %d)", hndl, err);
   1.105 @@ -271,7 +269,7 @@
   1.106  
   1.107  static cell_t GetPluginStatus(IPluginContext *pContext, const cell_t *params)
   1.108  {
   1.109 -	CPlugin *pPlugin = GetPluginFromHandle(pContext, params[1]);
   1.110 +	IPlugin *pPlugin = GetPluginFromHandle(pContext, params[1]);
   1.111  	if (!pPlugin)
   1.112  	{
   1.113  		return 0;
   1.114 @@ -282,7 +280,7 @@
   1.115  
   1.116  static cell_t GetPluginFilename(IPluginContext *pContext, const cell_t *params)
   1.117  {
   1.118 -	CPlugin *pPlugin = GetPluginFromHandle(pContext, params[1]);
   1.119 +	IPlugin *pPlugin = GetPluginFromHandle(pContext, params[1]);
   1.120  	if (!pPlugin)
   1.121  	{
   1.122  		return 0;
   1.123 @@ -295,7 +293,7 @@
   1.124  
   1.125  static cell_t IsPluginDebugging(IPluginContext *pContext, const cell_t *params)
   1.126  {
   1.127 -	CPlugin *pPlugin = GetPluginFromHandle(pContext, params[1]);
   1.128 +	IPlugin *pPlugin = GetPluginFromHandle(pContext, params[1]);
   1.129  	if (!pPlugin)
   1.130  	{
   1.131  		return 0;
   1.132 @@ -316,7 +314,7 @@
   1.133  
   1.134  static cell_t GetPluginInfo(IPluginContext *pContext, const cell_t *params)
   1.135  {
   1.136 -	CPlugin *pPlugin = GetPluginFromHandle(pContext, params[1]);
   1.137 +	IPlugin *pPlugin = GetPluginFromHandle(pContext, params[1]);
   1.138  	if (!pPlugin)
   1.139  	{
   1.140  		return 0;
   1.141 @@ -373,10 +371,10 @@
   1.142  static cell_t SetFailState(IPluginContext *pContext, const cell_t *params)
   1.143  {
   1.144  	char *str;
   1.145 -	CPlugin *pPlugin;
   1.146 +	SMPlugin *pPlugin;
   1.147  
   1.148  	pContext->LocalToString(params[1], &str);
   1.149 -	pPlugin = g_PluginSys.GetPluginByCtx(pContext->GetContext());
   1.150 +	pPlugin = scripts->FindPluginByContext(pContext->GetContext());
   1.151  
   1.152  	if (params[0] == 1)
   1.153  	{
   1.154 @@ -425,7 +423,7 @@
   1.155  
   1.156  static cell_t AutoExecConfig(IPluginContext *pContext, const cell_t *params)
   1.157  {
   1.158 -	CPlugin *plugin = g_PluginSys.GetPluginByCtx(pContext->GetContext());
   1.159 +	SMPlugin *plugin = scripts->FindPluginByContext(pContext->GetContext());
   1.160  
   1.161  	char *cfg, *folder;
   1.162  	pContext->LocalToString(params[2], &cfg);
   1.163 @@ -476,12 +474,11 @@
   1.164  static cell_t RegPluginLibrary(IPluginContext *pContext, const cell_t *params)
   1.165  {
   1.166  	char *name;
   1.167 -	CPlugin *pl = g_PluginSys.GetPluginByCtx(pContext->GetContext());
   1.168 +	SMPlugin *pl = scripts->FindPluginByContext(pContext->GetContext());
   1.169  
   1.170  	pContext->LocalToString(params[1], &name);
   1.171  
   1.172  	pl->AddLibrary(name);
   1.173 -
   1.174  	return 1;
   1.175  }
   1.176  
   1.177 @@ -495,12 +492,12 @@
   1.178  		return 1;
   1.179  	}
   1.180  
   1.181 -	if (g_PluginSys.LibraryExists(str))
   1.182 +	if (scripts->LibraryExists(str))
   1.183  	{
   1.184  		return 1;
   1.185  	}
   1.186  
   1.187 -	if (g_Extensions.LibraryExists(str))
   1.188 +	if (extsys->LibraryExists(str))
   1.189  	{
   1.190  		return 1;
   1.191  	}
   1.192 @@ -519,7 +516,7 @@
   1.193  		return 0;
   1.194  	}
   1.195  
   1.196 -	CPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pContext->GetContext());
   1.197 +	IPlugin *pPlugin = scripts->FindPluginByContext(pContext->GetContext());
   1.198  
   1.199  	LogAction(pPlugin->GetMyHandle(), 2, params[1], params[2], buffer);
   1.200  
   1.201 @@ -550,7 +547,7 @@
   1.202  		return 0;
   1.203  	}
   1.204  
   1.205 -	CPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pContext->GetContext());
   1.206 +	IPlugin *pPlugin = scripts->FindPluginByContext(pContext->GetContext());
   1.207  
   1.208  	g_Logger.LogToOpenFile(fp, "[%s] %s", pPlugin->GetFilename(), buffer);
   1.209  
   1.210 @@ -595,7 +592,7 @@
   1.211  	char *str;
   1.212  	pContext->LocalToString(params[1], &str);
   1.213  
   1.214 -	IExtension *pExtension = g_Extensions.FindExtensionByFile(str);
   1.215 +	IExtension *pExtension = extsys->FindExtensionByFile(str);
   1.216  	
   1.217  	if (!pExtension)
   1.218  	{
   1.219 @@ -619,7 +616,7 @@
   1.220  
   1.221  static cell_t FindPluginByNumber(IPluginContext *pContext, const cell_t *params)
   1.222  {
   1.223 -	CPlugin *pPlugin = g_PluginSys.GetPluginByOrder(params[1]);
   1.224 +	IPlugin *pPlugin = scripts->FindPluginByOrder(params[1]);
   1.225  	
   1.226  	if (pPlugin == NULL)
   1.227  	{
   1.228 @@ -641,7 +638,7 @@
   1.229  
   1.230  	pContext->LocalToString(params[2], &name);
   1.231  
   1.232 -	return g_ShareSys.TestFeature(pContext->GetRuntime(),type, name);
   1.233 +	return sharesys->TestFeature(pContext->GetRuntime(), type, name);
   1.234  }
   1.235  
   1.236  static cell_t RequireFeature(IPluginContext *pContext, const cell_t *params)
   1.237 @@ -651,12 +648,12 @@
   1.238  
   1.239  	pContext->LocalToString(params[2], &name);
   1.240  
   1.241 -	if (g_ShareSys.TestFeature(pContext->GetRuntime(),type, name) != FeatureStatus_Available)
   1.242 +	if (sharesys->TestFeature(pContext->GetRuntime(), type, name) != FeatureStatus_Available)
   1.243  	{
   1.244  		char buffer[255];
   1.245  		char *msg = buffer;
   1.246  		char default_message[255];
   1.247 -		CPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pContext->GetContext());
   1.248 +		SMPlugin *pPlugin = scripts->FindPluginByContext(pContext->GetContext());
   1.249  
   1.250  		g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 3);
   1.251  		if (pContext->GetLastNativeError() != SP_ERROR_NONE || buffer[0] == '\0')