refactoring of API -- looks nicer and uses namespaces

--HG--
extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/trunk%40482
This commit is contained in:
David Anderson 2007-10-08 18:47:31 +00:00
parent dc59c136df
commit b94553edb0
8 changed files with 867 additions and 791 deletions

View File

@ -25,18 +25,21 @@
* Version: $Id$ * Version: $Id$
*/ */
#ifndef _INCLUDE_PLUGINMANAGER_H #ifndef _INCLUDE_METAMOD_IPLUGINMANAGER_H
#define _INCLUDE_PLUGINMANAGER_H #define _INCLUDE_METAMOD_IPLUGINMANAGER_H
/** /**
* @brief Plugin Manager interface * @brief Plugin Manager interface
* @file IPluginManager.h * @file IPluginManager.h
*/ */
namespace SourceMM
{
/**
* @brief Used to uniquel identify plugins.
*/
typedef int PluginId; typedef int PluginId;
#include "ISmmPlugin.h"
/** /**
* @brief Load sources * @brief Load sources
*/ */
@ -60,9 +63,6 @@ enum Pl_Status
Pl_Running=0, Pl_Running=0,
}; };
typedef int PluginId;
struct factories;
class ISmmPluginManager class ISmmPluginManager
{ {
public: public:
@ -124,7 +124,6 @@ public:
* *
* @param id Id of plugin * @param id Id of plugin
* @param file Pointer to file string by reference * @param file Pointer to file string by reference
* @param list Pointer to factories by reference
* @param status By reference status of plugin * @param status By reference status of plugin
* @param source By reference source of plugin * @param source By reference source of plugin
* @return True on success, false if not found * @return True on success, false if not found
@ -150,5 +149,11 @@ public:
*/ */
virtual bool QueryHandle(PluginId id, void *&handle) =0; virtual bool QueryHandle(PluginId id, void *&handle) =0;
}; };
}
#if !defined METAMOD_NO_AUTO_NAMESPACE
using namespace SourceMM;
#endif
#endif //_INCLUDE_PLUGINMANAGER_H #endif //_INCLUDE_PLUGINMANAGER_H

View File

@ -37,7 +37,8 @@
#include <interface.h> #include <interface.h>
#include <eiface.h> #include <eiface.h>
#include <sourcehook.h> #include <sourcehook.h>
#include "IPluginManager.h" #include <IPluginManager.h>
#include <ISmmPlugin.h>
#if defined __GNUC__ #if defined __GNUC__
#if ((__GNUC__ == 3) && (__GNUC_MINOR__ < 4)) || (__GNUC__ < 3) #if ((__GNUC__ == 3) && (__GNUC_MINOR__ < 4)) || (__GNUC__ < 3)
@ -45,10 +46,6 @@
#endif //version check #endif //version check
#endif //__GNUC__ #endif //__GNUC__
class IMetamodListener;
class ISmmPluginManager;
class ISmmPlugin;
#define MMIFACE_SOURCEHOOK "ISourceHook" /**< ISourceHook Pointer */ #define MMIFACE_SOURCEHOOK "ISourceHook" /**< ISourceHook Pointer */
#define MMIFACE_PLMANAGER "IPluginManager" /**< SourceMM Plugin Functions */ #define MMIFACE_PLMANAGER "IPluginManager" /**< SourceMM Plugin Functions */
#define IFACE_MAXNUM 999 /**< Maximum interface version */ #define IFACE_MAXNUM 999 /**< Maximum interface version */
@ -58,6 +55,11 @@ class ISmmPlugin;
#define SOURCE_ENGINE_EPISODEONE 2 /**< Episode 1 Source Engine (second major SDK) */ #define SOURCE_ENGINE_EPISODEONE 2 /**< Episode 1 Source Engine (second major SDK) */
#define SOURCE_ENGINE_ORANGEBOX 3 /**< Orange Box Source Engine (third major SDK) */ #define SOURCE_ENGINE_ORANGEBOX 3 /**< Orange Box Source Engine (third major SDK) */
namespace SourceMM
{
class ISmmPlugin;
class IMetamodListener;
class ISmmAPI class ISmmAPI
{ {
public: public:
@ -100,7 +102,6 @@ public:
/** /**
* @brief Returns an interface factory for the GameDLL. * @brief Returns an interface factory for the GameDLL.
* *
* @param syn If syn is true, the synthetic wrapper is returned.
* If syn is false, the true function is returned. * If syn is false, the true function is returned.
* @return CreateInterfaceFn function pointer. * @return CreateInterfaceFn function pointer.
*/ */
@ -149,14 +150,15 @@ public:
virtual void ConPrintf(const char *fmt, ...) =0; virtual void ConPrintf(const char *fmt, ...) =0;
/** /**
* @brief Returns the Metamod Version numbers as major version and minor (API) version. * @brief Returns the Metamod Version numbers as major version and
* Changes to minor version are guaranteed to be backwards compatible. * minor (API) version. Changes to minor version are guaranteed to be
* Changes to major version are not. * backwards compatible. Changes to major version are not.
* *
* @param major Filled with the major API version number. * @param major Filled with the major API version number.
* @param minor Filled with the minor API version number. * @param minor Filled with the minor API version number.
* @param plvers Filled with the current plugin API version number. * @param plvers Filled with the current plugin API version number.
* @param plmin Filled with the minimum plugin API version number supported. * @param plmin Filled with the minimum plugin API version number
* supported.
*/ */
virtual void GetApiVersions(int &major, int &minor, int &plvers, int &plmin) =0; virtual void GetApiVersions(int &major, int &minor, int &plvers, int &plmin) =0;
@ -181,24 +183,28 @@ public:
* *
* @param iface String containing interface name * @param iface String containing interface name
* @param ret Optional pointer to store return status * @param ret Optional pointer to store return status
* @param id Optional pointer to store id of plugin that overrode interface, 0 if none * @param id Optional pointer to store id of plugin that
* overrode interface, 0 if none
* @return Returned pointer * @return Returned pointer
*/ */
virtual void *MetaFactory(const char *iface, int *ret, PluginId *id) =0; virtual void *MetaFactory(const char *iface, int *ret, PluginId *id) =0;
/** /**
* @brief Given a base interface name, such as ServerGameDLL or ServerGameDLL003, * @brief Given a base interface name, such as ServerGameDLL or
* reformats the string to increase the number, then returns the new number. * ServerGameDLL003, reformats the string to increase the number, then
* This is the base function to InterfaceSearch() and VInterfaceMatch(). * returns the new number. This is the base function to InterfaceSearch()
* and VInterfaceMatch().
* *
* @param iface Input/output interface name. Must be writable. * @param iface Input/output interface name. Must be writable.
* @param maxlength Maximum length of iface buffer. Must be at least strlen(iface)+4 chars. * @param maxlength Maximum length of iface buffer. Must be at least
* strlen(iface)+4 chars.
* @return The newly incremented iface version number. * @return The newly incremented iface version number.
*/ */
virtual int FormatIface(char iface[], unsigned int maxlength) =0; virtual int FormatIface(char iface[], unsigned int maxlength) =0;
/** /**
* @brief Searches for an interface, eliminating the need to loop through FormatIface(). * @brief Searches for an interface, eliminating the need to loop
* through FormatIface().
* *
* @param fn InterfaceFactory function. * @param fn InterfaceFactory function.
* @param iface Interface string name. * @param iface Interface string name.
@ -206,7 +212,10 @@ public:
* @param ret Last return code from interface factory function. * @param ret Last return code from interface factory function.
* @return Interface pointer, or NULL if not found. * @return Interface pointer, or NULL if not found.
*/ */
virtual void *InterfaceSearch(CreateInterfaceFn fn, const char *iface, int max, int *ret) =0; virtual void *InterfaceSearch(CreateInterfaceFn fn,
const char *iface,
int max,
int *ret) =0;
/** /**
* @brief Returns the base directory of the game/server, equivalent to * @brief Returns the base directory of the game/server, equivalent to
@ -219,18 +228,20 @@ public:
/** /**
* @brief Formats a file path to the local OS. * @brief Formats a file path to the local OS.
* *
* Does not include any base directories. Note that all slashes and black * Does not include any base directories. Note that all slashes and
* slashes are reverted to the local OS's expectancy. * black slashes are reverted to the local OS's expectancy.
* *
* @param buffer Destination buffer to store path. * @param buffer Destination buffer to store path.
* @param len Maximum length of buffer, including null terminator. * @param len Maximum length of buffer, including null
* terminator.
* @param fmt Formatted string. * @param fmt Formatted string.
*/ */
virtual void PathFormat(char *buffer, size_t len, const char *fmt, ...) =0; virtual void PathFormat(char *buffer, size_t len, const char *fmt, ...) =0;
/** /**
* @brief Prints text in the specified client's console. Same as * @brief Prints text in the specified client's console. Same as
* IVEngineServer::ClientPrintf except that it allows for string formatting. * IVEngineServer::ClientPrintf except that it allows for string
* formatting.
* *
* @param client Client edict pointer. * @param client Client edict pointer.
* @param fmt Formatted string to print to the client. * @param fmt Formatted string to print to the client.
@ -240,7 +251,8 @@ public:
/** /**
* @brief Wrapper around InterfaceSearch(). Assumes no maximum. * @brief Wrapper around InterfaceSearch(). Assumes no maximum.
* This is designed to replace the fact that searches only went upwards. * This is designed to replace the fact that searches only went upwards.
* The "V" is intended to convey that this is for Valve formatted interface strings. * The "V" is intended to convey that this is for Valve formatted
* interface strings.
* *
* @param fn Interface factory function. * @param fn Interface factory function.
* @param iface Interface string. * @param iface Interface string.
@ -253,7 +265,9 @@ public:
* minimum value to search from. * minimum value to search from.
* @return Interface pointer, or NULL if not found. * @return Interface pointer, or NULL if not found.
*/ */
virtual void *VInterfaceMatch(CreateInterfaceFn fn, const char *iface, int min=-1) =0; virtual void *VInterfaceMatch(CreateInterfaceFn fn,
const char *iface,
int min=-1) =0;
/** /**
* @brief Tells SourceMM to add VSP hooking capability to plugins. * @brief Tells SourceMM to add VSP hooking capability to plugins.
@ -308,8 +322,8 @@ public:
* versions of the Source engine, such as The Ship. * versions of the Source engine, such as The Ship.
* *
* @return Highest interface version of IServerPluginCallbacks. * @return Highest interface version of IServerPluginCallbacks.
* Returns 0 if SourceMM's VSP listener isn't currently * Returns 0 if SourceMM's VSP listener isn't
* enabled. * currently enabled.
*/ */
virtual int GetVSPVersion() =0; virtual int GetVSPVersion() =0;
@ -344,8 +358,8 @@ public:
* @param maxlength Maximum length of the buffer. * @param maxlength Maximum length of the buffer.
* @param format Format specifiers. * @param format Format specifiers.
* @param ... Format arguments. * @param ... Format arguments.
* @return Number of bytes actually written, not including the * @return Number of bytes actually written, not including
* null terminator. * the null terminator.
*/ */
virtual size_t Format(char *buffer, virtual size_t Format(char *buffer,
size_t maxlength, size_t maxlength,
@ -368,7 +382,11 @@ public:
const char *format, const char *format,
va_list ap) =0; va_list ap) =0;
}; };
}
#if !defined METAMOD_NO_AUTO_NAMESPACE
using namespace SourceMM;
#endif
/** /**
* Version History * Version History

View File

@ -35,55 +35,92 @@
#include <interface.h> #include <interface.h>
#include <sourcehook.h> #include <sourcehook.h>
#include "ISmmAPI.h" #include <IPluginManager.h>
#include <ISmmAPI.h>
#define PLAPI_VERSION 13 #define METAMOD_PLAPI_VERSION 13 /**< Version of this header file */
#define PLAPI_NAME "ISmmPlugin" #define METAMOD_PLAPI_NAME "ISmmPlugin" /**< Name of the plugin interface */
namespace SourceMM
{
class ISmmAPI; class ISmmAPI;
/**
* @brief Callbacks that a plugin must expose.
*/
class ISmmPlugin class ISmmPlugin
{ {
public: public:
virtual int GetApiVersion() { return PLAPI_VERSION; } /**
virtual ~ISmmPlugin() { } * @brief Called to request the plugin's API version.
*
* This is the first callback invoked, and always remains at the top
* of the virtual table.
*
* @return Plugin API version.
*/
virtual int GetApiVersion()
{
return METAMOD_PLAPI_VERSION;
}
/**
* @brief Virtual destructor so GCC doesn't complain.
*/
virtual ~ISmmPlugin()
{
}
public: public:
/** /**
* @brief Called on plugin load. * @brief Called on plugin load.
* *
* NOTE - As of API 7, this is called as DLLInit() executes - after the parameters are known, but before * This is called as DLLInit() executes - after the parameters are
* the original GameDLL function is called. Therefore, you cannot hook it, but you don't need to - * known, but before the original GameDLL function is called.
* Load() is basically your hook. * Therefore, you cannot hook it, but you don't need to - Load() is
* NOTE - As of API 7, you can override factories before the engine and gamedll exchange them. * basically your hook. You can override factories before the engine
* However, take care to note that if your plugin is unloaded, and the gamedll/engine have cached * and gamedll exchange them. However, take care to note that if your
* an interface you've passed, something will definitely crash. Be careful. * plugin is unloaded, and the gamedll/engine have cached an interface
* you've passed, something will definitely crash. Be careful.
* *
* @param id Internal id of plugin. Saved globally by PLUGIN_SAVEVARS() * @param id Internal id of plugin. Saved globally by PLUGIN_SAVEVARS()
* @param ismm External API for SourceMM. Saved globally by PLUGIN_SAVEVARS() * @param ismm External API for SourceMM. Saved globally by PLUGIN_SAVEVARS()
* @param list Contains a list of factories. Hook a factory call by setting one equal to your own function.
* @param late Set to true if your plugin was loaded late (not at server load).
* @param error Error message buffer * @param error Error message buffer
* @param maxlen Size of error message buffer * @param maxlength Size of error message buffer
* @param late Set to true if your plugin was loaded late (not at server load).
* @return True if successful, return false to reject the load. * @return True if successful, return false to reject the load.
*/ */
virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late) =0; virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late) =0;
/**
* @brief Called when all plugins have been loaded.
*
* This is called after DLLInit(), and thus the mod has been mostly initialized.
* It is also safe to assume that all other (automatically loaded) plugins are now
* ready to start interacting, because they are all loaded.
*/
virtual void AllPluginsLoaded()
{
}
/** /**
* @brief Called when your plugin is "queried". * @brief Called when your plugin is "queried".
* *
* This is useful for rejecting a loaded state. For example, if your plugin wants * This is useful for rejecting a loaded state. For example, if your
* to stop operating, it can simply return false and copy an error message. This * plugin wants to stop operating, it can simply return false and copy
* will notify other plugins or MM:S of something bad that happened. NOTE - MM:S * an error message. This will notify other plugins or MM:S of
* will not cache the return state, so if you return false, your plugin will not * something bad that happened. MM:S will not cache the return state,
* actually be paused or unloaded. This callback will be called when: * so if you return false, your plugin will not actually be paused or
* unloaded. This callback will be called when:
* - Another plugin requests it * - Another plugin requests it
* - Someone types "meta list", it will show up as "REFUSED" * - Someone types "meta list", it will show up as "REFUSED"
* - When Metamod need to re-check the plugin's status * - When Metamod need to re-check the plugin's status
* - If the plugin does something like overload a factory, Metamod will make sure the Query() returns true * - If the plugin does something like overload a factory, Metamod
* before calling it. * will make sure the Query() returns true before calling it.
* Also note that this query will only override Metamod when the plugin is running and not paused. * Also note that this query will only override Metamod when the
* plugin is running and not paused.
* *
* @param error Buffer for error message. This can be NULL! * @param error Buffer for error message, or NULL if none.
* @param maxlen Maximum length of error buffer. * @param maxlen Maximum length of error buffer.
* @return Status code - true for okay, false for badness. * @return Status code - true for okay, false for badness.
*/ */
@ -93,8 +130,8 @@ public:
} }
/** /**
* @brief Called on plugin unload. You can return false if you know your plugin * @brief Called on plugin unload. You can return false if you know
* is not capable of restoring critical states it modifies. * your plugin is not capable of restoring critical states it modifies.
* *
* @param error Error message buffer * @param error Error message buffer
* @param maxlen Size of error message buffer * @param maxlen Size of error message buffer
@ -105,7 +142,8 @@ public:
return true; return true;
} }
/** @brief Called on plugin pause. /**
* @brief Called on plugin pause.
* *
* @param error Error message buffer * @param error Error message buffer
* @param maxlen Size of error message buffer * @param maxlen Size of error message buffer
@ -116,7 +154,8 @@ public:
return true; return true;
} }
/** @brief Called on plugin unpause. /**
* @brief Called on plugin unpause.
* *
* @param error Error message buffer * @param error Error message buffer
* @param maxlen Size of error message buffer * @param maxlen Size of error message buffer
@ -150,28 +189,13 @@ public:
/** @brief Return author as string */ /** @brief Return author as string */
virtual const char *GetLogTag() =0; virtual const char *GetLogTag() =0;
public:
/**
* @brief Called when all plugins have been loaded.
*
* This is called after DLLInit(), and thus the mod has been mostly initialized.
* It is also safe to assume that all other (automatically loaded) plugins are now
* ready to start interacting, because they are all loaded.
*/
virtual void AllPluginsLoaded()
{
}
}; };
/** /**
* @brief Added in 1.1 so plugins could listen to specific events * @brief Various events that Metamod can fire.
*/ */
class IMetamodListener class IMetamodListener
{ {
public:
virtual ~IMetamodListener()
{
}
public: public:
/** /**
* @brief Called when a plugin is loaded. * @brief Called when a plugin is loaded.
@ -210,35 +234,47 @@ public:
} }
/** /**
* @brief Called when the level is loaded (after GameInit, before ServerActivate). * @brief Called when the level is loaded (after GameInit, before
* ServerActivate).
* *
* To override this, hook IServerGameDLL::LevelInit(). * To override this, hook IServerGameDLL::LevelInit().
* *
* @param pMapName Name of the map. * @param pMapName Name of the map.
* @param pMapEntities Lump string of the map entities, in KeyValue format. * @param pMapEntities Lump string of the map entities, in KeyValues
* format.
* @param pOldLevel Unknown. * @param pOldLevel Unknown.
* @param pLandmarkName Unknown. * @param pLandmarkName Unknown.
* @param loadGame Unknown. * @param loadGame Unknown.
* @param background Unknown. * @param background Unknown.
*/ */
virtual void OnLevelInit(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background) { } virtual void OnLevelInit(char const *pMapName,
char const *pMapEntities,
char const *pOldLevel,
char const *pLandmarkName,
bool loadGame,
bool background)
{
}
/** /**
* @brief Called when the level is shut down. May be called more than once. * @brief Called when the level is shut down. May be called more than
* once.
*/ */
virtual void OnLevelShutdown() virtual void OnLevelShutdown()
{ {
} }
/** /**
* @brief Called when engineFactory() is used through Metamod:Source's wrapper. * @brief Called when engineFactory() is used through Metamod:Source's
* This can be used to provide interfaces to other plugins or the GameDLL. * wrapper. This can be used to provide interfaces to other plugins or
* the GameDLL.
* *
* If ret is passed, you should fill it with IFACE_OK or IFACE_FAILED. * If ret is passed, you should fill it with IFACE_OK or IFACE_FAILED.
* *
* @param iface Interface string. * @param iface Interface string.
* @param ret Optional pointer to store return code. * @param ret Optional pointer to store return code.
* @return Generic pointer to the interface, or NULL if not found. * @return Generic pointer to the interface, or NULL if
* not found.
*/ */
virtual void *OnEngineQuery(const char *iface, int *ret) virtual void *OnEngineQuery(const char *iface, int *ret)
{ {
@ -251,14 +287,16 @@ public:
} }
/** /**
* @brief Called when the physics factory is used through Metamod:Source's wrapper. * @brief Called when the physics factory is used through
* This can be used to provide interfaces to other plugins. * Metamod:Source's wrapper. This can be used to provide interfaces to
* other plugins.
* *
* If ret is passed, you should fill it with IFACE_OK or IFACE_FAILED. * If ret is passed, you should fill it with IFACE_OK or IFACE_FAILED.
* *
* @param iface Interface string. * @param iface Interface string.
* @param ret Optional pointer to store return code. * @param ret Optional pointer to store return code.
* @return Generic pointer to the interface, or NULL if not found. * @return Generic pointer to the interface, or NULL if
* not found.
*/ */
virtual void *OnPhysicsQuery(const char *iface, int *ret) virtual void *OnPhysicsQuery(const char *iface, int *ret)
{ {
@ -271,14 +309,16 @@ public:
} }
/** /**
* @brief Called when the filesystem factory is used through Metamod:Source's wrapper. * @brief Called when the filesystem factory is used through
* This can be used to provide interfaces to other plugins. * Metamod:Source's wrapper. This can be used to provide interfaces to
* other plugins.
* *
* If ret is passed, you should fill it with IFACE_OK or IFACE_FAILED. * If ret is passed, you should fill it with IFACE_OK or IFACE_FAILED.
* *
* @param iface Interface string. * @param iface Interface string.
* @param ret Optional pointer to store return code. * @param ret Optional pointer to store return code.
* @return Generic pointer to the interface, or NULL if not found. * @return Generic pointer to the interface, or NULL if not
* found.
*/ */
virtual void *OnFileSystemQuery(const char *iface, int *ret) virtual void *OnFileSystemQuery(const char *iface, int *ret)
{ {
@ -291,14 +331,16 @@ public:
} }
/** /**
* @brief Called when the server DLL's factory is used through Metamod:Source's wrapper. * @brief Called when the server DLL's factory is used through
* This can be used to provide interfaces to other plugins. * Metamod:Source's wrapper. This can be used to provide interfaces to
* other plugins.
* *
* If ret is passed, you should fill it with IFACE_OK or IFACE_FAILED. * If ret is passed, you should fill it with IFACE_OK or IFACE_FAILED.
* *
* @param iface Interface string. * @param iface Interface string.
* @param ret Optional pointer to store return code. * @param ret Optional pointer to store return code.
* @return Generic pointer to the interface, or NULL if not found. * @return Generic pointer to the interface, or NULL if not
* found.
*/ */
virtual void *OnGameDLLQuery(const char *iface, int *ret) virtual void *OnGameDLLQuery(const char *iface, int *ret)
{ {
@ -318,7 +360,8 @@ public:
* *
* @param iface Interface string. * @param iface Interface string.
* @param ret Optional pointer to store return code. * @param ret Optional pointer to store return code.
* @return Generic pointer to the interface, or NULL if not found. * @return Generic pointer to the interface, or NULL if not
* found.
*/ */
virtual void *OnMetamodQuery(const char *iface, int *ret) virtual void *OnMetamodQuery(const char *iface, int *ret)
{ {
@ -331,35 +374,47 @@ public:
} }
/** /**
* @brief Called when Metamod:Source acquires a valid IServerPluginCallbacks * @brief Called when Metamod:Source acquires a valid
* pointer to be used for hooking by plugins. * IServerPluginCallbacks pointer to be used for hooking by plugins.
* *
* This will only be called after a call to ISmmAPI::EnableVSPListener(). * This will only be called after a call to ISmmAPI::EnableVSPListener().
* If called before GameInit, this callback will occur before LevelInit. * If called before GameInit, this callback will occur before LevelInit.
* Otherwise, it will be called on the first call after that. * Otherwise, it will be called on the first call after that.
* *
* This callback is provided to all plugins regardless of which (or how many) * This callback is provided to all plugins regardless of which (or how
* called EnableVSPListener(), but only if at least one did in fact enable it. * many) called EnableVSPListener(), but only if at least one did in
* fact enable it, and only once for all plugins. That is, a late
* loading plugin should use ISmmAPI::GetVSPInfo() before relying on
* this callback.
* *
* This callback is only available for plugins using API v1:5 (Metamod:Source 1.4+). * @param iface Interface pointer. If NULL, then the VSP
* If a plugin loads lately, it may still call EnableVSPListener(). * listening construct failed to initialize and
* * is not available.
* @param iface Interface pointer. If NULL, then the VSP listening construct
* failed to initialize and is not available.
*/ */
virtual void OnVSPListening(IServerPluginCallbacks *iface) { } virtual void OnVSPListening(IServerPluginCallbacks *iface)
{
}
/** /**
* @brief Called when Metamod:Source is about to remove a concommand or convar. * @brief Called when Metamod:Source is about to remove a concommand or
* This can also be called if ISmmAPI::UnregisterConCmdBase is used by a plugin. * convar. This can also be called if ISmmAPI::UnregisterConCmdBase is
* used by a plugin.
* *
* @param id Id of the plugin that created the concommand or convar. * @param id Id of the plugin that created the concommand or
* @param pCommand Pointer to concommand or convar that is being removed. * convar.
* @param pCommand Pointer to concommand or convar that is being
* removed.
*/ */
virtual void OnUnlinkConCommandBase(PluginId id, ConCommandBase *pCommand) virtual void OnUnlinkConCommandBase(PluginId id, ConCommandBase *pCommand)
{ {
} }
}; };
}
#if !defined METAMOD_NO_AUTO_NAMESPACE
using namespace SourceMM;
#endif
#define PL_EXPOSURE CreateInterface #define PL_EXPOSURE CreateInterface
#define PL_EXPOSURE_C "CreateInterface" #define PL_EXPOSURE_C "CreateInterface"
@ -370,7 +425,7 @@ public:
PluginId g_PLID = (PluginId)0; \ PluginId g_PLID = (PluginId)0; \
SourceHook::ISourceHook *g_SHPtr = NULL; \ SourceHook::ISourceHook *g_SHPtr = NULL; \
SMM_API void *PL_EXPOSURE(const char *name, int *code) { \ SMM_API void *PL_EXPOSURE(const char *name, int *code) { \
if (name && !strcmp(name, PLAPI_NAME)) { \ if (name && !strcmp(name, METAMOD_PLAPI_NAME)) { \
return static_cast<void *>(&var); \ return static_cast<void *>(&var); \
} \ } \
return NULL; \ return NULL; \

View File

@ -191,7 +191,7 @@ void InitMainStates()
SMM_API void *CreateInterface(const char *iface, int *ret) SMM_API void *CreateInterface(const char *iface, int *ret)
{ {
/* Prevent loading of self as a SourceMM plugin or Valve server plugin :x */ /* Prevent loading of self as a SourceMM plugin or Valve server plugin :x */
if (strcmp(iface, PLAPI_NAME) == 0) if (strcmp(iface, METAMOD_PLAPI_NAME) == 0)
{ {
provider->DisplayWarning("Do not try loading Metamod:Source as a plugin.\n"); provider->DisplayWarning("Do not try loading Metamod:Source as a plugin.\n");
@ -878,7 +878,7 @@ void MetamodSource::GetApiVersions(int &major, int &minor, int &plvers, int &plm
{ {
major = SM_VERS_API_MAJOR; major = SM_VERS_API_MAJOR;
minor = SM_VERS_API_MINOR; minor = SM_VERS_API_MINOR;
plvers = PLAPI_VERSION; plvers = METAMOD_PLAPI_VERSION;
plmin = PLAPI_MIN_VERSION; plmin = PLAPI_MIN_VERSION;
} }

View File

@ -38,7 +38,7 @@
#include <eiface.h> #include <eiface.h>
#include <sourcehook/sourcehook_impl.h> #include <sourcehook/sourcehook_impl.h>
#include <sourcehook/sourcehook.h> #include <sourcehook/sourcehook.h>
#include "ISmmAPI.h" #include <ISmmPlugin.h>
#include "metamod_provider.h" #include "metamod_provider.h"
#include "svn_version.h" #include "svn_version.h"

View File

@ -72,7 +72,7 @@ bool Command_Meta(IMetamodSourceCommandInfo *info)
{ {
CONMSG("Metamod:Source version %s\n", SOURCEMM_VERSION); CONMSG("Metamod:Source version %s\n", SOURCEMM_VERSION);
CONMSG("Compiled on: %s\n", SOURCEMM_DATE); CONMSG("Compiled on: %s\n", SOURCEMM_DATE);
CONMSG("Plugin interface version: %d:%d\n", PLAPI_VERSION, PLAPI_MIN_VERSION); CONMSG("Plugin interface version: %d:%d\n", METAMOD_PLAPI_VERSION, PLAPI_MIN_VERSION);
CONMSG("SourceHook version: %d:%d\n", g_SHPtr->GetIfaceVersion(), g_SHPtr->GetImplVersion()); CONMSG("SourceHook version: %d:%d\n", g_SHPtr->GetIfaceVersion(), g_SHPtr->GetImplVersion());
CONMSG("http://www.sourcemm.net/\n"); CONMSG("http://www.sourcemm.net/\n");
@ -679,7 +679,7 @@ bool Command_ClientMeta(edict_t *client, IMetamodSourceCommandInfo *info)
{ {
CLIENT_CONMSG(client, "Metamod:Source version %s\n", SOURCEMM_VERSION); CLIENT_CONMSG(client, "Metamod:Source version %s\n", SOURCEMM_VERSION);
CLIENT_CONMSG(client, "Compiled on: %s\n", SOURCEMM_DATE); CLIENT_CONMSG(client, "Compiled on: %s\n", SOURCEMM_DATE);
CLIENT_CONMSG(client, "Plugin interface version: %d:%d\n", PLAPI_VERSION, PLAPI_MIN_VERSION); CLIENT_CONMSG(client, "Plugin interface version: %d:%d\n", METAMOD_PLAPI_VERSION, PLAPI_MIN_VERSION);
CLIENT_CONMSG(client, "SourceHook version: %d:%d\n", g_SHPtr->GetIfaceVersion(), g_SHPtr->GetImplVersion()); CLIENT_CONMSG(client, "SourceHook version: %d:%d\n", g_SHPtr->GetIfaceVersion(), g_SHPtr->GetImplVersion());
CLIENT_CONMSG(client, "http://www.sourcemm.net/\n"); CLIENT_CONMSG(client, "http://www.sourcemm.net/\n");

View File

@ -95,12 +95,12 @@ const char *CPluginManager::LookupAlias(const char *alias)
return NULL; return NULL;
} }
SourceHook::List<SourceMM::CNameAlias *>::iterator CPluginManager::_alias_begin() SourceHook::List<CNameAlias *>::iterator CPluginManager::_alias_begin()
{ {
return m_Aliases.begin(); return m_Aliases.begin();
} }
SourceHook::List<SourceMM::CNameAlias *>::iterator CPluginManager::_alias_end() SourceHook::List<CNameAlias *>::iterator CPluginManager::_alias_end()
{ {
return m_Aliases.end(); return m_Aliases.end();
} }
@ -426,7 +426,7 @@ CPluginManager::CPlugin *CPluginManager::_Load(const char *file, PluginId source
} }
else else
{ {
pl->m_API = static_cast<ISmmPlugin *>((pfn)(PLAPI_NAME, NULL)); pl->m_API = static_cast<ISmmPlugin *>((pfn)(METAMOD_PLAPI_NAME, NULL));
if (!pl->m_API) if (!pl->m_API)
{ {
if (error) if (error)
@ -446,11 +446,11 @@ CPluginManager::CPlugin *CPluginManager::_Load(const char *file, PluginId source
} }
pl->m_Status = Pl_Error; pl->m_Status = Pl_Error;
} }
else if (api > PLAPI_VERSION) else if (api > METAMOD_PLAPI_VERSION)
{ {
if (error) if (error)
{ {
UTIL_Format(error, maxlen, "Plugin API %d is newer than internal version (%d)", api, PLAPI_VERSION); UTIL_Format(error, maxlen, "Plugin API %d is newer than internal version (%d)", api, METAMOD_PLAPI_VERSION);
} }
pl->m_Status = Pl_Error; pl->m_Status = Pl_Error;
} }

View File

@ -35,6 +35,7 @@
#include <interface.h> #include <interface.h>
#include <eiface.h> #include <eiface.h>
#include <convar.h>
#include <sh_list.h> #include <sh_list.h>
#include <sh_string.h> #include <sh_string.h>
#include "IPluginManager.h" #include "IPluginManager.h"
@ -62,8 +63,6 @@
#define PLAPI_MIN_VERSION 13 #define PLAPI_MIN_VERSION 13
namespace SourceMM
{
struct CNameAlias struct CNameAlias
{ {
SourceHook::String alias; SourceHook::String alias;
@ -139,12 +138,12 @@ namespace SourceMM
//get alias info //get alias info
const char *LookupAlias(const char *alias); const char *LookupAlias(const char *alias);
SourceHook::List<SourceMM::CNameAlias *>::iterator _alias_begin(); SourceHook::List<CNameAlias *>::iterator _alias_begin();
SourceHook::List<SourceMM::CNameAlias *>::iterator _alias_end(); SourceHook::List<CNameAlias *>::iterator _alias_end();
//Internal iterators //Internal iterators
SourceHook::List<SourceMM::CPluginManager::CPlugin *>::iterator _begin(); SourceHook::List<CPluginManager::CPlugin *>::iterator _begin();
SourceHook::List<SourceMM::CPluginManager::CPlugin *>::iterator _end(); SourceHook::List<CPluginManager::CPlugin *>::iterator _end();
private: private:
//These are identical internal functions for the wrappers above. //These are identical internal functions for the wrappers above.
CPlugin *_Load(const char *file, PluginId source, char *error, size_t maxlen); CPlugin *_Load(const char *file, PluginId source, char *error, size_t maxlen);
@ -158,12 +157,11 @@ namespace SourceMM
SourceHook::List<CNameAlias *> m_Aliases; SourceHook::List<CNameAlias *> m_Aliases;
bool m_AllLoaded; bool m_AllLoaded;
}; };
};
typedef SourceHook::List<SourceMM::CPluginManager::CPlugin *>::iterator PluginIter; typedef SourceHook::List<CPluginManager::CPlugin *>::iterator PluginIter;
/** @brief Singleton for plugin manager */ /** @brief Singleton for plugin manager */
extern SourceMM::CPluginManager g_PluginMngr; extern CPluginManager g_PluginMngr;
#endif //_INCLUDE_CPLUGIN_H #endif //_INCLUDE_CPLUGIN_H