core/sourcemm_api.cpp
author Scott Ehlert <ds@alliedmods.net>
Thu Mar 22 21:50:20 2007 +0000 (2007-03-22)
changeset 653 ef60870067ff
parent 644 2a90d4324fc0
child 654 e00dd6df311e
permissions -rw-r--r--
More consistency of some sort...

Oh god, what has possessed me to do this?
     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 
    33 PLUGIN_EXPOSE(SourceMod, g_SourceMod_Core);
    34 
    35 bool SourceMod_Core::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
    36 {
    37 	PLUGIN_SAVEVARS();
    38 
    39 	GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
    40 	GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
    41 	GET_V_IFACE_CURRENT(serverFactory, serverClients, IServerGameClients, INTERFACEVERSION_SERVERGAMECLIENTS);
    42 	GET_V_IFACE_CURRENT(engineFactory, icvar, ICvar, VENGINE_CVAR_INTERFACE_VERSION);
    43 	GET_V_IFACE_CURRENT(engineFactory, gameevents, IGameEventManager2, INTERFACEVERSION_GAMEEVENTSMANAGER2);
    44 	GET_V_IFACE_CURRENT(engineFactory, engrandom, IUniformRandomStream, VENGINE_SERVER_RANDOM_INTERFACE_VERSION);
    45 
    46 	/* :TODO: Make this optional and... make it find earlier versions [?] */
    47 	GET_V_IFACE_CURRENT(serverFactory, playerinfo, IPlayerInfoManager, INTERFACEVERSION_PLAYERINFOMANAGER);
    48 
    49 	if ((g_pMMPlugins = (ISmmPluginManager *)g_SMAPI->MetaFactory(MMIFACE_PLMANAGER, NULL, NULL)) == NULL)
    50 	{
    51 		if (error)
    52 		{
    53 			snprintf(error, maxlen, "Unable to find interface %s", MMIFACE_PLMANAGER);
    54 		}
    55 		return false;
    56 	}
    57 
    58 	gpGlobals = ismm->pGlobals();
    59 
    60 	return g_SourceMod.InitializeSourceMod(error, maxlen, late);
    61 }
    62 
    63 bool SourceMod_Core::Unload(char *error, size_t maxlen)
    64 {
    65 	g_SourceMod.CloseSourceMod();
    66 	return true;
    67 }
    68 
    69 bool SourceMod_Core::Pause(char *error, size_t maxlen)
    70 {
    71 	return true;
    72 }
    73 
    74 bool SourceMod_Core::Unpause(char *error, size_t maxlen)
    75 {
    76 	return true;
    77 }
    78 
    79 void SourceMod_Core::AllPluginsLoaded()
    80 {
    81 }
    82 
    83 const char *SourceMod_Core::GetAuthor()
    84 {
    85 	return "AlliedModders, LLC";
    86 }
    87 
    88 const char *SourceMod_Core::GetName()
    89 {
    90 	return "SourceMod";
    91 }
    92 
    93 const char *SourceMod_Core::GetDescription()
    94 {
    95 	return "Extensible administration and scripting system";
    96 }
    97 
    98 const char *SourceMod_Core::GetURL()
    99 {
   100 	return "http://www.sourcemod.net/";
   101 }
   102 
   103 const char *SourceMod_Core::GetLicense()
   104 {
   105 	return "See LICENSE.txt";
   106 }
   107 
   108 const char *SourceMod_Core::GetVersion()
   109 {
   110 	return SVN_FULL_VERSION;
   111 }
   112 
   113 const char *SourceMod_Core::GetDate()
   114 {
   115 	return __DATE__;
   116 }
   117 
   118 const char *SourceMod_Core::GetLogTag()
   119 {
   120 	return "SRCMOD";
   121 }