Move ConVar/ConCommand stuff to tier1 instead and cleanup KeyValues/KeyValuesSystem

This commit is contained in:
Kawe Mazidjatari 2022-04-09 16:16:40 +02:00
parent b3631facbe
commit 2dcbf59041
50 changed files with 514 additions and 359 deletions

View File

@ -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"

View File

@ -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"))
{

View File

@ -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"

View File

@ -1,5 +1,5 @@
#pragma once
#include "tier0/completion.h"
#include "vstdlib/completion.h"
#include "public/include/utility.h"
//#ifdef DEDICATED

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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

View File

@ -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"

View File

@ -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"

View File

@ -5,7 +5,7 @@
//=============================================================================//
#include "core/stdafx.h"
#include "tier0/cvar.h"
#include "tier1/cvar.h"
#include "game/server/detour_impl.h"
//-----------------------------------------------------------------------------

View File

@ -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

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -6,7 +6,7 @@
//=====================================================================================//
#include <core/stdafx.h>
#include <tier0/cvar.h>
#include <tier1/cvar.h>
#include <engine/net.h>
#include <engine/host_state.h>
#include <engine/sys_utils.h>

View File

@ -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"

View File

@ -9,7 +9,7 @@
#ifndef DEDICATED
#include "rui.h"
#include <tier0/cvar.h>
#include "tier1/cvar.h"
//-----------------------------------------------------------------------------
// Purpose: Probably responsible to decide if rUI is allowed to draw.

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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

View File

@ -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"

View File

@ -1,5 +1,5 @@
#pragma once
#include "tier0/cmd.h"
#include "tier1/cmd.h"
#include "mathlib/color.h"
//-----------------------------------------------------------------------------

View File

@ -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"
//-----------------------------------------------------------------------------

View File

@ -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"
//-----------------------------------------------------------------------------

View File

@ -1,5 +1,5 @@
#pragma once
#include "tier0/IConVar.h"
#include "tier1/IConVar.h"
//-------------------------------------------------------------------------
// ENGINE |

View File

@ -6,7 +6,7 @@
//===========================================================================//
#include <core/stdafx.h>
#include "tier0/cvar.h"
#include <tier1/cvar.h>
#include <engine/sys_utils.h>
#include <vgui/vgui_debugpanel.h>
#include <vgui/vgui_baseui_interface.h>

View File

@ -6,7 +6,7 @@
//===========================================================================//
#include <core/stdafx.h>
#include <tier0/cvar.h>
#include <tier1/cvar.h>
#include <windows/id3dx.h>
#include <vpc/keyvalues.h>
#include <mathlib/color.h>

View File

@ -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"

View File

@ -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<rsig_t>("\x48\x8B\xC4\x55\x56\x41\x00\x48\x8D\xA8\x00\xFD\xFF\xFF\x48\x81\xEC\x80"), "xxxxxx?xxx?xxxxxxx");

View File

@ -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<std::string> g_szAllPlaylists = { "none" };
CKeyValuesSystem* g_pKeyValuesSystem = reinterpret_cast<CKeyValuesSystem*>(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<KeyValues**>(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<KeyValues**>(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 * (__thiscall*)(KeyValues*, const char*, bool)>(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<int>(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<void(*)()>(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<KeyValues**>(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<KeyValues**>(p_Stryder_StitchRequest.FindPatternSelf("48 8B 0D", ADDRESS::Direction::DOWN, 100).ResolveRelativeAddressSelf(0x3, 0x7).GetPtr()); // Get the KeyValue for the playlist file.
#endif
vector<string> g_szAllPlaylists = { "<<null>>" };

View File

@ -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<std::string> g_szAllPlaylists;
typedef int HKeySymbol;
#define MAKE_3_BYTES_FROM_1_AND_2( x1, x2 ) (( (( uint16_t )x2) << 8 ) | (uint8_t)(x1))
extern vector<string> 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<rsig_t>("\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<bool (*)(const char* pszPlaylist)>(); /*E8 ?? ?? ?? ?? 80 3D ?? ?? ?? ?? ?? 74 0C*/
inline ADDRESS p_KeyValues_GetMemPool = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\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<void* (*)(void)>(); /*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<void>(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<void*>(index, this, size);
}
void FreeKeyValuesMemory(void* pMem) // @0x1413AA200 in R5pc_r5launch_N1094_CL456479_2019_10_30_05_20_PM
{
static int index = 2;
CallVFunc<void>(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<HKeySymbol>(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<const char*>(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<void*>(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<void>(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<bool>(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<HKeySymbol>(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 * (__thiscall*)(KeyValues*, const char*, bool)>(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<int>(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;
}

View File

@ -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"

View File

@ -75,14 +75,13 @@
<ClCompile Include="..\squirrel\sqvm.cpp" />
<ClCompile Include="..\thirdparty\imgui\src\imgui_utility.cpp" />
<ClCompile Include="..\tier0\commandline.cpp" />
<ClCompile Include="..\tier0\cmd.cpp" />
<ClCompile Include="..\tier0\completion.cpp" />
<ClCompile Include="..\tier0\cpu.cpp" />
<ClCompile Include="..\tier0\cputopology.cpp" />
<ClCompile Include="..\tier0\cvar.cpp" />
<ClCompile Include="..\tier0\fasttimer.cpp" />
<ClCompile Include="..\tier0\IConVar.cpp" />
<ClCompile Include="..\tier1\bitbuf.cpp" />
<ClCompile Include="..\tier1\cmd.cpp" />
<ClCompile Include="..\tier1\cvar.cpp" />
<ClCompile Include="..\tier1\IConVar.cpp" />
<ClCompile Include="..\tier1\NetAdr2.cpp" />
<ClCompile Include="..\tier2\socketcreator.cpp" />
<ClCompile Include="..\vguimatsurface\MatSystemSurface.cpp" />
@ -94,6 +93,8 @@
<ClCompile Include="..\vpc\keyvalues.cpp" />
<ClCompile Include="..\vphysics\QHull.cpp" />
<ClCompile Include="..\vpklib\packedstore.cpp" />
<ClCompile Include="..\vstdlib\completion.cpp" />
<ClCompile Include="..\vstdlib\keyvaluessystem.cpp" />
<ClCompile Include="..\windows\console.cpp" />
<ClCompile Include="..\windows\id3dx.cpp" />
<ClCompile Include="..\windows\input.cpp" />
@ -322,16 +323,15 @@
<ClInclude Include="..\thirdparty\spdlog\include\version.h" />
<ClInclude Include="..\tier0\basetypes.h" />
<ClInclude Include="..\tier0\commandline.h" />
<ClInclude Include="..\tier0\cmd.h" />
<ClInclude Include="..\tier0\completion.h" />
<ClInclude Include="..\tier0\cpu.h" />
<ClInclude Include="..\tier0\cputopology.h" />
<ClInclude Include="..\tier0\cvar.h" />
<ClInclude Include="..\tier0\fasttimer.h" />
<ClInclude Include="..\tier0\IConVar.h" />
<ClInclude Include="..\tier0\interface.h" />
<ClInclude Include="..\tier0\platform.h" />
<ClInclude Include="..\tier1\bitbuf.h" />
<ClInclude Include="..\tier1\cmd.h" />
<ClInclude Include="..\tier1\cvar.h" />
<ClInclude Include="..\tier1\IConVar.h" />
<ClInclude Include="..\tier1\NetAdr2.h" />
<ClInclude Include="..\tier1\utlmemory.h" />
<ClInclude Include="..\tier1\utlvector.h" />
@ -346,6 +346,8 @@
<ClInclude Include="..\vpc\keyvalues.h" />
<ClInclude Include="..\vphysics\QHull.h" />
<ClInclude Include="..\vpklib\packedstore.h" />
<ClInclude Include="..\vstdlib\completion.h" />
<ClInclude Include="..\vstdlib\keyvaluessystem.h" />
<ClInclude Include="..\windows\console.h" />
<ClInclude Include="..\windows\id3dx.h" />
<ClInclude Include="..\windows\input.h" />

View File

@ -166,6 +166,9 @@
<Filter Include="sdk\filesystem">
<UniqueIdentifier>{a61ad720-d7da-4aee-a9ca-f87f827423ea}</UniqueIdentifier>
</Filter>
<Filter Include="sdk\vstdlib">
<UniqueIdentifier>{fd290792-d36d-400c-9f4d-366a9ce57427}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\client\cdll_engine_int.cpp">
@ -222,18 +225,6 @@
<ClCompile Include="..\squirrel\sqapi.cpp">
<Filter>sdk\squirrel</Filter>
</ClCompile>
<ClCompile Include="..\tier0\completion.cpp">
<Filter>sdk\tier0</Filter>
</ClCompile>
<ClCompile Include="..\tier0\cvar.cpp">
<Filter>sdk\tier0</Filter>
</ClCompile>
<ClCompile Include="..\tier0\IConVar.cpp">
<Filter>sdk\tier0</Filter>
</ClCompile>
<ClCompile Include="..\tier0\cmd.cpp">
<Filter>sdk\tier0</Filter>
</ClCompile>
<ClCompile Include="..\vgui\vgui_fpspanel.cpp">
<Filter>sdk\vgui</Filter>
</ClCompile>
@ -402,6 +393,21 @@
<ClCompile Include="..\filesystem\basefilesystem.cpp">
<Filter>sdk\filesystem</Filter>
</ClCompile>
<ClCompile Include="..\tier1\IConVar.cpp">
<Filter>sdk\tier1</Filter>
</ClCompile>
<ClCompile Include="..\tier1\cmd.cpp">
<Filter>sdk\tier1</Filter>
</ClCompile>
<ClCompile Include="..\tier1\cvar.cpp">
<Filter>sdk\tier1</Filter>
</ClCompile>
<ClCompile Include="..\vstdlib\completion.cpp">
<Filter>sdk\vstdlib</Filter>
</ClCompile>
<ClCompile Include="..\vstdlib\keyvaluessystem.cpp">
<Filter>sdk\vstdlib</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\client\cdll_engine_int.h">
@ -803,21 +809,9 @@
<ClInclude Include="..\thirdparty\spdlog\include\cfg\argv.h">
<Filter>thirdparty\spdlog\include\cfg</Filter>
</ClInclude>
<ClInclude Include="..\tier0\completion.h">
<Filter>sdk\tier0</Filter>
</ClInclude>
<ClInclude Include="..\tier0\cvar.h">
<Filter>sdk\tier0</Filter>
</ClInclude>
<ClInclude Include="..\tier0\IConVar.h">
<Filter>sdk\tier0</Filter>
</ClInclude>
<ClInclude Include="..\tier0\basetypes.h">
<Filter>sdk\tier0</Filter>
</ClInclude>
<ClInclude Include="..\tier0\cmd.h">
<Filter>sdk\tier0</Filter>
</ClInclude>
<ClInclude Include="..\vgui\vgui_fpspanel.h">
<Filter>sdk\vgui</Filter>
</ClInclude>
@ -1154,6 +1148,21 @@
<ClInclude Include="..\common\sdktypes.h">
<Filter>sdk\common</Filter>
</ClInclude>
<ClInclude Include="..\tier1\IConVar.h">
<Filter>sdk\tier1</Filter>
</ClInclude>
<ClInclude Include="..\tier1\cmd.h">
<Filter>sdk\tier1</Filter>
</ClInclude>
<ClInclude Include="..\tier1\cvar.h">
<Filter>sdk\tier1</Filter>
</ClInclude>
<ClInclude Include="..\vstdlib\completion.h">
<Filter>sdk\vstdlib</Filter>
</ClInclude>
<ClInclude Include="..\vstdlib\keyvaluessystem.h">
<Filter>sdk\vstdlib</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Image Include="..\shared\resource\lockedserver.png">

View File

@ -331,16 +331,15 @@
<ClInclude Include="..\thirdparty\spdlog\include\version.h" />
<ClInclude Include="..\tier0\basetypes.h" />
<ClInclude Include="..\tier0\commandline.h" />
<ClInclude Include="..\tier0\cmd.h" />
<ClInclude Include="..\tier0\completion.h" />
<ClInclude Include="..\tier0\cpu.h" />
<ClInclude Include="..\tier0\cputopology.h" />
<ClInclude Include="..\tier0\cvar.h" />
<ClInclude Include="..\tier0\fasttimer.h" />
<ClInclude Include="..\tier0\IConVar.h" />
<ClInclude Include="..\tier0\interface.h" />
<ClInclude Include="..\tier0\platform.h" />
<ClInclude Include="..\tier1\bitbuf.h" />
<ClInclude Include="..\tier1\cmd.h" />
<ClInclude Include="..\tier1\cvar.h" />
<ClInclude Include="..\tier1\IConVar.h" />
<ClInclude Include="..\tier1\NetAdr2.h" />
<ClInclude Include="..\tier1\utlmemory.h" />
<ClInclude Include="..\tier1\utlvector.h" />
@ -350,6 +349,8 @@
<ClInclude Include="..\vpc\keyvalues.h" />
<ClInclude Include="..\vphysics\QHull.h" />
<ClInclude Include="..\vpklib\packedstore.h" />
<ClInclude Include="..\vstdlib\completion.h" />
<ClInclude Include="..\vstdlib\keyvaluessystem.h" />
<ClInclude Include="..\windows\console.h" />
<ClInclude Include="..\windows\system.h" />
</ItemGroup>
@ -416,14 +417,13 @@
<ClCompile Include="..\squirrel\sqinit.cpp" />
<ClCompile Include="..\squirrel\sqvm.cpp" />
<ClCompile Include="..\tier0\commandline.cpp" />
<ClCompile Include="..\tier0\cmd.cpp" />
<ClCompile Include="..\tier0\completion.cpp" />
<ClCompile Include="..\tier0\cpu.cpp" />
<ClCompile Include="..\tier0\cputopology.cpp" />
<ClCompile Include="..\tier0\cvar.cpp" />
<ClCompile Include="..\tier0\fasttimer.cpp" />
<ClCompile Include="..\tier0\IConVar.cpp" />
<ClCompile Include="..\tier1\bitbuf.cpp" />
<ClCompile Include="..\tier1\cmd.cpp" />
<ClCompile Include="..\tier1\cvar.cpp" />
<ClCompile Include="..\tier1\IConVar.cpp" />
<ClCompile Include="..\tier1\NetAdr2.cpp" />
<ClCompile Include="..\tier2\socketcreator.cpp" />
<ClCompile Include="..\vpc\IAppSystem.cpp" />
@ -431,6 +431,8 @@
<ClCompile Include="..\vpc\keyvalues.cpp" />
<ClCompile Include="..\vphysics\QHull.cpp" />
<ClCompile Include="..\vpklib\packedstore.cpp" />
<ClCompile Include="..\vstdlib\completion.cpp" />
<ClCompile Include="..\vstdlib\keyvaluessystem.cpp" />
<ClCompile Include="..\windows\console.cpp" />
<ClCompile Include="..\windows\system.cpp" />
</ItemGroup>

View File

@ -139,6 +139,9 @@
<Filter Include="sdk\filesystem">
<UniqueIdentifier>{ac641995-20c7-43a8-ae66-809b349b1de7}</UniqueIdentifier>
</Filter>
<Filter Include="sdk\vstdlib">
<UniqueIdentifier>{f6e1bcba-3548-4849-918d-9adea1603b0b}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\common\opcodes.h">
@ -513,21 +516,9 @@
<ClInclude Include="..\thirdparty\spdlog\include\cfg\argv.h">
<Filter>thirdparty\spdlog\include\cfg</Filter>
</ClInclude>
<ClInclude Include="..\tier0\completion.h">
<Filter>sdk\tier0</Filter>
</ClInclude>
<ClInclude Include="..\tier0\cvar.h">
<Filter>sdk\tier0</Filter>
</ClInclude>
<ClInclude Include="..\tier0\IConVar.h">
<Filter>sdk\tier0</Filter>
</ClInclude>
<ClInclude Include="..\tier0\basetypes.h">
<Filter>sdk\tier0</Filter>
</ClInclude>
<ClInclude Include="..\tier0\cmd.h">
<Filter>sdk\tier0</Filter>
</ClInclude>
<ClInclude Include="..\vpc\IAppSystem.h">
<Filter>sdk\vpc</Filter>
</ClInclude>
@ -837,6 +828,21 @@
<ClInclude Include="..\common\sdktypes.h">
<Filter>sdk\common</Filter>
</ClInclude>
<ClInclude Include="..\tier1\cmd.h">
<Filter>sdk\tier1</Filter>
</ClInclude>
<ClInclude Include="..\tier1\IConVar.h">
<Filter>sdk\tier1</Filter>
</ClInclude>
<ClInclude Include="..\tier1\cvar.h">
<Filter>sdk\tier1</Filter>
</ClInclude>
<ClInclude Include="..\vstdlib\completion.h">
<Filter>sdk\vstdlib</Filter>
</ClInclude>
<ClInclude Include="..\vstdlib\keyvaluessystem.h">
<Filter>sdk\vstdlib</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\common\opcodes.cpp">
@ -893,18 +899,6 @@
<ClCompile Include="..\squirrel\sqvm.cpp">
<Filter>sdk\squirrel</Filter>
</ClCompile>
<ClCompile Include="..\tier0\completion.cpp">
<Filter>sdk\tier0</Filter>
</ClCompile>
<ClCompile Include="..\tier0\cvar.cpp">
<Filter>sdk\tier0</Filter>
</ClCompile>
<ClCompile Include="..\tier0\IConVar.cpp">
<Filter>sdk\tier0</Filter>
</ClCompile>
<ClCompile Include="..\tier0\cmd.cpp">
<Filter>sdk\tier0</Filter>
</ClCompile>
<ClCompile Include="..\vpc\IAppSystem.cpp">
<Filter>sdk\vpc</Filter>
</ClCompile>
@ -1049,6 +1043,21 @@
<ClCompile Include="..\filesystem\basefilesystem.cpp">
<Filter>sdk\filesystem</Filter>
</ClCompile>
<ClCompile Include="..\tier1\IConVar.cpp">
<Filter>sdk\tier1</Filter>
</ClCompile>
<ClCompile Include="..\tier1\cmd.cpp">
<Filter>sdk\tier1</Filter>
</ClCompile>
<ClCompile Include="..\tier1\cvar.cpp">
<Filter>sdk\tier1</Filter>
</ClCompile>
<ClCompile Include="..\vstdlib\completion.cpp">
<Filter>sdk\vstdlib</Filter>
</ClCompile>
<ClCompile Include="..\vstdlib\keyvaluessystem.cpp">
<Filter>sdk\vstdlib</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="..\Dedicated.def" />

View File

@ -83,14 +83,13 @@
<ClCompile Include="..\squirrel\sqvm.cpp" />
<ClCompile Include="..\thirdparty\imgui\src\imgui_utility.cpp" />
<ClCompile Include="..\tier0\commandline.cpp" />
<ClCompile Include="..\tier0\cmd.cpp" />
<ClCompile Include="..\tier0\completion.cpp" />
<ClCompile Include="..\tier0\cpu.cpp" />
<ClCompile Include="..\tier0\cputopology.cpp" />
<ClCompile Include="..\tier0\cvar.cpp" />
<ClCompile Include="..\tier0\fasttimer.cpp" />
<ClCompile Include="..\tier0\IConVar.cpp" />
<ClCompile Include="..\tier1\bitbuf.cpp" />
<ClCompile Include="..\tier1\cmd.cpp" />
<ClCompile Include="..\tier1\cvar.cpp" />
<ClCompile Include="..\tier1\IConVar.cpp" />
<ClCompile Include="..\tier1\NetAdr2.cpp" />
<ClCompile Include="..\tier2\socketcreator.cpp" />
<ClCompile Include="..\vguimatsurface\MatSystemSurface.cpp" />
@ -102,6 +101,8 @@
<ClCompile Include="..\vpc\keyvalues.cpp" />
<ClCompile Include="..\vphysics\QHull.cpp" />
<ClCompile Include="..\vpklib\packedstore.cpp" />
<ClCompile Include="..\vstdlib\completion.cpp" />
<ClCompile Include="..\vstdlib\keyvaluessystem.cpp" />
<ClCompile Include="..\windows\console.cpp" />
<ClCompile Include="..\windows\id3dx.cpp" />
<ClCompile Include="..\windows\input.cpp" />
@ -341,16 +342,15 @@
<ClInclude Include="..\thirdparty\spdlog\include\version.h" />
<ClInclude Include="..\tier0\basetypes.h" />
<ClInclude Include="..\tier0\commandline.h" />
<ClInclude Include="..\tier0\cmd.h" />
<ClInclude Include="..\tier0\completion.h" />
<ClInclude Include="..\tier0\cpu.h" />
<ClInclude Include="..\tier0\cputopology.h" />
<ClInclude Include="..\tier0\cvar.h" />
<ClInclude Include="..\tier0\fasttimer.h" />
<ClInclude Include="..\tier0\IConVar.h" />
<ClInclude Include="..\tier0\interface.h" />
<ClInclude Include="..\tier0\platform.h" />
<ClInclude Include="..\tier1\bitbuf.h" />
<ClInclude Include="..\tier1\cmd.h" />
<ClInclude Include="..\tier1\cvar.h" />
<ClInclude Include="..\tier1\IConVar.h" />
<ClInclude Include="..\tier1\NetAdr2.h" />
<ClInclude Include="..\tier1\utlmemory.h" />
<ClInclude Include="..\tier1\utlvector.h" />
@ -365,6 +365,8 @@
<ClInclude Include="..\vpc\keyvalues.h" />
<ClInclude Include="..\vphysics\QHull.h" />
<ClInclude Include="..\vpklib\packedstore.h" />
<ClInclude Include="..\vstdlib\completion.h" />
<ClInclude Include="..\vstdlib\keyvaluessystem.h" />
<ClInclude Include="..\windows\console.h" />
<ClInclude Include="..\windows\id3dx.h" />
<ClInclude Include="..\windows\input.h" />

View File

@ -172,6 +172,9 @@
<Filter Include="sdk\filesystem">
<UniqueIdentifier>{9fbd3a16-56a4-4794-bfa6-680f41002c24}</UniqueIdentifier>
</Filter>
<Filter Include="sdk\vstdlib">
<UniqueIdentifier>{48abe326-8ad7-43fa-875d-2e73c7c64106}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\client\vengineclient_impl.cpp">
@ -234,18 +237,6 @@
<ClCompile Include="..\squirrel\sqapi.cpp">
<Filter>sdk\squirrel</Filter>
</ClCompile>
<ClCompile Include="..\tier0\completion.cpp">
<Filter>sdk\tier0</Filter>
</ClCompile>
<ClCompile Include="..\tier0\cvar.cpp">
<Filter>sdk\tier0</Filter>
</ClCompile>
<ClCompile Include="..\tier0\IConVar.cpp">
<Filter>sdk\tier0</Filter>
</ClCompile>
<ClCompile Include="..\tier0\cmd.cpp">
<Filter>sdk\tier0</Filter>
</ClCompile>
<ClCompile Include="..\vgui\vgui_fpspanel.cpp">
<Filter>sdk\vgui</Filter>
</ClCompile>
@ -432,6 +423,21 @@
<ClCompile Include="..\filesystem\basefilesystem.cpp">
<Filter>sdk\filesystem</Filter>
</ClCompile>
<ClCompile Include="..\tier1\IConVar.cpp">
<Filter>sdk\tier1</Filter>
</ClCompile>
<ClCompile Include="..\tier1\cmd.cpp">
<Filter>sdk\tier1</Filter>
</ClCompile>
<ClCompile Include="..\tier1\cvar.cpp">
<Filter>sdk\tier1</Filter>
</ClCompile>
<ClCompile Include="..\vstdlib\completion.cpp">
<Filter>sdk\vstdlib</Filter>
</ClCompile>
<ClCompile Include="..\vstdlib\keyvaluessystem.cpp">
<Filter>sdk\vstdlib</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\client\cdll_engine_int.h">
@ -839,21 +845,9 @@
<ClInclude Include="..\thirdparty\spdlog\include\cfg\argv.h">
<Filter>thirdparty\spdlog\include\cfg</Filter>
</ClInclude>
<ClInclude Include="..\tier0\completion.h">
<Filter>sdk\tier0</Filter>
</ClInclude>
<ClInclude Include="..\tier0\cvar.h">
<Filter>sdk\tier0</Filter>
</ClInclude>
<ClInclude Include="..\tier0\IConVar.h">
<Filter>sdk\tier0</Filter>
</ClInclude>
<ClInclude Include="..\tier0\basetypes.h">
<Filter>sdk\tier0</Filter>
</ClInclude>
<ClInclude Include="..\tier0\cmd.h">
<Filter>sdk\tier0</Filter>
</ClInclude>
<ClInclude Include="..\vgui\vgui_fpspanel.h">
<Filter>sdk\vgui</Filter>
</ClInclude>
@ -1217,6 +1211,21 @@
<ClInclude Include="..\common\sdktypes.h">
<Filter>core</Filter>
</ClInclude>
<ClInclude Include="..\tier1\cmd.h">
<Filter>sdk\tier1</Filter>
</ClInclude>
<ClInclude Include="..\tier1\IConVar.h">
<Filter>sdk\tier1</Filter>
</ClInclude>
<ClInclude Include="..\tier1\cvar.h">
<Filter>sdk\tier1</Filter>
</ClInclude>
<ClInclude Include="..\vstdlib\completion.h">
<Filter>sdk\vstdlib</Filter>
</ClInclude>
<ClInclude Include="..\vstdlib\keyvaluessystem.h">
<Filter>sdk\vstdlib</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Image Include="..\shared\resource\lockedserver.png">

View File

@ -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

View File

@ -1,5 +1,5 @@
#pragma once
#include "IConVar.h"
#include "tier1/IConVar.h"
/* ==== CONCOMMANDCALLBACK ============================================================================================================================================== */
#if defined (GAMEDLL_S1)

View File

@ -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<void>(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<void*>(index, this, nSize);
}
//-----------------------------------------------------------------------------
// Purpose: frees a KeyValues object from the shared mempool
// Input : *pMem -
//-----------------------------------------------------------------------------
void CKeyValuesSystem::FreeKeyValuesMemory(void* pMem)
{
static int index = 2;
CallVFunc<void>(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<HKeySymbol>(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<const char*>(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<void*>(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<void>(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<bool>(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<HKeySymbol>(index, this, hCaseInsensitiveSymbol, szName, bCreate);
}

View File

@ -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<rsig_t>("\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<rsig_t>("\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<CKeyValuesSystem*>();
///////////////////////////////////////////////////////////////////////////////
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);

View File

@ -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

View File

@ -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"