1.1 --- a/core/sourcemm_api.cpp Fri Jul 11 06:51:21 2008 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,240 +0,0 @@
1.4 -/**
1.5 - * vim: set ts=4 :
1.6 - * =============================================================================
1.7 - * SourceMod
1.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
1.9 - * =============================================================================
1.10 - *
1.11 - * This program is free software; you can redistribute it and/or modify it under
1.12 - * the terms of the GNU General Public License, version 3.0, as published by the
1.13 - * Free Software Foundation.
1.14 - *
1.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
1.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1.18 - * details.
1.19 - *
1.20 - * You should have received a copy of the GNU General Public License along with
1.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
1.22 - *
1.23 - * As a special exception, AlliedModders LLC gives you permission to link the
1.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
1.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
1.26 - * by the Valve Corporation. You must obey the GNU General Public License in
1.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
1.28 - * this exception to all derivative works. AlliedModders LLC defines further
1.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
1.30 - * or <http://www.sourcemod.net/license.php>.
1.31 - *
1.32 - * Version: $Id$
1.33 - */
1.34 -
1.35 -#include "sourcemod.h"
1.36 -#include "sourcemm_api.h"
1.37 -#include "sm_version.h"
1.38 -#include "Logger.h"
1.39 -#include "ExtensionSys.h"
1.40 -#include "concmd_cleaner.h"
1.41 -#include "compat_wrappers.h"
1.42 -
1.43 -SourceMod_Core g_SourceMod_Core;
1.44 -IVEngineServer *engine = NULL;
1.45 -IServerGameDLL *gamedll = NULL;
1.46 -IServerGameClients *serverClients = NULL;
1.47 -ISmmPluginManager *g_pMMPlugins = NULL;
1.48 -CGlobalVars *gpGlobals = NULL;
1.49 -ICvar *icvar = NULL;
1.50 -IGameEventManager2 *gameevents = NULL;
1.51 -IUniformRandomStream *engrandom = NULL;
1.52 -CallClass<IVEngineServer> *enginePatch = NULL;
1.53 -CallClass<IServerGameDLL> *gamedllPatch = NULL;
1.54 -IPlayerInfoManager *playerinfo = NULL;
1.55 -IBaseFileSystem *basefilesystem = NULL;
1.56 -IEngineSound *enginesound = NULL;
1.57 -IServerPluginHelpers *serverpluginhelpers = NULL;
1.58 -IServerPluginCallbacks *vsp_interface = NULL;
1.59 -int vsp_version = 0;
1.60 -
1.61 -PLUGIN_EXPOSE(SourceMod, g_SourceMod_Core);
1.62 -
1.63 -bool SourceMod_Core::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
1.64 -{
1.65 - PLUGIN_SAVEVARS();
1.66 -
1.67 - GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
1.68 - GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
1.69 - GET_V_IFACE_CURRENT(GetServerFactory, serverClients, IServerGameClients, INTERFACEVERSION_SERVERGAMECLIENTS);
1.70 - GET_V_IFACE_CURRENT(GetEngineFactory, icvar, ICvar, CVAR_INTERFACE_VERSION);
1.71 - GET_V_IFACE_CURRENT(GetEngineFactory, gameevents, IGameEventManager2, INTERFACEVERSION_GAMEEVENTSMANAGER2);
1.72 - GET_V_IFACE_CURRENT(GetEngineFactory, engrandom, IUniformRandomStream, VENGINE_SERVER_RANDOM_INTERFACE_VERSION);
1.73 - GET_V_IFACE_CURRENT(GetFileSystemFactory, basefilesystem, IBaseFileSystem, BASEFILESYSTEM_INTERFACE_VERSION);
1.74 - GET_V_IFACE_CURRENT(GetEngineFactory, enginesound, IEngineSound, IENGINESOUND_SERVER_INTERFACE_VERSION);
1.75 - GET_V_IFACE_CURRENT(GetEngineFactory, serverpluginhelpers, IServerPluginHelpers, INTERFACEVERSION_ISERVERPLUGINHELPERS);
1.76 -
1.77 - /* :TODO: Make this optional and... make it find earlier versions [?] */
1.78 - GET_V_IFACE_CURRENT(GetServerFactory, playerinfo, IPlayerInfoManager, INTERFACEVERSION_PLAYERINFOMANAGER);
1.79 -
1.80 - if ((g_pMMPlugins = (ISmmPluginManager *)g_SMAPI->MetaFactory(MMIFACE_PLMANAGER, NULL, NULL)) == NULL)
1.81 - {
1.82 - if (error)
1.83 - {
1.84 - snprintf(error, maxlen, "Unable to find interface %s", MMIFACE_PLMANAGER);
1.85 - }
1.86 - return false;
1.87 - }
1.88 -
1.89 - gpGlobals = ismm->GetCGlobals();
1.90 -
1.91 - ismm->AddListener(this, this);
1.92 -
1.93 -#if defined METAMOD_PLAPI_VERSION
1.94 - if ((vsp_interface = g_SMAPI->GetVSPInfo(&vsp_version)) == NULL)
1.95 -#endif
1.96 - {
1.97 - g_SMAPI->EnableVSPListener();
1.98 - }
1.99 -
1.100 - return g_SourceMod.InitializeSourceMod(error, maxlen, late);
1.101 -}
1.102 -
1.103 -bool SourceMod_Core::Unload(char *error, size_t maxlen)
1.104 -{
1.105 - g_SourceMod.CloseSourceMod();
1.106 - return true;
1.107 -}
1.108 -
1.109 -bool SourceMod_Core::Pause(char *error, size_t maxlen)
1.110 -{
1.111 - return true;
1.112 -}
1.113 -
1.114 -bool SourceMod_Core::Unpause(char *error, size_t maxlen)
1.115 -{
1.116 - return true;
1.117 -}
1.118 -
1.119 -void SourceMod_Core::AllPluginsLoaded()
1.120 -{
1.121 - g_SourceMod.AllPluginsLoaded();
1.122 -}
1.123 -
1.124 -const char *SourceMod_Core::GetAuthor()
1.125 -{
1.126 - return "AlliedModders LLC";
1.127 -}
1.128 -
1.129 -const char *SourceMod_Core::GetName()
1.130 -{
1.131 - return "SourceMod";
1.132 -}
1.133 -
1.134 -const char *SourceMod_Core::GetDescription()
1.135 -{
1.136 - return "Extensible administration and scripting system";
1.137 -}
1.138 -
1.139 -const char *SourceMod_Core::GetURL()
1.140 -{
1.141 - return "http://www.sourcemod.net/";
1.142 -}
1.143 -
1.144 -const char *SourceMod_Core::GetLicense()
1.145 -{
1.146 - return "See LICENSE.txt";
1.147 -}
1.148 -
1.149 -const char *SourceMod_Core::GetVersion()
1.150 -{
1.151 - return SVN_FULL_VERSION;
1.152 -}
1.153 -
1.154 -const char *SourceMod_Core::GetDate()
1.155 -{
1.156 - return __DATE__;
1.157 -}
1.158 -
1.159 -const char *SourceMod_Core::GetLogTag()
1.160 -{
1.161 - return "SM";
1.162 -}
1.163 -
1.164 -void SourceMod_Core::OnVSPListening(IServerPluginCallbacks *iface)
1.165 -{
1.166 - /* This shouldn't happen */
1.167 - if (!iface)
1.168 - {
1.169 - g_Logger.LogFatal("Metamod:Source version is out of date. SourceMod requires 1.4.2 or greater.");
1.170 - return;
1.171 - }
1.172 -
1.173 - if (vsp_interface == NULL)
1.174 - {
1.175 - vsp_interface = iface;
1.176 - }
1.177 -
1.178 - if (!g_Loaded)
1.179 - {
1.180 - return;
1.181 - }
1.182 -
1.183 -#if defined METAMOD_PLAPI_VERSION
1.184 - if (vsp_version == 0)
1.185 - {
1.186 - g_SMAPI->GetVSPInfo(&vsp_version);
1.187 - }
1.188 -#else
1.189 - if (vsp_version == 0)
1.190 - {
1.191 - if (strcmp(g_SourceMod.GetGameFolderName(), "ship") == 0)
1.192 - {
1.193 - vsp_version = 1;
1.194 - }
1.195 - else
1.196 - {
1.197 - vsp_version = 2;
1.198 - }
1.199 - }
1.200 -#endif
1.201 -
1.202 - /* Notify! */
1.203 - SMGlobalClass *pBase = SMGlobalClass::head;
1.204 - while (pBase)
1.205 - {
1.206 - pBase->OnSourceModVSPReceived();
1.207 - pBase = pBase->m_pGlobalClassNext;
1.208 - }
1.209 -}
1.210 -
1.211 -#if defined METAMOD_PLAPI_VERSION
1.212 -
1.213 -void SourceMod_Core::OnUnlinkConCommandBase(PluginId id, ConCommandBase *pCommand)
1.214 -{
1.215 - Global_OnUnlinkConCommandBase(pCommand);
1.216 -}
1.217 -
1.218 -#else
1.219 -
1.220 -void SourceMod_Core::OnPluginUnload(PluginId id)
1.221 -{
1.222 - Global_OnUnlinkConCommandBase(NULL);
1.223 -}
1.224 -
1.225 -#endif
1.226 -
1.227 -void *SourceMod_Core::OnMetamodQuery(const char *iface, int *ret)
1.228 -{
1.229 - void *ptr = NULL;
1.230 -
1.231 - if (strcmp(iface, SOURCEMOD_INTERFACE_EXTENSIONS) == 0)
1.232 - {
1.233 - ptr = (IExtensionManager *)&g_Extensions;
1.234 - }
1.235 -
1.236 - if (ret != NULL)
1.237 - {
1.238 - *ret = (ptr == NULL) ? IFACE_FAILED : IFACE_OK;
1.239 - }
1.240 -
1.241 - return ptr;
1.242 -}
1.243 -