- renamed global extension variables to be lowercase and simpler (old ones are still there so the SDK is still upgradeable)
- 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
1.1 --- a/public/sample_ext/sdk/smsdk_config.h Tue May 29 08:32:12 2007 +0000
1.2 +++ b/public/sample_ext/sdk/smsdk_config.h Tue May 29 16:42:47 2007 +0000
1.3 @@ -45,4 +45,10 @@
1.4 */
1.5 //#define SMEXT_CONF_METAMOD
1.6
1.7 +/** Enable interfaces you want to use here by uncommenting lines */
1.8 +//#define SMEXT_ENABLE_FORWARDSYS
1.9 +//#define SMEXT_ENABLE_HANDLESYS
1.10 +//#define SMEXT_ENABLE_PLAYERHELPERS
1.11 +//#define SMEXT_ENABLE_DBMANAGER
1.12 +
1.13 #endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
2.1 --- a/public/sample_ext/sdk/smsdk_ext.cpp Tue May 29 08:32:12 2007 +0000
2.2 +++ b/public/sample_ext/sdk/smsdk_ext.cpp Tue May 29 16:42:47 2007 +0000
2.3 @@ -25,11 +25,26 @@
2.4 * @brief Contains wrappers for making Extensions easier to write.
2.5 */
2.6
2.7 +IExtension *myself = NULL; /**< Ourself */
2.8 IShareSys *g_pShareSys = NULL; /**< Share system */
2.9 -IExtension *myself = NULL; /**< Ourself */
2.10 +IShareSys *sharesys = NULL; /**< Share system */
2.11 +ISourceMod *g_pSM = NULL; /**< SourceMod helpers */
2.12 +ISourceMod *smutils = NULL; /**< SourceMod helpers */
2.13 +
2.14 +#if defined SMEXT_ENABLE_FORWARDSYS
2.15 +IForwardManager *g_pForwards = NULL; /**< Forward system */
2.16 +IForwardManager *forwards = NULL; /**< Forward system */
2.17 +#endif
2.18 +#if defined SMEXT_ENABLE_HANDLESYS
2.19 IHandleSys *g_pHandleSys = NULL; /**< Handle system */
2.20 -ISourceMod *g_pSM = NULL; /**< SourceMod helpers */
2.21 -IForwardManager *g_pForwards = NULL; /**< Forward system */
2.22 +IHandleSys *handlesys = NULL; /**< Handle system */
2.23 +#endif
2.24 +#if defined SMEXT_ENABLE_PLAYERHELPERS
2.25 +IPlayerHelpers *playerhelpers = NULL; /**< Player helpers */
2.26 +#endif //SMEXT_ENABLE_PLAYERHELPERS
2.27 +#if defined SMEXT_ENABLE_DBMANAGER
2.28 +IDBManager *dbi = NULL; /**< DB Manager */
2.29 +#endif //SMEXT_ENABLE_DBMANAGER
2.30
2.31 /** Exports the main interface */
2.32 PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
2.33 @@ -48,7 +63,7 @@
2.34
2.35 bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late)
2.36 {
2.37 - g_pShareSys = sys;
2.38 + g_pShareSys = sharesys = sys;
2.39 myself = me;
2.40
2.41 #if defined SMEXT_CONF_METAMOD
2.42 @@ -63,10 +78,22 @@
2.43 return false;
2.44 }
2.45 #endif
2.46 -
2.47 + SM_GET_IFACE(SOURCEMOD, g_pSM);
2.48 + smutils = g_pSM;
2.49 +#if defined SMEXT_ENABLE_HANDLESYS
2.50 SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys);
2.51 - SM_GET_IFACE(SOURCEMOD, g_pSM);
2.52 + handlesys = g_pHandleSys;
2.53 +#endif
2.54 +#if defined SMEXT_ENABLE_FORWARDSYS
2.55 SM_GET_IFACE(FORWARDMANAGER, g_pForwards);
2.56 + forwards = g_pForwards;
2.57 +#endif
2.58 +#if defined SMEXT_ENABLE_PLAYERHELPERS
2.59 + SM_GET_IFACE(PLAYERMANAGER, playerhelpers);
2.60 +#endif
2.61 +#if defined SMEXT_ENABLE_DBMANAGER
2.62 + SM_GET_IFACE(DBI, dbi);
2.63 +#endif
2.64
2.65 if (SDK_OnLoad(error, maxlength, late))
2.66 {
3.1 --- a/public/sample_ext/sdk/smsdk_ext.h Tue May 29 08:32:12 2007 +0000
3.2 +++ b/public/sample_ext/sdk/smsdk_ext.h Tue May 29 16:42:47 2007 +0000
3.3 @@ -30,7 +30,15 @@
3.4 #include <sp_vm_api.h>
3.5 #include <sm_platform.h>
3.6 #include <ISourceMod.h>
3.7 +#if defined SMEXT_ENABLE_FORWARDSYS
3.8 #include <IForwardSys.h>
3.9 +#endif //SMEXT_ENABLE_FORWARDSYS
3.10 +#if defined SMEXT_ENABLE_PLAYERHELPERS
3.11 +#include <IPlayerHelpers.h>
3.12 +#endif //SMEXT_ENABLE_PlAYERHELPERS
3.13 +#if defined SMEXT_ENABLE_DBMANAGER
3.14 +#include <IDBDriver.h>
3.15 +#endif //SMEXT_ENABLE_DBMANAGER
3.16
3.17 #if defined SMEXT_CONF_METAMOD
3.18 #include <ISmmPlugin.h>
3.19 @@ -171,12 +179,28 @@
3.20 };
3.21
3.22 extern SDKExtension *g_pExtensionIface;
3.23 +extern IExtension *myself;
3.24
3.25 extern IShareSys *g_pShareSys;
3.26 -extern IExtension *myself;
3.27 +extern IShareSys *sharesys; /* Note: Newer name */
3.28 +extern ISourceMod *g_pSM;
3.29 +extern ISourceMod *smutils; /* Note: Newer name */
3.30 +
3.31 +/* Optional interfaces are below */
3.32 +#if defined SMEXT_ENABLE_FORWARDSYS
3.33 +extern IForwardManager *g_pForwards;
3.34 +extern IForwardManager *forwards; /* Note: Newer name */
3.35 +#endif //SMEXT_ENABLE_FORWARDSYS
3.36 +#if defined SMEXT_ENABLE_HANDLESYS
3.37 extern IHandleSys *g_pHandleSys;
3.38 -extern ISourceMod *g_pSM;
3.39 -extern IForwardManager *g_pForwards;
3.40 +extern IHandleSys *handlesys; /* Note: Newer name */
3.41 +#endif //SMEXT_ENABLE_HANDLESYS
3.42 +#if defined SMEXT_ENABLE_PLAYERHELPERS
3.43 +extern IPlayerHelpers *playerhelpers;
3.44 +#endif //SMEXT_ENABLE_PLAYERHELPERS
3.45 +#if defined SMEXT_ENABLE_DBMANAGER
3.46 +extern IDBManager *dbi;
3.47 +#endif //SMEXT_ENABLE_DBMANAGER
3.48
3.49 #if defined SMEXT_CONF_METAMOD
3.50 PLUGIN_GLOBALVARS();
3.51 @@ -192,7 +216,7 @@
3.52 { \
3.53 if (error) \
3.54 { \
3.55 - snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
3.56 + snprintf(error, maxlength, "Could not find interface: %s (version: %d)", SMINTERFACE_##prefix##_NAME, SMINTERFACE_##prefix##_VERSION); \
3.57 return false; \
3.58 } \
3.59 }