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
00095 #if defined SMEXT_CONF_METAMOD
00096 #include <ISmmPlugin.h>
00097 #include <eiface.h>
00098 #endif
00099
00100 using namespace SourceMod;
00101 using namespace SourcePawn;
00102
00103 class SDKExtension :
00104 #if defined SMEXT_CONF_METAMOD
00105 public ISmmPlugin,
00106 #endif
00107 public IExtensionInterface
00108 {
00109 public:
00110
00111 SDKExtension();
00112 public:
00113
00114
00115
00116
00117
00118
00119
00120
00121 virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
00122
00123
00124
00125
00126 virtual void SDK_OnUnload();
00127
00128
00129
00130
00131 virtual void SDK_OnAllLoaded();
00132
00133
00134
00135
00136 virtual void SDK_OnPauseChange(bool paused);
00137
00138 #if defined SMEXT_CONF_METAMOD
00139
00140
00141
00142
00143
00144
00145
00146
00147 virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157 virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength);
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168 virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength);
00169 #endif
00170
00171 public:
00172 virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late);
00173 virtual void OnExtensionUnload();
00174 virtual void OnExtensionsAllLoaded();
00175
00176
00177 virtual bool IsMetamodExtension();
00178
00179
00180
00181
00182
00183
00184 virtual void OnExtensionPauseChange(bool state);
00185
00186
00187 virtual const char *GetExtensionName();
00188
00189 virtual const char *GetExtensionURL();
00190
00191 virtual const char *GetExtensionTag();
00192
00193 virtual const char *GetExtensionAuthor();
00194
00195 virtual const char *GetExtensionVerString();
00196
00197 virtual const char *GetExtensionDescription();
00198
00199 virtual const char *GetExtensionDateString();
00200 #if defined SMEXT_CONF_METAMOD
00201 public:
00202
00203 virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late);
00204
00205 virtual const char *GetAuthor();
00206
00207 virtual const char *GetName();
00208
00209 virtual const char *GetDescription();
00210
00211 virtual const char *GetURL();
00212
00213 virtual const char *GetLicense();
00214
00215 virtual const char *GetVersion();
00216
00217 virtual const char *GetDate();
00218
00219 virtual const char *GetLogTag();
00220
00221 virtual bool Unload(char *error, size_t maxlength);
00222
00223 virtual bool Pause(char *error, size_t maxlength);
00224
00225 virtual bool Unpause(char *error, size_t maxlength);
00226 private:
00227 bool m_SourceMMLoaded;
00228 bool m_WeAreUnloaded;
00229 bool m_WeGotPauseChange;
00230 #endif
00231 };
00232
00233 extern SDKExtension *g_pExtensionIface;
00234 extern IExtension *myself;
00235
00236 extern IShareSys *g_pShareSys;
00237 extern IShareSys *sharesys;
00238 extern ISourceMod *g_pSM;
00239 extern ISourceMod *smutils;
00240
00241
00242 #if defined SMEXT_ENABLE_FORWARDSYS
00243 extern IForwardManager *g_pForwards;
00244 extern IForwardManager *forwards;
00245 #endif //SMEXT_ENABLE_FORWARDSYS
00246 #if defined SMEXT_ENABLE_HANDLESYS
00247 extern IHandleSys *g_pHandleSys;
00248 extern IHandleSys *handlesys;
00249 #endif //SMEXT_ENABLE_HANDLESYS
00250 #if defined SMEXT_ENABLE_PLAYERHELPERS
00251 extern IPlayerManager *playerhelpers;
00252 #endif //SMEXT_ENABLE_PLAYERHELPERS
00253 #if defined SMEXT_ENABLE_DBMANAGER
00254 extern IDBManager *dbi;
00255 #endif //SMEXT_ENABLE_DBMANAGER
00256 #if defined SMEXT_ENABLE_GAMECONF
00257 extern IGameConfigManager *gameconfs;
00258 #endif //SMEXT_ENABLE_DBMANAGER
00259 #if defined SMEXT_ENABLE_MEMUTILS
00260 extern IMemoryUtils *memutils;
00261 #endif
00262 #if defined SMEXT_ENABLE_GAMEHELPERS
00263 extern IGameHelpers *gamehelpers;
00264 #endif
00265 #if defined SMEXT_ENABLE_TIMERSYS
00266 extern ITimerSystem *timersys;
00267 #endif
00268 #if defined SMEXT_ENABLE_ADTFACTORY
00269 extern IADTFactory *adtfactory;
00270 #endif
00271 #if defined SMEXT_ENABLE_THREADER
00272 extern IThreader *threader;
00273 #endif
00274 #if defined SMEXT_ENABLE_LIBSYS
00275 extern ILibrarySys *libsys;
00276 #endif
00277 #if defined SMEXT_ENABLE_PLUGINSYS
00278 extern SourceMod::IPluginManager *plsys;
00279 #endif
00280 #if defined SMEXT_ENABLE_MENUS
00281 extern IMenuManager *menus;
00282 #endif
00283 #if defined SMEXT_ENABLE_ADMINSYS
00284 extern IAdminSystem *adminsys;
00285 #endif
00286 #if defined SMEXT_ENABLE_USERMSGS
00287 extern IUserMessages *usermsgs;
00288 #endif
00289 #if defined SMEXT_ENABLE_TRANSLATOR
00290 extern ITranslator *translator;
00291 #endif
00292
00293 #if defined SMEXT_CONF_METAMOD
00294 PLUGIN_GLOBALVARS();
00295 extern IVEngineServer *engine;
00296 extern IServerGameDLL *gamedll;
00297 #endif
00298
00299
00300 #define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION
00301
00302 #define SM_GET_IFACE(prefix, addr) \
00303 if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \
00304 { \
00305 if (error != NULL && maxlength) \
00306 { \
00307 size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
00308 if (len >= maxlength) \
00309 { \
00310 error[maxlength - 1] = '\0'; \
00311 } \
00312 } \
00313 return false; \
00314 }
00315
00316 #define SM_GET_LATE_IFACE(prefix, addr) \
00317 g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)
00318
00319 #define SM_CHECK_IFACE(prefix, addr) \
00320 if (!addr) \
00321 { \
00322 if (error != NULL && maxlength) \
00323 { \
00324 size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
00325 if (len >= maxlength) \
00326 { \
00327 error[maxlength - 1] = '\0'; \
00328 } \
00329 } \
00330 return false; \
00331 }
00332
00333 #endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_