core/sourcemm_api.cpp
author Scott Ehlert <ds@alliedmods.net>
Wed Mar 28 20:28:42 2007 +0000 (2007-03-28)
changeset 657 e9eea6cf8e41
parent 656 351fca8ce6a5
child 659 edd2ead1f13e
permissions -rw-r--r--
Couple of quick things...
- Changed SourceMod logtag from SRCMOD to SM
- ConVars dynamically created by convar manager now can properly be set on srcds command line
     1 /**
     2  * vim: set ts=4 :
     3  * ===============================================================
     4  * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     5  * ===============================================================
     6  *
     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
    11  *
    12  * Version: $Id$
    13  */
    14 
    15 #include <oslink.h>
    16 #include "sourcemm_api.h"
    17 #include "sm_version.h"
    18 #include "sourcemod.h"
    19 
    20 SourceMod_Core g_SourceMod_Core;
    21 IVEngineServer *engine = NULL;
    22 IServerGameDLL *gamedll = NULL;
    23 IServerGameClients *serverClients = NULL;
    24 ISmmPluginManager *g_pMMPlugins = NULL;
    25 CGlobalVars *gpGlobals = NULL;
    26 ICvar *icvar = NULL;
    27 IGameEventManager2 *gameevents = NULL;
    28 IUniformRandomStream *engrandom = NULL;
    29 CallClass<IVEngineServer> *enginePatch = NULL;
    30 CallClass<IServerGameDLL> *gamedllPatch = NULL;
    31 IPlayerInfoManager *playerinfo = NULL;
    32 IBaseFileSystem *basefilesystem = NULL;
    33 IEngineSound *enginesound = NULL;
    34 
    35 PLUGIN_EXPOSE(SourceMod, g_SourceMod_Core);
    36 
    37 bool SourceMod_Core::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
    38 {
    39 	PLUGIN_SAVEVARS();
    40 
    41 	GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
    42 	GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
    43 	GET_V_IFACE_CURRENT(serverFactory, serverClients, IServerGameClients, INTERFACEVERSION_SERVERGAMECLIENTS);
    44 	GET_V_IFACE_CURRENT(engineFactory, icvar, ICvar, VENGINE_CVAR_INTERFACE_VERSION);
    45 	GET_V_IFACE_CURRENT(engineFactory, gameevents, IGameEventManager2, INTERFACEVERSION_GAMEEVENTSMANAGER2);
    46 	GET_V_IFACE_CURRENT(engineFactory, engrandom, IUniformRandomStream, VENGINE_SERVER_RANDOM_INTERFACE_VERSION);
    47 	GET_V_IFACE_CURRENT(fileSystemFactory, basefilesystem, IBaseFileSystem, BASEFILESYSTEM_INTERFACE_VERSION);
    48 	GET_V_IFACE_CURRENT(engineFactory, enginesound, IEngineSound, IENGINESOUND_SERVER_INTERFACE_VERSION);
    49 
    50 	/* :TODO: Make this optional and... make it find earlier versions [?] */
    51 	GET_V_IFACE_CURRENT(serverFactory, playerinfo, IPlayerInfoManager, INTERFACEVERSION_PLAYERINFOMANAGER);
    52 
    53 	if ((g_pMMPlugins = (ISmmPluginManager *)g_SMAPI->MetaFactory(MMIFACE_PLMANAGER, NULL, NULL)) == NULL)
    54 	{
    55 		if (error)
    56 		{
    57 			snprintf(error, maxlen, "Unable to find interface %s", MMIFACE_PLMANAGER);
    58 		}
    59 		return false;
    60 	}
    61 
    62 	gpGlobals = ismm->pGlobals();
    63 
    64 	return g_SourceMod.InitializeSourceMod(error, maxlen, late);
    65 }
    66 
    67 bool SourceMod_Core::Unload(char *error, size_t maxlen)
    68 {
    69 	g_SourceMod.CloseSourceMod();
    70 	return true;
    71 }
    72 
    73 bool SourceMod_Core::Pause(char *error, size_t maxlen)
    74 {
    75 	return true;
    76 }
    77 
    78 bool SourceMod_Core::Unpause(char *error, size_t maxlen)
    79 {
    80 	return true;
    81 }
    82 
    83 void SourceMod_Core::AllPluginsLoaded()
    84 {
    85 }
    86 
    87 const char *SourceMod_Core::GetAuthor()
    88 {
    89 	return "AlliedModders, LLC";
    90 }
    91 
    92 const char *SourceMod_Core::GetName()
    93 {
    94 	return "SourceMod";
    95 }
    96 
    97 const char *SourceMod_Core::GetDescription()
    98 {
    99 	return "Extensible administration and scripting system";
   100 }
   101 
   102 const char *SourceMod_Core::GetURL()
   103 {
   104 	return "http://www.sourcemod.net/";
   105 }
   106 
   107 const char *SourceMod_Core::GetLicense()
   108 {
   109 	return "See LICENSE.txt";
   110 }
   111 
   112 const char *SourceMod_Core::GetVersion()
   113 {
   114 	return SVN_FULL_VERSION;
   115 }
   116 
   117 const char *SourceMod_Core::GetDate()
   118 {
   119 	return __DATE__;
   120 }
   121 
   122 const char *SourceMod_Core::GetLogTag()
   123 {
   124 	return "SM";
   125 }