- renamed global extension variables to be lowercase and simpler (old ones are still there so the SDK is still upgradeable)

- interface fetching is now configurable

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40865
This commit is contained in:
David Anderson 2007-05-29 16:42:47 +00:00
parent f48263b9d2
commit e942b77c48
3 changed files with 65 additions and 8 deletions

View File

@ -45,4 +45,10 @@
*/ */
//#define SMEXT_CONF_METAMOD //#define SMEXT_CONF_METAMOD
/** Enable interfaces you want to use here by uncommenting lines */
//#define SMEXT_ENABLE_FORWARDSYS
//#define SMEXT_ENABLE_HANDLESYS
//#define SMEXT_ENABLE_PLAYERHELPERS
//#define SMEXT_ENABLE_DBMANAGER
#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_ #endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_

View File

@ -25,11 +25,26 @@
* @brief Contains wrappers for making Extensions easier to write. * @brief Contains wrappers for making Extensions easier to write.
*/ */
IShareSys *g_pShareSys = NULL; /**< Share system */
IExtension *myself = NULL; /**< Ourself */ IExtension *myself = NULL; /**< Ourself */
IHandleSys *g_pHandleSys = NULL; /**< Handle system */ IShareSys *g_pShareSys = NULL; /**< Share system */
IShareSys *sharesys = NULL; /**< Share system */
ISourceMod *g_pSM = NULL; /**< SourceMod helpers */ ISourceMod *g_pSM = NULL; /**< SourceMod helpers */
ISourceMod *smutils = NULL; /**< SourceMod helpers */
#if defined SMEXT_ENABLE_FORWARDSYS
IForwardManager *g_pForwards = NULL; /**< Forward system */ IForwardManager *g_pForwards = NULL; /**< Forward system */
IForwardManager *forwards = NULL; /**< Forward system */
#endif
#if defined SMEXT_ENABLE_HANDLESYS
IHandleSys *g_pHandleSys = NULL; /**< Handle system */
IHandleSys *handlesys = NULL; /**< Handle system */
#endif
#if defined SMEXT_ENABLE_PLAYERHELPERS
IPlayerHelpers *playerhelpers = NULL; /**< Player helpers */
#endif //SMEXT_ENABLE_PLAYERHELPERS
#if defined SMEXT_ENABLE_DBMANAGER
IDBManager *dbi = NULL; /**< DB Manager */
#endif //SMEXT_ENABLE_DBMANAGER
/** Exports the main interface */ /** Exports the main interface */
PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI() PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
@ -48,7 +63,7 @@ SDKExtension::SDKExtension()
bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late) bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late)
{ {
g_pShareSys = sys; g_pShareSys = sharesys = sys;
myself = me; myself = me;
#if defined SMEXT_CONF_METAMOD #if defined SMEXT_CONF_METAMOD
@ -63,10 +78,22 @@ bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error,
return false; return false;
} }
#endif #endif
SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys);
SM_GET_IFACE(SOURCEMOD, g_pSM); SM_GET_IFACE(SOURCEMOD, g_pSM);
smutils = g_pSM;
#if defined SMEXT_ENABLE_HANDLESYS
SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys);
handlesys = g_pHandleSys;
#endif
#if defined SMEXT_ENABLE_FORWARDSYS
SM_GET_IFACE(FORWARDMANAGER, g_pForwards); SM_GET_IFACE(FORWARDMANAGER, g_pForwards);
forwards = g_pForwards;
#endif
#if defined SMEXT_ENABLE_PLAYERHELPERS
SM_GET_IFACE(PLAYERMANAGER, playerhelpers);
#endif
#if defined SMEXT_ENABLE_DBMANAGER
SM_GET_IFACE(DBI, dbi);
#endif
if (SDK_OnLoad(error, maxlength, late)) if (SDK_OnLoad(error, maxlength, late))
{ {

View File

@ -30,7 +30,15 @@
#include <sp_vm_api.h> #include <sp_vm_api.h>
#include <sm_platform.h> #include <sm_platform.h>
#include <ISourceMod.h> #include <ISourceMod.h>
#if defined SMEXT_ENABLE_FORWARDSYS
#include <IForwardSys.h> #include <IForwardSys.h>
#endif //SMEXT_ENABLE_FORWARDSYS
#if defined SMEXT_ENABLE_PLAYERHELPERS
#include <IPlayerHelpers.h>
#endif //SMEXT_ENABLE_PlAYERHELPERS
#if defined SMEXT_ENABLE_DBMANAGER
#include <IDBDriver.h>
#endif //SMEXT_ENABLE_DBMANAGER
#if defined SMEXT_CONF_METAMOD #if defined SMEXT_CONF_METAMOD
#include <ISmmPlugin.h> #include <ISmmPlugin.h>
@ -171,12 +179,28 @@ private:
}; };
extern SDKExtension *g_pExtensionIface; extern SDKExtension *g_pExtensionIface;
extern IExtension *myself;
extern IShareSys *g_pShareSys; extern IShareSys *g_pShareSys;
extern IExtension *myself; extern IShareSys *sharesys; /* Note: Newer name */
extern IHandleSys *g_pHandleSys;
extern ISourceMod *g_pSM; extern ISourceMod *g_pSM;
extern ISourceMod *smutils; /* Note: Newer name */
/* Optional interfaces are below */
#if defined SMEXT_ENABLE_FORWARDSYS
extern IForwardManager *g_pForwards; extern IForwardManager *g_pForwards;
extern IForwardManager *forwards; /* Note: Newer name */
#endif //SMEXT_ENABLE_FORWARDSYS
#if defined SMEXT_ENABLE_HANDLESYS
extern IHandleSys *g_pHandleSys;
extern IHandleSys *handlesys; /* Note: Newer name */
#endif //SMEXT_ENABLE_HANDLESYS
#if defined SMEXT_ENABLE_PLAYERHELPERS
extern IPlayerHelpers *playerhelpers;
#endif //SMEXT_ENABLE_PLAYERHELPERS
#if defined SMEXT_ENABLE_DBMANAGER
extern IDBManager *dbi;
#endif //SMEXT_ENABLE_DBMANAGER
#if defined SMEXT_CONF_METAMOD #if defined SMEXT_CONF_METAMOD
PLUGIN_GLOBALVARS(); PLUGIN_GLOBALVARS();
@ -192,7 +216,7 @@ extern IServerGameDLL *gamedll;
{ \ { \
if (error) \ if (error) \
{ \ { \
snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \ snprintf(error, maxlength, "Could not find interface: %s (version: %d)", SMINTERFACE_##prefix##_NAME, SMINTERFACE_##prefix##_VERSION); \
return false; \ return false; \
} \ } \
} }