core/smn_core.cpp
changeset 978 54782a83a1ef
parent 889 176ae94f3747
child 1011 b413072540fd
     1.1 --- a/core/smn_core.cpp	Mon Jun 18 03:39:15 2007 +0000
     1.2 +++ b/core/smn_core.cpp	Mon Jun 18 07:04:22 2007 +0000
     1.3 @@ -13,10 +13,13 @@
     1.4   */
     1.5  
     1.6  #include <time.h>
     1.7 +#include <string.h>
     1.8 +#include "sm_stringutil.h"
     1.9  #include "sm_globals.h"
    1.10  #include "sourcemod.h"
    1.11  #include "PluginSys.h"
    1.12  #include "HandleSys.h"
    1.13 +#include "LibrarySys.h"
    1.14  
    1.15  #if defined PLATFORM_WINDOWS
    1.16  #include <windows.h>
    1.17 @@ -283,8 +286,39 @@
    1.18  #endif
    1.19  }
    1.20  
    1.21 +static cell_t AutoExecConfig(IPluginContext *pContext, const cell_t *params)
    1.22 +{
    1.23 +	CPlugin *plugin = g_PluginSys.GetPluginByCtx(pContext->GetContext());
    1.24 +
    1.25 +	char *cfg, *folder;
    1.26 +	pContext->LocalToString(params[2], &cfg);
    1.27 +	pContext->LocalToString(params[3], &folder);
    1.28 +
    1.29 +	if (cfg[0] == '\0')
    1.30 +	{
    1.31 +		static char temp_str[255];
    1.32 +		static char temp_file[PLATFORM_MAX_PATH];
    1.33 +		char *ptr;
    1.34 +
    1.35 +		g_LibSys.GetFileFromPath(temp_str, sizeof(temp_str), plugin->GetFilename());
    1.36 +		if ((ptr = strstr(temp_str, ".smx")) != NULL)
    1.37 +		{
    1.38 +			*ptr = '\0';
    1.39 +		}
    1.40 +
    1.41 +		/* We have the raw filename! */
    1.42 +		UTIL_Format(temp_file, sizeof(temp_file), "plugin.%s", temp_str);
    1.43 +		cfg = temp_file;
    1.44 +	}
    1.45 +
    1.46 +	plugin->AddConfig(params[1] ? true : false, cfg, folder);
    1.47 +
    1.48 +	return 1;
    1.49 +}
    1.50 +
    1.51  REGISTER_NATIVES(coreNatives)
    1.52  {
    1.53 +	{"AutoExecConfig",		AutoExecConfig},
    1.54  	{"GetPluginFilename",	GetPluginFilename},
    1.55  	{"GetPluginInfo",		GetPluginInfo},
    1.56  	{"GetPluginIterator",	GetPluginIterator},