2009-10-29 06:07:23 +01:00
|
|
|
/**
|
2009-10-29 16:57:27 +01:00
|
|
|
* vim: set ts=4 sw=4 tw=99 noet :
|
2009-10-29 06:07:23 +01:00
|
|
|
* ======================================================
|
|
|
|
* Metamod:Source
|
2023-04-01 21:07:59 +02:00
|
|
|
* 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>
|
2009-12-10 07:59:50 +01:00
|
|
|
#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"
|
2015-07-11 19:58:53 +02:00
|
|
|
#include <tier1/KeyValues.h>
|
2015-09-21 19:29:01 +02:00
|
|
|
|
2009-10-29 06:07:23 +01:00
|
|
|
|
|
|
|
/* Imports */
|
2016-10-11 19:29:37 +02:00
|
|
|
#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;
|
2023-04-01 06:02:45 +02:00
|
|
|
|
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);
|
|
|
|
|
2012-05-26 23:46:02 +02:00
|
|
|
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);
|
|
|
|
|
2012-05-26 23:46:02 +02:00
|
|
|
Warning("%s", buffer);
|
2009-10-29 06:07:23 +01:00
|
|
|
}
|
|
|
|
|
2023-04-01 21:07:59 +02:00
|
|
|
void BaseProvider::DisplayDevMsg(const char* fmt, ...)
|
2009-10-29 06:07:23 +01:00
|
|
|
{
|
2023-04-01 21:07:59 +02:00
|
|
|
va_list ap;
|
|
|
|
char buffer[2048];
|
2016-10-11 19:29:37 +02:00
|
|
|
|
2023-04-01 21:07:59 +02:00
|
|
|
va_start(ap, fmt);
|
|
|
|
UTIL_FormatArgs(buffer, sizeof(buffer), fmt, ap);
|
|
|
|
va_end(ap);
|
2016-10-11 19:29:37 +02:00
|
|
|
|
2023-04-01 21:07:59 +02:00
|
|
|
DevMsg("%s", buffer);
|
2016-10-11 19:29:37 +02:00
|
|
|
}
|