Dvar fixes
This commit is contained in:
parent
f27844f19e
commit
f5765d5c15
@ -22,6 +22,7 @@ namespace command
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
utils::hook::detour client_command_hook;
|
utils::hook::detour client_command_hook;
|
||||||
|
utils::hook::detour parse_commandline_hook;
|
||||||
|
|
||||||
std::unordered_map<std::string, std::function<void(params&)>> handlers;
|
std::unordered_map<std::string, std::function<void(params&)>> handlers;
|
||||||
std::unordered_map<std::string, std::function<void(int, params_sv&)>> handlers_sv;
|
std::unordered_map<std::string, std::function<void(int, params_sv&)>> handlers_sv;
|
||||||
@ -96,7 +97,7 @@ namespace command
|
|||||||
void parse_commandline_stub()
|
void parse_commandline_stub()
|
||||||
{
|
{
|
||||||
parse_command_line();
|
parse_command_line();
|
||||||
utils::hook::invoke<void>(0x15A4F0_b);
|
parse_commandline_hook.invoke<void>();
|
||||||
}
|
}
|
||||||
|
|
||||||
game::dvar_t* dvar_command_stub()
|
game::dvar_t* dvar_command_stub()
|
||||||
@ -114,8 +115,8 @@ namespace command
|
|||||||
{
|
{
|
||||||
if (args.size() == 1)
|
if (args.size() == 1)
|
||||||
{
|
{
|
||||||
const auto current = game::Dvar_ValueToString(dvar, dvar->current);
|
const auto current = game::Dvar_ValueToString(dvar, true, dvar->current);
|
||||||
const auto reset = game::Dvar_ValueToString(dvar, dvar->reset);
|
const auto reset = game::Dvar_ValueToString(dvar, true, dvar->reset);
|
||||||
|
|
||||||
console::info("\"%s\" is: \"%s\" default: \"%s\" hash: 0x%08lX\n",
|
console::info("\"%s\" is: \"%s\" default: \"%s\" hash: 0x%08lX\n",
|
||||||
args[0], current, reset, dvar->hash);
|
args[0], current, reset, dvar->hash);
|
||||||
@ -127,9 +128,9 @@ namespace command
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//char command[0x1000] = { 0 }; <-- CRASHES??!?!?!?!
|
char command[0x1000] = {0};
|
||||||
//game::Dvar_GetCombinedString(command, 1);
|
game::Dvar_GetCombinedString(command, 1);
|
||||||
//game::Dvar_SetCommand(dvar->hash, "", command);
|
game::Dvar_SetCommand(dvar->hash, "", command);
|
||||||
}
|
}
|
||||||
|
|
||||||
return dvar;
|
return dvar;
|
||||||
@ -454,8 +455,6 @@ namespace command
|
|||||||
|
|
||||||
void add(const char* name, const std::function<void(const params&)>& callback)
|
void add(const char* name, const std::function<void(const params&)>& callback)
|
||||||
{
|
{
|
||||||
static game::cmd_function_s cmd_test;
|
|
||||||
|
|
||||||
const auto command = utils::string::to_lower(name);
|
const auto command = utils::string::to_lower(name);
|
||||||
|
|
||||||
if (handlers.find(command) == handlers.end())
|
if (handlers.find(command) == handlers.end())
|
||||||
@ -508,8 +507,8 @@ namespace command
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
utils::hook::call(0x157D8F_b, parse_commandline_stub);
|
// parse_commandline_hook.create(0x157D50_b, parse_commandline_stub);
|
||||||
//utils::hook::jump(0x4E9F40_b, dvar_command_stub);
|
utils::hook::jump(0x4E9F40_b, dvar_command_stub, true);
|
||||||
|
|
||||||
add_commands_mp();
|
add_commands_mp();
|
||||||
}
|
}
|
||||||
|
@ -249,6 +249,38 @@ namespace dvars
|
|||||||
utils::hook::detour dvar_set_string_hook;
|
utils::hook::detour dvar_set_string_hook;
|
||||||
utils::hook::detour dvar_set_from_string_hook;
|
utils::hook::detour dvar_set_from_string_hook;
|
||||||
|
|
||||||
|
utils::hook::detour dvar_re_register_hook;
|
||||||
|
utils::hook::detour dvar_register_new_hook;
|
||||||
|
|
||||||
|
game::dvar_type get_normal_type(const game::dvar_type type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case game::dvar_type::boolean_hashed:
|
||||||
|
return game::dvar_type::boolean;
|
||||||
|
case game::dvar_type::integer_hashed:
|
||||||
|
return game::dvar_type::integer;
|
||||||
|
case game::dvar_type::value_hashed:
|
||||||
|
return game::dvar_type::value;
|
||||||
|
default:
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dvar_re_register_stub(game::dvar_t* dvar, const int hash, const char* name, game::dvar_type type,
|
||||||
|
const unsigned int flags, game::dvar_value* value, game::dvar_limits* domain)
|
||||||
|
{
|
||||||
|
type = get_normal_type(type);
|
||||||
|
dvar_re_register_hook.invoke<void>(dvar, hash, name, type, flags, value, domain);
|
||||||
|
}
|
||||||
|
|
||||||
|
game::dvar_t* dvar_register_new_stub(const int hash, const char* name, game::dvar_type type,
|
||||||
|
const unsigned int flags, game::dvar_value* value, game::dvar_limits* domain)
|
||||||
|
{
|
||||||
|
type = get_normal_type(type);
|
||||||
|
return dvar_register_new_hook.invoke<game::dvar_t*>(hash, name, type, flags, value, domain);
|
||||||
|
}
|
||||||
|
|
||||||
game::dvar_t* dvar_register_bool(const int hash, const char* name, bool value, unsigned int flags)
|
game::dvar_t* dvar_register_bool(const int hash, const char* name, bool value, unsigned int flags)
|
||||||
{
|
{
|
||||||
auto* var = find_dvar(override::register_bool_overrides, hash);
|
auto* var = find_dvar(override::register_bool_overrides, hash);
|
||||||
@ -424,7 +456,13 @@ namespace dvars
|
|||||||
public:
|
public:
|
||||||
void post_unpack() override
|
void post_unpack() override
|
||||||
{
|
{
|
||||||
dvar_register_bool_hook.create(SELECT_VALUE(0x1403C47E0, 0x1404FA540), &dvar_register_bool);
|
if (game::environment::is_mp())
|
||||||
|
{
|
||||||
|
dvar_register_new_hook.create(0x184DF0_b, dvar_register_new_stub);
|
||||||
|
dvar_re_register_hook.create(0x185150_b, dvar_re_register_stub);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*dvar_register_bool_hook.create(SELECT_VALUE(0x1403C47E0, 0x1404FA540), &dvar_register_bool);
|
||||||
dvar_register_float_hook.create(SELECT_VALUE(0x1403C4BB0, 0x1404FA910), &dvar_register_float);
|
dvar_register_float_hook.create(SELECT_VALUE(0x1403C4BB0, 0x1404FA910), &dvar_register_float);
|
||||||
dvar_register_int_hook.create(SELECT_VALUE(0x1403C4CC0, 0x1404FAA20), &dvar_register_int);
|
dvar_register_int_hook.create(SELECT_VALUE(0x1403C4CC0, 0x1404FAA20), &dvar_register_int);
|
||||||
dvar_register_string_hook.create(SELECT_VALUE(0x1403C4DA0, 0x1404FAB00), &dvar_register_string);
|
dvar_register_string_hook.create(SELECT_VALUE(0x1403C4DA0, 0x1404FAB00), &dvar_register_string);
|
||||||
@ -435,9 +473,9 @@ namespace dvars
|
|||||||
dvar_set_float_hook.create(SELECT_VALUE(0x1403C7420, 0x1404FD360), &dvar_set_float);
|
dvar_set_float_hook.create(SELECT_VALUE(0x1403C7420, 0x1404FD360), &dvar_set_float);
|
||||||
dvar_set_int_hook.create(SELECT_VALUE(0x1403C76C0, 0x1404FD5E0), &dvar_set_int);
|
dvar_set_int_hook.create(SELECT_VALUE(0x1403C76C0, 0x1404FD5E0), &dvar_set_int);
|
||||||
dvar_set_string_hook.create(SELECT_VALUE(0x1403C7900, 0x1404FD8D0), &dvar_set_string);
|
dvar_set_string_hook.create(SELECT_VALUE(0x1403C7900, 0x1404FD8D0), &dvar_set_string);
|
||||||
dvar_set_from_string_hook.create(SELECT_VALUE(0x1403C7620, 0x1404FD520), &dvar_set_from_string);
|
dvar_set_from_string_hook.create(SELECT_VALUE(0x1403C7620, 0x1404FD520), &dvar_set_from_string);*/
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
//REGISTER_COMPONENT(dvars::component)
|
REGISTER_COMPONENT(dvars::component)
|
||||||
|
@ -286,10 +286,10 @@ namespace game_console
|
|||||||
{
|
{
|
||||||
const auto offset = (con.screen_max[0] - con.globals.x) / 4.f;
|
const auto offset = (con.screen_max[0] - con.globals.x) / 4.f;
|
||||||
|
|
||||||
draw_hint_text(0, game::Dvar_ValueToString(dvar, dvar->current),
|
draw_hint_text(0, game::Dvar_ValueToString(dvar, true, dvar->current),
|
||||||
dvars::con_inputDvarValueColor->current.vector, offset);
|
dvars::con_inputDvarValueColor->current.vector, offset);
|
||||||
draw_hint_text(1, " default", dvars::con_inputDvarInactiveValueColor->current.vector);
|
draw_hint_text(1, " default", dvars::con_inputDvarInactiveValueColor->current.vector);
|
||||||
draw_hint_text(1, game::Dvar_ValueToString(dvar, dvar->reset),
|
draw_hint_text(1, game::Dvar_ValueToString(dvar, true, dvar->reset),
|
||||||
dvars::con_inputDvarInactiveValueColor->current.vector, offset);
|
dvars::con_inputDvarInactiveValueColor->current.vector, offset);
|
||||||
draw_hint_text(2, matches[0].description.data(),
|
draw_hint_text(2, matches[0].description.data(),
|
||||||
color_white, 0);
|
color_white, 0);
|
||||||
@ -324,7 +324,7 @@ namespace game_console
|
|||||||
|
|
||||||
if (dvar)
|
if (dvar)
|
||||||
{
|
{
|
||||||
draw_hint_text(static_cast<int>(i), game::Dvar_ValueToString(dvar, dvar->current),
|
draw_hint_text(static_cast<int>(i), game::Dvar_ValueToString(dvar, true, dvar->current),
|
||||||
dvars::con_inputDvarValueColor->current.vector, offset);
|
dvars::con_inputDvarValueColor->current.vector, offset);
|
||||||
|
|
||||||
draw_hint_text(static_cast<int>(i), matches[i].description.data(),
|
draw_hint_text(static_cast<int>(i), matches[i].description.data(),
|
||||||
|
@ -72,9 +72,11 @@ namespace dvars
|
|||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case game::dvar_type::boolean:
|
case game::dvar_type::boolean:
|
||||||
|
case game::dvar_type::boolean_hashed:
|
||||||
return "Domain is 0 or 1"s;
|
return "Domain is 0 or 1"s;
|
||||||
|
|
||||||
case game::dvar_type::value:
|
case game::dvar_type::value:
|
||||||
|
case game::dvar_type::value_hashed:
|
||||||
if (domain.value.min == -FLT_MAX)
|
if (domain.value.min == -FLT_MAX)
|
||||||
{
|
{
|
||||||
if (domain.value.max == FLT_MAX)
|
if (domain.value.max == FLT_MAX)
|
||||||
@ -106,6 +108,7 @@ namespace dvars
|
|||||||
return dvar_get_vector_domain(4, domain);
|
return dvar_get_vector_domain(4, domain);
|
||||||
|
|
||||||
case game::dvar_type::integer:
|
case game::dvar_type::integer:
|
||||||
|
case game::dvar_type::integer_hashed:
|
||||||
if (domain.enumeration.stringCount == INT_MIN)
|
if (domain.enumeration.stringCount == INT_MIN)
|
||||||
{
|
{
|
||||||
if (domain.integer.max == INT_MAX)
|
if (domain.integer.max == INT_MAX)
|
||||||
|
@ -881,11 +881,14 @@ namespace game
|
|||||||
enum dvar_type : std::int8_t
|
enum dvar_type : std::int8_t
|
||||||
{
|
{
|
||||||
boolean = 0,
|
boolean = 0,
|
||||||
|
boolean_hashed = 10,
|
||||||
value = 1,
|
value = 1,
|
||||||
|
value_hashed = 11,
|
||||||
vec2 = 2,
|
vec2 = 2,
|
||||||
vec3 = 3,
|
vec3 = 3,
|
||||||
vec4 = 4,
|
vec4 = 4,
|
||||||
integer = 5,
|
integer = 5,
|
||||||
|
integer_hashed = 12,
|
||||||
enumeration = 6,
|
enumeration = 6,
|
||||||
string = 7,
|
string = 7,
|
||||||
color = 8,
|
color = 8,
|
||||||
|
@ -55,7 +55,7 @@ namespace game
|
|||||||
WEAK symbol<dvar_t*(const char* name)> Dvar_FindVar{0x0, 0x183EB0};
|
WEAK symbol<dvar_t*(const char* name)> Dvar_FindVar{0x0, 0x183EB0};
|
||||||
WEAK symbol<void(const dvar_t* dvar)> Dvar_ClearModified{0x0, 0x0};
|
WEAK symbol<void(const dvar_t* dvar)> Dvar_ClearModified{0x0, 0x0};
|
||||||
WEAK symbol<void(char* buffer, int index)> Dvar_GetCombinedString{0x0, 0x4EA020};
|
WEAK symbol<void(char* buffer, int index)> Dvar_GetCombinedString{0x0, 0x4EA020};
|
||||||
WEAK symbol<const char*(dvar_t* dvar, dvar_value value)> Dvar_ValueToString{0x0, 0x187000};
|
WEAK symbol<const char*(dvar_t* dvar, bool is_hashed, dvar_value value)> Dvar_ValueToString{0x0, 0x187000};
|
||||||
WEAK symbol<void(dvar_t* dvar, DvarSetSource source)> Dvar_Reset{0x0, 0x185390};
|
WEAK symbol<void(dvar_t* dvar, DvarSetSource source)> Dvar_Reset{0x0, 0x185390};
|
||||||
WEAK symbol<void(const char*, const char*,
|
WEAK symbol<void(const char*, const char*,
|
||||||
DvarSetSource)> Dvar_SetFromStringByNameFromSource{0x0, 0x185BD0};
|
DvarSetSource)> Dvar_SetFromStringByNameFromSource{0x0, 0x185BD0};
|
||||||
|
Loading…
Reference in New Issue
Block a user