initial import of extension API and SDK as well as auto-loading
authorDavid Anderson <dvander@alliedmods.net>
Tue Jan 16 19:41:21 2007 +0000 (2007-01-16)
changeset 29807f6b2fe8468
parent 297 3ab5f87d509f
child 299 f80dd1de6ebf
initial import of extension API and SDK as well as auto-loading
core/interfaces/IExtensionSys.h
core/systems/ExtensionSys.cpp
core/systems/ExtensionSys.h
core/systems/PluginSys.cpp
core/systems/PluginSys.h
extensions/sdk/extension.cpp
extensions/sdk/extension.h
extensions/sdk/sdk.sln
extensions/sdk/sdk.vcproj
plugins/include/core.inc
plugins/include/sourcemod.inc
     1.1 --- a/core/interfaces/IExtensionSys.h	Tue Jan 16 19:34:32 2007 +0000
     1.2 +++ b/core/interfaces/IExtensionSys.h	Tue Jan 16 19:41:21 2007 +0000
     1.3 @@ -15,6 +15,11 @@
     1.4  	{
     1.5  	public:
     1.6  		/**
     1.7 +		 * @brief Returns whether or not the extension is properly loaded.
     1.8 +		 */
     1.9 +		virtual bool IsLoaded() =0;
    1.10 +
    1.11 +		/**
    1.12  		 * @brief Returns the extension's API interface
    1.13  		 *
    1.14  		 * @return			An IExtensionInterface pointer.
    1.15 @@ -128,7 +133,7 @@
    1.16  		 * @param err_max	Maximum error buffer length.
    1.17  		 * @return			New IExtension on success, NULL on failure.
    1.18  		 */
    1.19 -		virtual IExtension *LoadModule(const char *path, 
    1.20 +		virtual IExtension *LoadExtension(const char *path, 
    1.21  									ExtensionLifetime lifetime, 
    1.22  									char *error,
    1.23  									size_t err_max) =0;
    1.24 @@ -158,7 +163,7 @@
    1.25  		 * @param pExt		IExtension pointer.
    1.26  		 * @return			True if successful, false otherwise.
    1.27  		 */
    1.28 -		virtual bool UnloadModule(IExtension *pExt) =0;
    1.29 +		virtual bool UnloadExtension(IExtension *pExt) =0;
    1.30  	};
    1.31  };
    1.32  
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/core/systems/ExtensionSys.cpp	Tue Jan 16 19:41:21 2007 +0000
     2.3 @@ -0,0 +1,222 @@
     2.4 +#include "ExtensionSys.h"
     2.5 +#include "LibrarySys.h"
     2.6 +#include "ShareSys.h"
     2.7 +#include "CLogger.h"
     2.8 +
     2.9 +CExtensionManager g_Extensions;
    2.10 +IdentityType_t g_ExtType;
    2.11 +
    2.12 +CExtension::CExtension(const char *filename, char *error, size_t err_max)
    2.13 +{
    2.14 +	m_File.assign(filename);
    2.15 +	m_pAPI = NULL;
    2.16 +	m_pIdentToken = NULL;
    2.17 +
    2.18 +	char path[PLATFORM_MAX_PATH+1];
    2.19 +	g_LibSys.PathFormat(path, PLATFORM_MAX_PATH, "%s/extensions/%s", g_SourceMod.GetSMBaseDir(), filename);
    2.20 +
    2.21 +	m_pLib = g_LibSys.OpenLibrary(path, error, err_max);
    2.22 +
    2.23 +	if (m_pLib == NULL)
    2.24 +	{
    2.25 +		return;
    2.26 +	}
    2.27 +
    2.28 +	typedef IExtensionInterface *(*GETAPI)();
    2.29 +	GETAPI pfnGetAPI = NULL;
    2.30 +
    2.31 +	if ((pfnGetAPI=(GETAPI)m_pLib->GetSymbolAddress("GetSMExtAPI")) == NULL)
    2.32 +	{
    2.33 +		m_pLib->CloseLibrary();
    2.34 +		m_pLib = NULL;
    2.35 +		snprintf(error, err_max, "Unable to find extension entry point");
    2.36 +		return;
    2.37 +	}
    2.38 +
    2.39 +	m_pAPI = pfnGetAPI();
    2.40 +	if (!m_pAPI || m_pAPI->GetExtensionVersion() > SMINTERFACE_EXTENSIONAPI_VERSION)
    2.41 +	{
    2.42 +		m_pLib->CloseLibrary();
    2.43 +		m_pLib = NULL;
    2.44 +		snprintf(error, err_max, "Extension version is too new to load (%d, max is %d)", m_pAPI->GetExtensionVersion(), SMINTERFACE_EXTENSIONAPI_VERSION);
    2.45 +		return;
    2.46 +	}
    2.47 +
    2.48 +	if (m_pAPI->IsMetamodExtension())
    2.49 +	{
    2.50 +		/* :TODO: STUFF */
    2.51 +	}
    2.52 +
    2.53 +	m_pIdentToken = g_ShareSys.CreateIdentity(g_ExtType);
    2.54 +
    2.55 +	if (!m_pAPI->OnExtensionLoad(this, &g_ShareSys, error, err_max, g_SourceMod.IsLateLoadInMap()))
    2.56 +	{
    2.57 +		if (m_pAPI->IsMetamodExtension())
    2.58 +		{
    2.59 +			/* :TODO: stuff */
    2.60 +		}
    2.61 +		m_pAPI = NULL;
    2.62 +		m_pLib->CloseLibrary();
    2.63 +		m_pLib = NULL;
    2.64 +		g_ShareSys.DestroyIdentity(m_pIdentToken);
    2.65 +		m_pIdentToken = NULL;
    2.66 +		return;
    2.67 +	}
    2.68 +}
    2.69 +
    2.70 +CExtension::~CExtension()
    2.71 +{
    2.72 +	if (m_pAPI)
    2.73 +	{
    2.74 +		m_pAPI->OnExtensionUnload();
    2.75 +	}
    2.76 +
    2.77 +	if (m_pIdentToken)
    2.78 +	{
    2.79 +		g_ShareSys.DestroyIdentity(m_pIdentToken);
    2.80 +	}
    2.81 +
    2.82 +	if (m_pLib)
    2.83 +	{
    2.84 +		m_pLib->CloseLibrary();
    2.85 +	}
    2.86 +}
    2.87 +
    2.88 +void CExtension::SetError(const char *error)
    2.89 +{
    2.90 +	m_Error.assign(error);
    2.91 +}
    2.92 +
    2.93 +IExtensionInterface *CExtension::GetAPI()
    2.94 +{
    2.95 +	return m_pAPI;
    2.96 +}
    2.97 +
    2.98 +const char *CExtension::GetFilename()
    2.99 +{
   2.100 +	return m_File.c_str();
   2.101 +}
   2.102 +
   2.103 +IdentityToken_t *CExtension::GetIdentity()
   2.104 +{
   2.105 +	return m_pIdentToken;
   2.106 +}
   2.107 +
   2.108 +bool CExtension::IsLoaded()
   2.109 +{
   2.110 +	return (m_pLib != NULL);
   2.111 +}
   2.112 +
   2.113 +void CExtensionManager::OnSourceModAllInitialized()
   2.114 +{
   2.115 +	g_ExtType = g_ShareSys.CreateIdentType("EXTENSION");
   2.116 +}
   2.117 +
   2.118 +void CExtensionManager::OnSourceModShutdown()
   2.119 +{
   2.120 +	g_ShareSys.DestroyIdentType(g_ExtType);
   2.121 +}
   2.122 +
   2.123 +IExtension *CExtensionManager::LoadAutoExtension(const char *path)
   2.124 +{
   2.125 +	char error[256];
   2.126 +	CExtension *p = new CExtension(path, error, sizeof(error));
   2.127 +
   2.128 +	if (!p->IsLoaded())
   2.129 +	{
   2.130 +		g_Logger.LogError("[SOURCEMOD] Unable to load extension \"%s\": %s", path, error);
   2.131 +		p->SetError(error);
   2.132 +	}
   2.133 +
   2.134 +	m_Libs.push_back(p);
   2.135 +
   2.136 +	return p;
   2.137 +}
   2.138 +
   2.139 +IExtension *CExtensionManager::FindExtensionByFile(const char *file)
   2.140 +{
   2.141 +	List<CExtension *>::iterator iter;
   2.142 +	CExtension *pExt;
   2.143 +
   2.144 +	/* Make sure the file direction is right */
   2.145 +	char path[PLATFORM_MAX_PATH+1];
   2.146 +	g_LibSys.PathFormat(path, PLATFORM_MAX_PATH, "%s", file);
   2.147 +
   2.148 +	for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
   2.149 +	{
   2.150 +		pExt = (*iter);
   2.151 +		if (strcmp(pExt->GetFilename(), path) == 0)
   2.152 +		{
   2.153 +			return pExt;
   2.154 +		}
   2.155 +	}
   2.156 +
   2.157 +	return NULL;
   2.158 +}
   2.159 +
   2.160 +IExtension *CExtensionManager::FindExtensionByName(const char *ext)
   2.161 +{
   2.162 +	List<CExtension *>::iterator iter;
   2.163 +	CExtension *pExt;
   2.164 +	IExtensionInterface *pAPI;
   2.165 +	const char *name;
   2.166 +
   2.167 +	for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
   2.168 +	{
   2.169 +		pExt = (*iter);
   2.170 +		if (!pExt->IsLoaded())
   2.171 +		{
   2.172 +			continue;
   2.173 +		}
   2.174 +		if ((pAPI = pExt->GetAPI()) == NULL)
   2.175 +		{
   2.176 +			continue;
   2.177 +		}
   2.178 +		name = pAPI->GetExtensionName();
   2.179 +		if (!name)
   2.180 +		{
   2.181 +			continue;
   2.182 +		}
   2.183 +		if (strcmp(name, ext) == 0)
   2.184 +		{
   2.185 +			return pExt;
   2.186 +		}
   2.187 +	}
   2.188 +
   2.189 +	return NULL;
   2.190 +}
   2.191 +
   2.192 +IExtension *CExtensionManager::LoadExtension(const char *file, ExtensionLifetime lifetime, char *error, size_t err_max)
   2.193 +{
   2.194 +	CExtension *pExt = new CExtension(file, error, err_max);
   2.195 +
   2.196 +	/* :NOTE: lifetime is currently ignored */
   2.197 +
   2.198 +	if (!pExt->IsLoaded())
   2.199 +	{
   2.200 +		delete pExt;
   2.201 +		return NULL;
   2.202 +	}
   2.203 +
   2.204 +	m_Libs.push_back(pExt);
   2.205 +
   2.206 +	return pExt;
   2.207 +}
   2.208 +
   2.209 +bool CExtensionManager::UnloadExtension(IExtension *pExt)
   2.210 +{
   2.211 +	/* :TODO: implement */
   2.212 +	return true;
   2.213 +}
   2.214 +
   2.215 +unsigned int CExtensionManager::NumberOfPluginDependents(IExtension *pExt, unsigned int *optional)
   2.216 +{
   2.217 +	/* :TODO: implement */
   2.218 +	return 0;
   2.219 +}
   2.220 +
   2.221 +bool CExtensionManager::IsExtensionUnloadable(IExtension *pExtension)
   2.222 +{
   2.223 +	/* :TODO: implement */
   2.224 +	return true;
   2.225 +}
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/core/systems/ExtensionSys.h	Tue Jan 16 19:41:21 2007 +0000
     3.3 @@ -0,0 +1,58 @@
     3.4 +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_SYSTEM_H_
     3.5 +#define _INCLUDE_SOURCEMOD_EXTENSION_SYSTEM_H_
     3.6 +
     3.7 +#include <IExtensionSys.h>
     3.8 +#include <ILibrarySys.h>
     3.9 +#include <sh_list.h>
    3.10 +#include <sh_string.h>
    3.11 +#include "sm_globals.h"
    3.12 +
    3.13 +using namespace SourceMod;
    3.14 +using namespace SourceHook;
    3.15 +
    3.16 +class CExtension : public IExtension
    3.17 +{
    3.18 +public:
    3.19 +	CExtension(const char *filename, char *error, size_t maxlen);
    3.20 +	~CExtension();
    3.21 +public: //IExtension
    3.22 +	IExtensionInterface *GetAPI();
    3.23 +	const char *GetFilename();
    3.24 +	IdentityToken_t *GetIdentity();
    3.25 +	bool IsLoaded();
    3.26 +public:
    3.27 +	void SetError(const char *error);
    3.28 +private:
    3.29 +	IdentityToken_t *m_pIdentToken;
    3.30 +	IExtensionInterface *m_pAPI;
    3.31 +	String m_File;
    3.32 +	ILibrary *m_pLib;
    3.33 +	String m_Error;
    3.34 +};
    3.35 +
    3.36 +class CExtensionManager : 
    3.37 +	public IExtensionManager,
    3.38 +	public SMGlobalClass
    3.39 +{
    3.40 +public: //SMGlobalClass
    3.41 +	void OnSourceModAllInitialized();
    3.42 +	void OnSourceModShutdown();
    3.43 +public: //IExtensionManager
    3.44 +	IExtension *LoadExtension(const char *path, 
    3.45 +		ExtensionLifetime lifetime, 
    3.46 +		char *error,
    3.47 +		size_t err_max);
    3.48 +	unsigned int NumberOfPluginDependents(IExtension *pExt, unsigned int *optional);
    3.49 +	bool IsExtensionUnloadable(IExtension *pExtension);
    3.50 +	bool UnloadExtension(IExtension *pExt);
    3.51 +	IExtension *FindExtensionByFile(const char *file);
    3.52 +	IExtension *FindExtensionByName(const char *ext);
    3.53 +public:
    3.54 +	IExtension *LoadAutoExtension(const char *path);
    3.55 +private:
    3.56 +	List<CExtension *> m_Libs;
    3.57 +};
    3.58 +
    3.59 +extern CExtensionManager g_Extensions;
    3.60 +
    3.61 +#endif //_INCLUDE_SOURCEMOD_EXTENSION_SYSTEM_H_
     4.1 --- a/core/systems/PluginSys.cpp	Tue Jan 16 19:34:32 2007 +0000
     4.2 +++ b/core/systems/PluginSys.cpp	Tue Jan 16 19:41:21 2007 +0000
     4.3 @@ -7,6 +7,7 @@
     4.4  #include "sourcemod.h"
     4.5  #include "CTextParsers.h"
     4.6  #include "CLogger.h"
     4.7 +#include "ExtensionSys.h"
     4.8  
     4.9  CPluginManager g_PluginSys;
    4.10  HandleType_t g_PluginType = 0;
    4.11 @@ -31,6 +32,16 @@
    4.12  
    4.13  CPlugin::~CPlugin()
    4.14  {
    4.15 +	if (m_handle)
    4.16 +	{
    4.17 +		HandleSecurity sec;
    4.18 +		sec.pOwner = g_PluginSys.GetIdentity();
    4.19 +		sec.pIdentity = sec.pOwner;
    4.20 +
    4.21 +		g_HandleSys.FreeHandle(m_handle, &sec);
    4.22 +		g_ShareSys.DestroyIdentity(m_ident);
    4.23 +	}
    4.24 +
    4.25  	if (m_ctx.base)
    4.26  	{
    4.27  		delete m_ctx.base;
    4.28 @@ -72,16 +83,6 @@
    4.29  		g_pSourcePawn->FreeFromMemory(m_plugin);
    4.30  		m_plugin = NULL;
    4.31  	}
    4.32 -
    4.33 -	if (m_handle)
    4.34 -	{
    4.35 -		HandleSecurity sec;
    4.36 -		sec.pOwner = g_PluginSys.GetIdentity();
    4.37 -		sec.pIdentity = sec.pOwner;
    4.38 -
    4.39 -		g_HandleSys.FreeHandle(m_handle, &sec);
    4.40 -		g_ShareSys.DestroyIdentity(m_ident);
    4.41 -	}
    4.42  }
    4.43  
    4.44  void CPlugin::InitIdentity()
    4.45 @@ -100,18 +101,16 @@
    4.46  	g_LibSys.PathFormat(fullpath, sizeof(fullpath), "%s/plugins/%s", g_SourceMod.GetSMBaseDir(), file);
    4.47  	FILE *fp = fopen(fullpath, "rb");
    4.48  
    4.49 +	CPlugin *pPlugin = new CPlugin(file);
    4.50 +
    4.51  	if (!fp)
    4.52  	{
    4.53  		if (error)
    4.54  		{
    4.55  			snprintf(error, maxlength, "Unable to open file");
    4.56 -			return NULL;
    4.57 -		} else {
    4.58 -			CPlugin *pPlugin = new CPlugin(file);
    4.59 -			snprintf(pPlugin->m_errormsg, sizeof(pPlugin->m_errormsg), "Unable to open file");
    4.60 -			pPlugin->m_status = Plugin_BadLoad;
    4.61 -			return pPlugin;
    4.62  		}
    4.63 +		pPlugin->m_status = Plugin_BadLoad;
    4.64 +		return pPlugin;
    4.65  	}
    4.66  
    4.67  	int err;
    4.68 @@ -122,19 +121,15 @@
    4.69  		if (error)
    4.70  		{
    4.71  			snprintf(error, maxlength, "Error %d while parsing plugin", err);
    4.72 -			return NULL;
    4.73 -		} else {
    4.74 -			CPlugin *pPlugin = new CPlugin(file);
    4.75 -			snprintf(pPlugin->m_errormsg, sizeof(pPlugin->m_errormsg), "Error %d while parsing plugin", err);
    4.76 -			pPlugin->m_status = Plugin_BadLoad;
    4.77 -			return pPlugin;
    4.78  		}
    4.79 +		pPlugin->m_status = Plugin_BadLoad;
    4.80 +		return pPlugin;
    4.81  	}
    4.82  
    4.83  	fclose(fp);
    4.84  
    4.85 -	CPlugin *pPlugin = new CPlugin(file);
    4.86  	pPlugin->m_plugin = pl;
    4.87 +
    4.88  	return pPlugin;
    4.89  }
    4.90  
    4.91 @@ -185,10 +180,8 @@
    4.92  	if (!m_ctx.ctx)
    4.93  	{
    4.94  		memset(&m_ctx, 0, sizeof(m_ctx));
    4.95 -		if (!error)
    4.96 +		if (error)
    4.97  		{
    4.98 -			SetErrorState(Plugin_Failed, "Failed to compile (error %d)", err);
    4.99 -		} else {
   4.100  			snprintf(error, maxlength, "Failed to compile (error %d)", err);
   4.101  		}
   4.102  		return false;
   4.103 @@ -377,12 +370,6 @@
   4.104  		return false;
   4.105  	}
   4.106  
   4.107 -	if (!error)
   4.108 -	{
   4.109 -		error = m_errormsg;
   4.110 -		maxlength = sizeof(m_errormsg);
   4.111 -	}
   4.112 -
   4.113  	m_status = Plugin_Loaded;
   4.114  
   4.115  	int err;
   4.116 @@ -676,20 +663,20 @@
   4.117  
   4.118  //well i have discovered that gabe newell is very fat, so i wrote this comment now
   4.119  //:TODO: remove this function, create a better wrapper for LoadPlugin()/LoadAutoPlugin()
   4.120 -void CPluginManager::LoadAutoPlugin(const char *file)
   4.121 +bool CPluginManager::_LoadPlugin(CPlugin **_plugin, const char *path, bool debug, PluginType type, char error[], size_t err_max)
   4.122  {
   4.123  	/**
   4.124  	 * Does this plugin already exist?
   4.125  	 */
   4.126  	CPlugin *pPlugin;
   4.127 -	if (sm_trie_retrieve(m_LoadLookup, file, (void **)&pPlugin))
   4.128 +	if (sm_trie_retrieve(m_LoadLookup, path, (void **)&pPlugin))
   4.129  	{
   4.130  		/* First check the type */
   4.131  		PluginType type = pPlugin->GetType();
   4.132  		if (type == PluginType_Private
   4.133  			|| type == PluginType_Global)
   4.134  		{
   4.135 -			return;
   4.136 +			return true;
   4.137  		}
   4.138  		/* Check to see if we should try reloading it */
   4.139  		if (pPlugin->GetStatus() == Plugin_BadLoad
   4.140 @@ -700,7 +687,7 @@
   4.141  		}
   4.142  	}
   4.143  
   4.144 -	pPlugin = CPlugin::CreatePlugin(file, NULL, 0);
   4.145 +	pPlugin = CPlugin::CreatePlugin(path, error, err_max);
   4.146  
   4.147  	assert(pPlugin != NULL);
   4.148  
   4.149 @@ -717,8 +704,7 @@
   4.150  	unsigned int setcount = m_PluginInfo.GetSettingsNum();
   4.151  	for (unsigned int i=0; i<setcount; i++)
   4.152  	{
   4.153 -		pset = m_PluginInfo.GetSettingsIfMatch(i, file);
   4.154 -		if (!pset)
   4.155 +		if ((pset=m_PluginInfo.GetSettingsIfMatch(i, path)) == NULL)
   4.156  		{
   4.157  			continue;
   4.158  		}
   4.159 @@ -735,8 +721,12 @@
   4.160  				}
   4.161  				if (!g_pVM->SetCompilationOption(co, key, val))
   4.162  				{
   4.163 -					pPlugin->SetErrorState(Plugin_Failed, "Unable to set option (key \"%s\") (value \"%s\")", key, val);
   4.164 +					if (error)
   4.165 +					{
   4.166 +						snprintf(error, err_max, "Unable to set JIT option (key \"%s\") (value \"%s\")", key, val);
   4.167 +					}
   4.168  					pPlugin->CancelMyCompile();
   4.169 +					pPlugin->m_status = Plugin_Failed;
   4.170  					co = NULL;
   4.171  					break;
   4.172  				}
   4.173 @@ -744,100 +734,71 @@
   4.174  		}
   4.175  	}
   4.176  
   4.177 +	/* Do the actual compiling */
   4.178  	if (co)
   4.179  	{
   4.180  		pPlugin->FinishMyCompile(NULL, 0);
   4.181  		co = NULL;
   4.182  	}
   4.183  
   4.184 -	/* We don't care about the return value */
   4.185 +	/* Get the status */
   4.186  	if (pPlugin->GetStatus() == Plugin_Created)
   4.187  	{
   4.188  		AddCoreNativesToPlugin(pPlugin);
   4.189  		pPlugin->InitIdentity();
   4.190 -		pPlugin->Call_AskPluginLoad(NULL, 0);
   4.191 +		pPlugin->Call_AskPluginLoad(error, err_max);
   4.192  	}
   4.193  
   4.194 -	AddPlugin(pPlugin);
   4.195 +	if (_plugin)
   4.196 +	{
   4.197 +		*_plugin = pPlugin;
   4.198 +	}
   4.199 +
   4.200 +	return (pPlugin->GetStatus() == Plugin_Loaded);
   4.201  }
   4.202  
   4.203  IPlugin *CPluginManager::LoadPlugin(const char *path, bool debug, PluginType type, char error[], size_t err_max)
   4.204  {
   4.205 -	/* See if this plugin is already loaded... reformat to get sep chars right */
   4.206 -	char checkpath[PLATFORM_MAX_PATH+1];
   4.207 -	g_LibSys.PathFormat(checkpath, sizeof(checkpath), "%s", path);
   4.208 -
   4.209 -	/**
   4.210 -	 * In manually loading a plugin, any sort of load error causes a deletion.
   4.211 -	 * This is because it's assumed manually loaded plugins will not be managed.
   4.212 -	 * For managed plugins, we need the UI to report them properly.
   4.213 -	 */
   4.214 +	CPlugin *pl;
   4.215  
   4.216 -	CPlugin *pPlugin;
   4.217 -	if (sm_trie_retrieve(m_LoadLookup, checkpath, (void **)&pPlugin))
   4.218 +	if (!_LoadPlugin(&pl, path, debug, type, error, err_max))
   4.219  	{
   4.220 -		snprintf(error, err_max, "Plugin file is already loaded");
   4.221 -		return NULL;
   4.222 -	}
   4.223 -
   4.224 -	pPlugin = CPlugin::CreatePlugin(path, error, err_max);
   4.225 -
   4.226 -	if (!pPlugin)
   4.227 -	{
   4.228 +		delete pl;
   4.229  		return NULL;
   4.230  	}
   4.231  
   4.232 -	ICompilation *co = pPlugin->StartMyCompile(g_pVM);
   4.233 -	if (!co || (debug && !g_pVM->SetCompilationOption(co, "debug", "1")))
   4.234 +	AddPlugin(pl);
   4.235 +
   4.236 +	return pl;
   4.237 +}
   4.238 +
   4.239 +void CPluginManager::LoadAutoPlugin(const char *plugin)
   4.240 +{
   4.241 +	CPlugin *pl;
   4.242 +	char error[255] = "Unknown error";
   4.243 +
   4.244 +	if (!_LoadPlugin(&pl, plugin, false, PluginType_MapUpdated, error, sizeof(error)))
   4.245  	{
   4.246 -		snprintf(error, err_max, "Unable to start%s compilation", debug ? " debug" : "");
   4.247 -		pPlugin->CancelMyCompile();
   4.248 -		delete pPlugin;
   4.249 -		return NULL;
   4.250 -	}
   4.251 -
   4.252 -	if (!pPlugin->FinishMyCompile(error, err_max))
   4.253 -	{
   4.254 -		delete pPlugin;
   4.255 -		return NULL;
   4.256 +		g_Logger.LogError("[SOURCEMOD] Failed to load plugin \"%s\": %s", plugin, error);
   4.257 +		pl->SetErrorState(Plugin_Failed, "%s", error);
   4.258  	}
   4.259  
   4.260 -	pPlugin->m_type = type;
   4.261 -
   4.262 -	AddCoreNativesToPlugin(pPlugin);
   4.263 -
   4.264 -	pPlugin->InitIdentity();
   4.265 -
   4.266 -	/* Finally, ask the plugin if it wants to be loaded */
   4.267 -	if (!pPlugin->Call_AskPluginLoad(error, err_max))
   4.268 -	{
   4.269 -		delete pPlugin;
   4.270 -		return NULL;
   4.271 -	}
   4.272 -
   4.273 -	AddPlugin(pPlugin);
   4.274 -
   4.275 -	return pPlugin;
   4.276 +	AddPlugin(pl);
   4.277  }
   4.278  
   4.279  void CPluginManager::AddPlugin(CPlugin *pPlugin)
   4.280  {
   4.281 -	m_plugins.push_back(pPlugin);
   4.282 -	sm_trie_insert(m_LoadLookup, pPlugin->m_filename, pPlugin);
   4.283 -
   4.284  	List<IPluginsListener *>::iterator iter;
   4.285  	IPluginsListener *pListener;
   4.286 +
   4.287  	for (iter=m_listeners.begin(); iter!=m_listeners.end(); iter++)
   4.288  	{
   4.289  		pListener = (*iter);
   4.290  		pListener->OnPluginCreated(pPlugin);
   4.291  	}
   4.292  
   4.293 -	/* If the second pass was already completed, we have to run the pass on this plugin */
   4.294 -	if (m_AllPluginsLoaded && pPlugin->GetStatus() == Plugin_Loaded)
   4.295 -	{
   4.296 -		RunSecondPass(pPlugin);
   4.297 -	}
   4.298 +	m_plugins.push_back(pPlugin);
   4.299 +	sm_trie_insert(m_LoadLookup, pPlugin->m_filename, pPlugin);
   4.300  }
   4.301  
   4.302  void CPluginManager::LoadAll_SecondPass()
   4.303 @@ -850,16 +811,77 @@
   4.304  		pPlugin = (*iter);
   4.305  		if (pPlugin->GetStatus() == Plugin_Loaded)
   4.306  		{
   4.307 -			RunSecondPass(pPlugin);
   4.308 +			/* :TODO: fix */
   4.309 +			RunSecondPass(pPlugin, NULL, 0);
   4.310  		}
   4.311  	}
   4.312 +
   4.313  	m_AllPluginsLoaded = true;
   4.314  }
   4.315  
   4.316 -void CPluginManager::RunSecondPass(CPlugin *pPlugin)
   4.317 +bool CPluginManager::RunSecondPass(CPlugin *pPlugin, char *error, size_t maxlength)
   4.318  {
   4.319 -	/* Tell this plugin to finish initializing itself */
   4.320 -	pPlugin->Call_OnPluginInit();
   4.321 +	/* Find any extensions this plugin needs */
   4.322 +	struct _ext
   4.323 +	{
   4.324 +		cell_t name;
   4.325 +		cell_t file;
   4.326 +		cell_t autoload;
   4.327 +		cell_t required;
   4.328 +	} *ext;
   4.329 +
   4.330 +	IPluginContext *pBase = pPlugin->GetBaseContext();
   4.331 +	uint32_t num = pBase->GetPubVarsNum();
   4.332 +	sp_pubvar_t *pubvar;
   4.333 +	IExtension *pExt;
   4.334 +	char path[PLATFORM_MAX_PATH+1];
   4.335 +	char *file, *name;
   4.336 +	for (uint32_t i=0; i<num; i++)
   4.337 +	{
   4.338 +		if (pBase->GetPubvarByIndex(i, &pubvar) != SP_ERROR_NONE)
   4.339 +		{
   4.340 +			continue;
   4.341 +		}
   4.342 +		if (strncmp(pubvar->name, "__ext_", 6) == 0)
   4.343 +		{
   4.344 +			ext = (_ext *)pubvar->offs;
   4.345 +			if (!ext->required && !ext->autoload)
   4.346 +			{
   4.347 +				continue;
   4.348 +			}
   4.349 +			if (pBase->LocalToString(ext->file, &file) != SP_ERROR_NONE)
   4.350 +			{
   4.351 +				continue;
   4.352 +			}
   4.353 +			if (pBase->LocalToString(ext->name, &name) != SP_ERROR_NONE)
   4.354 +			{
   4.355 +				continue;
   4.356 +			}
   4.357 +			snprintf(path, PLATFORM_MAX_PATH, "%s.%s", file, PLATFORM_LIB_EXT);
   4.358 +			pExt = NULL;
   4.359 +			/* Attempt to auto-load if necessary */
   4.360 +			if (ext->autoload)
   4.361 +			{
   4.362 +				pExt = g_Extensions.LoadAutoExtension(path);
   4.363 +			}
   4.364 +			if (ext->required && !pExt)
   4.365 +			{
   4.366 +				if ((pExt = g_Extensions.FindExtensionByFile(path)) == NULL)
   4.367 +				{
   4.368 +					pExt = g_Extensions.FindExtensionByName(name);
   4.369 +				}
   4.370 +			}
   4.371 +			if (ext->required && (!pExt || !pExt->IsLoaded()))
   4.372 +			{
   4.373 +				if (error)
   4.374 +				{
   4.375 +					snprintf(error, maxlength, "Required extension \"%s\" (file \"%s\") not found", name, file);
   4.376 +				}
   4.377 +				pPlugin->m_status = Plugin_Failed;
   4.378 +				return false;
   4.379 +			}
   4.380 +		}
   4.381 +	}
   4.382  
   4.383  	/* Finish by telling all listeners */
   4.384  	List<IPluginsListener *>::iterator iter;
   4.385 @@ -869,6 +891,11 @@
   4.386  		pListener = (*iter);
   4.387  		pListener->OnPluginLoaded(pPlugin);
   4.388  	}
   4.389 +	
   4.390 +	/* Tell this plugin to finish initializing itself */
   4.391 +	pPlugin->Call_OnPluginInit();
   4.392 +
   4.393 +	return true;
   4.394  }
   4.395  
   4.396  void CPluginManager::AddCoreNativesToPlugin(CPlugin *pPlugin)
   4.397 @@ -891,6 +918,13 @@
   4.398  bool CPluginManager::UnloadPlugin(IPlugin *plugin)
   4.399  {
   4.400  	CPlugin *pPlugin = (CPlugin *)plugin;
   4.401 +
   4.402 +	/* This prevents removal during insertion or anything else weird */
   4.403 +	if (m_plugins.find(pPlugin) == m_plugins.end())
   4.404 +	{
   4.405 +		return false;
   4.406 +	}
   4.407 +
   4.408  	List<IPluginsListener *>::iterator iter;
   4.409  	IPluginsListener *pListener;
   4.410  
   4.411 @@ -1215,6 +1249,12 @@
   4.412  
   4.413  void CPluginManager::OnSourceModShutdown()
   4.414  {
   4.415 +	List<CPlugin *>::iterator iter;
   4.416 +	while ( (iter = m_plugins.begin()) != m_plugins.end() )
   4.417 +	{
   4.418 +		UnloadPlugin((*iter));
   4.419 +	}
   4.420 +
   4.421  	g_HandleSys.RemoveType(g_PluginType, m_MyIdent);
   4.422  	g_ShareSys.DestroyIdentType(g_PluginIdent);
   4.423  	g_ShareSys.DestroyIdentity(m_MyIdent);
   4.424 @@ -1270,4 +1310,4 @@
   4.425  	iter->Release();
   4.426  
   4.427  	return pl;
   4.428 -}
   4.429 \ No newline at end of file
   4.430 +}
     5.1 --- a/core/systems/PluginSys.h	Tue Jan 16 19:34:32 2007 +0000
     5.2 +++ b/core/systems/PluginSys.h	Tue Jan 16 19:41:21 2007 +0000
     5.3 @@ -269,18 +269,16 @@
     5.4  	*/
     5.5  	CPlugin *GetPluginByOrder(int num);
     5.6  private:
     5.7 +	bool _LoadPlugin(CPlugin **pPlugin, const char *path, bool debug, PluginType type, char error[], size_t err_max);
     5.8 +
     5.9 +	void LoadAutoPlugin(const char *plugin);
    5.10 +
    5.11  	/**
    5.12  	 * Recursively loads all plugins in the given directory.
    5.13  	 */
    5.14  	void LoadPluginsFromDir(const char *basedir, const char *localdir);
    5.15  
    5.16  	/**
    5.17 -	 * Loads a plugin using automatic information.
    5.18 -	 * The file must be relative to the plugins folder.
    5.19 -	 */
    5.20 -	void LoadAutoPlugin(const char *file);
    5.21 -
    5.22 -	/**
    5.23  	 * Adds a plugin object.  This is wrapped by LoadPlugin functions.
    5.24  	 */
    5.25  	void AddPlugin(CPlugin *pPlugin);
    5.26 @@ -288,7 +286,7 @@
    5.27  	/**
    5.28  	 * Runs the second loading pass on a plugin.
    5.29  	 */
    5.30 -	void RunSecondPass(CPlugin *pPlugin);
    5.31 +	bool RunSecondPass(CPlugin *pPlugin, char *error, size_t maxlength);
    5.32  
    5.33  	/**
    5.34  	 * Adds any globally registered natives to a plugin
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/extensions/sdk/extension.cpp	Tue Jan 16 19:41:21 2007 +0000
     6.3 @@ -0,0 +1,5 @@
     6.4 +#include "extension.h"
     6.5 +
     6.6 +Sample g_Sample;
     6.7 +
     6.8 +SMEXT_LINK(&g_Sample);
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/extensions/sdk/extension.h	Tue Jan 16 19:41:21 2007 +0000
     7.3 @@ -0,0 +1,49 @@
     7.4 +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
     7.5 +#define _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
     7.6 +
     7.7 +#include "smsdk_ext.h"
     7.8 +
     7.9 +/**
    7.10 + * @brief Sample implementation of the SDK Extension.
    7.11 + * Note: Uncomment one of the pre-defined virtual functions in order to use it.
    7.12 + */
    7.13 +class Sample : public SDKExtension
    7.14 +{
    7.15 +public:
    7.16 +	/**
    7.17 +	 * @brief This is called after the initial loading sequence has been processed.
    7.18 +	 *
    7.19 +	 * @param error		Error message buffer.
    7.20 +	 * @param err_max	Size of error message buffer.
    7.21 +	 * @param late		Whether or not the module was loaded after map load.
    7.22 +	 * @return			True to succeed loading, false to fail.
    7.23 +	 */
    7.24 +	//virtual bool SDK_OnLoad(char *error, size_t err_max, bool late);
    7.25 +	
    7.26 +	/**
    7.27 +	 * @brief This is called right before the extension is unloaded.
    7.28 +	 */
    7.29 +	//virtual void SDK_OnUnload();
    7.30 +
    7.31 +	/**
    7.32 +	 * @brief This is called once all known extensions have been loaded.
    7.33 +	 */
    7.34 +	//virtual void SDK_OnAllLoaded();
    7.35 +
    7.36 +	/**
    7.37 +	 * @brief Called when the pause state is changed.
    7.38 +	 */
    7.39 +	//virtual void SDK_OnPauseChange(bool paused);
    7.40 +public:
    7.41 +#if defined SMEXT_CONF_METAMOD
    7.42 +	/**
    7.43 +	 * Read smext_base.h for documentation on these.
    7.44 +	 */
    7.45 +
    7.46 +	//virtual bool SDK_OnMetamodLoad(char *error, size_t err_max, bool late);
    7.47 +	//virtual bool SDK_OnMetamodUnload(char *error, size_t err_max);
    7.48 +	//virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t err_max);
    7.49 +#endif
    7.50 +};
    7.51 +
    7.52 +#endif //_INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/extensions/sdk/sdk.sln	Tue Jan 16 19:41:21 2007 +0000
     8.3 @@ -0,0 +1,26 @@
     8.4 +
     8.5 +Microsoft Visual Studio Solution File, Format Version 9.00
     8.6 +# Visual Studio 2005
     8.7 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdk", "sdk.vcproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}"
     8.8 +EndProject
     8.9 +Global
    8.10 +	GlobalSection(SolutionConfigurationPlatforms) = preSolution
    8.11 +		Debug - Metamod|Win32 = Debug - Metamod|Win32
    8.12 +		Debug|Win32 = Debug|Win32
    8.13 +		Release - Metamod|Win32 = Release - Metamod|Win32
    8.14 +		Release|Win32 = Release|Win32
    8.15 +	EndGlobalSection
    8.16 +	GlobalSection(ProjectConfigurationPlatforms) = postSolution
    8.17 +		{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Metamod|Win32.ActiveCfg = Debug - Metamod|Win32
    8.18 +		{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Metamod|Win32.Build.0 = Debug - Metamod|Win32
    8.19 +		{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.ActiveCfg = Debug|Win32
    8.20 +		{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug|Win32.Build.0 = Debug|Win32
    8.21 +		{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Metamod|Win32.ActiveCfg = Release - Metamod|Win32
    8.22 +		{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Metamod|Win32.Build.0 = Release - Metamod|Win32
    8.23 +		{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.ActiveCfg = Release|Win32
    8.24 +		{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release|Win32.Build.0 = Release|Win32
    8.25 +	EndGlobalSection
    8.26 +	GlobalSection(SolutionProperties) = preSolution
    8.27 +		HideSolutionNode = FALSE
    8.28 +	EndGlobalSection
    8.29 +EndGlobal
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/extensions/sdk/sdk.vcproj	Tue Jan 16 19:41:21 2007 +0000
     9.3 @@ -0,0 +1,364 @@
     9.4 +<?xml version="1.0" encoding="Windows-1252"?>
     9.5 +<VisualStudioProject
     9.6 +	ProjectType="Visual C++"
     9.7 +	Version="8.00"
     9.8 +	Name="sdk"
     9.9 +	ProjectGUID="{B3E797CF-4E77-4C9D-B8A8-7589B6902206}"
    9.10 +	RootNamespace="sdk"
    9.11 +	Keyword="Win32Proj"
    9.12 +	>
    9.13 +	<Platforms>
    9.14 +		<Platform
    9.15 +			Name="Win32"
    9.16 +		/>
    9.17 +	</Platforms>
    9.18 +	<ToolFiles>
    9.19 +	</ToolFiles>
    9.20 +	<Configurations>
    9.21 +		<Configuration
    9.22 +			Name="Debug|Win32"
    9.23 +			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
    9.24 +			IntermediateDirectory="$(ConfigurationName)"
    9.25 +			ConfigurationType="2"
    9.26 +			CharacterSet="2"
    9.27 +			>
    9.28 +			<Tool
    9.29 +				Name="VCPreBuildEventTool"
    9.30 +			/>
    9.31 +			<Tool
    9.32 +				Name="VCCustomBuildTool"
    9.33 +			/>
    9.34 +			<Tool
    9.35 +				Name="VCXMLDataGeneratorTool"
    9.36 +			/>
    9.37 +			<Tool
    9.38 +				Name="VCWebServiceProxyGeneratorTool"
    9.39 +			/>
    9.40 +			<Tool
    9.41 +				Name="VCMIDLTool"
    9.42 +			/>
    9.43 +			<Tool
    9.44 +				Name="VCCLCompilerTool"
    9.45 +				Optimization="0"
    9.46 +				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE"
    9.47 +				MinimalRebuild="true"
    9.48 +				BasicRuntimeChecks="3"
    9.49 +				RuntimeLibrary="3"
    9.50 +				UsePrecompiledHeader="0"
    9.51 +				WarningLevel="3"
    9.52 +				Detect64BitPortabilityProblems="true"
    9.53 +				DebugInformationFormat="4"
    9.54 +			/>
    9.55 +			<Tool
    9.56 +				Name="VCManagedResourceCompilerTool"
    9.57 +			/>
    9.58 +			<Tool
    9.59 +				Name="VCResourceCompilerTool"
    9.60 +			/>
    9.61 +			<Tool
    9.62 +				Name="VCPreLinkEventTool"
    9.63 +			/>
    9.64 +			<Tool
    9.65 +				Name="VCLinkerTool"
    9.66 +				LinkIncremental="2"
    9.67 +				GenerateDebugInformation="true"
    9.68 +				SubSystem="2"
    9.69 +				TargetMachine="1"
    9.70 +			/>
    9.71 +			<Tool
    9.72 +				Name="VCALinkTool"
    9.73 +			/>
    9.74 +			<Tool
    9.75 +				Name="VCManifestTool"
    9.76 +			/>
    9.77 +			<Tool
    9.78 +				Name="VCXDCMakeTool"
    9.79 +			/>
    9.80 +			<Tool
    9.81 +				Name="VCBscMakeTool"
    9.82 +			/>
    9.83 +			<Tool
    9.84 +				Name="VCFxCopTool"
    9.85 +			/>
    9.86 +			<Tool
    9.87 +				Name="VCAppVerifierTool"
    9.88 +			/>
    9.89 +			<Tool
    9.90 +				Name="VCWebDeploymentTool"
    9.91 +			/>
    9.92 +			<Tool
    9.93 +				Name="VCPostBuildEventTool"
    9.94 +			/>
    9.95 +		</Configuration>
    9.96 +		<Configuration
    9.97 +			Name="Release|Win32"
    9.98 +			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
    9.99 +			IntermediateDirectory="$(ConfigurationName)"
   9.100 +			ConfigurationType="2"
   9.101 +			CharacterSet="1"
   9.102 +			WholeProgramOptimization="1"
   9.103 +			>
   9.104 +			<Tool
   9.105 +				Name="VCPreBuildEventTool"
   9.106 +			/>
   9.107 +			<Tool
   9.108 +				Name="VCCustomBuildTool"
   9.109 +			/>
   9.110 +			<Tool
   9.111 +				Name="VCXMLDataGeneratorTool"
   9.112 +			/>
   9.113 +			<Tool
   9.114 +				Name="VCWebServiceProxyGeneratorTool"
   9.115 +			/>
   9.116 +			<Tool
   9.117 +				Name="VCMIDLTool"
   9.118 +			/>
   9.119 +			<Tool
   9.120 +				Name="VCCLCompilerTool"
   9.121 +				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE"
   9.122 +				RuntimeLibrary="2"
   9.123 +				UsePrecompiledHeader="0"
   9.124 +				WarningLevel="3"
   9.125 +				Detect64BitPortabilityProblems="true"
   9.126 +				DebugInformationFormat="3"
   9.127 +			/>
   9.128 +			<Tool
   9.129 +				Name="VCManagedResourceCompilerTool"
   9.130 +			/>
   9.131 +			<Tool
   9.132 +				Name="VCResourceCompilerTool"
   9.133 +			/>
   9.134 +			<Tool
   9.135 +				Name="VCPreLinkEventTool"
   9.136 +			/>
   9.137 +			<Tool
   9.138 +				Name="VCLinkerTool"
   9.139 +				LinkIncremental="1"
   9.140 +				GenerateDebugInformation="true"
   9.141 +				SubSystem="2"
   9.142 +				OptimizeReferences="2"
   9.143 +				EnableCOMDATFolding="2"
   9.144 +				TargetMachine="1"
   9.145 +			/>
   9.146 +			<Tool
   9.147 +				Name="VCALinkTool"
   9.148 +			/>
   9.149 +			<Tool
   9.150 +				Name="VCManifestTool"
   9.151 +			/>
   9.152 +			<Tool
   9.153 +				Name="VCXDCMakeTool"
   9.154 +			/>
   9.155 +			<Tool
   9.156 +				Name="VCBscMakeTool"
   9.157 +			/>
   9.158 +			<Tool
   9.159 +				Name="VCFxCopTool"
   9.160 +			/>
   9.161 +			<Tool
   9.162 +				Name="VCAppVerifierTool"
   9.163 +			/>
   9.164 +			<Tool
   9.165 +				Name="VCWebDeploymentTool"
   9.166 +			/>
   9.167 +			<Tool
   9.168 +				Name="VCPostBuildEventTool"
   9.169 +			/>
   9.170 +		</Configuration>
   9.171 +		<Configuration
   9.172 +			Name="Debug - Metamod|Win32"
   9.173 +			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
   9.174 +			IntermediateDirectory="$(ConfigurationName)"
   9.175 +			ConfigurationType="2"
   9.176 +			CharacterSet="2"
   9.177 +			>
   9.178 +			<Tool
   9.179 +				Name="VCPreBuildEventTool"
   9.180 +			/>
   9.181 +			<Tool
   9.182 +				Name="VCCustomBuildTool"
   9.183 +			/>
   9.184 +			<Tool
   9.185 +				Name="VCXMLDataGeneratorTool"
   9.186 +			/>
   9.187 +			<Tool
   9.188 +				Name="VCWebServiceProxyGeneratorTool"
   9.189 +			/>
   9.190 +			<Tool
   9.191 +				Name="VCMIDLTool"
   9.192 +			/>
   9.193 +			<Tool
   9.194 +				Name="VCCLCompilerTool"
   9.195 +				Optimization="0"
   9.196 +				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SMEXT_CONF_METAMOD"
   9.197 +				MinimalRebuild="true"
   9.198 +				BasicRuntimeChecks="3"
   9.199 +				RuntimeLibrary="3"
   9.200 +				UsePrecompiledHeader="0"
   9.201 +				WarningLevel="3"
   9.202 +				Detect64BitPortabilityProblems="true"
   9.203 +				DebugInformationFormat="4"
   9.204 +			/>
   9.205 +			<Tool
   9.206 +				Name="VCManagedResourceCompilerTool"
   9.207 +			/>
   9.208 +			<Tool
   9.209 +				Name="VCResourceCompilerTool"
   9.210 +			/>
   9.211 +			<Tool
   9.212 +				Name="VCPreLinkEventTool"
   9.213 +			/>
   9.214 +			<Tool
   9.215 +				Name="VCLinkerTool"
   9.216 +				AdditionalDependencies="tier0.lib"
   9.217 +				LinkIncremental="2"
   9.218 +				GenerateDebugInformation="true"
   9.219 +				SubSystem="2"
   9.220 +				TargetMachine="1"
   9.221 +			/>
   9.222 +			<Tool
   9.223 +				Name="VCALinkTool"
   9.224 +			/>
   9.225 +			<Tool
   9.226 +				Name="VCManifestTool"
   9.227 +			/>
   9.228 +			<Tool
   9.229 +				Name="VCXDCMakeTool"
   9.230 +			/>
   9.231 +			<Tool
   9.232 +				Name="VCBscMakeTool"
   9.233 +			/>
   9.234 +			<Tool
   9.235 +				Name="VCFxCopTool"
   9.236 +			/>
   9.237 +			<Tool
   9.238 +				Name="VCAppVerifierTool"
   9.239 +			/>
   9.240 +			<Tool
   9.241 +				Name="VCWebDeploymentTool"
   9.242 +			/>
   9.243 +			<Tool
   9.244 +				Name="VCPostBuildEventTool"
   9.245 +			/>
   9.246 +		</Configuration>
   9.247 +		<Configuration
   9.248 +			Name="Release - Metamod|Win32"
   9.249 +			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
   9.250 +			IntermediateDirectory="$(ConfigurationName)"
   9.251 +			ConfigurationType="2"
   9.252 +			CharacterSet="1"
   9.253 +			WholeProgramOptimization="1"
   9.254 +			>
   9.255 +			<Tool
   9.256 +				Name="VCPreBuildEventTool"
   9.257 +			/>
   9.258 +			<Tool
   9.259 +				Name="VCCustomBuildTool"
   9.260 +			/>
   9.261 +			<Tool
   9.262 +				Name="VCXMLDataGeneratorTool"
   9.263 +			/>
   9.264 +			<Tool
   9.265 +				Name="VCWebServiceProxyGeneratorTool"
   9.266 +			/>
   9.267 +			<Tool
   9.268 +				Name="VCMIDLTool"
   9.269 +			/>
   9.270 +			<Tool
   9.271 +				Name="VCCLCompilerTool"
   9.272 +				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SMEXT_CONF_METAMOD"
   9.273 +				RuntimeLibrary="2"
   9.274 +				UsePrecompiledHeader="0"
   9.275 +				WarningLevel="3"
   9.276 +				Detect64BitPortabilityProblems="true"
   9.277 +				DebugInformationFormat="3"
   9.278 +			/>
   9.279 +			<Tool
   9.280 +				Name="VCManagedResourceCompilerTool"
   9.281 +			/>
   9.282 +			<Tool
   9.283 +				Name="VCResourceCompilerTool"
   9.284 +			/>
   9.285 +			<Tool
   9.286 +				Name="VCPreLinkEventTool"
   9.287 +			/>
   9.288 +			<Tool
   9.289 +				Name="VCLinkerTool"
   9.290 +				LinkIncremental="1"
   9.291 +				GenerateDebugInformation="true"
   9.292 +				SubSystem="2"
   9.293 +				OptimizeReferences="2"
   9.294 +				EnableCOMDATFolding="2"
   9.295 +				TargetMachine="1"
   9.296 +			/>
   9.297 +			<Tool
   9.298 +				Name="VCALinkTool"
   9.299 +			/>
   9.300 +			<Tool
   9.301 +				Name="VCManifestTool"
   9.302 +			/>
   9.303 +			<Tool
   9.304 +				Name="VCXDCMakeTool"
   9.305 +			/>
   9.306 +			<Tool
   9.307 +				Name="VCBscMakeTool"
   9.308 +			/>
   9.309 +			<Tool
   9.310 +				Name="VCFxCopTool"
   9.311 +			/>
   9.312 +			<Tool
   9.313 +				Name="VCAppVerifierTool"
   9.314 +			/>
   9.315 +			<Tool
   9.316 +				Name="VCWebDeploymentTool"
   9.317 +			/>
   9.318 +			<Tool
   9.319 +				Name="VCPostBuildEventTool"
   9.320 +			/>
   9.321 +		</Configuration>
   9.322 +	</Configurations>
   9.323 +	<References>
   9.324 +	</References>
   9.325 +	<Files>
   9.326 +		<Filter
   9.327 +			Name="Source Files"
   9.328 +			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
   9.329 +			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
   9.330 +			>
   9.331 +			<File
   9.332 +				RelativePath=".\extension.cpp"
   9.333 +				>
   9.334 +			</File>
   9.335 +			<File
   9.336 +				RelativePath=".\smsdk_ext.cpp"
   9.337 +				>
   9.338 +			</File>
   9.339 +		</Filter>
   9.340 +		<Filter
   9.341 +			Name="Header Files"
   9.342 +			Filter="h;hpp;hxx;hm;inl;inc;xsd"
   9.343 +			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
   9.344 +			>
   9.345 +			<File
   9.346 +				RelativePath=".\extension.h"
   9.347 +				>
   9.348 +			</File>
   9.349 +			<File
   9.350 +				RelativePath=".\smsdk_config.h"
   9.351 +				>
   9.352 +			</File>
   9.353 +			<File
   9.354 +				RelativePath=".\smsdk_ext.h"
   9.355 +				>
   9.356 +			</File>
   9.357 +		</Filter>
   9.358 +		<Filter
   9.359 +			Name="Resource Files"
   9.360 +			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
   9.361 +			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
   9.362 +			>
   9.363 +		</Filter>
   9.364 +	</Files>
   9.365 +	<Globals>
   9.366 +	</Globals>
   9.367 +</VisualStudioProject>
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/plugins/include/core.inc	Tue Jan 16 19:41:21 2007 +0000
    10.3 @@ -0,0 +1,27 @@
    10.4 +#if defined _core_included
    10.5 + #endinput
    10.6 +#endif
    10.7 +#define _core_included
    10.8 +
    10.9 +#define SOURCEMOD_PLUGINAPI_VERSION		1
   10.10 +struct PlVers
   10.11 +{
   10.12 +	version,
   10.13 +};
   10.14 +
   10.15 +public PlVers:__version = 
   10.16 +{
   10.17 +	version = SOURCEMOD_PLUGINAPI_VERSION,
   10.18 +};
   10.19 +
   10.20 +struct Extension
   10.21 +{
   10.22 +	const String:name[],	/* Short name */
   10.23 +	const String:file[],	/* Default file name */
   10.24 +	bool:autoload,			/* Whether or not to auto-load */
   10.25 +	bool:required,			/* Whether or not to require */
   10.26 +};
   10.27 +
   10.28 +#define AUTOLOAD_EXTENSIONS
   10.29 +#define REQUIRE_EXTENSIONS
   10.30 +
    11.1 --- a/plugins/include/sourcemod.inc	Tue Jan 16 19:34:32 2007 +0000
    11.2 +++ b/plugins/include/sourcemod.inc	Tue Jan 16 19:41:21 2007 +0000
    11.3 @@ -16,10 +16,10 @@
    11.4     const String:url[],			/* Plugin URL */
    11.5  };
    11.6  
    11.7 +#include <core>
    11.8  #include <float>
    11.9  #include <handles>
   11.10  #include <string>
   11.11 -#include <files>
   11.12  
   11.13  /**
   11.14   * Declare this as a struct in your plugin to expose its information.