From c292d8ad46b22c7a34c6d3caf8143e131e8dd997 Mon Sep 17 00:00:00 2001
From: Amos <48657826+Mauler125@users.noreply.github.com>
Date: Sun, 9 Jan 2022 16:14:17 +0100
Subject: [PATCH] Implement new ConVar features
Slight cleanup with new ConVar features to be used throughout the SDK
---
r5dev/client/cdll_engine_int.cpp | 6 +-
r5dev/core/init.cpp | 2 +-
r5dev/dedicated.vcxproj | 2 +
r5dev/dedicated.vcxproj.filters | 6 +
r5dev/engine/host_state.cpp | 4 +-
r5dev/mathlib/bits.cpp | 46 +++
r5dev/mathlib/bits.h | 10 +
r5dev/r5dev.vcxproj | 2 +
r5dev/r5dev.vcxproj.filters | 6 +
r5dev/tier0/ConCommand.cpp | 199 +++++-----
r5dev/tier0/ConCommand.h | 35 +-
r5dev/tier0/IConVar.cpp | 618 ++++++++++++++++++++++++++-----
r5dev/tier0/IConVar.h | 132 +++----
r5dev/tier0/cvar.cpp | 87 ++++-
r5dev/tier0/cvar.h | 22 ++
r5dev/vgui/CEngineVGui.cpp | 17 +-
16 files changed, 889 insertions(+), 305 deletions(-)
create mode 100644 r5dev/mathlib/bits.cpp
create mode 100644 r5dev/mathlib/bits.h
diff --git a/r5dev/client/cdll_engine_int.cpp b/r5dev/client/cdll_engine_int.cpp
index 88347cb1..d41076e5 100644
--- a/r5dev/client/cdll_engine_int.cpp
+++ b/r5dev/client/cdll_engine_int.cpp
@@ -24,10 +24,10 @@ void __fastcall HFrameStageNotify(CHLClient* rcx, ClientFrameStage_t frameStage)
if (!bInitialized)
{
#ifdef GAMEDLL_S3
- IConVar_ClearHostNames(); // TODO: S1/S2
+ g_pConVar->ClearHostNames();
#endif // GAMEDLL_S3
- ConCommand_InitConCommand();
+ g_pConCommand->Init();
CKeyValueSystem_Init();
IVEngineClient_CommandExecute(NULL, "exec autoexec.cfg");
@@ -42,7 +42,7 @@ void __fastcall HFrameStageNotify(CHLClient* rcx, ClientFrameStage_t frameStage)
{
HNET_GenerateKey();
}
- g_pCvar->FindVar("net_usesocketsforloopback")->m_pParent->m_iValue = 1;
+ g_pCvar->FindVar("net_usesocketsforloopback")->SetValue(1);
bInitialized = true;
}
diff --git a/r5dev/core/init.cpp b/r5dev/core/init.cpp
index e90dbc93..8e582944 100644
--- a/r5dev/core/init.cpp
+++ b/r5dev/core/init.cpp
@@ -114,7 +114,7 @@ void Systems_Init()
TerminateProcess(GetCurrentProcess(), 0xBAD0C0DE);
}
- IConVar_InitConVar();
+ g_pConVar->Init();
#ifdef DEDICATED
Dedicated_Init();
diff --git a/r5dev/dedicated.vcxproj b/r5dev/dedicated.vcxproj
index 017a8898..a65957fe 100644
--- a/r5dev/dedicated.vcxproj
+++ b/r5dev/dedicated.vcxproj
@@ -189,6 +189,7 @@
+
@@ -373,6 +374,7 @@
+
diff --git a/r5dev/dedicated.vcxproj.filters b/r5dev/dedicated.vcxproj.filters
index c110b5a1..55f98901 100644
--- a/r5dev/dedicated.vcxproj.filters
+++ b/r5dev/dedicated.vcxproj.filters
@@ -657,6 +657,9 @@
thirdparty\lzham\lzhamdecomp\include
+
+ sdk\mathlib
+
@@ -857,6 +860,9 @@
thirdparty\lzham\lzhamdecomp
+
+ sdk\mathlib
+
diff --git a/r5dev/engine/host_state.cpp b/r5dev/engine/host_state.cpp
index 884cb360..1a741f37 100644
--- a/r5dev/engine/host_state.cpp
+++ b/r5dev/engine/host_state.cpp
@@ -129,8 +129,8 @@ void HCHostState_FrameUpdate(void* rcx, void* rdx, float time)
static bool bInitialized = false;
if (!bInitialized)
{
- IConVar_ClearHostNames();
- ConCommand_InitConCommand();
+ g_pConCommand->Init();
+ g_pConVar->ClearHostNames();
IVEngineClient_CommandExecute(NULL, "exec autoexec.cfg");
IVEngineClient_CommandExecute(NULL, "exec autoexec_server.cfg");
diff --git a/r5dev/mathlib/bits.cpp b/r5dev/mathlib/bits.cpp
new file mode 100644
index 00000000..a4bce347
--- /dev/null
+++ b/r5dev/mathlib/bits.cpp
@@ -0,0 +1,46 @@
+//=============================================================================//
+//
+// Purpose: look for NANs, infinities, and underflows.
+//
+//=============================================================================//
+
+#include "core/stdafx.h"
+#include "mathlib/bits.h"
+
+//-----------------------------------------------------------------------------
+// This follows the ANSI/IEEE 754-1985 standard
+//-----------------------------------------------------------------------------
+unsigned long& FloatBits(float& f)
+{
+ return *reinterpret_cast(&f);
+}
+
+unsigned long const& FloatBits(float const& f)
+{
+ return *reinterpret_cast(&f);
+}
+
+float BitsToFloat(unsigned long i)
+{
+ return *reinterpret_cast(&i);
+}
+
+bool IsFinite(float f)
+{
+ return ((FloatBits(f) & 0x7F800000) != 0x7F800000);
+}
+
+unsigned long FloatAbsBits(float f)
+{
+ return FloatBits(f) & 0x7FFFFFFF;
+}
+
+float FloatMakePositive(float f)
+{
+ return fabsf(f);
+}
+
+float FloatNegate(float f)
+{
+ return -f; //BitsToFloat( FloatBits(f) ^ 0x80000000 );
+}
diff --git a/r5dev/mathlib/bits.h b/r5dev/mathlib/bits.h
new file mode 100644
index 00000000..b35bcf47
--- /dev/null
+++ b/r5dev/mathlib/bits.h
@@ -0,0 +1,10 @@
+#pragma once
+
+unsigned long& FloatBits(float& f);
+unsigned long const& FloatBits(float const& f);
+float BitsToFloat(unsigned long i);
+bool IsFinite(float f);
+unsigned long FloatAbsBits(float f);
+
+#define FLOAT32_NAN_BITS (std::uint32_t)0x7FC00000 // NaN!
+#define FLOAT32_NAN BitsToFloat( FLOAT32_NAN_BITS )
diff --git a/r5dev/r5dev.vcxproj b/r5dev/r5dev.vcxproj
index 8d942be3..0f8ec856 100644
--- a/r5dev/r5dev.vcxproj
+++ b/r5dev/r5dev.vcxproj
@@ -44,6 +44,7 @@
+
@@ -236,6 +237,7 @@
+
diff --git a/r5dev/r5dev.vcxproj.filters b/r5dev/r5dev.vcxproj.filters
index 818da70f..dc8d19c2 100644
--- a/r5dev/r5dev.vcxproj.filters
+++ b/r5dev/r5dev.vcxproj.filters
@@ -396,6 +396,9 @@
thirdparty\lzham\lzhamdecomp
+
+ sdk\mathlib
+
@@ -1028,6 +1031,9 @@
thirdparty\lzham\lzhamdecomp\include
+
+ sdk\mathlib
+
diff --git a/r5dev/tier0/ConCommand.cpp b/r5dev/tier0/ConCommand.cpp
index c7ea41c9..e072a129 100644
--- a/r5dev/tier0/ConCommand.cpp
+++ b/r5dev/tier0/ConCommand.cpp
@@ -6,87 +6,20 @@
#include "engine/sys_utils.h"
//-----------------------------------------------------------------------------
-// Purpose: test each ConCommand query before execution
-// Input : *cmd - flag
-// Output : true if execution is not permitted, false if permitted
+// purpose: construct/allocate
//-----------------------------------------------------------------------------
-bool HConCommand_IsFlagSet(ConCommandBase* pCommandBase, int nFlag)
+ConCommand::ConCommand(const char* pszName, const char* pszHelpString, int nFlags, void* pCallback, void* pCommandCompletionCallback)
{
- if (cm_return_false_cmdquery_cheats->m_pParent->m_iValue > 0)
- {
- if (cm_debug_cmdquery->m_pParent->m_iValue > 0)
- {
- printf("--------------------------------------------------\n");
- printf(" Flaged: %08X\n", pCommandBase->m_nFlags);
- }
- // Mask off FCVAR_CHEATS and FCVAR_DEVELOPMENTONLY.
- pCommandBase->RemoveFlags(FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT);
- if (cm_debug_cmdquery->m_pParent->m_iValue > 0)
- {
- printf(" Masked: %08X\n", pCommandBase->m_nFlags);
- printf(" Verify: %08X\n", nFlag);
- printf("--------------------------------------------------\n");
- }
- if (nFlag & FCVAR_RELEASE && cm_return_false_cmdquery_all->m_pParent->m_iValue <= 0)
- {
- // Default retail behaviour.
- return ConCommand_IsFlagSet(pCommandBase, nFlag);
- }
- if (cm_return_false_cmdquery_all->m_pParent->m_iValue > 0)
- {
- // Returning false on all queries may cause problems.
- return false;
- }
- // Return false on every FCVAR_DEVELOPMENTONLY || FCVAR_CHEAT query.
- return pCommandBase->HasFlags(nFlag) != 0;
- }
- else
- {
- if (cm_debug_cmdquery->m_pParent->m_iValue > 0)
- {
- printf("--------------------------------------------------\n");
- printf(" Flaged: %08X\n", pCommandBase->m_nFlags);
- }
- // Mask off FCVAR_DEVELOPMENTONLY.
- pCommandBase->RemoveFlags(FCVAR_DEVELOPMENTONLY);
- if (cm_debug_cmdquery->m_pParent->m_iValue > 0)
- {
- printf(" Masked: %08X\n", pCommandBase->m_nFlags);
- printf(" Verify: %08X\n", nFlag);
- printf("--------------------------------------------------\n");
- }
- if (nFlag & FCVAR_RELEASE && cm_return_false_cmdquery_all->m_pParent->m_iValue <= 0)
- {
- // Default retail behaviour.
- return ConCommand_IsFlagSet(pCommandBase, nFlag);
- }
- if (cm_return_false_cmdquery_all->m_pParent->m_iValue > 0)
- {
- // Returning false on all queries may cause problems.
- return false;
- }
- // Return false on every FCVAR_DEVELOPMENTONLY query.
- return pCommandBase->HasFlags(nFlag) != 0;
- }
- // Default behaviour.
- return ConCommand_IsFlagSet(pCommandBase, nFlag);
-}
+ ConCommand* pCommand = reinterpret_cast(MemAlloc_Wrapper(0x68)); // Allocate new memory with StdMemAlloc else we crash.
+ memset(pCommand, 0, 0x68); // Set all to null.
+ std::uintptr_t pCommandBase = reinterpret_cast(pCommand); // To ptr.
-//-----------------------------------------------------------------------------
-// Purpose: register ConCommand's
-//-----------------------------------------------------------------------------
-void* ConCommand_RegisterCommand(const char* szName, const char* szHelpString, int nFlags, void* pCallback, void* pCommandCompletionCallback)
-{
- void* pCommand = reinterpret_cast(MemAlloc_Wrapper(0x68)); // Allocate new memory with StdMemAlloc else we crash.
- memset(pCommand, 0, 0x68); // Set all to null.
- std::uintptr_t pCommandBase = reinterpret_cast(pCommand); // To ptr.
-
- *(void**)pCommandBase = g_pConCommandVtable.RCast(); // 0x00 to ConCommand vtable.
- *(const char**)(pCommandBase + 0x18) = szName; // 0x18 to ConCommand Name.
- *(const char**)(pCommandBase + 0x20) = szHelpString; // 0x20 to ConCommand help string.
- *(std::int32_t*)(pCommandBase + 0x38) = nFlags; // 0x38 to ConCommand Flags.
- *(void**)(pCommandBase + 0x40) = p_ConCommand_NullSub.RCast(); // 0x40 Nullsub since every concommand has it.
- *(void**)(pCommandBase + 0x50) = pCallback; // 0x50 has function callback.
+ *(void**)pCommandBase = g_pConCommandVtable.RCast(); // 0x00 to ConCommand vtable.
+ *(const char**)(pCommandBase + 0x18) = pszName; // 0x18 to ConCommand Name.
+ *(const char**)(pCommandBase + 0x20) = pszHelpString; // 0x20 to ConCommand help string.
+ *(std::int32_t*)(pCommandBase + 0x38) = nFlags; // 0x38 to ConCommand Flags.
+ *(void**)(pCommandBase + 0x40) = p_ConCommand_NullSub.RCast(); // 0x40 Nullsub since every concommand has it.
+ *(void**)(pCommandBase + 0x50) = pCallback; // 0x50 has function callback.
*(std::int32_t*)(pCommandBase + 0x60) = 2; // 0x60 Set to use callback and newcommand callback.
if (pCommandCompletionCallback) // callback after execution desired?
@@ -100,49 +33,119 @@ void* ConCommand_RegisterCommand(const char* szName, const char* szHelpString, i
p_ConCommand_RegisterConCommand.RCast()((void*)pCommandBase); // Register command in ConVarAccessor.
- return pCommand;
+ *this = *pCommand;
}
//-----------------------------------------------------------------------------
-// Purpose: ConCommand definitions to be registered
+// Purpose: ConCommand registration
//-----------------------------------------------------------------------------
-void ConCommand_InitConCommand()
+void ConCommand::Init(void)
{
//-------------------------------------------------------------------------
// SERVER DLL |
- void* sv_kick = ConCommand_RegisterCommand("sv_kick", "Kick a client from the server by name. | Usage: kick .", 0, _Kick_f_CompletionFunc, nullptr);
- void* sv_kickid = ConCommand_RegisterCommand("sv_kickid", "Kick a client from the server by UserID or OriginID | Usage: kickid /.", 0, _KickID_f_CompletionFunc, nullptr);
- void* sv_ban = ConCommand_RegisterCommand("sv_ban", "Bans a client from the server by name. | Usage: ban .", 0, _Ban_f_CompletionFunc, nullptr);
- void* sv_banid = ConCommand_RegisterCommand("sv_banid", "Bans a client from the server by OriginID, UserID or IPAddress | Usage: banid //.", 0, _BanID_f_CompletionFunc, nullptr);
- void* sv_unban = ConCommand_RegisterCommand("sv_unban", "Unbans a client from the Server by IPAddress or OriginID | Usage: unban /.", 0, _Unban_f_CompletionFunc, nullptr);
- void* sv_reloadbanlist = ConCommand_RegisterCommand("sv_reloadbanlist", "Reloads the ban list from the disk.", 0, _ReloadBanList_f_CompletionFunc, nullptr);
+ ConCommand* sv_kick = new ConCommand("sv_kick", "Kick a client from the server by name. | Usage: kick .", 0, _Kick_f_CompletionFunc, nullptr);
+ ConCommand* sv_kickid = new ConCommand("sv_kickid", "Kick a client from the server by UserID or OriginID | Usage: kickid /.", 0, _KickID_f_CompletionFunc, nullptr);
+ ConCommand* sv_ban = new ConCommand("sv_ban", "Bans a client from the server by name. | Usage: ban .", 0, _Ban_f_CompletionFunc, nullptr);
+ ConCommand* sv_banid = new ConCommand("sv_banid", "Bans a client from the server by OriginID, UserID or IPAddress | Usage: banid //.", 0, _BanID_f_CompletionFunc, nullptr);
+ ConCommand* sv_unban = new ConCommand("sv_unban", "Unbans a client from the Server by IPAddress or OriginID | Usage: unban /.", 0, _Unban_f_CompletionFunc, nullptr);
+ ConCommand* sv_reloadbanlist = new ConCommand("sv_reloadbanlist", "Reloads the ban list from the disk.", 0, _ReloadBanList_f_CompletionFunc, nullptr);
#ifndef DEDICATED
//-------------------------------------------------------------------------
// CLIENT DLL |
- void* cl_showconsole = ConCommand_RegisterCommand("cl_showconsole", "Opens the game console.", 0, _CGameConsole_f_CompletionFunc, nullptr);
- void* cl_showbrowser = ConCommand_RegisterCommand("cl_showbrowser", "Opens the server browser.", 0, _CCompanion_f_CompletionFunc, nullptr);
+ ConCommand* cl_showconsole = new ConCommand("cl_showconsole", "Opens the game console.", 0, _CGameConsole_f_CompletionFunc, nullptr);
+ ConCommand* cl_showbrowser = new ConCommand("cl_showbrowser", "Opens the server browser.", 0, _CCompanion_f_CompletionFunc, nullptr);
#endif // !DEDICATED
//-------------------------------------------------------------------------
// FILESYSTEM API |
- void* fs_decompress_pak = ConCommand_RegisterCommand("fs_decompress_pak", "Decompresses user specified 'vpk_dir' file.", 0, _VPK_Decompress_f_CompletionFunc, nullptr);
+ ConCommand* fs_decompress_pak = new ConCommand("fs_decompress_pak", "Decompresses user specified 'vpk_dir' file.", 0, _VPK_Decompress_f_CompletionFunc, nullptr);
//-------------------------------------------------------------------------
// RTECH API |
- void* rtech_strtoguid = ConCommand_RegisterCommand("rtech_strtoguid", "Calculates the GUID from input data.", 0, _RTech_StringToGUID_f_CompletionFunc, nullptr);
- void* rtech_asyncload = ConCommand_RegisterCommand("rtech_asyncload", "Loads user specified 'RPak' file.", 0, _RTech_AsyncLoad_f_CompletionFunc, nullptr);
- void* rtech_decompress = ConCommand_RegisterCommand("rtech_decompress", "Decompresses user specified 'RPak' file.", 0, _RTech_Decompress_f_CompletionFunc, nullptr);
+ ConCommand* rtech_strtoguid = new ConCommand("rtech_strtoguid", "Calculates the GUID from input data.", 0, _RTech_StringToGUID_f_CompletionFunc, nullptr);
+ ConCommand* rtech_asyncload = new ConCommand("rtech_asyncload", "Loads user specified 'RPak' file.", 0, _RTech_AsyncLoad_f_CompletionFunc, nullptr);
+ ConCommand* rtech_decompress = new ConCommand("rtech_decompress", "Decompresses user specified 'RPak' file.", 0, _RTech_Decompress_f_CompletionFunc, nullptr);
//-------------------------------------------------------------------------
// NETCHANNEL |
- void* net_toggletrace = ConCommand_RegisterCommand("net_toggletrace", "Logs the sending and receiving datagram to a file on the disk.", 0, _NET_TraceNetChan_f_CompletionFunc, nullptr);
- void* net_setkey = ConCommand_RegisterCommand("net_setkey", "Sets user specified base64 net key.", 0, _NET_SetKey_f_CompletionFunc, nullptr);
- void* net_generatekey = ConCommand_RegisterCommand("net_generatekey", "Generates and sets a random base64 net key.", 0, _NET_GenerateKey_f_CompletionFunc, nullptr);
+ ConCommand* net_toggletrace = new ConCommand("net_toggletrace", "Logs the sending and receiving datagram to a file on the disk.", 0, _NET_TraceNetChan_f_CompletionFunc, nullptr);
+ ConCommand* net_setkey = new ConCommand("net_setkey", "Sets user specified base64 net key.", 0, _NET_SetKey_f_CompletionFunc, nullptr);
+ ConCommand* net_generatekey = new ConCommand("net_generatekey", "Generates and sets a random base64 net key.", 0, _NET_GenerateKey_f_CompletionFunc, nullptr);
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Add's flags to ConCommand.
+// Input : nFlags -
+//-----------------------------------------------------------------------------
+void ConCommandBase::AddFlags(int nFlags)
+{
+ m_nFlags |= nFlags;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Removes flags from ConCommand.
+// Input : nFlags -
+//-----------------------------------------------------------------------------
+void ConCommandBase::RemoveFlags(int nFlags)
+{
+ m_nFlags &= ~nFlags;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Checks if ConCommand has requested flags.
+// Input : nFlags -
+// Output : True if ConCommand has nFlags.
+//-----------------------------------------------------------------------------
+bool ConCommandBase::HasFlags(int nFlags)
+{
+ return m_nFlags & nFlags;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: test each ConCommand query before execution.
+// Input : *pCommandBase - nFlags
+// Output : false if execution is permitted, true if not.
+//-----------------------------------------------------------------------------
+bool ConCommandBase::IsFlagSet(ConCommandBase* pCommandBase, int nFlags)
+{
+ if (cm_debug_cmdquery->m_pParent->m_iValue > 0)
+ {
+ printf("--------------------------------------------------\n");
+ printf(" Flaged: %08X\n", pCommandBase->m_nFlags);
+ }
+ // Mask off FCVAR_CHEATS and FCVAR_DEVELOPMENTONLY.
+ if (cm_return_false_cmdquery_cheats->m_pParent->m_iValue > 0)
+ {
+ pCommandBase->RemoveFlags(FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT);
+ }
+ else // Mask off FCVAR_DEVELOPMENTONLY.
+ {
+ pCommandBase->RemoveFlags(FCVAR_DEVELOPMENTONLY);
+ }
+ if (cm_debug_cmdquery->m_pParent->m_iValue > 0)
+ {
+ printf(" Masked: %08X\n", pCommandBase->m_nFlags);
+ printf(" Verify: %08X\n", nFlags);
+ printf("--------------------------------------------------\n");
+ }
+ if (nFlags & FCVAR_RELEASE && cm_return_false_cmdquery_all->m_pParent->m_iValue <= 0)
+ {
+ // Default retail behaviour.
+ return ConCommandBase_IsFlagSet(pCommandBase, nFlags);
+ }
+ if (cm_return_false_cmdquery_all->m_pParent->m_iValue > 0)
+ {
+ // Returning false on all queries may cause problems.
+ return false;
+ }
+ // Return false on every FCVAR_DEVELOPMENTONLY || FCVAR_CHEAT query.
+ return pCommandBase->HasFlags(nFlags) != 0;
}
void ConCommand_Attach()
{
- DetourAttach((LPVOID*)&ConCommand_IsFlagSet, &HConCommand_IsFlagSet);
+ DetourAttach((LPVOID*)&ConCommandBase_IsFlagSet, &ConCommandBase::IsFlagSet);
}
void ConCommand_Detach()
{
- DetourDetach((LPVOID*)&ConCommand_IsFlagSet, &HConCommand_IsFlagSet);
+ DetourDetach((LPVOID*)&ConCommandBase_IsFlagSet, &ConCommandBase::IsFlagSet);
}
+ConCommand* g_pConCommand = new ConCommand();
diff --git a/r5dev/tier0/ConCommand.h b/r5dev/tier0/ConCommand.h
index a4da6d2f..59489823 100644
--- a/r5dev/tier0/ConCommand.h
+++ b/r5dev/tier0/ConCommand.h
@@ -64,27 +64,21 @@ private:
class ConCommand
{
+ friend class CCVar;
+public:
+ ConCommand(void) {};
+ ConCommand(const char* szName, const char* szHelpString, int nFlags, void* pCallback, void* pCommandCompletionCallback);
+ void Init(void);
// TODO
};
class ConCommandBase
{
public:
-
- void AddFlags(int flags)
- {
- m_nFlags |= flags;
- }
-
- void RemoveFlags(int flags)
- {
- m_nFlags &= ~flags;
- }
-
- bool HasFlags(int flags)
- {
- return m_nFlags & flags;
- }
+ void AddFlags(int nFlags);
+ void RemoveFlags(int nFlags);
+ bool HasFlags(int nFlags);
+ static bool IsFlagSet(ConCommandBase* pCommandBase, int nFlags);
void* m_pConCommandBaseVTable; //0x0000
ConCommandBase* m_pNext; //0x0008
@@ -105,8 +99,8 @@ private:
namespace
{
/* ==== CONCOMMAND ====================================================================================================================================================== */
- ADDRESS p_ConCommand_IsFlagSet = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x85\x51\x38\x0F\x95\xC0\xC3", "xxxxxxx");
- bool (*ConCommand_IsFlagSet)(ConCommandBase* cmd, int flag) = (bool (*)(ConCommandBase*, int))p_ConCommand_IsFlagSet.GetPtr(); /*85 51 38 0F 95 C0 C3*/
+ ADDRESS p_ConCommandBase_IsFlagSet = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x85\x51\x38\x0F\x95\xC0\xC3", "xxxxxxx");
+ bool (*ConCommandBase_IsFlagSet)(ConCommandBase* cmd, int flag) = (bool (*)(ConCommandBase*, int))p_ConCommandBase_IsFlagSet.GetPtr(); /*85 51 38 0F 95 C0 C3*/
ADDRESS p_ConCommand_CMaterialSystemCmdInit = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x55\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8B\xEC\x48\x83\xEC\x50\x48\x8B\x15\x00\x00\x00\x00", "xxxx?xxxx?xxxx?xxxxxxxxxxxxxxxxxxx????");
ConCommand*(*ConCommand_CMaterialSystemCmdInit)() = (ConCommand* (*)())p_ConCommand_CMaterialSystemCmdInit.GetPtr();
@@ -124,18 +118,17 @@ namespace
}
///////////////////////////////////////////////////////////////////////////////
-bool HConCommand_IsFlagSet(ConCommandBase* pCommand, int nFlag);
-void ConCommand_InitConCommand();
-
void ConCommand_Attach();
void ConCommand_Detach();
+extern ConCommand* g_pConCommand;
+
///////////////////////////////////////////////////////////////////////////////
class HConCommand : public IDetour
{
virtual void debugp()
{
- std::cout << "| FUN: ConCommand::IsFlagSet : 0x" << std::hex << std::uppercase << p_ConCommand_IsFlagSet.GetPtr() << std::setw(npad) << " |" << std::endl;
+ std::cout << "| FUN: ConCommandBase::IsFlagSet : 0x" << std::hex << std::uppercase << p_ConCommandBase_IsFlagSet.GetPtr() << std::setw(npad) << " |" << std::endl;
std::cout << "| FUN: ConCommand::CMaterialSystemCmdInit : 0x" << std::hex << std::uppercase << p_ConCommand_CMaterialSystemCmdInit.GetPtr() << std::setw(npad) << " |" << std::endl;
std::cout << "| FUN: ConCommand::NullSub : 0x" << std::hex << std::uppercase << p_ConCommand_NullSub.GetPtr() << std::setw(npad) << " |" << std::endl;
std::cout << "| FUN: ConCommand::CallbackCompletion : 0x" << std::hex << std::uppercase << p_ConCommand_CallbackCompletion.GetPtr() << std::setw(npad) << " |" << std::endl;
diff --git a/r5dev/tier0/IConVar.cpp b/r5dev/tier0/IConVar.cpp
index 01f9a8d6..60771b4b 100644
--- a/r5dev/tier0/IConVar.cpp
+++ b/r5dev/tier0/IConVar.cpp
@@ -1,15 +1,529 @@
+//=============================================================================//
+//
+// Purpose: Console Variables
+//
+//=============================================================================//
+
#include "core/stdafx.h"
#include "tier0/cvar.h"
#include "tier0/IConVar.h"
#include "engine/sys_utils.h"
#include "engine/sys_dll2.h"
+#include "mathlib/bits.h"
//-----------------------------------------------------------------------------
-// Purpose: test each ConVar query before setting the cvar
-// Input : **cvar - flag
-// Output : true if change is not permitted, false if permitted
+// purpose: construct/allocate
//-----------------------------------------------------------------------------
-bool HIConVar_IsFlagSet(ConVar* pConVar, int nFlags)
+ConVar::ConVar(const char* pszName, const char* pszDefaultValue, int nFlags, const char* pszHelpString, bool bMin, float fMin, bool bMax, float fMax, void* pCallback, void* unk)
+{
+ ConVar* allocatedConvar = reinterpret_cast(MemAlloc_Wrapper(0xA0)); // Allocate new memory with StdMemAlloc else we crash.
+ memset(allocatedConvar, 0, 0xA0); // Set all to null.
+ std::uintptr_t cvarPtr = reinterpret_cast(allocatedConvar); // To ptr.
+
+ *(void**)(cvarPtr + 0x40) = g_pIConVarVtable.RCast(); // 0x40 to ICvar table.
+ *(void**)cvarPtr = g_pConVarVtable.RCast(); // 0x0 to ConVar vtable.
+
+ p_ConVar_Register.RCast()
+ (allocatedConvar, pszName, pszDefaultValue, nFlags, pszHelpString, bMin, fMin, bMax, fMax, pCallback, unk); // Call to create ConVar.
+
+ *this = *allocatedConvar;
+}
+
+//-----------------------------------------------------------------------------
+// purpose: destructor
+//-----------------------------------------------------------------------------
+ConVar::~ConVar(void)
+{
+ if (m_pzsCurrentValue)
+ {
+ delete[] m_pzsCurrentValue;
+ m_pzsCurrentValue = NULL;
+ }
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: register ConVar
+//-----------------------------------------------------------------------------
+void ConVar::Init(void)
+{
+ //-------------------------------------------------------------------------
+ // ENGINE |
+ cm_debug_cmdquery = new ConVar("cm_debug_cmdquery", "0", FCVAR_DEVELOPMENTONLY, "Prints the flags of each ConVar/ConCommand query to the console ( !slower! ).", false, 0.f, false, 0.f, nullptr, nullptr);
+ cm_return_false_cmdquery_all = new ConVar("cm_return_false_cmdquery_all", "0", FCVAR_DEVELOPMENTONLY, "Returns false on every ConVar/ConCommand query ( !warning! ).", false, 0.f, false, 0.f, nullptr, nullptr);
+ cm_return_false_cmdquery_cheats = new ConVar("cm_return_false_cmdquery_cheats", "0", FCVAR_DEVELOPMENTONLY, "Returns false on all FCVAR_DEVELOPMENTONLY and FCVAR_CHEAT ConVar/ConCommand queries ( !warning! ).", false, 0.f, false, 0.f, nullptr, nullptr);
+ r_debug_overlay_nodecay = new ConVar("r_debug_overlay_nodecay", "0", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Keeps all debug overlays alive regardless of their lifetime. Use command 'clear_debug_overlays' to clear everything.", false, 0.f, false, 0.f, nullptr, nullptr);
+ //-------------------------------------------------------------------------
+ // SERVER |
+ sv_showconnecting = new ConVar("sv_showconnecting", "1", FCVAR_RELEASE, "Logs information about the connecting client to the console.", false, 0.f, false, 0.f, nullptr, nullptr);
+ sv_pylonvisibility = new ConVar("sv_pylonvisibility", "0", FCVAR_RELEASE, "Determines the visiblity to the Pylon Master Server, 0 = Not visible, 1 = Visible, 2 = Hidden BUG BUG: not implemented yet.", false, 0.f, false, 0.f, nullptr, nullptr);
+ //-------------------------------------------------------------------------
+ // CLIENT |
+ cl_drawconsoleoverlay = new ConVar("cl_drawconsoleoverlay", "0", FCVAR_DEVELOPMENTONLY, "Draw the console overlay at the top of the screen.", false, 0.f, false, 0.f, nullptr, nullptr);
+ cl_consoleoverlay_lines = new ConVar("cl_consoleoverlay_lines", "3", FCVAR_DEVELOPMENTONLY, "Number of lines of console output to draw.", false, 0.f, false, 0.f, nullptr, nullptr);
+ cl_consoleoverlay_offset_x = new ConVar("cl_consoleoverlay_offset_x", "10", FCVAR_DEVELOPMENTONLY, "X offset for console overlay.", false, 1.f, false, 50.f, nullptr, nullptr);
+ cl_consoleoverlay_offset_y = new ConVar("cl_consoleoverlay_offset_y", "10", FCVAR_DEVELOPMENTONLY, "Y offset for console overlay.", false, 1.f, false, 50.f, nullptr, nullptr);
+
+ cl_showsimstats = new ConVar("cl_showsimstats", "0", FCVAR_DEVELOPMENTONLY, "Shows the tick counter for the server/client simulation and the render frame.", false, 0.f, false, 0.f, nullptr, nullptr);
+ cl_simstats_offset_x = new ConVar("cl_simstats_offset_x", "1250", FCVAR_DEVELOPMENTONLY, "X offset for simulation debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr);
+ cl_simstats_offset_y = new ConVar("cl_simstats_offset_y", "885", FCVAR_DEVELOPMENTONLY, "Y offset for simulation debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr);
+
+ cl_showgpustats = new ConVar("cl_showgpustats", "0", FCVAR_DEVELOPMENTONLY, "Texture streaming debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr);
+ cl_gpustats_offset_x = new ConVar("cl_gpustats_offset_x", "1250", FCVAR_DEVELOPMENTONLY, "X offset for texture streaming debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr);
+ cl_gpustats_offset_y = new ConVar("cl_gpustats_offset_y", "900", FCVAR_DEVELOPMENTONLY, "Y offset for texture streaming debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr);
+ //-------------------------------------------------------------------------
+ // FILESYSTEM |
+ fs_warning_level_native = new ConVar("fs_warning_level_native", "0", FCVAR_DEVELOPMENTONLY, "Set the filesystem warning level ( !slower! ).", false, 0.f, false, 0.f, nullptr, nullptr);
+ fs_packedstore_entryblock_stats = new ConVar("fs_packedstore_entryblock_stats", "0", FCVAR_DEVELOPMENTONLY, "If set to 1, prints the stats of each file entry in the VPK during decompression ( !slower! ).", false, 0.f, false, 0.f, nullptr, nullptr);
+ //-------------------------------------------------------------------------
+ // FILESYSTEM |
+ mat_showdxoutput = new ConVar("mat_showdxoutput", "0", FCVAR_DEVELOPMENTONLY, "Shows debug output for the DirectX system.", false, 0.f, false, 0.f, nullptr, nullptr);
+ //-------------------------------------------------------------------------
+ // SQUIRREL |
+ sq_showrsonloading = new ConVar("sq_showrsonloading", "0", FCVAR_DEVELOPMENTONLY, "Logs all 'rson' files loaded by the SQVM ( !slower! ).", false, 0.f, false, 0.f, nullptr, nullptr);
+ sq_showscriptloading = new ConVar("sq_showscriptloading", "0", FCVAR_DEVELOPMENTONLY, "Logs all scripts loaded by the SQVM to be pre-compiled ( !slower! ).", false, 0.f, false, 0.f, nullptr, nullptr);
+ sq_showvmoutput = new ConVar("sq_showvmoutput", "1", FCVAR_DEVELOPMENTONLY, "Prints the VM output to the console. 1 = Log to file. 2 = 1 + log to console. 3 = 1 + 2 + log to overhead console. 4 = only log to overhead console.", false, 0.f, false, 0.f, nullptr, nullptr);
+ sq_showvmwarning = new ConVar("sq_showvmwarning", "0", FCVAR_DEVELOPMENTONLY, "Prints the VM warning output to the console. 1 = Log to file. 2 = 1 + log to console.", false, 0.f, false, 0.f, nullptr, nullptr);
+ //-------------------------------------------------------------------------
+ // NETCHANNEL |
+ net_userandomkey = new ConVar("net_userandomkey", "1", FCVAR_RELEASE, "If set to 1, the netchannel generates and sets a random base64 netkey.", false, 0.f, false, 0.f, nullptr, nullptr);
+ r5net_matchmaking_hostname = new ConVar("r5net_matchmaking_hostname", "r5a-comp-sv.herokuapp.com", FCVAR_RELEASE, "Holds the R5Net matchmaking hostname.", false, 0.f, false, 0.f, nullptr, nullptr);
+ r5net_show_debug = new ConVar("r5net_show_debug", "1", FCVAR_DEVELOPMENTONLY, "Shows debug output for R5Net.", false, 0.f, false, 0.f, nullptr, nullptr);
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Returns the base ConVar name.
+// Output : const char*
+//-----------------------------------------------------------------------------
+const char* ConVar::GetBaseName(void)
+{
+ return m_pParent->m_ConCommandBase.m_pszName;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Returns the ConVar help text.
+// Output : const char*
+//-----------------------------------------------------------------------------
+const char* ConVar::GetHelpText(void)
+{
+ return m_pParent->m_ConCommandBase.m_pszHelpString;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Add's flags to ConVar.
+// Input : nFlags -
+//-----------------------------------------------------------------------------
+void ConVar::AddFlags(int nFlags)
+{
+ m_pParent->m_ConCommandBase.m_nFlags |= nFlags;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Removes flags from ConVar.
+// Input : nFlags -
+//-----------------------------------------------------------------------------
+void ConVar::RemoveFlags(int nFlags)
+{
+ m_ConCommandBase.m_nFlags &= ~nFlags;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Checks if ConVar is registered.
+// Output : bool
+//-----------------------------------------------------------------------------
+bool ConVar::IsRegistered(void)
+{
+ return m_pParent->m_ConCommandBase.m_bRegistered;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Return ConVar value as a boolean.
+// Output : bool
+//-----------------------------------------------------------------------------
+bool ConVar::GetBool(void)
+{
+ return !!GetInt();
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Return ConVar value as a float.
+// Output : float
+//-----------------------------------------------------------------------------
+float ConVar::GetFloat(void)
+{
+ return m_pParent->m_flValue;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Return ConVar value as an integer.
+// Output : int
+//-----------------------------------------------------------------------------
+int ConVar::GetInt(void)
+{
+ return m_pParent->m_iValue;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Return ConVar value as a color.
+// Output : Color
+//-----------------------------------------------------------------------------
+Color ConVar::GetColor(void)
+{
+ unsigned char* pColorElement = ((unsigned char*)&m_pParent->m_iValue);
+ return Color(pColorElement[0], pColorElement[1], pColorElement[2], pColorElement[3]);
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Return ConVar value as a string.
+// Output : const char *
+//-----------------------------------------------------------------------------
+const char* ConVar::GetString(void)
+{
+ if (m_ConCommandBase.m_nFlags & FCVAR_NEVER_AS_STRING)
+ {
+ return "FCVAR_NEVER_AS_STRING";
+ }
+
+ char const* str = m_pParent->m_pzsCurrentValue;
+ return str ? str : "";
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+// Input : flMinVal -
+// Output : true if there is a min set.
+//-----------------------------------------------------------------------------
+bool ConVar::GetMin(float& flMinVal)
+{
+ flMinVal = m_pParent->m_flMinValue;
+ return m_pParent->m_bHasMin;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+// Input : flMaxVal -
+// Output : true if there is a max set.
+//-----------------------------------------------------------------------------
+bool ConVar::GetMax(float& flMaxVal)
+{
+ flMaxVal = m_pParent->m_flMaxValue;
+ return m_pParent->m_bHasMax;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: returns the min value.
+// Output : float
+//-----------------------------------------------------------------------------
+float ConVar::GetMinValue(void)
+{
+ return m_pParent->m_flMinValue;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: returns the max value.
+// Output : float
+//-----------------------------------------------------------------------------
+float ConVar::GetMaxValue(void)
+{
+ return m_pParent->m_flMaxValue;;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: checks if ConVar has min value.
+// Output : bool
+//-----------------------------------------------------------------------------
+bool ConVar::HasMin(void)
+{
+ return m_pParent->m_bHasMin;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: checks if ConVar has max value.
+// Output : bool
+//-----------------------------------------------------------------------------
+bool ConVar::HasMax(void)
+{
+ return m_pParent->m_bHasMax;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: sets the ConVar int value.
+// Input : nValue -
+//-----------------------------------------------------------------------------
+void ConVar::SetValue(int nValue)
+{
+ if (nValue == m_iValue)
+ {
+ return;
+ }
+
+ // Only valid for root ConVars.
+ assert(m_pParent == this);
+
+ float flValue = (float)nValue;
+
+ // Check bounds.
+ if (ClampValue(flValue))
+ {
+ nValue = (int)(flValue);
+ }
+
+ // Redetermine value.
+ float flOldValue = m_flValue;
+ m_flValue = flValue;
+ m_iValue = nValue;
+
+ if (!(m_ConCommandBase.m_nFlags & FCVAR_NEVER_AS_STRING))
+ {
+ char szTempValue[32];
+ snprintf(szTempValue, sizeof(szTempValue), "%d", m_iValue);
+ ChangeStringValue(szTempValue, flOldValue);
+ }
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: sets the ConVar float value.
+// Input : flValue -
+//-----------------------------------------------------------------------------
+void ConVar::SetValue(float flValue)
+{
+ if (flValue == m_flValue)
+ {
+ return;
+ }
+
+ // Only valid for root ConVars.
+ assert(m_pParent == this);
+
+ // Check bounds.
+ ClampValue(flValue);
+
+ // Redetermine value.
+ float flOldValue = m_flValue;
+ m_flValue = flValue;
+ m_iValue = (int)m_flValue;
+
+ if (!(m_ConCommandBase.m_nFlags & FCVAR_NEVER_AS_STRING))
+ {
+ char szTempValue[32];
+ snprintf(szTempValue, sizeof(szTempValue), "%f", m_flValue);
+ ChangeStringValue(szTempValue, flOldValue);
+ }
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: sets the ConVar string value.
+// Input : *szValue -
+//-----------------------------------------------------------------------------
+void ConVar::SetValue(const char* szValue)
+{
+ if (strcmp(this->m_pParent->m_pzsCurrentValue, szValue) == 0)
+ {
+ return;
+ }
+ this->m_pParent->m_pzsCurrentValue = szValue;
+
+ char szTempValue[32]{};
+ const char* pszValue{};
+
+ // Only valid for root convars.
+ assert(m_pParent == this);
+
+ float flOldValue = m_flValue;
+ pszValue = (char*)szValue;
+ if (!pszValue)
+ {
+ pszValue = "";
+ }
+
+ if (!SetColorFromString(szValue))
+ {
+ // Not a color, do the standard thing
+ float flNewValue = (float)atof(szValue);
+ if (!IsFinite(flNewValue))
+ {
+ DevMsg(eDLL_T::ENGINE ,"Warning: ConVar '%s' = '%s' is infinite, clamping value.\n", GetBaseName(), szValue);
+ flNewValue = FLT_MAX;
+ }
+
+ if (ClampValue(flNewValue))
+ {
+ snprintf(szTempValue, sizeof(szTempValue), "%f", flNewValue);
+ pszValue = szTempValue;
+ }
+
+ // Redetermine value
+ m_flValue = flNewValue;
+ m_iValue = (int)(m_flValue);
+ }
+
+ if (!(m_ConCommandBase.m_nFlags & FCVAR_NEVER_AS_STRING))
+ {
+ ChangeStringValue(pszValue, flOldValue);
+ }
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: sets the ConVar color value.
+// Input : clValue -
+//-----------------------------------------------------------------------------
+void ConVar::SetValue(Color clValue)
+{
+ std::string svResult = "";
+
+ for (int i = 0; i < 4; i++)
+ {
+ if (!(clValue._color[i] == 0 && svResult.size() == 0))
+ {
+ svResult += std::to_string(clValue._color[i]);
+ svResult.append(" ");
+ }
+ }
+
+ this->m_pParent->m_pzsCurrentValue = svResult.c_str();
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Reset to default value.
+//-----------------------------------------------------------------------------
+void ConVar::Revert(void)
+{
+ this->SetValue(this->m_pszDefaultValue);
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: returns the default ConVar value.
+// Output : const char
+//-----------------------------------------------------------------------------
+const char* ConVar::GetDefault(void)
+{
+ return m_pParent->m_pszDefaultValue;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: sets the default ConVar value.
+// Input : *pszDefault -
+//-----------------------------------------------------------------------------
+void ConVar::SetDefault(const char* pszDefault)
+{
+ static const char* pszEmpty = "";
+ m_pszDefaultValue = pszDefault ? pszDefault : pszEmpty;
+ assert(m_pszDefaultValue);
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: changes the ConVar string value.
+// Input : *pszTempVal - flOldValue
+//-----------------------------------------------------------------------------
+void ConVar::ChangeStringValue(const char* pszTempVal, float flOldValue)
+{
+ assert(!(m_nFlags & FCVAR_NEVER_AS_STRING));
+
+ char* pszOldValue = (char*)_malloca(m_iStringLength);
+ if (pszOldValue != NULL)
+ {
+ memcpy(pszOldValue, m_pzsCurrentValue, m_iStringLength);
+ }
+
+ if (pszTempVal)
+ {
+ int len = strlen(pszTempVal) + 1;
+
+ if (len > m_iStringLength)
+ {
+ if (m_pzsCurrentValue)
+ {
+ delete[] m_pzsCurrentValue;
+ }
+
+ m_pzsCurrentValue = new char[len];
+ m_iStringLength = len;
+ }
+
+ memcpy((char*)m_pzsCurrentValue, pszTempVal, len);
+ }
+ else
+ {
+ m_pzsCurrentValue = NULL;
+ }
+
+ pszOldValue = 0;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: sets the ConVar color value from string.
+// Input : *pszValue -
+//-----------------------------------------------------------------------------
+bool ConVar::SetColorFromString(const char* pszValue)
+{
+ bool bColor = false;
+
+ // Try pulling RGBA color values out of the string.
+ int nRGBA[4]{};
+ int nParamsRead = sscanf_s(pszValue, "%i %i %i %i", &(nRGBA[0]), &(nRGBA[1]), &(nRGBA[2]), &(nRGBA[3]));
+
+ if (nParamsRead >= 3)
+ {
+ // This is probably a color!
+ if (nParamsRead == 3)
+ {
+ // Assume they wanted full alpha.
+ nRGBA[3] = 255;
+ }
+
+ if (nRGBA[0] >= 0 && nRGBA[0] <= 255 &&
+ nRGBA[1] >= 0 && nRGBA[1] <= 255 &&
+ nRGBA[2] >= 0 && nRGBA[2] <= 255 &&
+ nRGBA[3] >= 0 && nRGBA[3] <= 255)
+ {
+ //printf("*** WOW! Found a color!! ***\n");
+
+ // This is definitely a color!
+ bColor = true;
+
+ // Stuff all the values into each byte of our int.
+ unsigned char* pColorElement = ((unsigned char*)&m_iValue);
+ pColorElement[0] = nRGBA[0];
+ pColorElement[1] = nRGBA[1];
+ pColorElement[2] = nRGBA[2];
+ pColorElement[3] = nRGBA[3];
+
+ // Copy that value into our float.
+ m_flValue = (float)(m_iValue);
+ }
+ }
+
+ return bColor;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Check whether to clamp and then perform clamp.
+// Input : flValue -
+// Output : Returns true if value changed.
+//-----------------------------------------------------------------------------
+bool ConVar::ClampValue(float& flValue)
+{
+ if (m_bHasMin && (flValue < m_flMinValue))
+ {
+ flValue = m_flMinValue;
+ return true;
+ }
+
+ if (m_bHasMax && (flValue > m_flMaxValue))
+ {
+ flValue = m_flMaxValue;
+ return true;
+ }
+
+ return false;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: test each ConVar query before setting the cvar.
+// Input : *pConVar - nFlags
+// Output : false if change is permitted, true if not.
+//-----------------------------------------------------------------------------
+bool ConVar::IsFlagSet(ConVar* pConVar, int nFlags)
{
if (cm_debug_cmdquery->m_pParent->m_iValue > 0)
{
@@ -21,9 +535,8 @@ bool HIConVar_IsFlagSet(ConVar* pConVar, int nFlags)
// Mask off FCVAR_CHEATS and FCVAR_DEVELOPMENTONLY.
pConVar->m_ConCommandBase.RemoveFlags(FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT);
}
- else
+ else // Mask off FCVAR_DEVELOPMENTONLY.
{
- // Mask off FCVAR_DEVELOPMENTONLY.
pConVar->m_ConCommandBase.RemoveFlags(FCVAR_DEVELOPMENTONLY);
}
if (cm_debug_cmdquery->m_pParent->m_iValue > 0)
@@ -47,90 +560,19 @@ bool HIConVar_IsFlagSet(ConVar* pConVar, int nFlags)
}
//-----------------------------------------------------------------------------
-// Purpose: register ConVar's
+// Purpose: clear all hostname ConVar's.
//-----------------------------------------------------------------------------
-ConVar* IConVar_RegisterConVar(const char* szName, const char* szDefaultValue, int nFlags, const char* szHelpString, bool bMin, float fMin, bool bMax, float fMax, void* pCallback, void* unk)
+void ConVar::ClearHostNames(void)
{
- ConVar* allocatedConvar = reinterpret_cast(MemAlloc_Wrapper(0xA0)); // Allocate new memory with StdMemAlloc else we crash.
- memset(allocatedConvar, 0, 0xA0); // Set all to null.
- std::uintptr_t cvarPtr = reinterpret_cast(allocatedConvar); // To ptr.
-
- *(void**)(cvarPtr + 0x40) = g_pIConVarVtable.RCast(); // 0x40 to ICvar table.
- *(void**)cvarPtr = g_pConVarVtable.RCast(); // 0x0 to ConVar vtable.
-
- p_ConVar_Register.RCast() // Call to create ConVar.
- (allocatedConvar, szName, szDefaultValue, nFlags, szHelpString, bMin, fMin, bMax, fMax, pCallback, unk);
-
- return allocatedConvar; // Return allocated ConVar.
-}
-
-//-----------------------------------------------------------------------------
-// Purpose: convar definitions to be registered
-//-----------------------------------------------------------------------------
-void IConVar_InitConVar()
-{
- //-------------------------------------------------------------------------
- // ENGINE |
- cm_debug_cmdquery = IConVar_RegisterConVar("cm_debug_cmdquery", "0", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Prints the flags of each ConVar/ConCommand query to the console ( !slower! ).", false, 0.f, false, 0.f, nullptr, nullptr);
- cm_return_false_cmdquery_all = IConVar_RegisterConVar("cm_return_false_cmdquery_all", "0", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Returns false on every ConVar/ConCommand query ( !warning! ).", false, 0.f, false, 0.f, nullptr, nullptr);
- cm_return_false_cmdquery_cheats = IConVar_RegisterConVar("cm_return_false_cmdquery_cheats", "0", FCVAR_RELEASE, "Returns false on all FCVAR_DEVELOPMENTONLY and FCVAR_CHEAT ConVar/ConCommand queries ( !warning! ).", false, 0.f, false, 0.f, nullptr, nullptr);
- r_debug_overlay_nodecay = IConVar_RegisterConVar("r_debug_overlay_nodecay", "0", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Keeps all debug overlays alive regardless of their lifetime. Use command 'clear_debug_overlays' to clear everything.", false, 0.f, false, 0.f, nullptr, nullptr);
- //-------------------------------------------------------------------------
- // SERVER |
- sv_showconnecting = IConVar_RegisterConVar("sv_showconnecting", "1", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Logs information about the connecting client to the console.", false, 0.f, false, 0.f, nullptr, nullptr);
- sv_pylonvisibility = IConVar_RegisterConVar("sv_pylonvisibility", "0", FCVAR_RELEASE, "Determines the visiblity to the Pylon Master Server, 0 = Not visible, 1 = Visible, 2 = Hidden BUG BUG: not implemented yet.", false, 0.f, false, 0.f, nullptr, nullptr);
- //-------------------------------------------------------------------------
- // CLIENT |
- cl_drawconsoleoverlay = IConVar_RegisterConVar("cl_drawconsoleoverlay", "1", FCVAR_RELEASE, "Draw the console overlay at the top of the screen.", false, 0.f, false, 0.f, nullptr, nullptr);
- cl_consoleoverlay_lines = IConVar_RegisterConVar("cl_consoleoverlay_lines", "3", FCVAR_RELEASE, "Number of lines of console output to draw.", false, 0.f, false, 0.f, nullptr, nullptr);
- cl_consoleoverlay_offset_x = IConVar_RegisterConVar("cl_consoleoverlay_offset_x", "10", FCVAR_RELEASE, "X offset for console overlay.", false, 1.f, false, 50.f, nullptr, nullptr);
- cl_consoleoverlay_offset_y = IConVar_RegisterConVar("cl_consoleoverlay_offset_y", "10", FCVAR_RELEASE, "Y offset for console overlay.", false, 1.f, false, 50.f, nullptr, nullptr);
-
- cl_showsimstats = IConVar_RegisterConVar("cl_showsimstats", "1", FCVAR_RELEASE, "Shows the tick counter for the server/client simulation and the render frame.", false, 0.f, false, 0.f, nullptr, nullptr);
- cl_simstats_offset_x = IConVar_RegisterConVar("cl_simstats_offset_x", "1250", FCVAR_RELEASE, "X offset for simulation debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr);
- cl_simstats_offset_y = IConVar_RegisterConVar("cl_simstats_offset_y", "885", FCVAR_RELEASE, "Y offset for simulation debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr);
-
- cl_showgpustats = IConVar_RegisterConVar("cl_showgpustats", "1", FCVAR_RELEASE, "Texture streaming debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr);
- cl_gpustats_offset_x = IConVar_RegisterConVar("cl_gpustats_offset_x", "1250", FCVAR_RELEASE, "X offset for texture streaming debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr);
- cl_gpustats_offset_y = IConVar_RegisterConVar("cl_gpustats_offset_y", "900", FCVAR_RELEASE, "Y offset for texture streaming debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr);
- //-------------------------------------------------------------------------
- // FILESYSTEM |
- fs_warning_level_native = IConVar_RegisterConVar("fs_warning_level_native", "0", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Set the filesystem warning level ( !slower! ).", false, 0.f, false, 0.f, nullptr, nullptr);
- fs_packedstore_entryblock_stats = IConVar_RegisterConVar("fs_packedstore_entryblock_stats", "0", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "If set to 1, prints the stats of each file entry in the VPK during decompression ( !slower! ).", false, 0.f, false, 0.f, nullptr, nullptr);
- //-------------------------------------------------------------------------
- // FILESYSTEM |
- mat_showdxoutput = IConVar_RegisterConVar("mat_showdxoutput", "0", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Shows debug output for the DirectX system.", false, 0.f, false, 0.f, nullptr, nullptr);
- //-------------------------------------------------------------------------
- // SQUIRREL |
- sq_showrsonloading = IConVar_RegisterConVar("sq_showrsonloading", "1", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Logs all 'rson' files loaded by the SQVM ( !slower! ).", false, 0.f, false, 0.f, nullptr, nullptr);
- sq_showscriptloading = IConVar_RegisterConVar("sq_showscriptloading", "0", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Logs all scripts loaded by the SQVM to be pre-compiled ( !slower! ).", false, 0.f, false, 0.f, nullptr, nullptr);
- sq_showvmoutput = IConVar_RegisterConVar("sq_showvmoutput", "3", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Prints the VM output to the console. 1 = Log to file. 2 = 1 + log to console. 3 = 1 + 2 + log to overhead console. 4 = only log to overhead console.", false, 0.f, false, 0.f, nullptr, nullptr);
- sq_showvmwarning = IConVar_RegisterConVar("sq_showvmwarning", "0", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT, "Prints the VM warning output to the console. 1 = Log to file. 2 = 1 + log to console.", false, 0.f, false, 0.f, nullptr, nullptr);
- //-------------------------------------------------------------------------
- // NETCHANNEL |
- net_userandomkey = IConVar_RegisterConVar("net_userandomkey", "1", FCVAR_RELEASE, "If set to 1, the netchannel generates and sets a random base64 netkey.", false, 0.f, false, 0.f, nullptr, nullptr);
- r5net_matchmaking_hostname = IConVar_RegisterConVar("r5net_matchmaking_hostname", "r5a-comp-sv.herokuapp.com", FCVAR_RELEASE, "Holds the R5Net matchmaking hostname.", false, 0.f, false, 0.f, nullptr, nullptr);
- r5net_show_debug = IConVar_RegisterConVar("r5net_show_debug", "1", FCVAR_RELEASE, "Shows debug output for R5Net.", false, 0.f, false, 0.f, nullptr, nullptr);
-}
-
-//-----------------------------------------------------------------------------
-// Purpose: clear all hostname ConVar's
-//-----------------------------------------------------------------------------
-void IConVar_ClearHostNames()
-{
- const char* szHostnameArray[] =
+ const char* pszHostnameArray[] =
{
"pin_telemetry_hostname",
-#ifdef GAMEDLL_S3
"assetdownloads_hostname",
-#endif // GAMEDLL_S3
"users_hostname",
"persistence_hostname",
"speechtotexttoken_hostname",
"communities_hostname",
-#ifdef GAMEDLL_S3
"persistenceDef_hostname",
-#endif // GAMEDLL_S3
"party_hostname",
"speechtotext_hostname",
"serverReports_hostname",
@@ -145,18 +587,26 @@ void IConVar_ClearHostNames()
for (int i = 0; i < 17; i++)
{
- const char* szName = szHostnameArray[i];
- g_pCvar->FindVar(szName)->m_pzsCurrentValue = "0.0.0.0";
+ const char* pszName = pszHostnameArray[i];
+ ConVar* pCVar = g_pCvar->FindVar(pszName);
+
+ if (pCVar != nullptr)
+ {
+ pCVar->m_pzsCurrentValue = "0.0.0.0";
+ }
}
}
///////////////////////////////////////////////////////////////////////////////
void IConVar_Attach()
{
- DetourAttach((LPVOID*)&IConVar_IsFlagSet, &HIConVar_IsFlagSet);
+ DetourAttach((LPVOID*)&IConVar_IsFlagSet, &ConVar::IsFlagSet);
}
void IConVar_Detach()
{
- DetourDetach((LPVOID*)&IConVar_IsFlagSet, &HIConVar_IsFlagSet);
+ DetourDetach((LPVOID*)&IConVar_IsFlagSet, &ConVar::IsFlagSet);
}
+
+///////////////////////////////////////////////////////////////////////////////
+ConVar* g_pConVar = new ConVar();
diff --git a/r5dev/tier0/IConVar.h b/r5dev/tier0/IConVar.h
index e19f3753..ae92b23a 100644
--- a/r5dev/tier0/IConVar.h
+++ b/r5dev/tier0/IConVar.h
@@ -1,6 +1,7 @@
#pragma once
#include "basetypes.h"
#include "ConCommand.h"
+#include "mathlib/color.h"
//-----------------------------------------------------------------------------
// Command to ConVars and ConCommands
@@ -83,75 +84,66 @@ dq offset RegisterConVar; #STR: "Convar '%s' is flagged as both FCVAR_ARCHIVE an
class ConVar
{
public:
- ConCommandBase m_ConCommandBase; //0x0000
- void* m_pConVarVTable; //0x0040
- ConVar* m_pParent; //0x0048
- const char* n_pszDefaultValue; //0x0050
- const char* m_pzsCurrentValue; //0x0058
- std::int64_t m_iStringLength; //0x0060
- float m_flValue; //0x0068
- int m_iValue; //0x006C
- bool m_bHasMin; //0x0070
- float m_flMinValue; //0x0074
- bool m_bHasMax; //0x0078
- float m_flMaxValue; //0x007C
- char pad_0080[32]; //0x0080
+ ConVar(void){};
+ ConVar(const char* pszName, const char* pszDefaultValue, int nFlags, const char*pszHelpString,
+ bool bMin, float fMin, bool bMax, float fMax, void* pCallback, void* unk);
+ ~ConVar(void);
+
+ void Init(void);
+
+ const char* GetBaseName(void);
+ const char* GetHelpText(void);
+
+ void AddFlags(int nFlags);
+ void RemoveFlags(int nFlags);
+
+ bool IsRegistered(void);
+
+ bool GetBool(void);
+ float GetFloat(void);
+ int GetInt(void);
+ Color GetColor(void);
+ const char* GetString(void);
+
+ bool GetMin(float& flMinValue);
+ bool GetMax(float& flMaxValue);
+ float GetMinValue(void);
+ float GetMaxValue(void);
+ bool HasMin(void);
+ bool HasMax(void);
+
+ void SetValue(int nValue);
+ void SetValue(float flValue);
+ void SetValue(const char* pszValue);
+ void SetValue(Color clValue);
+
+ void Revert(void);
+
+ const char* GetDefault(void);
+ void SetDefault(const char* pszDefault);
+
+ void ChangeStringValue(const char* pszTempValue, float flOldValue);
+ bool SetColorFromString(const char* pszValue);
+ bool ClampValue(float& value);
+
+ static bool IsFlagSet(ConVar* pConVar, int nFlags);
+ void ClearHostNames(void);
+
+ ConCommandBase m_ConCommandBase {}; //0x0000
+ void* m_pConVarVTable {}; //0x0040
+ ConVar* m_pParent {}; //0x0048
+ const char* m_pszDefaultValue{}; //0x0050
+ const char* m_pzsCurrentValue{}; //0x0058
+ std::int64_t m_iStringLength {}; //0x0060
+ float m_flValue {}; //0x0068
+ int m_iValue {}; //0x006C
+ bool m_bHasMin {}; //0x0070
+ float m_flMinValue {}; //0x0074
+ bool m_bHasMax {}; //0x0078
+ float m_flMaxValue {}; //0x007C
+ char pad_0080[32] {}; //0x0080
}; //Size: 0x00A0
-class CCVarIteratorInternal // Fully reversed table, just look at the virtual function table and rename the function.
-{
-public:
- virtual void SetFirst(void) = 0; //0
- virtual void Next(void) = 0; //1
- virtual bool IsValid(void) = 0; //2
- virtual ConCommandBase* Get(void) = 0; //3
-};
-
-class CCVar
-{
-public:
- ConCommandBase* FindCommandBase(const char* szCommandName) // @0x1405983A0 in R5pc_r5launch_N1094_CL456479_2019_10_30_05_20_PM
- {
- using OriginalFn = ConCommandBase * (__thiscall*)(CCVar*, const char*);
- return (*reinterpret_cast(this))[14](this, szCommandName);
- }
-
- ConVar* FindVar(const char* szVarName) // @0x1405983B0 in R5pc_r5launch_N1094_CL456479_2019_10_30_05_20_PM
- {
- using OriginalFn = ConVar * (__thiscall*)(CCVar*, const char*);
- return (*reinterpret_cast(this))[16](this, szVarName);
- }
-
- void* /*Implement ConCommand class.*/ FindCommand(const char* szCommandName) // @0x1405983F0 in R5pc_r5launch_N1094_CL456479_2019_10_30_05_20_PM
- {
- using OriginalFn = void* (__thiscall*)(CCVar*, const char*);
- return (*reinterpret_cast(this))[18](this, szCommandName);
- }
-
- CCVarIteratorInternal* FactoryInternalIterator() // @0x140597C10 in R5pc_r5launch_N1094_CL456479_2019_10_30_05_20_PM
- {
- using OriginalFn = CCVarIteratorInternal * (__thiscall*)(CCVar*);
- return (*reinterpret_cast(this))[41](this);
- }
-
- std::unordered_map DumpToMap()
- {
- std::stringstream ss;
- CCVarIteratorInternal* itint = FactoryInternalIterator(); // Allocatd new InternalIterator.
-
- std::unordered_map allConVars;
-
- for (itint->SetFirst(); itint->IsValid(); itint->Next()) // Loop through all instances.
- {
- ConCommandBase* pCommand = itint->Get();
- const char* commandName = pCommand->m_pszName;
- allConVars[commandName] = pCommand;
- }
-
- return allConVars;
- }
-};
-
namespace
{
/* ==== ICONVAR ========================================================================================================================================================= */
@@ -176,13 +168,11 @@ namespace
}
///////////////////////////////////////////////////////////////////////////////
-bool HIConVar_IsFlagSet(ConVar* pConVar, int nFlag);
-void IConVar_InitConVar();
-void IConVar_ClearHostNames();
-
void IConVar_Attach();
void IConVar_Detach();
+extern ConVar* g_pConVar;
+
///////////////////////////////////////////////////////////////////////////////
class HConVar : public IDetour
{
diff --git a/r5dev/tier0/cvar.cpp b/r5dev/tier0/cvar.cpp
index 7b470d2b..d0531640 100644
--- a/r5dev/tier0/cvar.cpp
+++ b/r5dev/tier0/cvar.cpp
@@ -3,18 +3,18 @@
#include "tier0/IConVar.h"
#include "engine/sys_dll2.h"
-//-------------------------------------------------------------------------
-// ENGINE |
+//-----------------------------------------------------------------------------
+// ENGINE |
ConVar* cm_debug_cmdquery = new ConVar();
ConVar* cm_return_false_cmdquery_all = new ConVar();
ConVar* cm_return_false_cmdquery_cheats = new ConVar();
ConVar* r_debug_overlay_nodecay = new ConVar();
-//-------------------------------------------------------------------------
-// SERVER |
+//-----------------------------------------------------------------------------
+// SERVER |
ConVar* sv_showconnecting = new ConVar();
ConVar* sv_pylonvisibility = new ConVar();
-//-------------------------------------------------------------------------
-// CLIENT |
+//-----------------------------------------------------------------------------
+// CLIENT |
ConVar* cl_drawconsoleoverlay = new ConVar();
ConVar* cl_consoleoverlay_lines = new ConVar();
ConVar* cl_consoleoverlay_offset_x = new ConVar();
@@ -27,24 +27,83 @@ ConVar* cl_simstats_offset_y = new ConVar();
ConVar* cl_showgpustats = new ConVar();
ConVar* cl_gpustats_offset_x = new ConVar();
ConVar* cl_gpustats_offset_y = new ConVar();
-//-------------------------------------------------------------------------
-// FILESYSTEM |
+//-----------------------------------------------------------------------------
+// FILESYSTEM |
ConVar* fs_warning_level_native = new ConVar();
ConVar* fs_packedstore_entryblock_stats = new ConVar();
-//-------------------------------------------------------------------------
-// MATERIALSYSTEM |
+//-----------------------------------------------------------------------------
+// MATERIALSYSTEM |
ConVar* mat_showdxoutput = new ConVar();
-//-------------------------------------------------------------------------
-// SQUIRREL |
+//-----------------------------------------------------------------------------
+// SQUIRREL |
ConVar* sq_showrsonloading = new ConVar();
ConVar* sq_showscriptloading = new ConVar();
ConVar* sq_showvmoutput = new ConVar();
ConVar* sq_showvmwarning = new ConVar();
-//-------------------------------------------------------------------------
-// NETCHANNEL |
+//-----------------------------------------------------------------------------
+// NETCHANNEL |
ConVar* net_userandomkey = new ConVar();
ConVar* r5net_matchmaking_hostname = new ConVar();
ConVar* r5net_show_debug = new ConVar();
+//-----------------------------------------------------------------------------
+// Purpose: finds base commands.
+// Input : *pszCommandName -
+//-----------------------------------------------------------------------------
+ConCommandBase* CCVar::FindCommandBase(const char* pszCommandName)
+{
+ using OriginalFn = ConCommandBase * (__thiscall*)(CCVar*, const char*);
+ return (*reinterpret_cast(this))[14](this, pszCommandName);
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: finds ConVars.
+// Input : *pszVarName -
+//-----------------------------------------------------------------------------
+ConVar* CCVar::FindVar(const char* pszVarName)
+{
+ using OriginalFn = ConVar * (__thiscall*)(CCVar*, const char*);
+ return (*reinterpret_cast(this))[16](this, pszVarName);
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: finds ConCommands.
+// Input : *pszCommandName -
+//-----------------------------------------------------------------------------
+ConCommand* CCVar::FindCommand(const char* pszCommandName)
+{
+ using OriginalFn = ConCommand* (__thiscall*)(CCVar*, const char*);
+ return (*reinterpret_cast(this))[18](this, pszCommandName);
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: iterates over all ConVars
+//-----------------------------------------------------------------------------
+CCVarIteratorInternal* CCVar::FactoryInternalIterator()
+{
+ using OriginalFn = CCVarIteratorInternal * (__thiscall*)(CCVar*);
+ return (*reinterpret_cast(this))[41](this);
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: returns all ConVars
+//-----------------------------------------------------------------------------
+std::unordered_map CCVar::DumpToMap()
+{
+ std::stringstream ss;
+ CCVarIteratorInternal* itint = FactoryInternalIterator(); // Allocatd new InternalIterator.
+
+ std::unordered_map 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;
+}
+
///////////////////////////////////////////////////////////////////////////////
CCVar* g_pCvar = reinterpret_cast(p_CEngineAPI_Connect.FindPatternSelf("48 8D 0D", ADDRESS::Direction::DOWN, 40).ResolveRelativeAddressSelf(0x3, 0x7).GetPtr());
diff --git a/r5dev/tier0/cvar.h b/r5dev/tier0/cvar.h
index 04a4c192..53da011a 100644
--- a/r5dev/tier0/cvar.h
+++ b/r5dev/tier0/cvar.h
@@ -57,6 +57,28 @@ extern ConVar* net_userandomkey;
extern ConVar* r5net_matchmaking_hostname;
extern ConVar* r5net_show_debug;
+extern ConVar* test_color_test;
+
+
+class CCVarIteratorInternal // Fully reversed table, just look at the virtual function table and rename the function.
+{
+public:
+ virtual void SetFirst(void) = 0; //0
+ virtual void Next(void) = 0; //1
+ virtual bool IsValid(void) = 0; //2
+ virtual ConCommandBase* Get(void) = 0; //3
+};
+
+class CCVar
+{
+public:
+ ConCommandBase* FindCommandBase(const char* pszCommandName); // @0x1405983A0 in R5pc_r5launch_N1094_CL456479_2019_10_30_05_20_PM
+ ConVar* FindVar(const char* pszVarName); // @0x1405983B0 in R5pc_r5launch_N1094_CL456479_2019_10_30_05_20_PM
+ ConCommand* FindCommand(const char* pszCommandName);
+ CCVarIteratorInternal* FactoryInternalIterator();
+ std::unordered_map DumpToMap();
+};
+
///////////////////////////////////////////////////////////////////////////////
extern CCVar* g_pCvar;
diff --git a/r5dev/vgui/CEngineVGui.cpp b/r5dev/vgui/CEngineVGui.cpp
index 4b19f630..407d7ed8 100644
--- a/r5dev/vgui/CEngineVGui.cpp
+++ b/r5dev/vgui/CEngineVGui.cpp
@@ -40,21 +40,20 @@ void CLogSystem::Update()
{
return;
}
- if (cl_drawconsoleoverlay->m_pParent->m_iValue > 0)
+ if (cl_drawconsoleoverlay->GetBool())
{
DrawLog();
}
- if (cl_showsimstats->m_pParent->m_iValue > 0)
+ if (cl_showsimstats->GetBool())
{
DrawSimStats();
}
- if (cl_showgpustats->m_pParent->m_iValue > 0)
+ if (cl_showgpustats->GetBool())
{
DrawGPUStats();
}
}
-
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
@@ -66,7 +65,6 @@ void CLogSystem::AddLog(LogType_t type, std::string message)
}
}
-
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
@@ -106,7 +104,6 @@ void CLogSystem::DrawLog()
}
}
-
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
@@ -114,13 +111,12 @@ void CLogSystem::DrawSimStats()
{
Color c = { 255, 255, 255, 255 };
static const char* szLogbuf[4096]{};
- snprintf((char*)szLogbuf, 4096, "Server Frame: (%d) Client Frame (%d) Render Frame (%d)\n",
+ snprintf((char*)szLogbuf, 4096, "Server Frame: (%d) Client Frame: (%d) Render Frame: (%d)\n",
*sv_m_nTickCount, *cl_host_tickcount, *render_tickcount);
- CMatSystemSurface_DrawColoredText(g_pMatSystemSurface, 0x13, fontHeight, cl_simstats_offset_x->m_iValue, cl_simstats_offset_y->m_iValue, c._color[0], c._color[1], c._color[2], 255, (char*)szLogbuf);
+ CMatSystemSurface_DrawColoredText(g_pMatSystemSurface, 0x13, fontHeight, cl_simstats_offset_x->GetInt(), cl_simstats_offset_y->GetInt(), c._color[0], c._color[1], c._color[2], 255, (char*)szLogbuf);
}
-
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
@@ -131,10 +127,9 @@ void CLogSystem::DrawGPUStats()
snprintf((char*)szLogbuf, 4096, "%8d/%8d/%8dkiB unusable/unfree/total GPU Streaming Texture memory\n",
*unusable_streaming_tex_memory / 1024, *unfree_streaming_tex_memory / 1024, *unusable_streaming_tex_memory / 1024);
- CMatSystemSurface_DrawColoredText(g_pMatSystemSurface, 0x13, fontHeight, cl_gpustats_offset_x->m_iValue, cl_gpustats_offset_y->m_iValue, c._color[0], c._color[1], c._color[2], 255, (char*)szLogbuf);
+ CMatSystemSurface_DrawColoredText(g_pMatSystemSurface, 0x13, fontHeight, cl_gpustats_offset_x->GetInt(), cl_gpustats_offset_y->GetInt(), c._color[0], c._color[1], c._color[2], 255, (char*)szLogbuf);
}
-
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------