core/sourcemm_api.cpp
author David Anderson <dvander@alliedmods.net>
Mon Mar 19 01:44:09 2007 +0000 (2007-03-19)
changeset 647 1e29dcc9ca97
parent 644 2a90d4324fc0
child 653 ef60870067ff
permissions -rw-r--r--
fixed a potential bug with kicking players during authorization
     1 /**
     2  * ===============================================================
     3  * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     4  * ===============================================================
     5  *
     6  * This file is not open source and may not be copied without explicit
     7  * written permission of AlliedModders LLC.  This file may not be redistributed 
     8  * in whole or significant part.
     9  * For information, see LICENSE.txt or http://www.sourcemod.net/license.php
    10  *
    11  * Version: $Id$
    12  */
    13 
    14 #include <oslink.h>
    15 #include "sourcemm_api.h"
    16 #include "sm_version.h"
    17 #include "sourcemod.h"
    18 
    19 SourceMod_Core g_SourceMod_Core;
    20 IVEngineServer *engine = NULL;
    21 IServerGameDLL *gamedll = NULL;
    22 IServerGameClients *serverClients = NULL;
    23 ISmmPluginManager *g_pMMPlugins = NULL;
    24 CGlobalVars *gpGlobals = NULL;
    25 ICvar *icvar = NULL;
    26 IGameEventManager2 *gameevents = NULL;
    27 IUniformRandomStream *engrandom = NULL;
    28 CallClass<IVEngineServer> *enginePatch = NULL;
    29 CallClass<IServerGameDLL> *gamedllPatch = NULL;
    30 IPlayerInfoManager *playerinfo = NULL;
    31 
    32 PLUGIN_EXPOSE(SourceMod, g_SourceMod_Core);
    33 
    34 bool SourceMod_Core::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
    35 {
    36 	PLUGIN_SAVEVARS();
    37 
    38 	GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
    39 	GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
    40 	GET_V_IFACE_CURRENT(serverFactory, serverClients, IServerGameClients, INTERFACEVERSION_SERVERGAMECLIENTS);
    41 	GET_V_IFACE_CURRENT(engineFactory, icvar, ICvar, VENGINE_CVAR_INTERFACE_VERSION);
    42 	GET_V_IFACE_CURRENT(engineFactory, gameevents, IGameEventManager2, INTERFACEVERSION_GAMEEVENTSMANAGER2);
    43 	GET_V_IFACE_CURRENT(engineFactory, engrandom, IUniformRandomStream, VENGINE_SERVER_RANDOM_INTERFACE_VERSION);
    44 
    45 	/* :TODO: Make this optional and... make it find earlier versions [?] */
    46 	GET_V_IFACE_CURRENT(serverFactory, playerinfo, IPlayerInfoManager, INTERFACEVERSION_PLAYERINFOMANAGER);
    47 
    48 	if ((g_pMMPlugins = (ISmmPluginManager *)g_SMAPI->MetaFactory(MMIFACE_PLMANAGER, NULL, NULL)) == NULL)
    49 	{
    50 		if (error)
    51 		{
    52 			snprintf(error, maxlen, "Unable to find interface %s", MMIFACE_PLMANAGER);
    53 		}
    54 		return false;
    55 	}
    56 
    57 	gpGlobals = ismm->pGlobals();
    58 
    59 	return g_SourceMod.InitializeSourceMod(error, maxlen, late);
    60 }
    61 
    62 bool SourceMod_Core::Unload(char *error, size_t maxlen)
    63 {
    64 	g_SourceMod.CloseSourceMod();
    65 	return true;
    66 }
    67 
    68 bool SourceMod_Core::Pause(char *error, size_t maxlen)
    69 {
    70 	return true;
    71 }
    72 
    73 bool SourceMod_Core::Unpause(char *error, size_t maxlen)
    74 {
    75 	return true;
    76 }
    77 
    78 void SourceMod_Core::AllPluginsLoaded()
    79 {
    80 }
    81 
    82 const char *SourceMod_Core::GetAuthor()
    83 {
    84 	return "AlliedModders, LLC";
    85 }
    86 
    87 const char *SourceMod_Core::GetName()
    88 {
    89 	return "SourceMod";
    90 }
    91 
    92 const char *SourceMod_Core::GetDescription()
    93 {
    94 	return "Extensible administration and scripting system";
    95 }
    96 
    97 const char *SourceMod_Core::GetURL()
    98 {
    99 	return "http://www.sourcemod.net/";
   100 }
   101 
   102 const char *SourceMod_Core::GetLicense()
   103 {
   104 	return "See LICENSE.txt";
   105 }
   106 
   107 const char *SourceMod_Core::GetVersion()
   108 {
   109 	return SVN_FULL_VERSION;
   110 }
   111 
   112 const char *SourceMod_Core::GetDate()
   113 {
   114 	return __DATE__;
   115 }
   116 
   117 const char *SourceMod_Core::GetLogTag()
   118 {
   119 	return "SRCMOD";
   120 }