2007-01-25 23:36:38 +01:00
|
|
|
/**
|
2007-03-22 22:50:20 +01:00
|
|
|
* vim: set ts=4 :
|
2007-01-25 23:36:38 +01:00
|
|
|
* ===============================================================
|
|
|
|
* SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
|
|
|
|
* ===============================================================
|
|
|
|
*
|
|
|
|
* This file is not open source and may not be copied without explicit
|
|
|
|
* written permission of AlliedModders LLC. This file may not be redistributed
|
|
|
|
* in whole or significant part.
|
|
|
|
* For information, see LICENSE.txt or http://www.sourcemod.net/license.php
|
|
|
|
*
|
|
|
|
* Version: $Id$
|
|
|
|
*/
|
|
|
|
|
2006-11-04 20:27:20 +01:00
|
|
|
#include <oslink.h>
|
2006-11-06 11:57:37 +01:00
|
|
|
#include "sourcemm_api.h"
|
2006-11-04 20:27:20 +01:00
|
|
|
#include "sm_version.h"
|
2006-11-08 08:32:44 +01:00
|
|
|
#include "sourcemod.h"
|
2007-04-08 20:19:06 +02:00
|
|
|
#include "Logger.h"
|
2006-11-04 20:27:20 +01:00
|
|
|
|
2006-11-08 08:32:44 +01:00
|
|
|
SourceMod_Core g_SourceMod_Core;
|
2006-12-13 12:16:20 +01:00
|
|
|
IVEngineServer *engine = NULL;
|
|
|
|
IServerGameDLL *gamedll = NULL;
|
2006-12-28 01:48:09 +01:00
|
|
|
IServerGameClients *serverClients = NULL;
|
2007-01-17 04:01:38 +01:00
|
|
|
ISmmPluginManager *g_pMMPlugins = NULL;
|
2007-02-07 09:44:48 +01:00
|
|
|
CGlobalVars *gpGlobals = NULL;
|
2007-02-08 22:41:28 +01:00
|
|
|
ICvar *icvar = NULL;
|
2007-02-08 02:11:45 +01:00
|
|
|
IGameEventManager2 *gameevents = NULL;
|
2007-02-26 05:24:06 +01:00
|
|
|
IUniformRandomStream *engrandom = NULL;
|
2007-02-15 21:35:17 +01:00
|
|
|
CallClass<IVEngineServer> *enginePatch = NULL;
|
2007-02-26 06:26:54 +01:00
|
|
|
CallClass<IServerGameDLL> *gamedllPatch = NULL;
|
2007-03-18 00:03:44 +01:00
|
|
|
IPlayerInfoManager *playerinfo = NULL;
|
2007-03-26 00:25:45 +02:00
|
|
|
IBaseFileSystem *basefilesystem = NULL;
|
|
|
|
IEngineSound *enginesound = NULL;
|
2007-03-29 21:48:54 +02:00
|
|
|
IServerPluginHelpers *serverpluginhelpers = NULL;
|
2006-11-04 20:27:20 +01:00
|
|
|
|
2006-11-08 08:32:44 +01:00
|
|
|
PLUGIN_EXPOSE(SourceMod, g_SourceMod_Core);
|
2006-11-04 20:27:20 +01:00
|
|
|
|
2006-11-05 01:29:44 +01:00
|
|
|
bool SourceMod_Core::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
|
2006-11-04 20:27:20 +01:00
|
|
|
{
|
|
|
|
PLUGIN_SAVEVARS();
|
|
|
|
|
2006-12-13 12:16:20 +01:00
|
|
|
GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
|
2006-12-16 03:16:21 +01:00
|
|
|
GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
|
2006-12-28 01:48:09 +01:00
|
|
|
GET_V_IFACE_CURRENT(serverFactory, serverClients, IServerGameClients, INTERFACEVERSION_SERVERGAMECLIENTS);
|
2007-02-08 22:41:28 +01:00
|
|
|
GET_V_IFACE_CURRENT(engineFactory, icvar, ICvar, VENGINE_CVAR_INTERFACE_VERSION);
|
2007-02-08 02:11:45 +01:00
|
|
|
GET_V_IFACE_CURRENT(engineFactory, gameevents, IGameEventManager2, INTERFACEVERSION_GAMEEVENTSMANAGER2);
|
2007-02-26 05:24:06 +01:00
|
|
|
GET_V_IFACE_CURRENT(engineFactory, engrandom, IUniformRandomStream, VENGINE_SERVER_RANDOM_INTERFACE_VERSION);
|
2007-03-25 22:20:43 +02:00
|
|
|
GET_V_IFACE_CURRENT(fileSystemFactory, basefilesystem, IBaseFileSystem, BASEFILESYSTEM_INTERFACE_VERSION);
|
2007-03-26 00:25:45 +02:00
|
|
|
GET_V_IFACE_CURRENT(engineFactory, enginesound, IEngineSound, IENGINESOUND_SERVER_INTERFACE_VERSION);
|
2007-03-29 21:48:54 +02:00
|
|
|
GET_V_IFACE_CURRENT(engineFactory, serverpluginhelpers, IServerPluginHelpers, INTERFACEVERSION_ISERVERPLUGINHELPERS);
|
2006-12-13 12:16:20 +01:00
|
|
|
|
2007-03-18 00:03:44 +01:00
|
|
|
/* :TODO: Make this optional and... make it find earlier versions [?] */
|
|
|
|
GET_V_IFACE_CURRENT(serverFactory, playerinfo, IPlayerInfoManager, INTERFACEVERSION_PLAYERINFOMANAGER);
|
|
|
|
|
2007-01-17 04:01:38 +01:00
|
|
|
if ((g_pMMPlugins = (ISmmPluginManager *)g_SMAPI->MetaFactory(MMIFACE_PLMANAGER, NULL, NULL)) == NULL)
|
|
|
|
{
|
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
snprintf(error, maxlen, "Unable to find interface %s", MMIFACE_PLMANAGER);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-02-07 09:44:48 +01:00
|
|
|
gpGlobals = ismm->pGlobals();
|
2007-04-08 20:19:06 +02:00
|
|
|
|
|
|
|
ismm->AddListener(this, this);
|
|
|
|
ismm->EnableVSPListener();
|
2007-02-07 09:44:48 +01:00
|
|
|
|
2006-11-08 08:32:44 +01:00
|
|
|
return g_SourceMod.InitializeSourceMod(error, maxlen, late);
|
2006-11-04 20:27:20 +01:00
|
|
|
}
|
|
|
|
|
2006-12-28 01:48:09 +01:00
|
|
|
bool SourceMod_Core::Unload(char *error, size_t maxlen)
|
2006-11-04 20:27:20 +01:00
|
|
|
{
|
2007-01-13 05:28:13 +01:00
|
|
|
g_SourceMod.CloseSourceMod();
|
2006-11-04 20:27:20 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2006-11-05 01:29:44 +01:00
|
|
|
bool SourceMod_Core::Pause(char *error, size_t maxlen)
|
2006-11-04 20:27:20 +01:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2006-11-05 01:29:44 +01:00
|
|
|
bool SourceMod_Core::Unpause(char *error, size_t maxlen)
|
2006-11-04 20:27:20 +01:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2006-11-05 01:29:44 +01:00
|
|
|
void SourceMod_Core::AllPluginsLoaded()
|
2006-11-04 20:27:20 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-11-05 01:29:44 +01:00
|
|
|
const char *SourceMod_Core::GetAuthor()
|
2006-11-04 20:27:20 +01:00
|
|
|
{
|
|
|
|
return "AlliedModders, LLC";
|
|
|
|
}
|
|
|
|
|
2006-11-05 01:29:44 +01:00
|
|
|
const char *SourceMod_Core::GetName()
|
2006-11-04 20:27:20 +01:00
|
|
|
{
|
|
|
|
return "SourceMod";
|
|
|
|
}
|
|
|
|
|
2006-11-05 01:29:44 +01:00
|
|
|
const char *SourceMod_Core::GetDescription()
|
2006-11-04 20:27:20 +01:00
|
|
|
{
|
|
|
|
return "Extensible administration and scripting system";
|
|
|
|
}
|
|
|
|
|
2006-11-05 01:29:44 +01:00
|
|
|
const char *SourceMod_Core::GetURL()
|
2006-11-04 20:27:20 +01:00
|
|
|
{
|
|
|
|
return "http://www.sourcemod.net/";
|
|
|
|
}
|
|
|
|
|
2006-11-05 01:29:44 +01:00
|
|
|
const char *SourceMod_Core::GetLicense()
|
2006-11-04 20:27:20 +01:00
|
|
|
{
|
|
|
|
return "See LICENSE.txt";
|
|
|
|
}
|
|
|
|
|
2006-11-05 01:29:44 +01:00
|
|
|
const char *SourceMod_Core::GetVersion()
|
2006-11-04 20:27:20 +01:00
|
|
|
{
|
2007-03-03 08:50:01 +01:00
|
|
|
return SVN_FULL_VERSION;
|
2006-11-04 20:27:20 +01:00
|
|
|
}
|
|
|
|
|
2006-11-05 01:29:44 +01:00
|
|
|
const char *SourceMod_Core::GetDate()
|
2006-11-04 20:27:20 +01:00
|
|
|
{
|
|
|
|
return __DATE__;
|
|
|
|
}
|
|
|
|
|
2006-11-05 01:29:44 +01:00
|
|
|
const char *SourceMod_Core::GetLogTag()
|
2006-11-04 20:27:20 +01:00
|
|
|
{
|
2007-03-28 22:28:42 +02:00
|
|
|
return "SM";
|
2006-11-04 20:27:20 +01:00
|
|
|
}
|
2007-04-08 20:19:06 +02:00
|
|
|
|
|
|
|
void SourceMod_Core::OnVSPListening(IServerPluginCallbacks *iface)
|
|
|
|
{
|
|
|
|
/* This shouldn't happen */
|
|
|
|
if (!iface)
|
|
|
|
{
|
|
|
|
g_Logger.LogFatal("Metamod:Source version is out of date. SourceMod requires 1.4 or greater.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Notify! */
|
|
|
|
SMGlobalClass *pBase = SMGlobalClass::head;
|
|
|
|
while (pBase)
|
|
|
|
{
|
|
|
|
pBase->OnSourceModVSPReceived(iface);
|
|
|
|
pBase = pBase->m_pGlobalClassNext;
|
|
|
|
}
|
|
|
|
}
|