1
0
mirror of https://github.com/alliedmodders/metamod-source.git synced 2024-12-04 16:24:16 +01:00
HLMetaModOfficial/core/provider/provider_base.cpp

121 lines
2.8 KiB
C++
Raw Normal View History

2009-10-29 06:07:23 +01:00
/**
* vim: set ts=4 sw=4 tw=99 noet :
2009-10-29 06:07:23 +01:00
* ======================================================
* Metamod:Source
* Copyright (C) 2004-2023 AlliedModders LLC and authors.
2009-10-29 06:07:23 +01:00
* All rights reserved.
* ======================================================
*
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from
* the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software in a
* product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
#include <stdio.h>
#include <setjmp.h>
2009-10-29 06:07:23 +01:00
#include "../metamod_oslink.h"
#include <sourcehook.h>
#include <convar.h>
#include <eiface.h>
#include <tier0/icommandline.h>
#include "../metamod_util.h"
2023-04-01 05:32:21 +02:00
#include "provider_base.h"
2009-10-29 06:07:23 +01:00
#include "metamod_console.h"
#include <filesystem.h>
#include "metamod.h"
#include <tier1/KeyValues.h>
2009-10-29 06:07:23 +01:00
/* Imports */
#if SOURCE_ENGINE < SE_ORANGEBOX
2009-10-29 06:07:23 +01:00
#undef CommandLine
DLL_IMPORT ICommandLine *CommandLine();
#endif
void _ServerCommand();
/* Variables */
static List<ConCommandBase *> conbases_unreg;
ICvar *icvar = NULL;
IServerGameDLL *server = NULL;
IVEngineServer *engine = NULL;
IServerGameClients *gameclients = NULL;
2015-07-09 03:39:28 +02:00
CGlobalVars *gpGlobals = NULL;
2009-10-29 06:07:23 +01:00
bool BaseProvider::IsSourceEngineBuildCompatible(int build)
{
return (build == SOURCE_ENGINE_ORIGINAL
|| build == SOURCE_ENGINE_EPISODEONE);
}
int BaseProvider::TryServerGameDLL(const char *iface)
{
if (strncmp(iface, "ServerGameDLL", 13) != 0)
{
return 0;
}
return atoi(&iface[13]);
}
bool BaseProvider::LogMessage(const char *buffer)
{
if (!engine)
{
return false;
}
engine->LogPrint(buffer);
return true;
}
void BaseProvider::DisplayError(const char *fmt, ...)
{
va_list ap;
char buffer[2048];
va_start(ap, fmt);
UTIL_FormatArgs(buffer, sizeof(buffer), fmt, ap);
va_end(ap);
Error("%s", buffer);
2009-10-29 06:07:23 +01:00
}
void BaseProvider::DisplayWarning(const char *fmt, ...)
{
va_list ap;
char buffer[2048];
va_start(ap, fmt);
UTIL_FormatArgs(buffer, sizeof(buffer), fmt, ap);
va_end(ap);
Warning("%s", buffer);
2009-10-29 06:07:23 +01:00
}
void BaseProvider::DisplayDevMsg(const char* fmt, ...)
2009-10-29 06:07:23 +01:00
{
va_list ap;
char buffer[2048];
va_start(ap, fmt);
UTIL_FormatArgs(buffer, sizeof(buffer), fmt, ap);
va_end(ap);
DevMsg("%s", buffer);
}