From 2dcbf5904130b008647d3eea8be6b2b8076fab22 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sat, 9 Apr 2022 16:16:40 +0200 Subject: [PATCH] Move ConVar/ConCommand stuff to tier1 instead and cleanup KeyValues/KeyValuesSystem --- r5dev/bsplib/bsplib.cpp | 2 +- r5dev/client/cdll_engine_int.cpp | 6 +- r5dev/core/init.cpp | 9 +- r5dev/ebisusdk/EbisuSDK.h | 2 +- r5dev/engine/cl_rcon.cpp | 6 +- r5dev/engine/host_state.cpp | 4 +- r5dev/engine/net.cpp | 4 +- r5dev/engine/net_chan.cpp | 2 +- r5dev/engine/sv_rcon.cpp | 6 +- r5dev/engine/sys_utils.cpp | 2 +- r5dev/filesystem/basefilesystem.cpp | 2 +- r5dev/game/server/ai_network.cpp | 2 +- r5dev/game/server/ai_networkmanager.cpp | 4 +- r5dev/game/server/ai_utility.cpp | 2 +- r5dev/gameui/IBrowser.cpp | 8 +- r5dev/gameui/IConsole.cpp | 2 +- r5dev/launcher/IApplication.cpp | 2 +- r5dev/materialsystem/cmaterialsystem.cpp | 2 +- r5dev/networksystem/pylon.cpp | 2 +- r5dev/networksystem/r5net.cpp | 2 +- r5dev/rtech/rui/rui.cpp | 2 +- r5dev/server/server.cpp | 2 +- r5dev/server/vengineserver_impl.cpp | 2 +- r5dev/squirrel/sqvm.cpp | 4 +- r5dev/tier0/commandline.cpp | 2 +- r5dev/{tier0 => tier1}/IConVar.cpp | 4 +- r5dev/{tier0 => tier1}/IConVar.h | 2 +- r5dev/{tier0 => tier1}/cmd.cpp | 6 +- r5dev/{tier0 => tier1}/cmd.h | 0 r5dev/{tier0 => tier1}/cvar.cpp | 4 +- r5dev/{tier0 => tier1}/cvar.h | 2 +- r5dev/vgui/vgui_baseui_interface.cpp | 2 +- r5dev/vgui/vgui_debugpanel.cpp | 2 +- r5dev/vgui/vgui_fpspanel.cpp | 2 +- r5dev/vgui/vgui_fpspanel.h | 2 +- r5dev/vpc/keyvalues.cpp | 153 +++++++++++++++----- r5dev/vpc/keyvalues.h | 177 ++--------------------- r5dev/vpklib/packedstore.cpp | 2 +- r5dev/vproj/clientsdk.vcxproj | 18 ++- r5dev/vproj/clientsdk.vcxproj.filters | 57 +++++--- r5dev/vproj/dedicated.vcxproj | 18 ++- r5dev/vproj/dedicated.vcxproj.filters | 57 +++++--- r5dev/vproj/gamesdk.vcxproj | 18 ++- r5dev/vproj/gamesdk.vcxproj.filters | 57 +++++--- r5dev/{tier0 => vstdlib}/completion.cpp | 6 +- r5dev/{tier0 => vstdlib}/completion.h | 2 +- r5dev/vstdlib/keyvaluessystem.cpp | 137 ++++++++++++++++++ r5dev/vstdlib/keyvaluessystem.h | 58 ++++++++ r5dev/windows/console.cpp | 2 +- r5dev/windows/id3dx.cpp | 2 +- 50 files changed, 514 insertions(+), 359 deletions(-) rename r5dev/{tier0 => tier1}/IConVar.cpp (99%) rename r5dev/{tier0 => tier1}/IConVar.h (99%) rename r5dev/{tier0 => tier1}/cmd.cpp (99%) rename r5dev/{tier0 => tier1}/cmd.h (100%) rename r5dev/{tier0 => tier1}/cvar.cpp (99%) rename r5dev/{tier0 => tier1}/cvar.h (99%) rename r5dev/{tier0 => vstdlib}/completion.cpp (99%) rename r5dev/{tier0 => vstdlib}/completion.h (99%) create mode 100644 r5dev/vstdlib/keyvaluessystem.cpp create mode 100644 r5dev/vstdlib/keyvaluessystem.h diff --git a/r5dev/bsplib/bsplib.cpp b/r5dev/bsplib/bsplib.cpp index 4fee54ad..9b2fa85f 100644 --- a/r5dev/bsplib/bsplib.cpp +++ b/r5dev/bsplib/bsplib.cpp @@ -1,5 +1,5 @@ #include "core/stdafx.h" -#include "tier0/cvar.h" +#include "tier1/cvar.h" #include "common/pseudodefs.h" #include "bsplib/bsplib.h" #include "engine/host_state.h" diff --git a/r5dev/client/cdll_engine_int.cpp b/r5dev/client/cdll_engine_int.cpp index 8522df83..66dfd0b4 100644 --- a/r5dev/client/cdll_engine_int.cpp +++ b/r5dev/client/cdll_engine_int.cpp @@ -1,8 +1,8 @@ #include "core/stdafx.h" /*****************************************************************************/ -#include "tier0/IConVar.h" -#include "tier0/cvar.h" +#include "tier1/cvar.h" #include "tier0/commandline.h" +#include "tier1/IConVar.h" #include "client/vengineclient_impl.h" #include "client/cdll_engine_int.h" #include "engine/net_chan.h" @@ -27,7 +27,7 @@ void __fastcall HFrameStageNotify(CHLClient* rcx, ClientFrameStage_t frameStage) #ifdef GAMEDLL_S3 g_pConVar->ClearHostNames(); #endif // GAMEDLL_S3 - CKeyValueSystem_Init(); + KeyValues::Init(); #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) || defined (GAMEDLL_S2) // !TEMP UNTIL CHOSTSTATE IS BUILD AGNOSTIC! // if (!g_pCmdLine->CheckParm("-devsdk")) { diff --git a/r5dev/core/init.cpp b/r5dev/core/init.cpp index 7365a86e..eebe8e79 100644 --- a/r5dev/core/init.cpp +++ b/r5dev/core/init.cpp @@ -7,13 +7,14 @@ #include "core/stdafx.h" #include "core/init.h" #include "tier0/commandline.h" -#include "tier0/completion.h" -#include "tier0/cmd.h" -#include "tier0/cvar.h" -#include "tier0/IConVar.h" +#include "tier1/cmd.h" +#include "tier1/IConVar.h" +#include "tier1/cvar.h" #include "vpc/IAppSystem.h" #include "vpc/keyvalues.h" #include "vpc/interfaces.h" +#include "vstdlib/completion.h" +#include "vstdlib/keyvaluessystem.h" #include "common/opcodes.h" #include "common/netmessages.h" #include "launcher/IApplication.h" diff --git a/r5dev/ebisusdk/EbisuSDK.h b/r5dev/ebisusdk/EbisuSDK.h index 2269116c..1bbda527 100644 --- a/r5dev/ebisusdk/EbisuSDK.h +++ b/r5dev/ebisusdk/EbisuSDK.h @@ -1,5 +1,5 @@ #pragma once -#include "tier0/completion.h" +#include "vstdlib/completion.h" #include "public/include/utility.h" //#ifdef DEDICATED diff --git a/r5dev/engine/cl_rcon.cpp b/r5dev/engine/cl_rcon.cpp index 72e69476..5a915810 100644 --- a/r5dev/engine/cl_rcon.cpp +++ b/r5dev/engine/cl_rcon.cpp @@ -5,9 +5,9 @@ //===========================================================================// #include "core/stdafx.h" -#include "tier0/IConVar.h" -#include "tier0/cmd.h" -#include "tier0/cvar.h" +#include "tier1/IConVar.h" +#include "tier1/cmd.h" +#include "tier1/cvar.h" #include "protoc/sv_rcon.pb.h" #include "protoc/cl_rcon.pb.h" #include "engine/cl_rcon.h" diff --git a/r5dev/engine/host_state.cpp b/r5dev/engine/host_state.cpp index 9e00b96b..2699f701 100644 --- a/r5dev/engine/host_state.cpp +++ b/r5dev/engine/host_state.cpp @@ -5,10 +5,10 @@ //=============================================================================// #include "core/stdafx.h" -#include "tier0/cmd.h" -#include "tier0/cvar.h" #include "tier0/commandline.h" #include "tier0/fasttimer.h" +#include "tier1/cmd.h" +#include "tier1/cvar.h" #include "tier1/NetAdr2.h" #include "tier2/socketcreator.h" #include "vpc/keyvalues.h" diff --git a/r5dev/engine/net.cpp b/r5dev/engine/net.cpp index c66a8c5d..f979475d 100644 --- a/r5dev/engine/net.cpp +++ b/r5dev/engine/net.cpp @@ -8,8 +8,8 @@ #include "engine/net.h" #ifndef NETCONSOLE #include "core/logdef.h" -#include "tier0/cvar.h" -#include "tier0/completion.h" +#include "tier1/cvar.h" +#include "vstdlib/completion.h" #include "mathlib/color.h" #include "engine/sys_utils.h" #include "engine/net.h" diff --git a/r5dev/engine/net_chan.cpp b/r5dev/engine/net_chan.cpp index d2364428..8dfc87de 100644 --- a/r5dev/engine/net_chan.cpp +++ b/r5dev/engine/net_chan.cpp @@ -5,7 +5,7 @@ //=============================================================================// #include "core/stdafx.h" -#include "tier0/cvar.h" +#include "tier1/cvar.h" #include "engine/sys_utils.h" #include "engine/net.h" #include "engine/net_chan.h" diff --git a/r5dev/engine/sv_rcon.cpp b/r5dev/engine/sv_rcon.cpp index 23061c84..62b103c5 100644 --- a/r5dev/engine/sv_rcon.cpp +++ b/r5dev/engine/sv_rcon.cpp @@ -5,9 +5,9 @@ //===========================================================================// #include "core/stdafx.h" -#include "tier0/cmd.h" -#include "tier0/cvar.h" -#include "tier0/IConVar.h" +#include "tier1/cmd.h" +#include "tier1/cvar.h" +#include "tier1/IConVar.h" #include "tier1/NetAdr2.h" #include "tier2/socketcreator.h" #include "engine/sys_utils.h" diff --git a/r5dev/engine/sys_utils.cpp b/r5dev/engine/sys_utils.cpp index 18806948..4d5e026e 100644 --- a/r5dev/engine/sys_utils.cpp +++ b/r5dev/engine/sys_utils.cpp @@ -6,8 +6,8 @@ #include "core/stdafx.h" #include "core/logdef.h" -#include "tier0/cvar.h" #include "tier0/commandline.h" +#include "tier1/cvar.h" #include "engine/common.h" #include "engine/host_state.h" #include "engine/sys_utils.h" diff --git a/r5dev/filesystem/basefilesystem.cpp b/r5dev/filesystem/basefilesystem.cpp index 2a38db53..e9c952c6 100644 --- a/r5dev/filesystem/basefilesystem.cpp +++ b/r5dev/filesystem/basefilesystem.cpp @@ -1,6 +1,6 @@ #include "core/stdafx.h" #include "core/logdef.h" -#include "tier0/cvar.h" +#include "tier1/cvar.h" #include "filesystem/basefilesystem.h" #include "filesystem/filesystem.h" #ifndef DEDICATED diff --git a/r5dev/game/server/ai_network.cpp b/r5dev/game/server/ai_network.cpp index fcbd3a6a..3ebbc9e6 100644 --- a/r5dev/game/server/ai_network.cpp +++ b/r5dev/game/server/ai_network.cpp @@ -4,7 +4,7 @@ // //=============================================================================// #include "core/stdafx.h" -#include "tier0/cvar.h" +#include "tier1/cvar.h" #include "engine/sys_utils.h" #include "game/server/ai_network.h" diff --git a/r5dev/game/server/ai_networkmanager.cpp b/r5dev/game/server/ai_networkmanager.cpp index da889104..09cb858e 100644 --- a/r5dev/game/server/ai_networkmanager.cpp +++ b/r5dev/game/server/ai_networkmanager.cpp @@ -5,9 +5,9 @@ //=============================================================================// #include "core/stdafx.h" -#include "tier0/cvar.h" -#include "tier0/cmd.h" #include "tier0/fasttimer.h" +#include "tier1/cvar.h" +#include "tier1/cmd.h" #include "mathlib/crc32.h" #include "public/include/edict.h" #include "public/include/utility.h" diff --git a/r5dev/game/server/ai_utility.cpp b/r5dev/game/server/ai_utility.cpp index 13121e21..f6b866d9 100644 --- a/r5dev/game/server/ai_utility.cpp +++ b/r5dev/game/server/ai_utility.cpp @@ -5,7 +5,7 @@ //=============================================================================// #include "core/stdafx.h" -#include "tier0/cvar.h" +#include "tier1/cvar.h" #include "game/server/detour_impl.h" //----------------------------------------------------------------------------- diff --git a/r5dev/gameui/IBrowser.cpp b/r5dev/gameui/IBrowser.cpp index 0f615eda..215aeef4 100644 --- a/r5dev/gameui/IBrowser.cpp +++ b/r5dev/gameui/IBrowser.cpp @@ -14,10 +14,9 @@ History: #include "core/stdafx.h" #include "core/init.h" #include "core/resource.h" -#include "tier0/IConVar.h" -#include "tier0/cvar.h" #include "tier0/commandline.h" -#include "tier0/completion.h" +#include "tier1/IConVar.h" +#include "tier1/cvar.h" #include "windows/id3dx.h" #include "windows/console.h" #include "engine/net.h" @@ -30,6 +29,7 @@ History: #include "server/server.h" #include "client/vengineclient_impl.h" #include "vpc/keyvalues.h" +#include "vstdlib/completion.h" #include "vpklib/packedstore.h" #include "gameui/IBrowser.h" @@ -574,7 +574,7 @@ void IBrowser::HostServerSection(void) if (ImGui::Button("Reload Playlist from Disk##ServerHost_ReloadPlaylist", ImVec2(ImGui::GetWindowSize().x, 32))) { DownloadPlaylists_f_CompletionFunc(); - CKeyValueSystem_InitPlaylist(); // Re-Init playlist. + KeyValues::InitPlaylist(); // Re-Init playlist. } } #endif // !CLIENT_DLL diff --git a/r5dev/gameui/IConsole.cpp b/r5dev/gameui/IConsole.cpp index f6f54a9a..ac73586a 100644 --- a/r5dev/gameui/IConsole.cpp +++ b/r5dev/gameui/IConsole.cpp @@ -14,8 +14,8 @@ History: #include "core/stdafx.h" #include "core/init.h" -#include "tier0/cvar.h" #include "tier0/commandline.h" +#include "tier1/cvar.h" #include "windows/id3dx.h" #include "windows/console.h" #include "gameui/IConsole.h" diff --git a/r5dev/launcher/IApplication.cpp b/r5dev/launcher/IApplication.cpp index 868b7b43..90bf1f8b 100644 --- a/r5dev/launcher/IApplication.cpp +++ b/r5dev/launcher/IApplication.cpp @@ -5,7 +5,7 @@ //=============================================================================// #include "core/stdafx.h" -#include "tier0/cvar.h" +#include "tier1/cvar.h" #include "vpc/interfaces.h" #include "launcher/IApplication.h" #include "ebisusdk/EbisuSDK.h" diff --git a/r5dev/materialsystem/cmaterialsystem.cpp b/r5dev/materialsystem/cmaterialsystem.cpp index 8fe513ba..87db1714 100644 --- a/r5dev/materialsystem/cmaterialsystem.cpp +++ b/r5dev/materialsystem/cmaterialsystem.cpp @@ -4,7 +4,7 @@ // //===========================================================================// #include "core/stdafx.h" -#include "tier0/cvar.h" +#include "tier1/cvar.h" #include "engine/sys_utils.h" #include "materialsystem/cmaterialsystem.h" diff --git a/r5dev/networksystem/pylon.cpp b/r5dev/networksystem/pylon.cpp index 9676d0dd..8ee73173 100644 --- a/r5dev/networksystem/pylon.cpp +++ b/r5dev/networksystem/pylon.cpp @@ -6,7 +6,7 @@ //=====================================================================================// #include -#include +#include #include #include #include diff --git a/r5dev/networksystem/r5net.cpp b/r5dev/networksystem/r5net.cpp index ff0c2be6..3dbb48a5 100644 --- a/r5dev/networksystem/r5net.cpp +++ b/r5dev/networksystem/r5net.cpp @@ -2,7 +2,7 @@ // #include "core/stdafx.h" -#include "tier0/cvar.h" +#include "tier1/cvar.h" #include "engine/sys_utils.h" #include "networksystem/r5net.h" diff --git a/r5dev/rtech/rui/rui.cpp b/r5dev/rtech/rui/rui.cpp index b3661c4b..fd3328a9 100644 --- a/r5dev/rtech/rui/rui.cpp +++ b/r5dev/rtech/rui/rui.cpp @@ -9,7 +9,7 @@ #ifndef DEDICATED #include "rui.h" -#include +#include "tier1/cvar.h" //----------------------------------------------------------------------------- // Purpose: Probably responsible to decide if rUI is allowed to draw. diff --git a/r5dev/server/server.cpp b/r5dev/server/server.cpp index 71c51ccf..0ef67141 100644 --- a/r5dev/server/server.cpp +++ b/r5dev/server/server.cpp @@ -1,5 +1,5 @@ #include "core/stdafx.h" -#include "tier0/cvar.h" +#include "tier1/cvar.h" #include "engine/sys_utils.h" #include "server/server.h" #include "engine/baseclient.h" diff --git a/r5dev/server/vengineserver_impl.cpp b/r5dev/server/vengineserver_impl.cpp index 55e53d71..0ede721c 100644 --- a/r5dev/server/vengineserver_impl.cpp +++ b/r5dev/server/vengineserver_impl.cpp @@ -5,7 +5,7 @@ //=============================================================================// #include "core/stdafx.h" -#include "tier0/cvar.h" +#include "tier1/cvar.h" #include "common/protocol.h" #include "engine/sys_utils.h" #include "engine/baseclient.h" diff --git a/r5dev/squirrel/sqvm.cpp b/r5dev/squirrel/sqvm.cpp index e0e33607..fc7f6bbe 100644 --- a/r5dev/squirrel/sqvm.cpp +++ b/r5dev/squirrel/sqvm.cpp @@ -6,9 +6,9 @@ #include "core/stdafx.h" #include "core/logdef.h" -#include "tier0/cvar.h" -#include "tier0/IConVar.h" #include "tier0/commandline.h" +#include "tier1/cvar.h" +#include "tier1/IConVar.h" #include "engine/sys_utils.h" #ifdef DEDICATED #include "engine/sv_rcon.h" diff --git a/r5dev/tier0/commandline.cpp b/r5dev/tier0/commandline.cpp index ec07c67f..6c417059 100644 --- a/r5dev/tier0/commandline.cpp +++ b/r5dev/tier0/commandline.cpp @@ -5,8 +5,8 @@ //=============================================================================// #include "core/stdafx.h" -#include "tier0/cvar.h" #include "tier0/commandline.h" +#include "tier1/cvar.h" //----------------------------------------------------------------------------- // Purpose: Create a command line from the passed in string diff --git a/r5dev/tier0/IConVar.cpp b/r5dev/tier1/IConVar.cpp similarity index 99% rename from r5dev/tier0/IConVar.cpp rename to r5dev/tier1/IConVar.cpp index f7fcf37b..3cf0b90e 100644 --- a/r5dev/tier0/IConVar.cpp +++ b/r5dev/tier1/IConVar.cpp @@ -5,8 +5,8 @@ //=============================================================================// #include "core/stdafx.h" -#include "tier0/cvar.h" -#include "tier0/IConVar.h" +#include "tier1/IConVar.h" +#include "tier1/cvar.h" #include "engine/sys_utils.h" #include "engine/sys_dll2.h" #include "mathlib/bits.h" diff --git a/r5dev/tier0/IConVar.h b/r5dev/tier1/IConVar.h similarity index 99% rename from r5dev/tier0/IConVar.h rename to r5dev/tier1/IConVar.h index e6fd0402..d8017b05 100644 --- a/r5dev/tier0/IConVar.h +++ b/r5dev/tier1/IConVar.h @@ -1,5 +1,5 @@ #pragma once -#include "tier0/cmd.h" +#include "tier1/cmd.h" #include "mathlib/color.h" //----------------------------------------------------------------------------- diff --git a/r5dev/tier0/cmd.cpp b/r5dev/tier1/cmd.cpp similarity index 99% rename from r5dev/tier0/cmd.cpp rename to r5dev/tier1/cmd.cpp index 9f7328a0..ee718b64 100644 --- a/r5dev/tier0/cmd.cpp +++ b/r5dev/tier1/cmd.cpp @@ -1,7 +1,7 @@ #include "core/stdafx.h" -#include "tier0/cmd.h" -#include "tier0/cvar.h" -#include "tier0/completion.h" +#include "tier1/cmd.h" +#include "tier1/cvar.h" +#include "vstdlib/completion.h" #include "engine/sys_utils.h" //----------------------------------------------------------------------------- diff --git a/r5dev/tier0/cmd.h b/r5dev/tier1/cmd.h similarity index 100% rename from r5dev/tier0/cmd.h rename to r5dev/tier1/cmd.h diff --git a/r5dev/tier0/cvar.cpp b/r5dev/tier1/cvar.cpp similarity index 99% rename from r5dev/tier0/cvar.cpp rename to r5dev/tier1/cvar.cpp index ae3971b4..90171e76 100644 --- a/r5dev/tier0/cvar.cpp +++ b/r5dev/tier1/cvar.cpp @@ -1,6 +1,6 @@ #include "core/stdafx.h" -#include "tier0/cvar.h" -#include "tier0/IConVar.h" +#include "tier1/cvar.h" +#include "tier1/IConVar.h" #include "engine/sys_dll2.h" //----------------------------------------------------------------------------- diff --git a/r5dev/tier0/cvar.h b/r5dev/tier1/cvar.h similarity index 99% rename from r5dev/tier0/cvar.h rename to r5dev/tier1/cvar.h index 09856a7b..7b908a43 100644 --- a/r5dev/tier0/cvar.h +++ b/r5dev/tier1/cvar.h @@ -1,5 +1,5 @@ #pragma once -#include "tier0/IConVar.h" +#include "tier1/IConVar.h" //------------------------------------------------------------------------- // ENGINE | diff --git a/r5dev/vgui/vgui_baseui_interface.cpp b/r5dev/vgui/vgui_baseui_interface.cpp index 3cd783b9..c991dfa7 100644 --- a/r5dev/vgui/vgui_baseui_interface.cpp +++ b/r5dev/vgui/vgui_baseui_interface.cpp @@ -6,7 +6,7 @@ //===========================================================================// #include -#include "tier0/cvar.h" +#include #include #include #include diff --git a/r5dev/vgui/vgui_debugpanel.cpp b/r5dev/vgui/vgui_debugpanel.cpp index 22674ac8..cd668922 100644 --- a/r5dev/vgui/vgui_debugpanel.cpp +++ b/r5dev/vgui/vgui_debugpanel.cpp @@ -6,7 +6,7 @@ //===========================================================================// #include -#include +#include #include #include #include diff --git a/r5dev/vgui/vgui_fpspanel.cpp b/r5dev/vgui/vgui_fpspanel.cpp index 1edab289..13b8c1a9 100644 --- a/r5dev/vgui/vgui_fpspanel.cpp +++ b/r5dev/vgui/vgui_fpspanel.cpp @@ -6,7 +6,7 @@ //===========================================================================// #include "core/stdafx.h" -#include "tier0/cvar.h" +#include "tier1/cvar.h" #include "vgui/vgui_fpspanel.h" #include "vgui/vgui_debugpanel.h" diff --git a/r5dev/vgui/vgui_fpspanel.h b/r5dev/vgui/vgui_fpspanel.h index 1ab02af8..a420a3de 100644 --- a/r5dev/vgui/vgui_fpspanel.h +++ b/r5dev/vgui/vgui_fpspanel.h @@ -1,5 +1,5 @@ #pragma once -#include "tier0/IConVar.h" +#include "tier1/IConVar.h" /* ==== CFPSPANEL ======================================================================================================================================================= */ inline ADDRESS p_CFPSPanel_Paint = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x55\x56\x41\x00\x48\x8D\xA8\x00\xFD\xFF\xFF\x48\x81\xEC\x80"), "xxxxxx?xxx?xxxxxxx"); diff --git a/r5dev/vpc/keyvalues.cpp b/r5dev/vpc/keyvalues.cpp index 7052d158..928265c0 100644 --- a/r5dev/vpc/keyvalues.cpp +++ b/r5dev/vpc/keyvalues.cpp @@ -1,28 +1,119 @@ +//=============================================================================// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + #include "core/stdafx.h" #include "vpc/keyvalues.h" +#include "vstdlib/keyvaluessystem.h" #include "rtech/stryder/stryder.h" #include "engine/sys_dll2.h" -/////////////////////////////////////////////////////////////////////////////// -std::vector g_szAllPlaylists = { "none" }; -CKeyValuesSystem* g_pKeyValuesSystem = reinterpret_cast(p_KeyValues_Init.FindPatternSelf("48 8D ?? ?? ?? ?? 01", ADDRESS::Direction::DOWN, 100).ResolveRelativeAddressSelf(0x3, 0x7).GetPtr()); - -#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) -KeyValues** g_pPlaylistKeyValues = reinterpret_cast(p_Stryder_StitchRequest.FindPatternSelf("48 8B 2D", ADDRESS::Direction::DOWN, 100).ResolveRelativeAddressSelf(0x3, 0x7).GetPtr()); // Get the KeyValue for the playlist file. -#elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) -KeyValues** g_pPlaylistKeyValues = reinterpret_cast(p_Stryder_StitchRequest.FindPatternSelf("48 8B 0D", ADDRESS::Direction::DOWN, 100).ResolveRelativeAddressSelf(0x3, 0x7).GetPtr()); // Get the KeyValue for the playlist file. -#endif - //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- -void CKeyValueSystem_InitPlaylist() +void KeyValues::Init(void) +{ + std::thread t1(KeyValues::InitPlaylist); // Start thread to grab playlists. + t1.detach(); // Detach thread from current one. +} + +//----------------------------------------------------------------------------- +// Purpose: Find a keyValue, create it if it is not found. +// Set bCreate to true to create the key if it doesn't already exist +// (which ensures a valid pointer will be returned) +// Input : *pKeyName - +// bCreate - +// Output : *KeyValues +//----------------------------------------------------------------------------- +KeyValues* KeyValues::FindKey(const char* keyName, bool bCreate) +{ + static auto func = reinterpret_cast(KeyValues_FindKey); + return func(this, keyName, bCreate); +} + +//----------------------------------------------------------------------------- +// Purpose: Get the name of the current key section +// Output : const char* +//----------------------------------------------------------------------------- +const char* KeyValues::GetName(void) const +{ + return g_pKeyValuesSystem->GetStringForSymbol(MAKE_3_BYTES_FROM_1_AND_2(m_iKeyNameCaseSensitive, m_iKeyNameCaseSensitive2)); +} + +//----------------------------------------------------------------------------- +// Purpose: Get the integer value of a keyName. Default value is returned +// if the keyName can't be found. +// Input : *pKeyName - +// nDefaultValue - +// Output : int +//----------------------------------------------------------------------------- +int KeyValues::GetInt(const char* pKeyName, int nDefaultValue) +{ + KeyValues* dat = FindKey(pKeyName, false); + + if (!dat) + return nDefaultValue; + + switch (dat->m_iDataType) + { + case TYPE_STRING: + return atoi(dat->m_sValue); + case TYPE_FLOAT: + return static_cast(m_flValue()); + case TYPE_WSTRING: + return _wtoi(dat->m_wsValue); + case TYPE_UINT64: + return 0; + default: + return dat->m_iValue(); + } + + return nDefaultValue; +} + +//----------------------------------------------------------------------------- +// Purpose: Set the integer value of a keyName. +// Input : *pKeyName - +// iValue - +//----------------------------------------------------------------------------- +void KeyValues::SetInt(const char* pKeyName, int iValue) +{ + KeyValues* dat = FindKey(pKeyName, true); + if (dat) + { + dat->m_iValue() = iValue; + dat->m_iDataType = TYPE_INT; + } +} + +//----------------------------------------------------------------------------- +// Purpose: Set the float value of a keyName. +// Input : *pKeyName - +// flValue - +//----------------------------------------------------------------------------- +void KeyValues::SetFloat(const char* pKeyName, float flValue) +{ + KeyValues* dat = FindKey(pKeyName, true); + if (dat) + { + dat->m_flValue() = flValue; + dat->m_iDataType = TYPE_FLOAT; + } +} + +//----------------------------------------------------------------------------- +// Purpose: Initializes the playlist +//----------------------------------------------------------------------------- +void KeyValues::InitPlaylist(void) { while (true) { if ((*g_pPlaylistKeyValues)) { - KeyValues* playlists = (*g_pPlaylistKeyValues)->FindKey("Playlists", false); // Find playlists key. + KeyValues* playlists = (*g_pPlaylistKeyValues)->FindKey("Playlists", false); if (playlists) { g_szAllPlaylists.clear(); @@ -40,11 +131,12 @@ void CKeyValueSystem_InitPlaylist() } //----------------------------------------------------------------------------- -// Purpose: +// Purpose: loads the playlist +// Input : *szPlaylist - //----------------------------------------------------------------------------- -bool HKeyValues_LoadPlaylist(const char* playlist) +bool KeyValues::LoadPlaylist(const char* szPlaylist) { - memset(g_pMapVPKCache, 0, 0x40); // Clear VPK cache to prevent crash while loading playlist. + memset(g_pMapVPKCache, '\0', 0x40); // Clear VPK cache to prevent crash while loading playlist. CHAR sPlaylistPath[] = "\x77\x27\x35\x2b\x2c\x6c\x2b\x2c\x2b"; PCHAR curr = sPlaylistPath; @@ -68,33 +160,24 @@ bool HKeyValues_LoadPlaylist(const char* playlist) reinterpret_cast(verifyPlaylistIntegrityFn)(); } - return KeyValues_LoadPlaylist(playlist); // Parse playlist. -} - -//----------------------------------------------------------------------------- -// Purpose: -//----------------------------------------------------------------------------- -const char* KeyValues::GetName() -{ - return g_pKeyValuesSystem->GetStringForSymbol(MAKE_3_BYTES_FROM_1_AND_2(m_iKeyNameCaseSensitive, m_iKeyNameCaseSensitive2)); -} - -//----------------------------------------------------------------------------- -// Purpose: -//----------------------------------------------------------------------------- -void CKeyValueSystem_Init() -{ - std::thread t1(CKeyValueSystem_InitPlaylist); // Start thread to grab playlists. - t1.detach(); // Detach thread from current one. + return KeyValues_LoadPlaylist(szPlaylist); // Parse playlist. } /////////////////////////////////////////////////////////////////////////////// void CKeyValueSystem_Attach() { - DetourAttach((LPVOID*)&KeyValues_LoadPlaylist, &HKeyValues_LoadPlaylist); + DetourAttach((LPVOID*)&KeyValues_LoadPlaylist, &KeyValues::LoadPlaylist); } void CKeyValueSystem_Detach() { - DetourDetach((LPVOID*)&KeyValues_LoadPlaylist, &HKeyValues_LoadPlaylist); + DetourDetach((LPVOID*)&KeyValues_LoadPlaylist, &KeyValues::LoadPlaylist); } + +/////////////////////////////////////////////////////////////////////////////// +#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) +inline KeyValues** g_pPlaylistKeyValues = reinterpret_cast(p_Stryder_StitchRequest.FindPatternSelf("48 8B 2D", ADDRESS::Direction::DOWN, 100).ResolveRelativeAddressSelf(0x3, 0x7).GetPtr()); // Get the KeyValue for the playlist file. +#elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) +inline KeyValues** g_pPlaylistKeyValues = reinterpret_cast(p_Stryder_StitchRequest.FindPatternSelf("48 8B 0D", ADDRESS::Direction::DOWN, 100).ResolveRelativeAddressSelf(0x3, 0x7).GetPtr()); // Get the KeyValue for the playlist file. +#endif +vector g_szAllPlaylists = { "<>" }; \ No newline at end of file diff --git a/r5dev/vpc/keyvalues.h b/r5dev/vpc/keyvalues.h index b6a9e478..73eaadb1 100644 --- a/r5dev/vpc/keyvalues.h +++ b/r5dev/vpc/keyvalues.h @@ -1,14 +1,12 @@ #pragma once -#define MAKE_3_BYTES_FROM_1_AND_2( x1, x2 ) (( (( std::uint16_t )x2) << 8 ) | (std::uint8_t)(x1)) -extern std::vector g_szAllPlaylists; -typedef int HKeySymbol; +#define MAKE_3_BYTES_FROM_1_AND_2( x1, x2 ) (( (( uint16_t )x2) << 8 ) | (uint8_t)(x1)) +extern vector g_szAllPlaylists; //--------------------------------------------------------------------------------- // Purpose: Forward declarations //--------------------------------------------------------------------------------- class KeyValues; -class CKeyValuesSystem; /* ==== KEYVALUES ======================================================================================================================================================= */ #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) @@ -33,11 +31,6 @@ inline auto KeyValues_GetCurrentPlaylist = p_KeyValues_GetCurrentPlaylist.RCast< inline ADDRESS p_KeyValues_LoadPlaylist = g_mGameDll.FindPatternSIMD(reinterpret_cast("\xE8\x00\x00\x00\x00\x80\x3D\x00\x00\x00\x00\x00\x74\x0C"), "x????xx?????xx").FollowNearCallSelf().GetPtr(); inline auto KeyValues_LoadPlaylist = p_KeyValues_LoadPlaylist.RCast(); /*E8 ?? ?? ?? ?? 80 3D ?? ?? ?? ?? ?? 74 0C*/ -inline ADDRESS p_KeyValues_GetMemPool = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\x05\x00\x00\x00\x00\xC3\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\x48\x85\xD2"), "xxx????xxxxxxxxxxxx"); -inline auto KeyValues_GetMemPool = p_KeyValues_GetMemPool.RCast(); /*48 8B 05 ?? ?? ?? ?? C3 CC CC CC CC CC CC CC CC 48 85 D2*/ - -inline uintptr_t g_pKeyValuesMemPool = p_KeyValues_GetMemPool.ResolveRelativeAddressSelf(0x3, 0x7).GetPtr(); - enum KeyValuesTypes { TYPE_NONE = 0x0, @@ -54,161 +47,19 @@ enum KeyValuesTypes TYPE_NUMTYPES = 0xB, }; -class CKeyValuesSystem // VTABLE @ 0x1413AA1E8 in R5pc_r5launch_N1094_CL456479_2019_10_30_05_20_PM -{ -public: - - void RegisterSizeofKeyValues(std::int64_t size) //@0x1413AA1F0 in R5pc_r5launch_N1094_CL456479_2019_10_30_05_20_PM - { - static int index = 0; - CallVFunc(index, this, size); - } - - void* AllocKeyValuesMemory(std::int64_t size) // @0x1413AA1F8 in R5pc_r5launch_N1094_CL456479_2019_10_30_05_20_PM - { - static int index = 1; - return CallVFunc(index, this, size); - } - - void FreeKeyValuesMemory(void* pMem) // @0x1413AA200 in R5pc_r5launch_N1094_CL456479_2019_10_30_05_20_PM - { - static int index = 2; - CallVFunc(index, this, pMem); - } - - HKeySymbol GetSymbolForString(const char* name, bool bCreate) // @0x1413AA208 in R5pc_r5launch_N1094_CL456479_2019_10_30_05_20_PM - { - static int index = 3; - return CallVFunc(index, this, name, bCreate); - } - - const char* GetStringForSymbol(HKeySymbol symbol) // @0x1413AA210 in R5pc_r5launch_N1094_CL456479_2019_10_30_05_20_PM - { - static int index = 4; - return CallVFunc(index, this, symbol); - } - - // void __fastcall CKeyValuesSystem::FreeKeyValuesMemory(CKeyValuesSystem* this_arg, void* ptr_mem_arg) - // { - // __int64* v2; // rax - // __int64 v4; // rax - // __int64* v5; // rax - // - // v2 = qword_14D40B538; - // if (!qword_14D40B538) - // { - // v2 = sub_140462930(); - // qword_14D40B538 = v2; - // } - // v4 = (*(*v2 + 48))(v2, ptr_mem_arg); - // if (v4 > 0) - // CKeyValuesSystem::m_pMemPool -= v4; - // v5 = qword_14D40B538; - // if (!qword_14D40B538) - // { - // v5 = sub_140462930(); - // qword_14D40B538 = v5; - // } - // (*(*v5 + 40))(v5, ptr_mem_arg); - // } - - // GetMemPool return a global variable called m_pMemPool it gets modified by AllocKeyValuesMemory and FreeKeyValuesMemory above you can see where the find it in FreeKeyValuesMemory. - void* GetMemPool() // @0x1413AA228 in R5pc_r5launch_N1094_CL456479_2019_10_30_05_20_PM - { - return reinterpret_cast(g_pKeyValuesMemPool); // May need to dereference this once more not sure right now. - } - - void SetKeyValuesExpressionSymbol(const char* name, bool bValue) // @0x1413AA230 in R5pc_r5launch_N1094_CL456479_2019_10_30_05_20_PM - { - static int index = 8; - CallVFunc(index, this, name, bValue); - } - - bool GetKeyValuesExpressionSymbol(const char* name) // @0x1413AA238 in R5pc_r5launch_N1094_CL456479_2019_10_30_05_20_PM - { - static int index = 9; - return CallVFunc(index, this, name); - } - - HKeySymbol GetSymbolForStringCaseSensitive(HKeySymbol& hCaseInsensitiveSymbol, const char* name, bool bCreate) // @0x1413AA240 in R5pc_r5launch_N1094_CL456479_2019_10_30_05_20_PM - { - static int index = 10; - return CallVFunc(index, this, hCaseInsensitiveSymbol, name, bCreate); - } - -// Datatypes aren't accurate. But full fill the actual byte distance. -public: - void* vtable; // 0x0000 - std::int64_t m_iMaxKeyValuesSize; // 0x0008 -private: - char gap10[240]; // 0x0010 -public: - int m_KvConditionalSymbolTable; // 0x0100 -private: - char gap104[4]; // 0x0104 -public: - std::int64_t field_108; // 0x0108 -private: - char gap110[32]; // 0x0110 -public: - int m_mutex; // 0x0130 -}; - class KeyValues { public: - KeyValues* FindKey(const char* keyName, bool bCreate) - { - static auto func = reinterpret_cast(KeyValues_FindKey); - return func(this, keyName, bCreate); - } + static void Init(void); + KeyValues* FindKey(const char* pKeyName, bool bCreate); + const char* GetName(void) const; + int GetInt(const char* pKeyName, int nDefaultValue); + void SetInt(const char* pKeyName, int iValue); + void SetFloat(const char* keyName, float flValue); - const char* GetName(); - - int GetInt(const char* keyName, int defaultValue) - { - KeyValues* dat = FindKey(keyName, false); - - if (!dat) - return defaultValue; - - switch (dat->m_iDataType) - { - case TYPE_STRING: - return atoi(dat->m_sValue); - case TYPE_FLOAT: - return static_cast(m_flValue()); - case TYPE_WSTRING: - return _wtoi(dat->m_wsValue); - case TYPE_UINT64: - return 0; - default: - return dat->m_iValue(); - } - - return defaultValue; - } - - void SetInt(const char* keyName, int iValue) - { - KeyValues* dat = FindKey(keyName, true); - if (dat) - { - dat->m_iValue() = iValue; - dat->m_iDataType = TYPE_INT; - } - } - - void SetFloat(const char* keyName, float flValue) - { - KeyValues* dat = FindKey(keyName, true); - if (dat) - { - dat->m_flValue() = flValue; - dat->m_iDataType = TYPE_FLOAT; - } - } + static void InitPlaylist(void); + static bool LoadPlaylist(const char* szPlaylist); // Compiler makes it so m_Value shares the offset spot with m_flValue that why we cast it like this. MEMBER_AT_OFFSET(float, m_flValue, 0x18); @@ -231,15 +82,10 @@ public: }; /////////////////////////////////////////////////////////////////////////////// -void CKeyValueSystem_InitPlaylist(); -void CKeyValueSystem_Init(); -bool HKeyValues_LoadPlaylist(const char* playlist); - void CKeyValueSystem_Attach(); void CKeyValueSystem_Detach(); /////////////////////////////////////////////////////////////////////////////// -extern CKeyValuesSystem* g_pKeyValuesSystem; extern KeyValues** g_pPlaylistKeyValues; /////////////////////////////////////////////////////////////////////////////// @@ -249,11 +95,8 @@ class HKeyValues : public IDetour { std::cout << "| FUN: KeyValues::Init : 0x" << std::hex << std::uppercase << p_KeyValues_Init.GetPtr() << std::setw(npad) << " |" << std::endl; std::cout << "| FUN: KeyValues::FindKey : 0x" << std::hex << std::uppercase << p_KeyValues_FindKey.GetPtr() << std::setw(npad) << " |" << std::endl; - std::cout << "| FUN: KeyValues::GetMemPool : 0x" << std::hex << std::uppercase << p_KeyValues_GetMemPool.GetPtr() << std::setw(npad) << " |" << std::endl; std::cout << "| FUN: KeyValues::LoadPlaylist : 0x" << std::hex << std::uppercase << p_KeyValues_LoadPlaylist.GetPtr() << std::setw(npad) << " |" << std::endl; std::cout << "| FUN: KeyValues::GetCurrentPlaylist : 0x" << std::hex << std::uppercase << p_KeyValues_GetCurrentPlaylist.GetPtr() << std::setw(npad) << " |" << std::endl; - std::cout << "| VAR: g_pKeyValuesMemPool : 0x" << std::hex << std::uppercase << g_pKeyValuesMemPool << std::setw(npad) << " |" << std::endl; - std::cout << "| VAR: g_pKeyValuesSystem : 0x" << std::hex << std::uppercase << g_pKeyValuesSystem << std::setw(0) << " |" << std::endl; std::cout << "| VAR: g_pPlaylistKeyValues : 0x" << std::hex << std::uppercase << g_pPlaylistKeyValues << std::setw(0) << " |" << std::endl; std::cout << "+----------------------------------------------------------------+" << std::endl; } diff --git a/r5dev/vpklib/packedstore.cpp b/r5dev/vpklib/packedstore.cpp index c7791cf0..b71f4251 100644 --- a/r5dev/vpklib/packedstore.cpp +++ b/r5dev/vpklib/packedstore.cpp @@ -8,7 +8,7 @@ ***********************************************************************/ #include "core/stdafx.h" -#include "tier0/cvar.h" +#include "tier1/cvar.h" #include "mathlib/adler32.h" #include "mathlib/crc32.h" #include "engine/sys_utils.h" diff --git a/r5dev/vproj/clientsdk.vcxproj b/r5dev/vproj/clientsdk.vcxproj index 4ba61bf5..3b1aff2c 100644 --- a/r5dev/vproj/clientsdk.vcxproj +++ b/r5dev/vproj/clientsdk.vcxproj @@ -75,14 +75,13 @@ - - - - + + + @@ -94,6 +93,8 @@ + + @@ -322,16 +323,15 @@ - - - - + + + @@ -346,6 +346,8 @@ + + diff --git a/r5dev/vproj/clientsdk.vcxproj.filters b/r5dev/vproj/clientsdk.vcxproj.filters index a5341f3e..258d0c5c 100644 --- a/r5dev/vproj/clientsdk.vcxproj.filters +++ b/r5dev/vproj/clientsdk.vcxproj.filters @@ -166,6 +166,9 @@ {a61ad720-d7da-4aee-a9ca-f87f827423ea} + + {fd290792-d36d-400c-9f4d-366a9ce57427} + @@ -222,18 +225,6 @@ sdk\squirrel - - sdk\tier0 - - - sdk\tier0 - - - sdk\tier0 - - - sdk\tier0 - sdk\vgui @@ -402,6 +393,21 @@ sdk\filesystem + + sdk\tier1 + + + sdk\tier1 + + + sdk\tier1 + + + sdk\vstdlib + + + sdk\vstdlib + @@ -803,21 +809,9 @@ thirdparty\spdlog\include\cfg - - sdk\tier0 - - - sdk\tier0 - - - sdk\tier0 - sdk\tier0 - - sdk\tier0 - sdk\vgui @@ -1154,6 +1148,21 @@ sdk\common + + sdk\tier1 + + + sdk\tier1 + + + sdk\tier1 + + + sdk\vstdlib + + + sdk\vstdlib + diff --git a/r5dev/vproj/dedicated.vcxproj b/r5dev/vproj/dedicated.vcxproj index 86665ecf..7b102f5c 100644 --- a/r5dev/vproj/dedicated.vcxproj +++ b/r5dev/vproj/dedicated.vcxproj @@ -331,16 +331,15 @@ - - - - + + + @@ -350,6 +349,8 @@ + + @@ -416,14 +417,13 @@ - - - - + + + @@ -431,6 +431,8 @@ + + diff --git a/r5dev/vproj/dedicated.vcxproj.filters b/r5dev/vproj/dedicated.vcxproj.filters index 8ca456dc..910c60c8 100644 --- a/r5dev/vproj/dedicated.vcxproj.filters +++ b/r5dev/vproj/dedicated.vcxproj.filters @@ -139,6 +139,9 @@ {ac641995-20c7-43a8-ae66-809b349b1de7} + + {f6e1bcba-3548-4849-918d-9adea1603b0b} + @@ -513,21 +516,9 @@ thirdparty\spdlog\include\cfg - - sdk\tier0 - - - sdk\tier0 - - - sdk\tier0 - sdk\tier0 - - sdk\tier0 - sdk\vpc @@ -837,6 +828,21 @@ sdk\common + + sdk\tier1 + + + sdk\tier1 + + + sdk\tier1 + + + sdk\vstdlib + + + sdk\vstdlib + @@ -893,18 +899,6 @@ sdk\squirrel - - sdk\tier0 - - - sdk\tier0 - - - sdk\tier0 - - - sdk\tier0 - sdk\vpc @@ -1049,6 +1043,21 @@ sdk\filesystem + + sdk\tier1 + + + sdk\tier1 + + + sdk\tier1 + + + sdk\vstdlib + + + sdk\vstdlib + diff --git a/r5dev/vproj/gamesdk.vcxproj b/r5dev/vproj/gamesdk.vcxproj index bf708eed..345a2af8 100644 --- a/r5dev/vproj/gamesdk.vcxproj +++ b/r5dev/vproj/gamesdk.vcxproj @@ -83,14 +83,13 @@ - - - - + + + @@ -102,6 +101,8 @@ + + @@ -341,16 +342,15 @@ - - - - + + + @@ -365,6 +365,8 @@ + + diff --git a/r5dev/vproj/gamesdk.vcxproj.filters b/r5dev/vproj/gamesdk.vcxproj.filters index 26710028..c310e5ef 100644 --- a/r5dev/vproj/gamesdk.vcxproj.filters +++ b/r5dev/vproj/gamesdk.vcxproj.filters @@ -172,6 +172,9 @@ {9fbd3a16-56a4-4794-bfa6-680f41002c24} + + {48abe326-8ad7-43fa-875d-2e73c7c64106} + @@ -234,18 +237,6 @@ sdk\squirrel - - sdk\tier0 - - - sdk\tier0 - - - sdk\tier0 - - - sdk\tier0 - sdk\vgui @@ -432,6 +423,21 @@ sdk\filesystem + + sdk\tier1 + + + sdk\tier1 + + + sdk\tier1 + + + sdk\vstdlib + + + sdk\vstdlib + @@ -839,21 +845,9 @@ thirdparty\spdlog\include\cfg - - sdk\tier0 - - - sdk\tier0 - - - sdk\tier0 - sdk\tier0 - - sdk\tier0 - sdk\vgui @@ -1217,6 +1211,21 @@ core + + sdk\tier1 + + + sdk\tier1 + + + sdk\tier1 + + + sdk\vstdlib + + + sdk\vstdlib + diff --git a/r5dev/tier0/completion.cpp b/r5dev/vstdlib/completion.cpp similarity index 99% rename from r5dev/tier0/completion.cpp rename to r5dev/vstdlib/completion.cpp index 7f4bc815..852457a4 100644 --- a/r5dev/tier0/completion.cpp +++ b/r5dev/vstdlib/completion.cpp @@ -6,9 +6,8 @@ #include "core/stdafx.h" #include "windows/id3dx.h" -#include "tier0/cvar.h" -#include "tier0/IConVar.h" -#include "tier0/completion.h" +#include "tier1/cvar.h" +#include "tier1/IConVar.h" #ifndef DEDICATED #include "engine/cl_rcon.h" #endif // !DEDICATED @@ -28,6 +27,7 @@ #endif // !DEDICATED #include "public/include/bansystem.h" #include "mathlib/crc32.h" +#include "vstdlib/completion.h" #ifndef DEDICATED #include "materialsystem/cmaterialglue.h" #endif // !DEDICATED diff --git a/r5dev/tier0/completion.h b/r5dev/vstdlib/completion.h similarity index 99% rename from r5dev/tier0/completion.h rename to r5dev/vstdlib/completion.h index 4bab838d..44ab1c09 100644 --- a/r5dev/tier0/completion.h +++ b/r5dev/vstdlib/completion.h @@ -1,5 +1,5 @@ #pragma once -#include "IConVar.h" +#include "tier1/IConVar.h" /* ==== CONCOMMANDCALLBACK ============================================================================================================================================== */ #if defined (GAMEDLL_S1) diff --git a/r5dev/vstdlib/keyvaluessystem.cpp b/r5dev/vstdlib/keyvaluessystem.cpp new file mode 100644 index 00000000..80457470 --- /dev/null +++ b/r5dev/vstdlib/keyvaluessystem.cpp @@ -0,0 +1,137 @@ +//=============================================================================// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#include "core/stdafx.h" +#include "vstdlib/keyvaluessystem.h" + +//----------------------------------------------------------------------------- +// Purpose: registers the size of the KeyValues in the specified instance +// so it can build a properly sized memory pool for the KeyValues objects +// the sizes will usually never differ but this is for versioning safety +// Input : nSize - +//----------------------------------------------------------------------------- +void CKeyValuesSystem::RegisterSizeofKeyValues(int64_t nSize) +{ + static int index = 0; + CallVFunc(index, this, nSize); +} + +//----------------------------------------------------------------------------- +// Purpose: allocates a KeyValues object from the shared mempool +// Input : nSize - +// Output : pointer to allocated pool +//----------------------------------------------------------------------------- +void* CKeyValuesSystem::AllocKeyValuesMemory(int64_t nSize) +{ + static int index = 1; + return CallVFunc(index, this, nSize); +} + +//----------------------------------------------------------------------------- +// Purpose: frees a KeyValues object from the shared mempool +// Input : *pMem - +//----------------------------------------------------------------------------- +void CKeyValuesSystem::FreeKeyValuesMemory(void* pMem) +{ + static int index = 2; + CallVFunc(index, this, pMem); +} + +//----------------------------------------------------------------------------- +// Purpose: symbol table access (used for key names) +// Input : *szName - +// bCreate - +// Output : handle to KeyValue symbol on success, -1 on failure +//----------------------------------------------------------------------------- +HKeySymbol CKeyValuesSystem::GetSymbolForString(const char* szName, bool bCreate) +{ + static int index = 3; + return CallVFunc(index, this, szName, bCreate); +} + +//----------------------------------------------------------------------------- +// Purpose: symbol table access +// Input : symbol - +// Output : symbol string if found, empty if not found +//----------------------------------------------------------------------------- +const char* CKeyValuesSystem::GetStringForSymbol(HKeySymbol symbol) +{ + static int index = 4; + return CallVFunc(index, this, symbol); +} + +//----------------------------------------------------------------------------- +// Purpose: frees a KeyValues object from the shared mempool +// Input : *pMem - +//----------------------------------------------------------------------------- +void CKeyValuesSystem::FreeKeyValuesMemory(CKeyValuesSystem* thisptr, void* pMem) +{ + //__int64* v2; // rax + //__int64 v4; // rax + //__int64* v5; // rax + + //v2 = qword_14D40B538; + //if (!qword_14D40B538) + //{ + // v2 = sub_140462930(); + // qword_14D40B538 = v2; + //} + //v4 = (*(*v2 + 48))(v2, pMem); + //if (v4 > 0) + // CKeyValuesSystem::m_pMemPool -= v4; + //v5 = qword_14D40B538; + //if (!qword_14D40B538) + //{ + // v5 = sub_140462930(); + // qword_14D40B538 = v5; + //} + //(*(*v5 + 40))(v5, pMem); +} + +//----------------------------------------------------------------------------- +// Purpose: gets the global KeyValues memory pool +// Output : *g_pKeyValuesMemPool - +//----------------------------------------------------------------------------- +void* CKeyValuesSystem::GetMemPool(void) const +{ + return reinterpret_cast(g_pKeyValuesMemPool); // May need to dereference this once more not sure right now. +} + +//----------------------------------------------------------------------------- +// Purpose: set a value for keyvalues resolution symbol +// e.g.: SetKeyValuesExpressionSymbol( "LOWVIOLENCE", true ) - enables [$LOWVIOLENCE] +// Input : *szName - +// bValue - +//----------------------------------------------------------------------------- +void CKeyValuesSystem::SetKeyValuesExpressionSymbol(const char* szName, bool bValue) +{ + static int index = 8; + CallVFunc(index, this, szName, bValue); +} + +//----------------------------------------------------------------------------- +// Purpose: get a value for keyvalues resolution symbol +// Input : *szName - +//----------------------------------------------------------------------------- +bool CKeyValuesSystem::GetKeyValuesExpressionSymbol(const char* szName) +{ + static int index = 9; + return CallVFunc(index, this, szName); +} + +//----------------------------------------------------------------------------- +// Purpose: symbol table access (used for key names) +// Input : *hCaseInsensitiveSymbol - +// *szName - +// bCreate - +// Output : handle to KeyValue symbol on success, -1 on failure +//----------------------------------------------------------------------------- +HKeySymbol CKeyValuesSystem::GetSymbolForStringCaseSensitive(HKeySymbol& hCaseInsensitiveSymbol, const char* szName, bool bCreate) +{ + static int index = 10; + return CallVFunc(index, this, hCaseInsensitiveSymbol, szName, bCreate); +} diff --git a/r5dev/vstdlib/keyvaluessystem.h b/r5dev/vstdlib/keyvaluessystem.h new file mode 100644 index 00000000..1a7c25dc --- /dev/null +++ b/r5dev/vstdlib/keyvaluessystem.h @@ -0,0 +1,58 @@ +#pragma once + +typedef int HKeySymbol; + +class CKeyValuesSystem // VTABLE @ 0x1413AA1E8 in R5pc_r5launch_N1094_CL456479_2019_10_30_05_20_PM +{ +public: + void RegisterSizeofKeyValues(int64_t size); + void* AllocKeyValuesMemory(int64_t size); + void FreeKeyValuesMemory(void* pMem); + HKeySymbol GetSymbolForString(const char* name, bool bCreate); + const char* GetStringForSymbol(HKeySymbol symbol); + void __fastcall FreeKeyValuesMemory(CKeyValuesSystem* this_arg, void* ptr_mem_arg); + + void* GetMemPool(void) const; // GetMemPool returns a global variable called m_pMemPool, it gets modified by AllocKeyValuesMemory and with FreeKeyValuesMemory you can see where to find it in FreeKeyValuesMemory. + void SetKeyValuesExpressionSymbol(const char* name, bool bValue); + bool GetKeyValuesExpressionSymbol(const char* name); + HKeySymbol GetSymbolForStringCaseSensitive(HKeySymbol& hCaseInsensitiveSymbol, const char* name, bool bCreate); + + // Datatypes aren't accurate. But full fill the actual byte distance. +public: + void* m_pVTable; // 0x0000 + int64_t m_iMaxKeyValuesSize; // 0x0008 +private: + char gap10[240]; // 0x0010 +public: + int m_KvConditionalSymbolTable; // 0x0100 +private: + char gap104[4]; // 0x0104 +public: + int64_t field_108; // 0x0108 +private: + char gap110[32]; // 0x0110 +public: + int m_mutex; // 0x0130 +}; + +/* ==== KEYVALUESSYSTEM ================================================================================================================================================= */ +inline uintptr_t g_pKeyValuesMemPool = g_mGameDll.FindPatternSIMD( + reinterpret_cast("\x48\x8B\x05\x00\x00\x00\x00\xC3\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\x48\x85\xD2"), "xxx????xxxxxxxxxxxx"). + ResolveRelativeAddressSelf(0x3, 0x7).GetPtr(); +inline CKeyValuesSystem* g_pKeyValuesSystem = g_mGameDll.FindPatternSIMD( + reinterpret_cast("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x56\x57\x41\x56\x48\x83\xEC\x40\x48\x8B\xF1"), "xxxx?xxxx?xxxxxxxxxxx") + .FindPatternSelf("48 8D 0D", ADDRESS::Direction::DOWN, 100).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); + +/////////////////////////////////////////////////////////////////////////////// +class HKeyValuesSystem : public IDetour +{ + virtual void debugp() + { + std::cout << "| VAR: g_pKeyValuesMemPool : 0x" << std::hex << std::uppercase << g_pKeyValuesMemPool << std::setw(npad) << " |" << std::endl; + std::cout << "| VAR: g_pKeyValuesSystem : 0x" << std::hex << std::uppercase << g_pKeyValuesSystem << std::setw(0) << " |" << std::endl; + std::cout << "+----------------------------------------------------------------+" << std::endl; + } +}; +/////////////////////////////////////////////////////////////////////////////// + +REGISTER(HKeyValuesSystem); diff --git a/r5dev/windows/console.cpp b/r5dev/windows/console.cpp index bf3fb06e..8b1b5f93 100644 --- a/r5dev/windows/console.cpp +++ b/r5dev/windows/console.cpp @@ -7,7 +7,7 @@ #include "core/stdafx.h" #include "core/init.h" #include "core/logdef.h" -#include "tier0/cmd.h" +#include "tier1/cmd.h" #ifndef DEDICATED #include "windows/id3dx.h" #endif // !DEDICATED diff --git a/r5dev/windows/id3dx.cpp b/r5dev/windows/id3dx.cpp index 024ff5d9..c5e57e09 100644 --- a/r5dev/windows/id3dx.cpp +++ b/r5dev/windows/id3dx.cpp @@ -2,7 +2,7 @@ #ifndef DEDICATED // This file should not be compiled for DEDICATED! //------------------------------ #define STB_IMAGE_IMPLEMENTATION -#include "tier0/cvar.h" +#include "tier1/cvar.h" #include "windows/id3dx.h" #include "windows/input.h" #include "gameui/IConsole.h"