Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
00033 #define _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
00034
00035
00036
00037
00038
00039
00040 #include "smsdk_config.h"
00041 #include <IExtensionSys.h>
00042 #include <IHandleSys.h>
00043 #include <sp_vm_api.h>
00044 #include <sm_platform.h>
00045 #include <ISourceMod.h>
00046 #if defined SMEXT_ENABLE_FORWARDSYS
00047 #include <IForwardSys.h>
00048 #endif //SMEXT_ENABLE_FORWARDSYS
00049 #if defined SMEXT_ENABLE_PLAYERHELPERS
00050 #include <IPlayerHelpers.h>
00051 #endif //SMEXT_ENABLE_PlAYERHELPERS
00052 #if defined SMEXT_ENABLE_DBMANAGER
00053 #include <IDBDriver.h>
00054 #endif //SMEXT_ENABLE_DBMANAGER
00055 #if defined SMEXT_ENABLE_GAMECONF
00056 #include <IGameConfigs.h>
00057 #endif
00058 #if defined SMEXT_ENABLE_MEMUTILS
00059 #include <IMemoryUtils.h>
00060 #endif
00061 #if defined SMEXT_ENABLE_GAMEHELPERS
00062 #include <IGameHelpers.h>
00063 #endif
00064 #if defined SMEXT_ENABLE_TIMERSYS
00065 #include <ITimerSystem.h>
00066 #endif
00067 #if defined SMEXT_ENABLE_ADTFACTORY
00068 #include <IADTFactory.h>
00069 #endif
00070 #if defined SMEXT_ENABLE_THREADER
00071 #include <IThreader.h>
00072 #endif
00073 #if defined SMEXT_ENABLE_LIBSYS
00074 #include <ILibrarySys.h>
00075 #endif
00076 #if defined SMEXT_ENABLE_PLUGINSYS
00077 #include <IPluginSys.h>
00078 #endif
00079 #if defined SMEXT_ENABLE_MENUS
00080 #include <IMenuManager.h>
00081 #endif
00082 #if defined SMEXT_ENABLE_ADMINSYS
00083 #include <IAdminSystem.h>
00084 #endif
00085 #if defined SMEXT_ENABLE_TEXTPARSERS
00086 #include <ITextParsers.h>
00087 #endif
00088 #if defined SMEXT_ENABLE_USERMSGS
00089 #include <IUserMessages.h>
00090 #endif
00091 #if defined SMEXT_ENABLE_TRANSLATOR
00092 #include <ITranslator.h>
00093 #endif
00094 #if defined SMEXT_ENABLE_NINVOKE
00095 #include <INativeInvoker.h>
00096 #endif
00097 #if defined SMEXT_ENABLE_ROOTCONSOLEMENU
00098 #include <IRootConsoleMenu.h>
00099 #endif
00100
00101 #if defined SMEXT_CONF_METAMOD
00102 #include <ISmmPlugin.h>
00103 #include <eiface.h>
00104 #endif
00105
00106 using namespace SourceMod;
00107 using namespace SourcePawn;
00108
00109 class SDKExtension :
00110 #if defined SMEXT_CONF_METAMOD
00111 public ISmmPlugin,
00112 #endif
00113 public IExtensionInterface
00114 {
00115 public:
00116
00117 SDKExtension();
00118 public:
00119
00120
00121
00122
00123
00124
00125
00126
00127 virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
00128
00129
00130
00131
00132 virtual void SDK_OnUnload();
00133
00134
00135
00136
00137 virtual void SDK_OnAllLoaded();
00138
00139
00140
00141
00142 virtual void SDK_OnPauseChange(bool paused);
00143
00144 #if defined SMEXT_CONF_METAMOD
00145
00146
00147
00148
00149
00150
00151
00152
00153 virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163 virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength);
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174 virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength);
00175 #endif
00176
00177 public:
00178 virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late);
00179 virtual void OnExtensionUnload();
00180 virtual void OnExtensionsAllLoaded();
00181
00182
00183 virtual bool IsMetamodExtension();
00184
00185
00186
00187
00188
00189
00190 virtual void OnExtensionPauseChange(bool state);
00191
00192
00193 virtual const char *GetExtensionName();
00194
00195 virtual const char *GetExtensionURL();
00196
00197 virtual const char *GetExtensionTag();
00198
00199 virtual const char *GetExtensionAuthor();
00200
00201 virtual const char *GetExtensionVerString();
00202
00203 virtual const char *GetExtensionDescription();
00204
00205 virtual const char *GetExtensionDateString();
00206 #if defined SMEXT_CONF_METAMOD
00207 public:
00208
00209 virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late);
00210
00211 virtual const char *GetAuthor();
00212
00213 virtual const char *GetName();
00214
00215 virtual const char *GetDescription();
00216
00217 virtual const char *GetURL();
00218
00219 virtual const char *GetLicense();
00220
00221 virtual const char *GetVersion();
00222
00223 virtual const char *GetDate();
00224
00225 virtual const char *GetLogTag();
00226
00227 virtual bool Unload(char *error, size_t maxlength);
00228
00229 virtual bool Pause(char *error, size_t maxlength);
00230
00231 virtual bool Unpause(char *error, size_t maxlength);
00232 private:
00233 bool m_SourceMMLoaded;
00234 bool m_WeAreUnloaded;
00235 bool m_WeGotPauseChange;
00236 #endif
00237 };
00238
00239 extern SDKExtension *g_pExtensionIface;
00240 extern IExtension *myself;
00241
00242 extern IShareSys *g_pShareSys;
00243 extern IShareSys *sharesys;
00244 extern ISourceMod *g_pSM;
00245 extern ISourceMod *smutils;
00246
00247
00248 #if defined SMEXT_ENABLE_FORWARDSYS
00249 extern IForwardManager *g_pForwards;
00250 extern IForwardManager *forwards;
00251 #endif //SMEXT_ENABLE_FORWARDSYS
00252 #if defined SMEXT_ENABLE_HANDLESYS
00253 extern IHandleSys *g_pHandleSys;
00254 extern IHandleSys *handlesys;
00255 #endif //SMEXT_ENABLE_HANDLESYS
00256 #if defined SMEXT_ENABLE_PLAYERHELPERS
00257 extern IPlayerManager *playerhelpers;
00258 #endif //SMEXT_ENABLE_PLAYERHELPERS
00259 #if defined SMEXT_ENABLE_DBMANAGER
00260 extern IDBManager *dbi;
00261 #endif //SMEXT_ENABLE_DBMANAGER
00262 #if defined SMEXT_ENABLE_GAMECONF
00263 extern IGameConfigManager *gameconfs;
00264 #endif //SMEXT_ENABLE_DBMANAGER
00265 #if defined SMEXT_ENABLE_MEMUTILS
00266 extern IMemoryUtils *memutils;
00267 #endif
00268 #if defined SMEXT_ENABLE_GAMEHELPERS
00269 extern IGameHelpers *gamehelpers;
00270 #endif
00271 #if defined SMEXT_ENABLE_TIMERSYS
00272 extern ITimerSystem *timersys;
00273 #endif
00274 #if defined SMEXT_ENABLE_ADTFACTORY
00275 extern IADTFactory *adtfactory;
00276 #endif
00277 #if defined SMEXT_ENABLE_THREADER
00278 extern IThreader *threader;
00279 #endif
00280 #if defined SMEXT_ENABLE_LIBSYS
00281 extern ILibrarySys *libsys;
00282 #endif
00283 #if defined SMEXT_ENABLE_PLUGINSYS
00284 extern SourceMod::IPluginManager *plsys;
00285 #endif
00286 #if defined SMEXT_ENABLE_MENUS
00287 extern IMenuManager *menus;
00288 #endif
00289 #if defined SMEXT_ENABLE_ADMINSYS
00290 extern IAdminSystem *adminsys;
00291 #endif
00292 #if defined SMEXT_ENABLE_USERMSGS
00293 extern IUserMessages *usermsgs;
00294 #endif
00295 #if defined SMEXT_ENABLE_TRANSLATOR
00296 extern ITranslator *translator;
00297 #endif
00298 #if defined SMEXT_ENABLE_NINVOKE
00299 extern INativeInterface *ninvoke;
00300 #endif
00301
00302 #if defined SMEXT_CONF_METAMOD
00303 PLUGIN_GLOBALVARS();
00304 extern IVEngineServer *engine;
00305 extern IServerGameDLL *gamedll;
00306 #endif
00307
00308
00309 #define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION
00310
00311 #define SM_GET_IFACE(prefix, addr) \
00312 if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \
00313 { \
00314 if (error != NULL && maxlength) \
00315 { \
00316 size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
00317 if (len >= maxlength) \
00318 { \
00319 error[maxlength - 1] = '\0'; \
00320 } \
00321 } \
00322 return false; \
00323 }
00324
00325 #define SM_GET_LATE_IFACE(prefix, addr) \
00326 g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)
00327
00328 #define SM_CHECK_IFACE(prefix, addr) \
00329 if (!addr) \
00330 { \
00331 if (error != NULL && maxlength) \
00332 { \
00333 size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
00334 if (len >= maxlength) \
00335 { \
00336 error[maxlength - 1] = '\0'; \
00337 } \
00338 } \
00339 return false; \
00340 }
00341
00342 #endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_