2022-04-14 19:18:59 +02:00
|
|
|
//=============================================================================//
|
|
|
|
//
|
|
|
|
// Purpose: Callback functions for ConVar's.
|
|
|
|
//
|
|
|
|
//=============================================================================//
|
|
|
|
|
|
|
|
#include "core/stdafx.h"
|
2023-03-15 21:11:20 +01:00
|
|
|
#include "core/init.h"
|
2022-05-16 21:15:25 +02:00
|
|
|
#include "windows/id3dx.h"
|
2022-06-04 03:12:46 +02:00
|
|
|
#include "tier0/fasttimer.h"
|
2022-04-14 19:18:59 +02:00
|
|
|
#include "tier1/cvar.h"
|
2024-01-28 18:15:19 +01:00
|
|
|
#include "tier1/fmtstr.h"
|
2023-01-29 16:07:02 +01:00
|
|
|
#ifndef CLIENT_DLL
|
2022-07-25 19:35:08 +02:00
|
|
|
#include "engine/server/sv_rcon.h"
|
2023-01-29 16:07:02 +01:00
|
|
|
#endif // !CLIENT_DLL
|
2022-05-16 21:15:25 +02:00
|
|
|
#ifndef DEDICATED
|
2022-05-20 11:52:19 +02:00
|
|
|
#include "engine/client/cl_rcon.h"
|
2023-05-10 00:05:38 +02:00
|
|
|
#include "engine/client/cdll_engine_int.h"
|
2023-10-15 10:40:46 +02:00
|
|
|
#include "engine/client/clientstate.h"
|
2022-05-16 21:15:25 +02:00
|
|
|
#endif // !DEDICATED
|
2022-05-20 11:52:19 +02:00
|
|
|
#include "engine/client/client.h"
|
2022-05-16 21:15:25 +02:00
|
|
|
#include "engine/net.h"
|
2022-08-22 03:53:38 +02:00
|
|
|
#include "engine/host_cmd.h"
|
|
|
|
#include "engine/host_state.h"
|
2023-01-22 12:09:12 +01:00
|
|
|
#include "engine/enginetrace.h"
|
2022-09-01 01:32:32 +02:00
|
|
|
#ifndef CLIENT_DLL
|
|
|
|
#include "engine/server/server.h"
|
|
|
|
#endif // !CLIENT_DLL
|
2024-04-05 17:51:19 +02:00
|
|
|
|
2024-01-25 00:04:39 +01:00
|
|
|
#include "rtech/pak/pakencode.h"
|
2024-04-05 17:51:19 +02:00
|
|
|
#include "rtech/pak/pakdecode.h"
|
|
|
|
#include "rtech/pak/pakparse.h"
|
|
|
|
#include "rtech/pak/pakstate.h"
|
|
|
|
#include "rtech/pak/paktools.h"
|
|
|
|
|
2024-04-05 17:42:05 +02:00
|
|
|
#include "rtech/playlists/playlists.h"
|
2024-04-05 17:51:19 +02:00
|
|
|
|
2022-05-16 21:15:25 +02:00
|
|
|
#include "filesystem/basefilesystem.h"
|
|
|
|
#include "filesystem/filesystem.h"
|
|
|
|
#include "vpklib/packedstore.h"
|
2023-05-06 16:23:56 +02:00
|
|
|
#include "vscript/vscript.h"
|
2023-09-16 00:45:11 +02:00
|
|
|
#include "localize/localize.h"
|
2022-09-01 01:32:32 +02:00
|
|
|
#include "ebisusdk/EbisuSDK.h"
|
2022-05-16 21:15:25 +02:00
|
|
|
#ifndef DEDICATED
|
2023-09-12 17:44:24 +02:00
|
|
|
#include "geforce/reflex.h"
|
2022-05-16 21:15:25 +02:00
|
|
|
#include "gameui/IBrowser.h"
|
|
|
|
#include "gameui/IConsole.h"
|
|
|
|
#endif // !DEDICATED
|
2022-07-21 15:13:48 +02:00
|
|
|
#ifndef CLIENT_DLL
|
2022-08-09 17:34:10 +02:00
|
|
|
#include "networksystem/bansystem.h"
|
2022-07-21 15:13:48 +02:00
|
|
|
#endif // !CLIENT_DLL
|
2022-11-03 17:12:22 +01:00
|
|
|
#include "public/edict.h"
|
2022-08-09 17:18:07 +02:00
|
|
|
#include "public/worldsize.h"
|
2022-05-16 21:15:25 +02:00
|
|
|
#include "mathlib/crc32.h"
|
2022-07-30 00:54:33 +02:00
|
|
|
#include "mathlib/mathlib.h"
|
2023-05-10 00:05:38 +02:00
|
|
|
#include "common/completion.h"
|
|
|
|
#include "common/callback.h"
|
2022-05-16 21:15:25 +02:00
|
|
|
#ifndef DEDICATED
|
|
|
|
#include "materialsystem/cmaterialglue.h"
|
2023-01-24 18:39:12 +01:00
|
|
|
#endif // !DEDICATED
|
2023-01-22 12:09:12 +01:00
|
|
|
#include "public/bspflags.h"
|
|
|
|
#include "public/cmodel.h"
|
2022-08-09 17:18:07 +02:00
|
|
|
#include "public/idebugoverlay.h"
|
2023-09-15 18:25:31 +02:00
|
|
|
#include "public/localize/ilocalize.h"
|
2022-11-03 10:44:59 +01:00
|
|
|
#ifndef CLIENT_DLL
|
|
|
|
#include "game/server/detour_impl.h"
|
2023-01-16 21:16:34 +01:00
|
|
|
#include "game/server/gameinterface.h"
|
2022-11-03 10:44:59 +01:00
|
|
|
#endif // !CLIENT_DLL
|
2022-07-30 00:54:33 +02:00
|
|
|
#ifndef DEDICATED
|
2023-01-20 00:28:49 +01:00
|
|
|
#include "game/client/cliententitylist.h"
|
2022-11-10 00:53:12 +01:00
|
|
|
#include "game/client/viewrender.h"
|
2022-07-30 00:54:33 +02:00
|
|
|
#endif // !DEDICATED
|
2022-05-16 21:15:25 +02:00
|
|
|
|
2022-04-14 19:18:59 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
=====================
|
|
|
|
MP_GameMode_Changed_f
|
|
|
|
=====================
|
|
|
|
*/
|
2022-08-04 11:06:56 +02:00
|
|
|
void MP_GameMode_Changed_f(IConVar* pConVar, const char* pOldString, float flOldValue)
|
2022-04-14 19:18:59 +02:00
|
|
|
{
|
2024-01-02 15:21:36 +01:00
|
|
|
v_SetupGamemode(mp_gamemode->GetString());
|
2022-05-16 21:15:25 +02:00
|
|
|
}
|
|
|
|
|
2022-08-27 18:57:56 +02:00
|
|
|
/*
|
|
|
|
=====================
|
|
|
|
MP_HostName_Changed_f
|
|
|
|
=====================
|
|
|
|
*/
|
|
|
|
void MP_HostName_Changed_f(IConVar* pConVar, const char* pOldString, float flOldValue)
|
|
|
|
{
|
|
|
|
#ifndef DEDICATED
|
2024-01-21 21:29:23 +01:00
|
|
|
g_Browser.SetHostName(pylon_matchmaking_hostname->GetString());
|
2022-08-27 18:57:56 +02:00
|
|
|
#endif // !DEDICATED
|
|
|
|
}
|
|
|
|
|
2022-09-18 00:48:00 +02:00
|
|
|
#ifndef CLIENT_DLL
|
2022-09-16 00:51:35 +02:00
|
|
|
/*
|
|
|
|
=====================
|
|
|
|
Host_Changelevel_f
|
|
|
|
|
|
|
|
Goes to a new map,
|
|
|
|
taking all clients along
|
|
|
|
=====================
|
|
|
|
*/
|
|
|
|
void Host_Changelevel_f(const CCommand& args)
|
|
|
|
{
|
2024-01-21 21:53:48 +01:00
|
|
|
const int argCount = args.ArgC();
|
|
|
|
|
|
|
|
if (argCount >= 2
|
2022-09-16 00:51:35 +02:00
|
|
|
&& IsOriginInitialized()
|
|
|
|
&& g_pServer->IsActive())
|
|
|
|
{
|
2024-01-21 21:53:48 +01:00
|
|
|
const char* levelName = args[1];
|
|
|
|
const char* landMarkName = argCount > 2 ? args[2] : "";
|
|
|
|
|
2022-09-16 00:51:35 +02:00
|
|
|
v_SetLaunchOptions(args);
|
2024-01-21 21:53:48 +01:00
|
|
|
v_HostState_ChangeLevelMP(levelName, landMarkName);
|
2022-09-16 00:51:35 +02:00
|
|
|
}
|
|
|
|
}
|
2022-07-21 15:13:48 +02:00
|
|
|
#endif // !CLIENT_DLL
|
2024-01-25 00:04:39 +01:00
|
|
|
|
2022-05-16 21:15:25 +02:00
|
|
|
/*
|
|
|
|
=====================
|
2022-05-30 02:56:15 +02:00
|
|
|
VPK_Pack_f
|
|
|
|
|
2022-11-16 00:54:51 +01:00
|
|
|
Packs VPK files into
|
|
|
|
'PLATFORM' VPK directory.
|
2022-05-30 02:56:15 +02:00
|
|
|
=====================
|
|
|
|
*/
|
|
|
|
void VPK_Pack_f(const CCommand& args)
|
|
|
|
{
|
Proper VPK repacking
Initial proper implementation pending cleanup.
The new system builds a manifest file when a VPK is unpacked. The manifest files contains data such as the entry flags and texture flags. It also contains a field determining whether the file should be compressed or not.
When a user repacks a pack, the system attempts to load this manifest file and does a lookup to the object to retrieve the flags (most of these flags are unknown, but they are used by the engine and are necessary for stuff like cubemaps and texture files to work correctly. Cubemaps won't work with proper flags, and textures (decals, particle system components, etc..) will look washed out without them.
I think some also determine whether a file within the VPK should be cached or not, so simply marking everything as 0x101 will probably end up in more CPU time and higher filesystem cache usage (depot/ is only 0x1, I don't think anything there is getting cached ever without the 0x100 flag).
User could also repack a VPK while excluding anything that is not in the manifest file. So you could unpack all VPK's into a single directory (each VPK has its own manifest file tied to its level name), and rebuild all the VPK's with only the files that where originally in them.
fs_pack_vpk command usage: <locale> <context> <level_name> <manifest_only>
locale determines the pak language (default english), context determines whether is a server/client vpk, level_name determines the BSP name of the pak, manifest_only determines whether the pack system should only include files within the manifest (leaving this arg out will build all files into the vpk).
The VPK workspace path is determined with ConVar 'fs_packedstore_workspace'.
2022-06-04 01:08:23 +02:00
|
|
|
if (args.ArgC() < 4)
|
2022-05-30 02:56:15 +02:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-01-14 01:51:17 +01:00
|
|
|
const char* workspacePath = fs_packedstore_workspace->GetString();
|
|
|
|
|
2024-01-14 02:03:27 +01:00
|
|
|
if (!FileSystem()->IsDirectory(workspacePath, "PLATFORM"))
|
2024-01-14 01:51:17 +01:00
|
|
|
{
|
|
|
|
Error(eDLL_T::FS, NO_ERROR, "Workspace path \"%s\" doesn't exist!\n", workspacePath);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-11-23 17:09:48 +01:00
|
|
|
VPKPair_t pair(args.Arg(1), args.Arg(2), args.Arg(3), NULL);
|
2024-01-14 01:51:17 +01:00
|
|
|
Msg(eDLL_T::FS, "*** Starting VPK build command for: '%s'\n", pair.m_DirName.String());
|
2022-06-04 03:12:46 +02:00
|
|
|
|
2024-01-14 01:51:17 +01:00
|
|
|
CFastTimer timer;
|
2022-11-17 20:41:34 +01:00
|
|
|
timer.Start();
|
2022-06-04 03:12:46 +02:00
|
|
|
|
2024-01-12 11:02:54 +01:00
|
|
|
CPackedStoreBuilder builder;
|
2024-01-12 11:01:04 +01:00
|
|
|
|
2024-01-13 14:02:46 +01:00
|
|
|
builder.InitLzEncoder(fs_packedstore_max_helper_threads->GetInt(), fs_packedstore_compression_level->GetString());
|
2024-01-14 01:51:17 +01:00
|
|
|
builder.PackStore(pair, workspacePath, "vpk/");
|
2022-06-04 03:12:46 +02:00
|
|
|
|
2022-11-17 20:41:34 +01:00
|
|
|
timer.End();
|
2023-08-21 19:12:29 +02:00
|
|
|
Msg(eDLL_T::FS, "*** Time elapsed: '%lf' seconds\n", timer.GetDuration().GetSeconds());
|
|
|
|
Msg(eDLL_T::FS, "\n");
|
2022-05-30 02:56:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=====================
|
|
|
|
VPK_Unpack_f
|
2022-05-16 21:15:25 +02:00
|
|
|
|
2022-11-16 00:54:51 +01:00
|
|
|
Unpacks VPK files into
|
|
|
|
workspace directory.
|
2022-05-16 21:15:25 +02:00
|
|
|
=====================
|
|
|
|
*/
|
|
|
|
void VPK_Unpack_f(const CCommand& args)
|
|
|
|
{
|
|
|
|
if (args.ArgC() < 2)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2022-11-17 20:41:34 +01:00
|
|
|
|
2024-01-14 01:51:17 +01:00
|
|
|
CUtlString fileName = args.Arg(1);
|
|
|
|
VPKDir_t vpk(fileName, (args.ArgC() > 2));
|
2022-05-16 21:15:25 +02:00
|
|
|
|
2024-01-14 01:51:17 +01:00
|
|
|
if (vpk.Failed())
|
|
|
|
{
|
|
|
|
Error(eDLL_T::FS, NO_ERROR, "Failed to parse directory tree file \"%s\"!\n", fileName.String());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Msg(eDLL_T::FS, "*** Starting VPK extraction command for: '%s'\n", fileName.String());
|
|
|
|
|
|
|
|
CFastTimer timer;
|
2022-11-17 20:41:34 +01:00
|
|
|
timer.Start();
|
2022-05-16 21:15:25 +02:00
|
|
|
|
2024-01-12 11:02:54 +01:00
|
|
|
CPackedStoreBuilder builder;
|
2024-01-12 11:01:04 +01:00
|
|
|
|
2024-01-13 14:02:46 +01:00
|
|
|
builder.InitLzDecoder();
|
2024-01-13 14:09:37 +01:00
|
|
|
builder.UnpackStore(vpk, fs_packedstore_workspace->GetString());
|
2022-05-16 21:15:25 +02:00
|
|
|
|
2022-11-17 20:41:34 +01:00
|
|
|
timer.End();
|
2023-08-21 19:12:29 +02:00
|
|
|
Msg(eDLL_T::FS, "*** Time elapsed: '%lf' seconds\n", timer.GetDuration().GetSeconds());
|
|
|
|
Msg(eDLL_T::FS, "\n");
|
2022-05-16 21:15:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=====================
|
|
|
|
VPK_Mount_f
|
|
|
|
|
|
|
|
Mounts input VPK file for
|
|
|
|
internal FileSystem usage
|
|
|
|
=====================
|
|
|
|
*/
|
|
|
|
void VPK_Mount_f(const CCommand& args)
|
|
|
|
{
|
|
|
|
if (args.ArgC() < 2)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-12-22 01:05:39 +01:00
|
|
|
FileSystem()->MountVPKFile(args.Arg(1));
|
2022-11-06 12:21:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=====================
|
|
|
|
VPK_Unmount_f
|
|
|
|
|
|
|
|
Unmounts input VPK file
|
|
|
|
and clears its cache
|
|
|
|
=====================
|
|
|
|
*/
|
|
|
|
void VPK_Unmount_f(const CCommand& args)
|
|
|
|
{
|
|
|
|
if (args.ArgC() < 2)
|
2022-05-16 21:15:25 +02:00
|
|
|
{
|
2022-11-06 12:21:21 +01:00
|
|
|
return;
|
2022-05-16 21:15:25 +02:00
|
|
|
}
|
2022-11-06 12:21:21 +01:00
|
|
|
|
2022-12-22 01:05:39 +01:00
|
|
|
FileSystem()->UnmountVPKFile(args.Arg(1));
|
2022-05-16 21:15:25 +02:00
|
|
|
}
|
|
|
|
|
2022-08-30 12:10:07 +02:00
|
|
|
/*
|
|
|
|
=====================
|
|
|
|
NET_UseRandomKeyChanged_f
|
|
|
|
|
|
|
|
Use random AES encryption
|
|
|
|
key for game packets
|
|
|
|
=====================
|
|
|
|
*/
|
|
|
|
void NET_UseRandomKeyChanged_f(IConVar* pConVar, const char* pOldString, float flOldValue)
|
|
|
|
{
|
2023-03-28 01:24:55 +02:00
|
|
|
if (ConVar* pConVarRef = g_pCVar->FindVar(pConVar->GetCommandName()))
|
2022-08-30 12:10:07 +02:00
|
|
|
{
|
|
|
|
if (strcmp(pOldString, pConVarRef->GetString()) == NULL)
|
|
|
|
return; // Same value.
|
|
|
|
|
|
|
|
if (pConVarRef->GetBool())
|
|
|
|
NET_GenerateKey();
|
|
|
|
else
|
|
|
|
NET_SetKey(DEFAULT_NET_ENCRYPTION_KEY);
|
|
|
|
}
|
|
|
|
}
|
2023-03-15 21:11:20 +01:00
|
|
|
|
2023-04-30 11:34:47 +02:00
|
|
|
/*
|
|
|
|
=====================
|
|
|
|
NET_UseSocketsForLoopbackChanged_f
|
|
|
|
|
|
|
|
Use random AES encryption
|
|
|
|
key for game packets
|
|
|
|
=====================
|
|
|
|
*/
|
|
|
|
void NET_UseSocketsForLoopbackChanged_f(IConVar* pConVar, const char* pOldString, float flOldValue)
|
|
|
|
{
|
|
|
|
if (ConVar* pConVarRef = g_pCVar->FindVar(pConVar->GetCommandName()))
|
|
|
|
{
|
|
|
|
if (strcmp(pOldString, pConVarRef->GetString()) == NULL)
|
|
|
|
return; // Same value.
|
|
|
|
|
|
|
|
#ifndef CLIENT_DLL
|
|
|
|
// Reboot the RCON server to switch address type.
|
|
|
|
if (RCONServer()->IsInitialized())
|
|
|
|
{
|
2023-08-21 19:12:29 +02:00
|
|
|
Msg(eDLL_T::SERVER, "Rebooting RCON server...\n");
|
2023-04-30 11:34:47 +02:00
|
|
|
RCONServer()->Shutdown();
|
|
|
|
RCONServer()->Init();
|
|
|
|
}
|
|
|
|
#endif // !CLIENT_DLL
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-16 21:15:25 +02:00
|
|
|
#ifndef DEDICATED
|
2023-08-04 17:28:01 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
=====================
|
|
|
|
RCON_SendLogs_f
|
|
|
|
|
|
|
|
request logs from RCON server
|
|
|
|
=====================
|
|
|
|
*/
|
|
|
|
void RCON_InputOnlyChanged_f(IConVar* pConVar, const char* pOldString, float flOldValue)
|
|
|
|
{
|
|
|
|
RCONClient()->RequestConsoleLog(RCONClient()->ShouldReceive());
|
|
|
|
}
|
2023-09-12 17:44:24 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
=====================
|
|
|
|
GFX_NVN_Changed_f
|
|
|
|
|
|
|
|
force update NVIDIA Reflex
|
|
|
|
Low Latency parameters
|
|
|
|
=====================
|
|
|
|
*/
|
|
|
|
void GFX_NVN_Changed_f(IConVar* pConVar, const char* pOldString, float flOldValue)
|
|
|
|
{
|
|
|
|
GFX_MarkLowLatencyParametersOutOfDate();
|
|
|
|
}
|
2022-05-16 21:15:25 +02:00
|
|
|
#endif // !DEDICATED
|
|
|
|
|
2023-08-17 20:22:28 +01:00
|
|
|
void LanguageChanged_f(IConVar* pConVar, const char* pOldString, float flOldValue)
|
2023-08-01 22:45:58 +01:00
|
|
|
{
|
|
|
|
if (ConVar* pConVarRef = g_pCVar->FindVar(pConVar->GetCommandName()))
|
|
|
|
{
|
|
|
|
const char* pNewString = pConVarRef->GetString();
|
|
|
|
|
2023-09-16 13:08:56 +02:00
|
|
|
if (strcmp(pOldString, pConVarRef->GetString()) == NULL)
|
|
|
|
return; // Same language.
|
|
|
|
|
2023-09-16 00:45:11 +02:00
|
|
|
if (!Localize_IsLanguageSupported(pNewString))
|
2023-08-01 22:45:58 +01:00
|
|
|
{
|
2023-09-16 00:45:11 +02:00
|
|
|
// if new text isn't valid but the old value is, reset the value
|
|
|
|
if (Localize_IsLanguageSupported(pOldString))
|
|
|
|
pNewString = pOldString;
|
|
|
|
else // this shouldn't really happen, but if neither the old nor new values are valid, set to english
|
|
|
|
pNewString = g_LanguageNames[0];
|
2023-08-01 22:45:58 +01:00
|
|
|
}
|
2023-08-17 20:22:28 +01:00
|
|
|
|
2023-09-16 00:45:11 +02:00
|
|
|
pConVarRef->SetValue(pNewString);
|
2024-01-21 21:29:23 +01:00
|
|
|
g_MasterServer.SetLanguage(pNewString);
|
2023-08-01 22:45:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-25 19:35:08 +02:00
|
|
|
/*
|
|
|
|
=====================
|
|
|
|
RCON_PasswordChanged_f
|
|
|
|
|
2023-04-16 17:51:48 +02:00
|
|
|
Change RCON password
|
|
|
|
on server and client
|
2022-07-25 19:35:08 +02:00
|
|
|
=====================
|
|
|
|
*/
|
|
|
|
void RCON_PasswordChanged_f(IConVar* pConVar, const char* pOldString, float flOldValue)
|
|
|
|
{
|
2023-03-28 01:24:55 +02:00
|
|
|
if (ConVar* pConVarRef = g_pCVar->FindVar(pConVar->GetCommandName()))
|
2022-07-25 19:35:08 +02:00
|
|
|
{
|
2022-08-11 11:07:45 +02:00
|
|
|
if (strcmp(pOldString, pConVarRef->GetString()) == NULL)
|
|
|
|
return; // Same password.
|
|
|
|
|
2022-07-25 19:35:08 +02:00
|
|
|
#ifndef DEDICATED
|
2023-01-29 16:07:02 +01:00
|
|
|
if (!RCONClient()->IsInitialized())
|
2022-08-11 11:07:45 +02:00
|
|
|
RCONClient()->Init(); // Initialize first.
|
2023-01-29 16:07:02 +01:00
|
|
|
#endif // !DEDICATED
|
|
|
|
#ifndef CLIENT_DLL
|
2022-08-11 11:07:45 +02:00
|
|
|
if (RCONServer()->IsInitialized())
|
|
|
|
RCONServer()->SetPassword(pConVarRef->GetString());
|
|
|
|
else
|
|
|
|
RCONServer()->Init(); // Initialize first.
|
2023-01-29 16:07:02 +01:00
|
|
|
#endif // !CLIENT_DLL
|
2022-07-25 19:35:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-16 17:51:48 +02:00
|
|
|
#ifndef CLIENT_DLL
|
|
|
|
/*
|
|
|
|
=====================
|
|
|
|
RCON_WhiteListAddresChanged_f
|
|
|
|
|
|
|
|
Change whitelist address
|
|
|
|
on RCON server
|
|
|
|
=====================
|
|
|
|
*/
|
|
|
|
void RCON_WhiteListAddresChanged_f(IConVar* pConVar, const char* pOldString, float flOldValue)
|
|
|
|
{
|
|
|
|
if (ConVar* pConVarRef = g_pCVar->FindVar(pConVar->GetCommandName()))
|
|
|
|
{
|
|
|
|
if (strcmp(pOldString, pConVarRef->GetString()) == NULL)
|
|
|
|
return; // Same address.
|
|
|
|
|
|
|
|
if (!RCONServer()->SetWhiteListAddress(pConVarRef->GetString()))
|
|
|
|
{
|
2023-04-22 16:51:18 +02:00
|
|
|
Warning(eDLL_T::SERVER, "Failed to set RCON whitelist address: %s\n", pConVarRef->GetString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=====================
|
|
|
|
RCON_ConnectionCountChanged_f
|
|
|
|
|
|
|
|
Change max connection
|
|
|
|
count on RCON server
|
|
|
|
=====================
|
|
|
|
*/
|
|
|
|
void RCON_ConnectionCountChanged_f(IConVar* pConVar, const char* pOldString, float flOldValue)
|
|
|
|
{
|
|
|
|
if (!RCONServer()->IsInitialized())
|
|
|
|
return; // Not initialized; no sockets at this point.
|
|
|
|
|
|
|
|
if (ConVar* pConVarRef = g_pCVar->FindVar(pConVar->GetCommandName()))
|
|
|
|
{
|
|
|
|
if (strcmp(pOldString, pConVarRef->GetString()) == NULL)
|
|
|
|
return; // Same count.
|
|
|
|
|
|
|
|
const int maxCount = pConVarRef->GetInt();
|
|
|
|
|
|
|
|
int count = RCONServer()->GetAuthenticatedCount();
|
|
|
|
CSocketCreator* pCreator = RCONServer()->GetSocketCreator();
|
|
|
|
|
|
|
|
if (count < maxCount)
|
|
|
|
{
|
|
|
|
if (!pCreator->IsListening())
|
|
|
|
{
|
|
|
|
pCreator->CreateListenSocket(*RCONServer()->GetNetAddress());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while (count > maxCount)
|
|
|
|
{
|
|
|
|
RCONServer()->Disconnect(count-1, "too many authenticated sockets");
|
|
|
|
count = RCONServer()->GetAuthenticatedCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
pCreator->CloseListenSocket();
|
|
|
|
RCONServer()->CloseNonAuthConnection();
|
2023-04-16 17:51:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // !CLIENT_DLL
|
|
|
|
|
2022-05-16 21:15:25 +02:00
|
|
|
#ifndef DEDICATED
|
|
|
|
/*
|
|
|
|
=====================
|
|
|
|
Mat_CrossHair_f
|
|
|
|
|
|
|
|
Print the material under the crosshair.
|
|
|
|
=====================
|
|
|
|
*/
|
|
|
|
void Mat_CrossHair_f(const CCommand& args)
|
|
|
|
{
|
2024-01-02 15:21:36 +01:00
|
|
|
CMaterialGlue* material = v_GetMaterialAtCrossHair();
|
2022-05-16 21:15:25 +02:00
|
|
|
if (material)
|
|
|
|
{
|
2023-08-21 19:12:29 +02:00
|
|
|
Msg(eDLL_T::MS, "______________________________________________________________\n");
|
|
|
|
Msg(eDLL_T::MS, "-+ Material --------------------------------------------------\n");
|
|
|
|
Msg(eDLL_T::MS, " |-- ADDR: '%llX'\n", material);
|
2024-01-24 23:39:57 +01:00
|
|
|
Msg(eDLL_T::MS, " |-- GUID: '%llX'\n", material->assetGuid);
|
|
|
|
Msg(eDLL_T::MS, " |-- Num Streaming Textures: '%d'\n", material->numStreamingTextureHandles);
|
|
|
|
Msg(eDLL_T::MS, " |-- Material width: '%d'\n", material->width);
|
|
|
|
Msg(eDLL_T::MS, " |-- Material height: '%d'\n", material->height);
|
|
|
|
Msg(eDLL_T::MS, " |-- Samplers: '%08X'\n", material->samplers);
|
2022-05-16 21:15:25 +02:00
|
|
|
|
|
|
|
std::function<void(CMaterialGlue*, const char*)> fnPrintChild = [](CMaterialGlue* material, const char* print)
|
|
|
|
{
|
2023-08-21 19:12:29 +02:00
|
|
|
Msg(eDLL_T::MS, " |-+\n");
|
|
|
|
Msg(eDLL_T::MS, " | |-+ Child material ----------------------------------------\n");
|
|
|
|
Msg(eDLL_T::MS, print, material);
|
2024-01-24 23:39:57 +01:00
|
|
|
Msg(eDLL_T::MS, " | |-- GUID: '%llX'\n", material->assetGuid);
|
|
|
|
Msg(eDLL_T::MS, " | |-- Material name: '%s'\n", material->name);
|
2022-05-16 21:15:25 +02:00
|
|
|
};
|
|
|
|
|
2024-01-24 23:39:57 +01:00
|
|
|
Msg(eDLL_T::MS, " |-- Material name: '%s'\n", material->name);
|
|
|
|
Msg(eDLL_T::MS, " |-- Material surface name 1: '%s'\n", material->surfaceProp);
|
|
|
|
Msg(eDLL_T::MS, " |-- Material surface name 2: '%s'\n", material->surfaceProp2);
|
|
|
|
Msg(eDLL_T::MS, " |-- DX buffer: '%llX'\n", material->dxBuffer);
|
|
|
|
Msg(eDLL_T::MS, " |-- DX buffer VFTable: '%llX'\n", material->unkD3DPointer);
|
2022-10-13 02:22:50 +02:00
|
|
|
|
2024-01-24 23:39:57 +01:00
|
|
|
material->depthShadowMaterial
|
|
|
|
? fnPrintChild(material->depthShadowMaterial, " | |-+ DepthShadow: '%llX'\n")
|
2023-08-21 19:12:29 +02:00
|
|
|
: Msg(eDLL_T::MS, " | |-+ DepthShadow: 'NULL'\n");
|
2024-01-24 23:39:57 +01:00
|
|
|
material->depthPrepassMaterial
|
|
|
|
? fnPrintChild(material->depthPrepassMaterial, " | |-+ DepthPrepass: '%llX'\n")
|
2023-08-21 19:12:29 +02:00
|
|
|
: Msg(eDLL_T::MS, " | |-+ DepthPrepass: 'NULL'\n");
|
2024-01-24 23:39:57 +01:00
|
|
|
material->depthVSMMaterial
|
|
|
|
? fnPrintChild(material->depthVSMMaterial, " | |-+ DepthVSM: '%llX'\n")
|
2023-08-21 19:12:29 +02:00
|
|
|
: Msg(eDLL_T::MS, " | |-+ DepthVSM: 'NULL'\n");
|
2024-01-24 23:39:57 +01:00
|
|
|
material->depthShadowTightMaterial
|
|
|
|
? fnPrintChild(material->depthShadowTightMaterial, " | |-+ DepthShadowTight: '%llX'\n")
|
2023-08-21 19:12:29 +02:00
|
|
|
: Msg(eDLL_T::MS, " | |-+ DepthShadowTight: 'NULL'\n");
|
2024-01-24 23:39:57 +01:00
|
|
|
material->colpassMaterial
|
|
|
|
? fnPrintChild(material->colpassMaterial, " | |-+ ColPass: '%llX'\n")
|
2023-08-21 19:12:29 +02:00
|
|
|
: Msg(eDLL_T::MS, " | |-+ ColPass: 'NULL'\n");
|
2022-05-16 21:15:25 +02:00
|
|
|
|
2023-08-21 19:12:29 +02:00
|
|
|
Msg(eDLL_T::MS, "-+ Texture GUID map ------------------------------------------\n");
|
2024-01-24 23:39:57 +01:00
|
|
|
Msg(eDLL_T::MS, " |-- Texture handles: '%llX'\n", material->textureHandles);
|
|
|
|
Msg(eDLL_T::MS, " |-- Streaming texture handles: '%llX'\n", material->streamingTextureHandles);
|
2022-05-16 21:15:25 +02:00
|
|
|
|
2023-08-21 19:12:29 +02:00
|
|
|
Msg(eDLL_T::MS, "--------------------------------------------------------------\n");
|
2022-05-16 21:15:25 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-08-21 19:12:29 +02:00
|
|
|
Msg(eDLL_T::MS, "%s: No material found >:(\n", __FUNCTION__);
|
2022-05-16 21:15:25 +02:00
|
|
|
}
|
|
|
|
}
|
2022-07-12 17:46:47 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
=====================
|
|
|
|
Line_f
|
|
|
|
|
|
|
|
Draws a line at
|
|
|
|
start<x1 y1 z1> end<x2 y2 z2>.
|
|
|
|
=====================
|
|
|
|
*/
|
|
|
|
void Line_f(const CCommand& args)
|
|
|
|
{
|
|
|
|
if (args.ArgC() != 7)
|
|
|
|
{
|
2023-08-21 19:12:29 +02:00
|
|
|
Msg(eDLL_T::CLIENT, "Usage 'line': start(vector) end(vector)\n");
|
2022-07-12 17:46:47 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Vector3D start, end;
|
|
|
|
for (int i = 0; i < 3; ++i)
|
|
|
|
{
|
2023-04-02 00:59:24 +02:00
|
|
|
start[i] = float(atof(args[i + 1]));
|
|
|
|
end[i] = float(atof(args[i + 4]));
|
2022-07-12 17:46:47 +02:00
|
|
|
}
|
|
|
|
|
2023-01-24 12:05:09 +01:00
|
|
|
g_pDebugOverlay->AddLineOverlay(start, end, 255, 255, 0, !r_debug_draw_depth_test->GetBool(), 100);
|
2022-07-12 17:46:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=====================
|
|
|
|
Sphere_f
|
|
|
|
|
|
|
|
Draws a sphere at origin(x1 y1 z1)
|
|
|
|
radius(float) theta(int) phi(int).
|
|
|
|
=====================
|
|
|
|
*/
|
|
|
|
void Sphere_f(const CCommand& args)
|
|
|
|
{
|
|
|
|
if (args.ArgC() != 7)
|
|
|
|
{
|
2023-08-21 19:12:29 +02:00
|
|
|
Msg(eDLL_T::CLIENT, "Usage 'sphere': origin(vector) radius(float) theta(int) phi(int)\n");
|
2022-07-12 17:46:47 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Vector3D start;
|
|
|
|
for (int i = 0; i < 3; ++i)
|
|
|
|
{
|
2023-04-02 00:59:24 +02:00
|
|
|
start[i] = float(atof(args[i + 1]));
|
2022-07-12 17:46:47 +02:00
|
|
|
}
|
|
|
|
|
2023-04-02 00:59:24 +02:00
|
|
|
float radius = float(atof(args[4]));
|
2022-07-12 17:46:47 +02:00
|
|
|
int theta = atoi(args[5]);
|
|
|
|
int phi = atoi(args[6]);
|
|
|
|
|
|
|
|
g_pDebugOverlay->AddSphereOverlay(start, radius, theta, phi, 20, 210, 255, 0, 100);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=====================
|
|
|
|
Capsule_f
|
|
|
|
|
|
|
|
Draws a capsule at start<x1 y1 z1>
|
|
|
|
end<x2 y2 z2> radius <x3 y3 z3>.
|
|
|
|
=====================
|
|
|
|
*/
|
|
|
|
void Capsule_f(const CCommand& args)
|
|
|
|
{
|
|
|
|
if (args.ArgC() != 10)
|
|
|
|
{
|
2023-08-21 19:12:29 +02:00
|
|
|
Msg(eDLL_T::CLIENT, "Usage 'capsule': start(vector) end(vector) radius(vector)\n");
|
2022-07-12 17:46:47 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Vector3D start, end, radius;
|
|
|
|
for (int i = 0; i < 3; ++i)
|
|
|
|
{
|
2023-04-02 00:59:24 +02:00
|
|
|
start[i] = float(atof(args[i + 1]));
|
|
|
|
end[i] = float(atof(args[i + 4]));
|
|
|
|
radius[i] = float(atof(args[i + 7]));
|
2022-07-12 17:46:47 +02:00
|
|
|
}
|
|
|
|
g_pDebugOverlay->AddCapsuleOverlay(start, end, radius, { 0,0,0 }, { 0,0,0 }, 141, 233, 135, 0, 100);
|
|
|
|
}
|
|
|
|
#endif // !DEDICATED
|
2024-01-02 15:21:36 +01:00
|
|
|
|
2022-07-30 00:54:33 +02:00
|
|
|
/*
|
|
|
|
=====================
|
|
|
|
BHit_f
|
|
|
|
|
|
|
|
Bullet trajectory tracing
|
|
|
|
from shooter to target entity.
|
|
|
|
=====================
|
|
|
|
*/
|
|
|
|
void BHit_f(const CCommand& args)
|
|
|
|
{
|
2023-01-24 18:39:12 +01:00
|
|
|
#ifndef CLIENT_DLL // Stubbed to suppress server warnings as this is a GAMEDLL command!
|
2022-07-30 00:54:33 +02:00
|
|
|
if (args.ArgC() != 9)
|
|
|
|
return;
|
|
|
|
|
2023-01-22 12:12:06 +01:00
|
|
|
if (!bhit_enable->GetBool())
|
2022-10-11 01:32:43 +02:00
|
|
|
return;
|
2022-07-30 00:54:33 +02:00
|
|
|
|
2023-01-22 12:12:06 +01:00
|
|
|
if (sv_visualizetraces->GetBool())
|
|
|
|
{
|
|
|
|
Vector3D vecAbsStart;
|
|
|
|
Vector3D vecAbsEnd;
|
2022-10-11 01:32:43 +02:00
|
|
|
|
2023-01-22 12:12:06 +01:00
|
|
|
for (int i = 0; i < 3; ++i)
|
2023-04-02 00:59:24 +02:00
|
|
|
vecAbsStart[i] = float(atof(args[i + 4]));
|
2022-07-30 00:54:33 +02:00
|
|
|
|
2023-01-22 12:12:06 +01:00
|
|
|
QAngle vecBulletAngles;
|
|
|
|
for (int i = 0; i < 2; ++i)
|
2023-04-02 00:59:24 +02:00
|
|
|
vecBulletAngles[i] = float(atof(args[i + 7]));
|
2022-07-30 00:54:33 +02:00
|
|
|
|
2023-01-22 12:12:06 +01:00
|
|
|
vecBulletAngles.z = 180.f; // Flipped axis.
|
|
|
|
AngleVectors(vecBulletAngles, &vecAbsEnd);
|
2022-07-30 00:54:33 +02:00
|
|
|
|
2023-01-22 12:12:06 +01:00
|
|
|
vecAbsEnd.MulAdd(vecAbsStart, vecAbsEnd, MAX_COORD_RANGE);
|
2022-10-01 00:27:51 +02:00
|
|
|
|
2023-01-22 12:12:06 +01:00
|
|
|
Ray_t ray(vecAbsStart, vecAbsEnd);
|
|
|
|
trace_t trace;
|
2023-01-22 12:09:12 +01:00
|
|
|
|
2023-01-22 12:12:06 +01:00
|
|
|
g_pEngineTraceServer->TraceRay(ray, TRACE_MASK_NPCWORLDSTATIC, &trace);
|
2023-01-22 12:09:12 +01:00
|
|
|
|
2023-01-24 12:05:09 +01:00
|
|
|
g_pDebugOverlay->AddLineOverlay(trace.startpos, trace.endpos, 0, 255, 0, !bhit_depth_test->GetBool(), sv_visualizetraces_duration->GetFloat());
|
|
|
|
g_pDebugOverlay->AddLineOverlay(trace.endpos, vecAbsEnd, 255, 0, 0, !bhit_depth_test->GetBool(), sv_visualizetraces_duration->GetFloat());
|
2023-01-22 12:12:06 +01:00
|
|
|
}
|
2023-01-24 18:39:12 +01:00
|
|
|
#endif // !CLIENT_DLL
|
2023-01-22 12:09:12 +01:00
|
|
|
|
2023-01-24 18:39:12 +01:00
|
|
|
#ifndef DEDICATED
|
2023-01-22 12:09:12 +01:00
|
|
|
if (bhit_abs_origin->GetBool() && r_visualizetraces->GetBool())
|
2022-10-11 01:32:43 +02:00
|
|
|
{
|
2022-11-24 15:43:26 +01:00
|
|
|
const int iEnt = atoi(args[2]);
|
2022-10-11 01:32:43 +02:00
|
|
|
if (const IClientEntity* pEntity = g_pClientEntityList->GetClientEntity(iEnt))
|
2022-10-01 00:27:51 +02:00
|
|
|
{
|
2022-10-11 01:32:43 +02:00
|
|
|
g_pDebugOverlay->AddSphereOverlay( // Render a debug sphere at the client's predicted entity origin.
|
2023-01-22 12:09:12 +01:00
|
|
|
pEntity->GetAbsOrigin(), 10.f, 8, 6, 20, 60, 255, 0, r_visualizetraces_duration->GetFloat());
|
2022-10-01 00:27:51 +02:00
|
|
|
}
|
2022-07-30 00:54:33 +02:00
|
|
|
}
|
2022-08-04 11:06:56 +02:00
|
|
|
#endif // !DEDICATED
|
2022-07-30 00:54:33 +02:00
|
|
|
}
|
2024-01-02 15:21:36 +01:00
|
|
|
|
2022-08-13 12:57:52 +02:00
|
|
|
/*
|
|
|
|
=====================
|
|
|
|
CVHelp_f
|
|
|
|
|
|
|
|
Show help text for a
|
|
|
|
particular convar/concommand
|
|
|
|
=====================
|
|
|
|
*/
|
|
|
|
void CVHelp_f(const CCommand& args)
|
|
|
|
{
|
|
|
|
cv->CvarHelp(args);
|
|
|
|
}
|
|
|
|
|
2022-08-13 12:39:57 +02:00
|
|
|
/*
|
|
|
|
=====================
|
|
|
|
CVList_f
|
|
|
|
|
|
|
|
List all ConCommandBases
|
|
|
|
=====================
|
|
|
|
*/
|
|
|
|
void CVList_f(const CCommand& args)
|
|
|
|
{
|
|
|
|
cv->CvarList(args);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=====================
|
|
|
|
CVDiff_f
|
|
|
|
|
|
|
|
List all ConVar's
|
|
|
|
who's values deviate
|
|
|
|
from default value
|
|
|
|
=====================
|
|
|
|
*/
|
|
|
|
void CVDiff_f(const CCommand& args)
|
|
|
|
{
|
|
|
|
cv->CvarDifferences(args);
|
|
|
|
}
|
2022-08-13 13:06:30 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
=====================
|
|
|
|
CVFlag_f
|
|
|
|
|
|
|
|
List all ConVar's
|
|
|
|
with specified flags
|
|
|
|
=====================
|
|
|
|
*/
|
|
|
|
void CVFlag_f(const CCommand& args)
|
|
|
|
{
|
|
|
|
cv->CvarFindFlags_f(args);
|
|
|
|
}
|
2023-01-16 15:52:33 +01:00
|
|
|
|
2023-12-30 17:31:55 +01:00
|
|
|
#ifndef DEDICATED
|
|
|
|
static double s_flScriptExecTimeBase = 0.0f;
|
|
|
|
static int s_nScriptExecCount = 0;
|
|
|
|
#endif // !DEDICATED
|
2023-10-15 10:40:46 +02:00
|
|
|
/*
|
|
|
|
=====================
|
|
|
|
Cmd_Exec_f
|
|
|
|
|
|
|
|
executes a cfg file
|
|
|
|
=====================
|
|
|
|
*/
|
|
|
|
void Cmd_Exec_f(const CCommand& args)
|
|
|
|
{
|
|
|
|
#ifndef DEDICATED
|
|
|
|
// Prevent users from running neo strafe commands and other quick hacks.
|
|
|
|
// TODO: when reBar becomes a thing, we should verify this function and
|
|
|
|
// flag users that patch them out.
|
2023-12-30 17:31:55 +01:00
|
|
|
if (!ThreadInServerFrameThread() && g_pClientState->IsActive())
|
2023-10-15 10:40:46 +02:00
|
|
|
{
|
2023-12-30 17:31:55 +01:00
|
|
|
const int execQuota = sv_quota_scriptExecsPerSecond->GetInt();
|
2023-10-15 10:40:46 +02:00
|
|
|
|
2023-12-30 17:31:55 +01:00
|
|
|
if (execQuota > 0)
|
|
|
|
{
|
|
|
|
const double flCurrentTime = Plat_FloatTime();
|
|
|
|
|
|
|
|
// Reset every second.
|
|
|
|
if ((flCurrentTime - s_flScriptExecTimeBase) > 1.0)
|
|
|
|
{
|
|
|
|
s_flScriptExecTimeBase = flCurrentTime;
|
|
|
|
s_nScriptExecCount = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (s_nScriptExecCount >= execQuota)
|
|
|
|
{
|
|
|
|
DevWarning(eDLL_T::ENGINE, "Client is simulating and exec count = %d of %d; dropped exec command: %s\n",
|
|
|
|
s_nScriptExecCount, execQuota, args.ArgS());
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
s_nScriptExecCount++;
|
|
|
|
}
|
2023-10-15 10:40:46 +02:00
|
|
|
}
|
|
|
|
#endif // !DEDICATED
|
2024-01-02 15:21:36 +01:00
|
|
|
v__Cmd_Exec_f(args);
|
2023-10-15 10:40:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-11-26 13:21:20 +01:00
|
|
|
void VCallback::Detour(const bool bAttach) const
|
2023-10-15 10:40:46 +02:00
|
|
|
{
|
2024-01-02 15:21:36 +01:00
|
|
|
DetourSetup(&v__Cmd_Exec_f, &Cmd_Exec_f, bAttach);
|
2023-10-15 10:40:46 +02:00
|
|
|
}
|