From f1d2d13e358748fd4c38c4ed989487b35d93a001 Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Wed, 1 Jun 2022 01:22:39 +0200 Subject: [PATCH] Also lookup dvars by hash in dvar command --- src/client/component/command.cpp | 23 ++++++++++++++++++----- src/client/game/symbols.hpp | 1 + 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/client/component/command.cpp b/src/client/component/command.cpp index 458ed522..6b4febb2 100644 --- a/src/client/component/command.cpp +++ b/src/client/component/command.cpp @@ -115,7 +115,12 @@ namespace command return 0; } - const auto dvar = game::Dvar_FindVar(args[0]); + auto dvar = game::Dvar_FindVar(args[0]); + if (dvar == nullptr) + { + const auto hash = static_cast(std::strtoull(args[0], nullptr, 16)); + dvar = game::Dvar_FindMalleableVar(hash); + } if (dvar) { @@ -124,12 +129,20 @@ namespace command const auto current = game::Dvar_ValueToString(dvar, true, dvar->current); const auto reset = game::Dvar_ValueToString(dvar, true, dvar->reset); + const auto info = dvars::get_dvar_info_from_hash(dvar->hash); + std::string desc{}; + std::string name = args[0]; + + if (info.has_value()) + { + name = info.value().name; + desc = info.value().description; + } + console::info("\"%s\" is: \"%s\" default: \"%s\" hash: 0x%08lX type: %i\n", - args[0], current, reset, dvar->hash, dvar->type); + name.data(), current, reset, dvar->hash, dvar->type); - const auto dvar_info = dvars::dvar_get_description(args[0]); - - console::info("%s\n", dvar_info.data()); + console::info("%s\n", desc.data()); console::info(" %s\n", dvars::dvar_get_domain(dvar->type, dvar->domain).data()); } else diff --git a/src/client/game/symbols.hpp b/src/client/game/symbols.hpp index 89e40177..7e70294a 100644 --- a/src/client/game/symbols.hpp +++ b/src/client/game/symbols.hpp @@ -71,6 +71,7 @@ namespace game WEAK symbol Dvar_SetCommand{0x41BAD0, 0x1857D0}; WEAK symbol Dvar_FindVar{0x41A600, 0x183EB0}; + WEAK symbol Dvar_FindMalleableVar{0x41A570, 0x183E20}; WEAK symbol Dvar_ClearModified{0x41A4F0, 0x183D50}; WEAK symbol Dvar_GetCombinedString{0x3A7D60, 0x4EA020}; WEAK symbol Dvar_ValueToString{0x41CE00, 0x187000};