r5sdk/r5dev/tier1/cvar.cpp

218 lines
9.4 KiB
C++
Raw Normal View History

Code base refactor + major performance and readability improvement. Read description for details. * Codebase restructured to SourceSDK codebase style and .cpp/.h assertion paths in the game executable. * Document most functions with valve style 'Purpose' blocks. * Rename variables to match the rest of the codebase and Valve's naming convention. * Dedicated DLL and the SDKLauncher now share the same codebase as the DevSDK. * Obtain globals or pointers directly instead of waiting for runtime initialized data. * Dynamically search for all functions and globals (this doesn't count for dedicated yet!). * Initialize most in-SDK variables. * Move certain prints and other utilities under ConVars to reduce verbosity and increase performance. * Print all pattern scan results through a virtual function to make it easier to add and debug new patterns in the future. * Type global var pointers appropriately if class or type is known and implemented. * Forward declare 'CClient' class to avoid having 2 'g_pClient' copies. * Add IDA's pseudo definitions for easier prototyping with decompiled assembly code. * RPAK decompress Command callback implementation. * Load decompressed RPaks from 'paks\Win32\' overriding the ones in 'paks\Win64\' (the decompress callback will automatically fix the header and write it to 'paks\Win32\'). * VPK decompress Command callback implementation. * Move CRC32 ands Adler32 to implementation files. * Server will print out more details about the connecting client. * Upgrade ImGui lib to v1.86. * Don't compile id3dx.h for dedicated. * Don't compile id3dx.cpp for dedicated * Implement DevMsg print function allowing to print information to the in-game VGUI/RUI console overlay, ImGui console overlay and the external windows console * Fixed bug where the Error function would not properly terminate the process when an error is called. This caused access violations for critical/non-recoverable errors. * Fixed bug where the game would crash if the console or server browser was enabled while the game was still starting up. * Several bug fixes for the dedicated server (warning: dedicated is still considered work-in-progress!).
2021-12-25 22:36:38 +01:00
#include "core/stdafx.h"
#include "tier1/cvar.h"
#include "tier1/IConVar.h"
Code base refactor + major performance and readability improvement. Read description for details. * Codebase restructured to SourceSDK codebase style and .cpp/.h assertion paths in the game executable. * Document most functions with valve style 'Purpose' blocks. * Rename variables to match the rest of the codebase and Valve's naming convention. * Dedicated DLL and the SDKLauncher now share the same codebase as the DevSDK. * Obtain globals or pointers directly instead of waiting for runtime initialized data. * Dynamically search for all functions and globals (this doesn't count for dedicated yet!). * Initialize most in-SDK variables. * Move certain prints and other utilities under ConVars to reduce verbosity and increase performance. * Print all pattern scan results through a virtual function to make it easier to add and debug new patterns in the future. * Type global var pointers appropriately if class or type is known and implemented. * Forward declare 'CClient' class to avoid having 2 'g_pClient' copies. * Add IDA's pseudo definitions for easier prototyping with decompiled assembly code. * RPAK decompress Command callback implementation. * Load decompressed RPaks from 'paks\Win32\' overriding the ones in 'paks\Win64\' (the decompress callback will automatically fix the header and write it to 'paks\Win32\'). * VPK decompress Command callback implementation. * Move CRC32 ands Adler32 to implementation files. * Server will print out more details about the connecting client. * Upgrade ImGui lib to v1.86. * Don't compile id3dx.h for dedicated. * Don't compile id3dx.cpp for dedicated * Implement DevMsg print function allowing to print information to the in-game VGUI/RUI console overlay, ImGui console overlay and the external windows console * Fixed bug where the Error function would not properly terminate the process when an error is called. This caused access violations for critical/non-recoverable errors. * Fixed bug where the game would crash if the console or server browser was enabled while the game was still starting up. * Several bug fixes for the dedicated server (warning: dedicated is still considered work-in-progress!).
2021-12-25 22:36:38 +01:00
#include "engine/sys_dll2.h"
//-----------------------------------------------------------------------------
// ENGINE |
ConVar* single_frame_shutdown_for_reload = nullptr;
ConVar* old_gather_props = nullptr;
2022-06-15 01:24:29 +02:00
ConVar* enable_debug_overlays = nullptr;
ConVar* staticProp_defaultBuildFrustum = nullptr;
ConVar* staticProp_no_fade_scalar = nullptr;
ConVar* staticProp_gather_size_weight = nullptr;
ConVar* model_defaultFadeDistScale = nullptr;
ConVar* model_defaultFadeDistMin = nullptr;
ConVar* hostname = nullptr;
ConVar* hostport = nullptr;
ConVar* host_hasIrreversibleShutdown = nullptr;
ConVar* mp_gamemode = nullptr;
2022-02-21 12:06:05 +01:00
ConVar* cm_debug_cmdquery = nullptr;
ConVar* cm_unset_all_cmdquery = nullptr;
ConVar* cm_unset_dev_cmdquery = nullptr;
ConVar* cm_unset_cheat_cmdquery = nullptr;
2022-02-06 15:54:52 +01:00
2022-02-21 12:06:05 +01:00
ConVar* rcon_address = nullptr;
ConVar* rcon_password = nullptr;
ConVar* r_debug_overlay_nodecay = nullptr;
ConVar* r_drawWorldMeshes = nullptr;
ConVar* r_drawWorldMeshesDepthOnly = nullptr;
ConVar* r_drawWorldMeshesDepthAtTheEnd = nullptr;
//-----------------------------------------------------------------------------
// SERVER |
ConVar* ai_ainDumpOnLoad = nullptr;
ConVar* ai_ainDebugConnect = nullptr;
ConVar* navmesh_always_reachable = nullptr;
2022-02-21 12:06:05 +01:00
ConVar* sv_showconnecting = nullptr;
2022-05-24 19:26:05 +02:00
ConVar* sv_pylonVisibility = nullptr;
ConVar* sv_pylonRefreshInterval = nullptr;
ConVar* sv_banlistRefreshInterval = nullptr;
ConVar* sv_statusRefreshInterval = nullptr;
2022-02-06 15:54:52 +01:00
#ifdef DEDICATED
2022-02-21 12:06:05 +01:00
ConVar* sv_rcon_debug = nullptr;
ConVar* sv_rcon_banpenalty = nullptr; // TODO
ConVar* sv_rcon_maxfailures = nullptr;
ConVar* sv_rcon_maxignores = nullptr;
ConVar* sv_rcon_maxsockets = nullptr;
ConVar* sv_rcon_whitelist_address = nullptr;
#endif // DEDICATED
//-----------------------------------------------------------------------------
// CLIENT |
#ifndef DEDICATED
2022-02-21 12:06:05 +01:00
ConVar* cl_drawconsoleoverlay = nullptr;
ConVar* cl_consoleoverlay_lines = nullptr;
ConVar* cl_consoleoverlay_invert_rect_x = nullptr;
ConVar* cl_consoleoverlay_invert_rect_y = nullptr;
2022-02-21 12:06:05 +01:00
ConVar* cl_consoleoverlay_offset_x = nullptr;
ConVar* cl_consoleoverlay_offset_y = nullptr;
2022-02-21 12:06:05 +01:00
ConVar* cl_conoverlay_script_server_clr = nullptr;
ConVar* cl_conoverlay_script_client_clr = nullptr;
ConVar* cl_conoverlay_script_ui_clr = nullptr;
ConVar* cl_conoverlay_native_server_clr = nullptr;
ConVar* cl_conoverlay_native_client_clr = nullptr;
ConVar* cl_conoverlay_native_ui_clr = nullptr;
ConVar* cl_conoverlay_native_engine_clr = nullptr;
ConVar* cl_conoverlay_native_fs_clr = nullptr;
ConVar* cl_conoverlay_native_rtech_clr = nullptr;
ConVar* cl_conoverlay_native_ms_clr = nullptr;
ConVar* cl_conoverlay_netcon_clr = nullptr;
ConVar* cl_conoverlay_warning_clr = nullptr;
ConVar* cl_conoverlay_error_clr = nullptr;
ConVar* cl_showhoststats = nullptr;
ConVar* cl_hoststats_invert_rect_x = nullptr;
ConVar* cl_hoststats_invert_rect_y = nullptr;
ConVar* cl_hoststats_offset_x = nullptr;
ConVar* cl_hoststats_offset_y = nullptr;
2022-02-21 12:06:05 +01:00
ConVar* cl_showsimstats = nullptr;
ConVar* cl_simstats_invert_rect_x = nullptr;
ConVar* cl_simstats_invert_rect_y = nullptr;
2022-02-21 12:06:05 +01:00
ConVar* cl_simstats_offset_x = nullptr;
ConVar* cl_simstats_offset_y = nullptr;
2022-02-21 12:06:05 +01:00
ConVar* cl_showgpustats = nullptr;
ConVar* cl_gpustats_invert_rect_x = nullptr;
ConVar* cl_gpustats_invert_rect_y = nullptr;
2022-02-21 12:06:05 +01:00
ConVar* cl_gpustats_offset_x = nullptr;
ConVar* cl_gpustats_offset_y = nullptr;
2022-02-21 12:06:05 +01:00
ConVar* con_max_size_logvector = nullptr;
ConVar* con_suggestion_limit = nullptr;
ConVar* con_suggestion_showhelptext = nullptr;
ConVar* con_suggestion_showflags = nullptr;
ConVar* con_suggestion_flags_realtime = nullptr;
#endif // !DEDICATED
//-----------------------------------------------------------------------------
// FILESYSTEM |
2022-02-21 12:06:05 +01:00
ConVar* fs_warning_level_sdk = nullptr;
ConVar* fs_show_warning_output = nullptr;
ConVar* fs_packedstore_entryblock_stats = nullptr;
ConVar* fs_packedstore_workspace = nullptr;
//-----------------------------------------------------------------------------
// MATERIALSYSTEM |
#ifndef DEDICATED
2022-02-21 12:06:05 +01:00
ConVar* mat_showdxoutput = nullptr;
#endif // !DEDICATED
//-----------------------------------------------------------------------------
// SQUIRREL |
2022-02-21 12:06:05 +01:00
ConVar* sq_showrsonloading = nullptr;
ConVar* sq_showscriptloading = nullptr;
ConVar* sq_showvmoutput = nullptr;
ConVar* sq_showvmwarning = nullptr;
//-----------------------------------------------------------------------------
// NETCHANNEL |
ConVar* net_tracePayload = nullptr;
ConVar* net_encryptionEnable = nullptr;
ConVar* net_useRandomKey = nullptr;
ConVar* net_usesocketsforloopback = nullptr;
2022-02-21 12:06:05 +01:00
ConVar* r5net_matchmaking_hostname = nullptr;
ConVar* r5net_show_debug = nullptr;
//-----------------------------------------------------------------------------
// RTECH API |
//-----------------------------------------------------------------------------
// RUI |
#ifndef DEDICATED
ConVar* rui_drawEnable = nullptr;
#endif // !DEDICATED
Code base refactor + major performance and readability improvement. Read description for details. * Codebase restructured to SourceSDK codebase style and .cpp/.h assertion paths in the game executable. * Document most functions with valve style 'Purpose' blocks. * Rename variables to match the rest of the codebase and Valve's naming convention. * Dedicated DLL and the SDKLauncher now share the same codebase as the DevSDK. * Obtain globals or pointers directly instead of waiting for runtime initialized data. * Dynamically search for all functions and globals (this doesn't count for dedicated yet!). * Initialize most in-SDK variables. * Move certain prints and other utilities under ConVars to reduce verbosity and increase performance. * Print all pattern scan results through a virtual function to make it easier to add and debug new patterns in the future. * Type global var pointers appropriately if class or type is known and implemented. * Forward declare 'CClient' class to avoid having 2 'g_pClient' copies. * Add IDA's pseudo definitions for easier prototyping with decompiled assembly code. * RPAK decompress Command callback implementation. * Load decompressed RPaks from 'paks\Win32\' overriding the ones in 'paks\Win64\' (the decompress callback will automatically fix the header and write it to 'paks\Win32\'). * VPK decompress Command callback implementation. * Move CRC32 ands Adler32 to implementation files. * Server will print out more details about the connecting client. * Upgrade ImGui lib to v1.86. * Don't compile id3dx.h for dedicated. * Don't compile id3dx.cpp for dedicated * Implement DevMsg print function allowing to print information to the in-game VGUI/RUI console overlay, ImGui console overlay and the external windows console * Fixed bug where the Error function would not properly terminate the process when an error is called. This caused access violations for critical/non-recoverable errors. * Fixed bug where the game would crash if the console or server browser was enabled while the game was still starting up. * Several bug fixes for the dedicated server (warning: dedicated is still considered work-in-progress!).
2021-12-25 22:36:38 +01:00
//-----------------------------------------------------------------------------
// Purpose: registers input commands.
// Input : *pszCommandName -
//-----------------------------------------------------------------------------
ConCommandBase* CCVar::RegisterConCommand(ConCommandBase* pCommandToRemove)
{
static int index = 9;
return CallVFunc<ConCommandBase*>(index, this, pCommandToRemove);
}
//-----------------------------------------------------------------------------
// Purpose: unregisters input commands.
// Input : *pszCommandName -
//-----------------------------------------------------------------------------
ConCommandBase* CCVar::UnregisterConCommand(ConCommandBase* pCommandToRemove)
{
static int index = 10;
return CallVFunc<ConCommandBase*>(index, this, pCommandToRemove);
}
//-----------------------------------------------------------------------------
// Purpose: finds base commands.
// Input : *pszCommandName -
//-----------------------------------------------------------------------------
ConCommandBase* CCVar::FindCommandBase(const char* pszCommandName)
{
static int index = 14;
return CallVFunc<ConCommandBase*>(index, this, pszCommandName);
}
//-----------------------------------------------------------------------------
// Purpose: finds ConVars.
// Input : *pszVarName -
//-----------------------------------------------------------------------------
ConVar* CCVar::FindVar(const char* pszVarName)
{
static int index = 16;
return CallVFunc<ConVar*>(index, this, pszVarName);
}
//-----------------------------------------------------------------------------
// Purpose: finds ConCommands.
// Input : *pszCommandName -
//-----------------------------------------------------------------------------
ConCommand* CCVar::FindCommand(const char* pszCommandName)
{
static int index = 18;
return CallVFunc<ConCommand*>(index, this, pszCommandName);
}
//-----------------------------------------------------------------------------
// Purpose: iterates over all ConVars
//-----------------------------------------------------------------------------
CCVarIteratorInternal* CCVar::FactoryInternalIterator(void)
{
static int index = 41;
return CallVFunc<CCVarIteratorInternal*>(index, this);
}
//-----------------------------------------------------------------------------
// Purpose: returns all ConVars
//-----------------------------------------------------------------------------
unordered_map<string, ConCommandBase*> CCVar::DumpToMap(void)
{
stringstream ss;
CCVarIteratorInternal* itint = FactoryInternalIterator(); // Allocate new InternalIterator.
unordered_map<string, ConCommandBase*> allConVars;
for (itint->SetFirst(); itint->IsValid(); itint->Next()) // Loop through all instances.
{
ConCommandBase* pCommand = itint->Get();
const char* pszCommandName = pCommand->m_pszName;
allConVars[pszCommandName] = pCommand;
}
return allConVars;
}
Code base refactor + major performance and readability improvement. Read description for details. * Codebase restructured to SourceSDK codebase style and .cpp/.h assertion paths in the game executable. * Document most functions with valve style 'Purpose' blocks. * Rename variables to match the rest of the codebase and Valve's naming convention. * Dedicated DLL and the SDKLauncher now share the same codebase as the DevSDK. * Obtain globals or pointers directly instead of waiting for runtime initialized data. * Dynamically search for all functions and globals (this doesn't count for dedicated yet!). * Initialize most in-SDK variables. * Move certain prints and other utilities under ConVars to reduce verbosity and increase performance. * Print all pattern scan results through a virtual function to make it easier to add and debug new patterns in the future. * Type global var pointers appropriately if class or type is known and implemented. * Forward declare 'CClient' class to avoid having 2 'g_pClient' copies. * Add IDA's pseudo definitions for easier prototyping with decompiled assembly code. * RPAK decompress Command callback implementation. * Load decompressed RPaks from 'paks\Win32\' overriding the ones in 'paks\Win64\' (the decompress callback will automatically fix the header and write it to 'paks\Win32\'). * VPK decompress Command callback implementation. * Move CRC32 ands Adler32 to implementation files. * Server will print out more details about the connecting client. * Upgrade ImGui lib to v1.86. * Don't compile id3dx.h for dedicated. * Don't compile id3dx.cpp for dedicated * Implement DevMsg print function allowing to print information to the in-game VGUI/RUI console overlay, ImGui console overlay and the external windows console * Fixed bug where the Error function would not properly terminate the process when an error is called. This caused access violations for critical/non-recoverable errors. * Fixed bug where the game would crash if the console or server browser was enabled while the game was still starting up. * Several bug fixes for the dedicated server (warning: dedicated is still considered work-in-progress!).
2021-12-25 22:36:38 +01:00
///////////////////////////////////////////////////////////////////////////////
CCVar* g_pCVar = nullptr;