r5sdk/r5dev/tier0/cvar.cpp
Amos 62604e8fe9 CAI related stuff (see description)
* Partially rebuild CGlobalVarsBase and CGlobalVars struct.
* Partially implement BuildAINFile (disk builder) written by BobTheBob9. All that needs to be found are the addresses/offsets for 'pUnkStruct0Count' and 'pUnkLinkStruct1Count' (see ai_node.h). I didn't have time for it yet.
* Patch call which restarts the engine once AIN file has been build (so it doesn't get cleared from memory).
* Temporarily patch write operation in 'Detours_LevelInit()' which writes out of scope since the navmesh structure is misaligned somewhere still with a few bytes.

NOTE: 'CAI_NetworkBuilder::BuildFile()' is for now commented out until the 2 other structs are found in the game dll. Once found then we could start fixing the struct offsets and hope it works as-is.
2022-02-27 03:15:00 +01:00

147 lines
6.4 KiB
C++

#include "core/stdafx.h"
#include "tier0/cvar.h"
#include "tier0/IConVar.h"
#include "engine/sys_dll2.h"
//-----------------------------------------------------------------------------
// ENGINE |
ConVar* cm_debug_cmdquery = nullptr;
ConVar* cm_return_false_cmdquery_all = nullptr;
ConVar* cm_return_false_cmdquery_cheats = nullptr;
ConVar* r_debug_overlay_nodecay = nullptr;
ConVar* rcon_address = nullptr;
ConVar* rcon_password = nullptr;
//-----------------------------------------------------------------------------
// SERVER |
ConVar* ai_dumpAINfileFromLoad = nullptr;
ConVar* sv_showconnecting = nullptr;
ConVar* sv_pylonvisibility = nullptr;
#ifdef DEDICATED
ConVar* sv_rcon_debug = nullptr;
ConVar* sv_rcon_banpenalty = nullptr; // TODO
ConVar* sv_rcon_maxfailures = nullptr;
ConVar* sv_rcon_maxignores = nullptr;
ConVar* sv_rcon_maxsockets = nullptr;
ConVar* sv_rcon_whitelist_address = nullptr;
#endif // DEDICATED
//-----------------------------------------------------------------------------
// CLIENT |
#ifndef DEDICATED
ConVar* cl_drawconsoleoverlay = nullptr;
ConVar* cl_consoleoverlay_lines = nullptr;
ConVar* cl_consoleoverlay_offset_x = nullptr;
ConVar* cl_consoleoverlay_offset_y = nullptr;
ConVar* cl_conoverlay_script_server_clr = nullptr;
ConVar* cl_conoverlay_script_client_clr = nullptr;
ConVar* cl_conoverlay_script_ui_clr = nullptr;
ConVar* cl_conoverlay_native_server_clr = nullptr;
ConVar* cl_conoverlay_native_client_clr = nullptr;
ConVar* cl_conoverlay_native_ui_clr = nullptr;
ConVar* cl_conoverlay_native_engine_clr = nullptr;
ConVar* cl_conoverlay_native_fs_clr = nullptr;
ConVar* cl_conoverlay_native_rtech_clr = nullptr;
ConVar* cl_conoverlay_native_ms_clr = nullptr;
ConVar* cl_conoverlay_netcon_clr = nullptr;
ConVar* cl_conoverlay_warning_clr = nullptr;
ConVar* cl_conoverlay_error_clr = nullptr;
ConVar* cl_showsimstats = nullptr;
ConVar* cl_simstats_offset_x = nullptr;
ConVar* cl_simstats_offset_y = nullptr;
ConVar* cl_showgpustats = nullptr;
ConVar* cl_gpustats_offset_x = nullptr;
ConVar* cl_gpustats_offset_y = nullptr;
ConVar* con_max_size_logvector = nullptr;
ConVar* con_suggestion_limit = nullptr;
ConVar* con_suggestion_helptext = nullptr;
#endif // !DEDICATED
//-----------------------------------------------------------------------------
// FILESYSTEM |
ConVar* fs_warning_level_sdk = nullptr;
ConVar* fs_show_warning_output = nullptr;
ConVar* fs_packedstore_entryblock_stats = nullptr;
//-----------------------------------------------------------------------------
// MATERIALSYSTEM |
#ifndef DEDICATED
ConVar* mat_showdxoutput = nullptr;
#endif // !DEDICATED
//-----------------------------------------------------------------------------
// SQUIRREL |
ConVar* sq_showrsonloading = nullptr;
ConVar* sq_showscriptloading = nullptr;
ConVar* sq_showvmoutput = nullptr;
ConVar* sq_showvmwarning = nullptr;
//-----------------------------------------------------------------------------
// NETCHANNEL |
ConVar* net_userandomkey = nullptr;
ConVar* r5net_matchmaking_hostname = nullptr;
ConVar* r5net_show_debug = nullptr;
//-----------------------------------------------------------------------------
// Purpose: finds base commands.
// Input : *pszCommandName -
//-----------------------------------------------------------------------------
ConCommandBase* CCVar::FindCommandBase(const char* pszCommandName)
{
static int index = 14;
return CallVFunc<ConCommandBase*>(index, this, pszCommandName);
}
//-----------------------------------------------------------------------------
// Purpose: finds ConVars.
// Input : *pszVarName -
//-----------------------------------------------------------------------------
ConVar* CCVar::FindVar(const char* pszVarName)
{
static int index = 16;
return CallVFunc<ConVar*>(index, this, pszVarName);
}
//-----------------------------------------------------------------------------
// Purpose: finds ConCommands.
// Input : *pszCommandName -
//-----------------------------------------------------------------------------
ConCommand* CCVar::FindCommand(const char* pszCommandName)
{
static int index = 18;
return CallVFunc<ConCommand*>(index, this, pszCommandName);
}
//-----------------------------------------------------------------------------
// Purpose: iterates over all ConVars
//-----------------------------------------------------------------------------
CCVarIteratorInternal* CCVar::FactoryInternalIterator()
{
static int index = 41;
return CallVFunc<CCVarIteratorInternal*>(index, this);
}
//-----------------------------------------------------------------------------
// Purpose: returns all ConVars
//-----------------------------------------------------------------------------
std::unordered_map<std::string, ConCommandBase*> CCVar::DumpToMap()
{
std::stringstream ss;
CCVarIteratorInternal* itint = FactoryInternalIterator(); // Allocate new InternalIterator.
std::unordered_map<std::string, ConCommandBase*> allConVars;
for (itint->SetFirst(); itint->IsValid(); itint->Next()) // Loop through all instances.
{
ConCommandBase* pCommand = itint->Get();
const char* pszCommandName = pCommand->m_pszName;
allConVars[pszCommandName] = pCommand;
}
return allConVars;
}
///////////////////////////////////////////////////////////////////////////////
std::vector<std::string> g_vsvCommandBases;
CCVar* g_pCVar = reinterpret_cast<CCVar*>(p_CEngineAPI_Connect.FindPatternSelf("48 8D 0D", ADDRESS::Direction::DOWN, 40).ResolveRelativeAddressSelf(0x3, 0x7).GetPtr());