core/sourcemm_api.cpp
author David Anderson <dvander@alliedmods.net>
Mon Feb 26 05:26:54 2007 +0000 (2007-02-26)
changeset 532 fe6bb91d79b1
parent 530 ab92d2d7bdb8
child 566 7640076104f5
permissions -rw-r--r--
added a crapload of random natives
     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 
    31 PLUGIN_EXPOSE(SourceMod, g_SourceMod_Core);
    32 
    33 bool SourceMod_Core::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
    34 {
    35 	PLUGIN_SAVEVARS();
    36 
    37 	GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
    38 	GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
    39 	GET_V_IFACE_CURRENT(serverFactory, serverClients, IServerGameClients, INTERFACEVERSION_SERVERGAMECLIENTS);
    40 	GET_V_IFACE_CURRENT(engineFactory, icvar, ICvar, VENGINE_CVAR_INTERFACE_VERSION);
    41 	GET_V_IFACE_CURRENT(engineFactory, gameevents, IGameEventManager2, INTERFACEVERSION_GAMEEVENTSMANAGER2);
    42 	GET_V_IFACE_CURRENT(engineFactory, engrandom, IUniformRandomStream, VENGINE_SERVER_RANDOM_INTERFACE_VERSION);
    43 
    44 	if ((g_pMMPlugins = (ISmmPluginManager *)g_SMAPI->MetaFactory(MMIFACE_PLMANAGER, NULL, NULL)) == NULL)
    45 	{
    46 		if (error)
    47 		{
    48 			snprintf(error, maxlen, "Unable to find interface %s", MMIFACE_PLMANAGER);
    49 		}
    50 		return false;
    51 	}
    52 
    53 	gpGlobals = ismm->pGlobals();
    54 
    55 	return g_SourceMod.InitializeSourceMod(error, maxlen, late);
    56 }
    57 
    58 bool SourceMod_Core::Unload(char *error, size_t maxlen)
    59 {
    60 	g_SourceMod.CloseSourceMod();
    61 	return true;
    62 }
    63 
    64 bool SourceMod_Core::Pause(char *error, size_t maxlen)
    65 {
    66 	return true;
    67 }
    68 
    69 bool SourceMod_Core::Unpause(char *error, size_t maxlen)
    70 {
    71 	return true;
    72 }
    73 
    74 void SourceMod_Core::AllPluginsLoaded()
    75 {
    76 }
    77 
    78 const char *SourceMod_Core::GetAuthor()
    79 {
    80 	return "AlliedModders, LLC";
    81 }
    82 
    83 const char *SourceMod_Core::GetName()
    84 {
    85 	return "SourceMod";
    86 }
    87 
    88 const char *SourceMod_Core::GetDescription()
    89 {
    90 	return "Extensible administration and scripting system";
    91 }
    92 
    93 const char *SourceMod_Core::GetURL()
    94 {
    95 	return "http://www.sourcemod.net/";
    96 }
    97 
    98 const char *SourceMod_Core::GetLicense()
    99 {
   100 	return "See LICENSE.txt";
   101 }
   102 
   103 const char *SourceMod_Core::GetVersion()
   104 {
   105 	return SOURCEMOD_VERSION;
   106 }
   107 
   108 const char *SourceMod_Core::GetDate()
   109 {
   110 	return __DATE__;
   111 }
   112 
   113 const char *SourceMod_Core::GetLogTag()
   114 {
   115 	return "SRCMOD";
   116 }