added more "remote extension" stuff

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401661
This commit is contained in:
David Anderson 2007-10-30 20:43:59 +00:00
parent 11c5ce6996
commit e425558f3f
4 changed files with 44 additions and 1 deletions

View File

@ -33,6 +33,7 @@
#include "sourcemm_api.h"
#include "sm_version.h"
#include "Logger.h"
#include "ExtensionSys.h"
#include "concmd_cleaner.h"
#include "compat_wrappers.h"
@ -219,3 +220,21 @@ void SourceMod_Core::OnPluginUnload(PluginId id)
}
#endif
void *SourceMod_Core::OnMetamodQuery(const char *iface, int *ret)
{
void *ptr = NULL;
if (strcmp(iface, SOURCEMOD_INTERFACE_EXTENSIONS) == 0)
{
ptr = (IExtensionManager *)&g_Extensions;
}
if (ret != NULL)
{
*ret = (ptr == NULL) ? IFACE_FAILED : IFACE_OK;
}
return NULL;
}

View File

@ -79,6 +79,7 @@ public:
#else
void OnPluginUnload(PluginId id);
#endif
void *OnMetamodQuery(const char *iface, int *ret);
};
extern SourceMod_Core g_SourceMod_Core;
@ -105,3 +106,4 @@ extern int vsp_version;
PLUGIN_GLOBALVARS();
#endif //_INCLUDE_SOURCEMOD_MM_API_H_

View File

@ -406,6 +406,9 @@ void SourceModBase::DoGlobalPluginLoads()
/* Load any auto extensions */
g_Extensions.TryAutoload();
/* Fire the extensions ready message */
g_SMAPI->MetaFactory(SOURCEMOD_NOTICE_EXTENSIONS, NULL, NULL);
/* Load any game extension */
const char *game_ext;
if ((game_ext = g_pGameConf->GetKeyValue("GameExtension")) != NULL)

View File

@ -288,6 +288,24 @@ namespace SourceMod
virtual const char *GetExtensionDateString() =0;
};
/**
* @brief Returned via OnMetamodQuery() to get an IExtensionManager pointer.
*/
#define SOURCEMOD_INTERFACE_EXTENSIONS "SM_ExtensionManager"
/**
* @brief Fired through OnMetamodQuery() to notify plugins that SourceMod is
* loaded.
*
* Plugins should not return an interface pointer or IFACE_OK, instead,
* they should attach as needed by searching for SOURCEMOD_INTERFACE_EXTENSIONS.
*
* This may be fired more than once; if already attached, an extension should
* not attempt to re-attach. The purpose of this is to notify Metamod:Source
* plugins which load after SourceMod loads.
*/
#define SOURCEMOD_NOTICE_EXTENSIONS "SM_ExtensionsAttachable"
#define SMINTERFACE_EXTENSIONMANAGER_NAME "IExtensionManager"
#define SMINTERFACE_EXTENSIONMANAGER_VERSION 2
@ -389,7 +407,8 @@ namespace SourceMod
}
#define SM_FIND_IFACE(prefix, variable) \
sharesys->RequestInterface(SM_IFACEPAIR(prefix), myself, (SMInterface **)&variable));
sharesys->RequestInterface(SM_IFACEPAIR(prefix), myself, (SMInterface **)&variable);
}
#endif //_INCLUDE_SOURCEMOD_MODULE_INTERFACE_H_
`