3 * ===============================================================
4 * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
5 * ===============================================================
7 * This file is not open source and may not be copied without explicit
8 * written permission of AlliedModders LLC. This file may not be redistributed
9 * in whole or significant part.
10 * For information, see LICENSE.txt or http://www.sourcemod.net/license.php
16 #include "sourcemm_api.h"
17 #include "sm_version.h"
18 #include "sourcemod.h"
20 #include "ConVarManager.h"
22 SourceMod_Core g_SourceMod_Core;
23 IVEngineServer *engine = NULL;
24 IServerGameDLL *gamedll = NULL;
25 IServerGameClients *serverClients = NULL;
26 ISmmPluginManager *g_pMMPlugins = NULL;
27 CGlobalVars *gpGlobals = NULL;
29 IGameEventManager2 *gameevents = NULL;
30 IUniformRandomStream *engrandom = NULL;
31 CallClass<IVEngineServer> *enginePatch = NULL;
32 CallClass<IServerGameDLL> *gamedllPatch = NULL;
33 IPlayerInfoManager *playerinfo = NULL;
34 IBaseFileSystem *basefilesystem = NULL;
35 IEngineSound *enginesound = NULL;
36 IServerPluginHelpers *serverpluginhelpers = NULL;
38 PLUGIN_EXPOSE(SourceMod, g_SourceMod_Core);
40 bool SourceMod_Core::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
44 GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
45 GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
46 GET_V_IFACE_CURRENT(serverFactory, serverClients, IServerGameClients, INTERFACEVERSION_SERVERGAMECLIENTS);
47 GET_V_IFACE_CURRENT(engineFactory, icvar, ICvar, VENGINE_CVAR_INTERFACE_VERSION);
48 GET_V_IFACE_CURRENT(engineFactory, gameevents, IGameEventManager2, INTERFACEVERSION_GAMEEVENTSMANAGER2);
49 GET_V_IFACE_CURRENT(engineFactory, engrandom, IUniformRandomStream, VENGINE_SERVER_RANDOM_INTERFACE_VERSION);
50 GET_V_IFACE_CURRENT(fileSystemFactory, basefilesystem, IBaseFileSystem, BASEFILESYSTEM_INTERFACE_VERSION);
51 GET_V_IFACE_CURRENT(engineFactory, enginesound, IEngineSound, IENGINESOUND_SERVER_INTERFACE_VERSION);
52 GET_V_IFACE_CURRENT(engineFactory, serverpluginhelpers, IServerPluginHelpers, INTERFACEVERSION_ISERVERPLUGINHELPERS);
54 /* :TODO: Make this optional and... make it find earlier versions [?] */
55 GET_V_IFACE_CURRENT(serverFactory, playerinfo, IPlayerInfoManager, INTERFACEVERSION_PLAYERINFOMANAGER);
57 if ((g_pMMPlugins = (ISmmPluginManager *)g_SMAPI->MetaFactory(MMIFACE_PLMANAGER, NULL, NULL)) == NULL)
61 snprintf(error, maxlen, "Unable to find interface %s", MMIFACE_PLMANAGER);
66 gpGlobals = ismm->pGlobals();
68 ismm->AddListener(this, this);
69 ismm->EnableVSPListener();
71 return g_SourceMod.InitializeSourceMod(error, maxlen, late);
74 bool SourceMod_Core::Unload(char *error, size_t maxlen)
76 g_SourceMod.CloseSourceMod();
80 bool SourceMod_Core::Pause(char *error, size_t maxlen)
85 bool SourceMod_Core::Unpause(char *error, size_t maxlen)
90 void SourceMod_Core::AllPluginsLoaded()
92 g_SourceMod.AllPluginsLoaded();
95 const char *SourceMod_Core::GetAuthor()
97 return "AlliedModders, LLC";
100 const char *SourceMod_Core::GetName()
105 const char *SourceMod_Core::GetDescription()
107 return "Extensible administration and scripting system";
110 const char *SourceMod_Core::GetURL()
112 return "http://www.sourcemod.net/";
115 const char *SourceMod_Core::GetLicense()
117 return "See LICENSE.txt";
120 const char *SourceMod_Core::GetVersion()
122 return SVN_FULL_VERSION;
125 const char *SourceMod_Core::GetDate()
130 const char *SourceMod_Core::GetLogTag()
135 void SourceMod_Core::OnVSPListening(IServerPluginCallbacks *iface)
137 /* This shouldn't happen */
140 g_Logger.LogFatal("Metamod:Source version is out of date. SourceMod requires 1.4 or greater.");
145 SMGlobalClass *pBase = SMGlobalClass::head;
148 pBase->OnSourceModVSPReceived(iface);
149 pBase = pBase->m_pGlobalClassNext;
153 #if PLAPI_VERSION >= 12
154 void SourceMod_Core::OnUnlinkConCommandBase(PluginId id, ConCommandBase *pCommand)
156 g_ConVarManager.OnUnlinkConCommandBase(id, pCommand);
159 void SourceMod_Core::OnPluginUnload(PluginId id)
161 g_ConVarManager.OnMetamodPluginUnloaded(id);