Also lookup dvars by hash in dvar command

This commit is contained in:
Federico Cecchetto 2022-06-01 01:22:39 +02:00
parent 3b471319ab
commit 46454bae4a
2 changed files with 19 additions and 5 deletions

View File

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

View File

@ -71,6 +71,7 @@ namespace game
WEAK symbol<void(int hash, const char* name, const char* buffer)> Dvar_SetCommand{0x41BAD0, 0x1857D0};
WEAK symbol<dvar_t*(const char* name)> Dvar_FindVar{0x41A600, 0x183EB0};
WEAK symbol<dvar_t*(int hash)> Dvar_FindMalleableVar{0x41A570, 0x183E20};
WEAK symbol<void(const dvar_t* dvar)> Dvar_ClearModified{0x41A4F0, 0x183D50};
WEAK symbol<void(char* buffer, int index)> Dvar_GetCombinedString{0x3A7D60, 0x4EA020};
WEAK symbol<const char*(dvar_t* dvar, bool is_hashed, dvar_value value)> Dvar_ValueToString{0x41CE00, 0x187000};