sourcemm/CSmmAPI.cpp
author David Anderson <dvander@alliedmods.net>
Tue Apr 19 05:36:59 2005 +0000 (2005-04-19)
changeset 26 084d848d60d6
parent 9 01b8b7435e67
child 64 ad98b9f2d80c
permissions -rw-r--r--
Added doxyfile
Placed CSmmAPI in SourceMM namespace
     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 using namespace SourceMM;
    20 
    21 CSmmAPI g_SmmAPI;
    22 
    23 ISmmPluginManager *CSmmAPI::PluginManager()
    24 {
    25 	return static_cast<ISmmPluginManager *>(&g_PluginMngr);
    26 }
    27 
    28 SourceHook::ISourceHook *CSmmAPI::SourceHook()
    29 {
    30 	return static_cast<SourceHook::ISourceHook *>(&g_SourceHook);
    31 }
    32 
    33 void CSmmAPI::LogMsg(ISmmPlugin *pl, const char *msg, ...)
    34 {
    35 	va_list ap;
    36 	static char buffer[2048];
    37 
    38 	buffer[0] = '\0';
    39 
    40 	va_start(ap, msg);
    41 	vsnprintf(buffer, sizeof(buffer)-1, msg, ap);
    42 	va_end(ap);
    43 
    44 	LogMessage("[%s] %s", pl->GetLogTag(), buffer);
    45 }
    46 
    47 CreateInterfaceFn CSmmAPI::engineFactory(bool syn)
    48 {
    49 	if (syn)
    50 		return EngineFactory;
    51 	return g_Engine.engineFactory;
    52 }
    53 
    54 CreateInterfaceFn CSmmAPI::physicsFactory(bool syn)
    55 {
    56 	if (syn)
    57 		return PhysicsFactory;
    58 	return g_Engine.physicsFactory;
    59 }
    60 
    61 CreateInterfaceFn CSmmAPI::fileSystemFactory(bool syn)
    62 {
    63 	if (syn)
    64 		return FileSystemFactory;
    65 	return g_Engine.fileSystemFactory;
    66 }
    67 
    68 CreateInterfaceFn CSmmAPI::serverFactory(bool syn)
    69 {
    70 	if (syn)
    71 		return CreateInterface;
    72 	return g_GameDll.factory;
    73 }
    74 
    75 CGlobalVars *CSmmAPI::pGlobals()
    76 {
    77 	return g_Engine.pGlobals;
    78 }
    79 
    80 void CSmmAPI::SetLastMetaReturn(META_RES res)
    81 {
    82 	m_Res = res;
    83 }
    84 
    85 META_RES CSmmAPI::GetLastMetaReturn()
    86 {
    87 	return m_Res;
    88 }