sourcemm/CSmmAPI.cpp
author David Anderson <dvander@alliedmods.net>
Sat Apr 16 23:33:39 2005 +0000 (2005-04-16)
changeset 9 01b8b7435e67
parent 7 8ef11f6189e4
child 26 084d848d60d6
permissions -rw-r--r--
Implemented factory hooks
Added commands: clear, load, pause, unload, unpause
Rewrote headers
     1 /* ======== SourceMM ========
     2 * Copyright (C) 2004-2005 Metamod:Source Development Team
     3 * No warranties of any kind
     4 *
     5 * License: zlib/libpng
     6 *
     7 * Author(s): David "BAILOPAN" Anderson
     8 * ============================
     9 */
    10 
    11 #include "CSmmAPI.h"
    12 #include "sourcemm.h"
    13 
    14 /**
    15  * @brief Implementation of main API interface
    16  * @file CSmmAPI.cpp
    17  */
    18 
    19 CSmmAPI g_SmmAPI;
    20 
    21 ISmmPluginManager *CSmmAPI::PluginManager()
    22 {
    23 	return static_cast<ISmmPluginManager *>(&g_PluginMngr);
    24 }
    25 
    26 SourceHook::ISourceHook *CSmmAPI::SourceHook()
    27 {
    28 	return static_cast<SourceHook::ISourceHook *>(&g_SourceHook);
    29 }
    30 
    31 void CSmmAPI::LogMsg(ISmmPlugin *pl, const char *msg, ...)
    32 {
    33 	va_list ap;
    34 	static char buffer[2048];
    35 
    36 	buffer[0] = '\0';
    37 
    38 	va_start(ap, msg);
    39 	vsnprintf(buffer, sizeof(buffer)-1, msg, ap);
    40 	va_end(ap);
    41 
    42 	LogMessage("[%s] %s", pl->GetLogTag(), buffer);
    43 }
    44 
    45 CreateInterfaceFn CSmmAPI::engineFactory(bool syn)
    46 {
    47 	if (syn)
    48 		return EngineFactory;
    49 	return g_Engine.engineFactory;
    50 }
    51 
    52 CreateInterfaceFn CSmmAPI::physicsFactory(bool syn)
    53 {
    54 	if (syn)
    55 		return PhysicsFactory;
    56 	return g_Engine.physicsFactory;
    57 }
    58 
    59 CreateInterfaceFn CSmmAPI::fileSystemFactory(bool syn)
    60 {
    61 	if (syn)
    62 		return FileSystemFactory;
    63 	return g_Engine.fileSystemFactory;
    64 }
    65 
    66 CreateInterfaceFn CSmmAPI::serverFactory(bool syn)
    67 {
    68 	if (syn)
    69 		return CreateInterface;
    70 	return g_GameDll.factory;
    71 }
    72 
    73 CGlobalVars *CSmmAPI::pGlobals()
    74 {
    75 	return g_Engine.pGlobals;
    76 }
    77 
    78 void CSmmAPI::SetLastMetaReturn(META_RES res)
    79 {
    80 	m_Res = res;
    81 }
    82 
    83 META_RES CSmmAPI::GetLastMetaReturn()
    84 {
    85 	return m_Res;
    86 }