Merge branch 'main' into dedicated

This commit is contained in:
fed 2022-03-01 03:03:37 +01:00 committed by GitHub
commit 2d30f73261
9 changed files with 100 additions and 14 deletions

View File

@ -125,8 +125,10 @@ namespace console
this->console_thread_.join(); this->console_thread_.join();
} }
#ifndef NATIVE_CONSOLE
_close(this->handles_[0]); _close(this->handles_[0]);
_close(this->handles_[1]); _close(this->handles_[1]);
#endif
messages.access([&](message_queue& msgs) messages.access([&](message_queue& msgs)
{ {

View File

@ -144,6 +144,7 @@ namespace dvars
static std::unordered_map<std::string, float> set_float_overrides; static std::unordered_map<std::string, float> set_float_overrides;
static std::unordered_map<std::string, int> set_int_overrides; static std::unordered_map<std::string, int> set_int_overrides;
static std::unordered_map<std::string, std::string> set_string_overrides; static std::unordered_map<std::string, std::string> set_string_overrides;
static std::unordered_map<std::string, std::string> set_from_string_overrides;
void register_bool(const std::string& name, const bool value, const unsigned int flags) void register_bool(const std::string& name, const bool value, const unsigned int flags)
{ {
@ -228,6 +229,11 @@ namespace dvars
{ {
set_string_overrides[name] = value; set_string_overrides[name] = value;
} }
void set_from_string(const std::string& name, const std::string& value)
{
set_from_string_overrides[name] = value;
}
} }
utils::hook::detour dvar_register_bool_hook; utils::hook::detour dvar_register_bool_hook;
@ -241,6 +247,7 @@ namespace dvars
utils::hook::detour dvar_set_float_hook; utils::hook::detour dvar_set_float_hook;
utils::hook::detour dvar_set_int_hook; utils::hook::detour dvar_set_int_hook;
utils::hook::detour dvar_set_string_hook; utils::hook::detour dvar_set_string_hook;
utils::hook::detour dvar_set_from_string_hook;
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)
{ {
@ -395,6 +402,23 @@ namespace dvars
return dvar_set_string_hook.invoke<void>(dvar, string); return dvar_set_string_hook.invoke<void>(dvar, string);
} }
void dvar_set_from_string(game::dvar_t* dvar, const char* string, game::DvarSetSource source)
{
const auto disabled = find_dvar(disable::set_string_disables, dvar->hash);
if (disabled)
{
return;
}
auto* var = find_dvar(override::set_from_string_overrides, dvar->hash);
if (var)
{
string = var->data();
}
return dvar_set_from_string_hook.invoke<void>(dvar, string, source);
}
class component final : public component_interface class component final : public component_interface
{ {
public: public:
@ -411,6 +435,7 @@ 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(0, 0x1404FD520), &dvar_set_from_string);
} }
}; };
} }

View File

@ -23,5 +23,6 @@ namespace dvars
void set_float(const std::string& name, float fl); void set_float(const std::string& name, float fl);
void set_int(const std::string& name, int integer); void set_int(const std::string& name, int integer);
void set_string(const std::string& name, const std::string& string); void set_string(const std::string& name, const std::string& string);
void set_from_string(const std::string& name, const std::string& value);
} }
} }

View File

@ -33,7 +33,6 @@ namespace patches
{ {
return; return;
} }
return sv_kick_client_num_hook.invoke<void>(client_num, reason); return sv_kick_client_num_hook.invoke<void>(client_num, reason);
} }
@ -134,6 +133,14 @@ namespace patches
reinterpret_cast<void(*)(game::mp::client_t*, game::msg_t*)>(0x140481A00)(client, msg); reinterpret_cast<void(*)(game::mp::client_t*, game::msg_t*)>(0x140481A00)(client, msg);
} }
void aim_assist_add_to_target_list(void* a1, void* a2)
{
if (!dvars::aimassist_enabled->current.enabled)
return;
game::AimAssist_AddToTargetList(a1, a2);
}
} }
class component final : public component_interface class component final : public component_interface
@ -160,6 +167,10 @@ namespace patches
// Make cg_fov and cg_fovscale saved dvars // Make cg_fov and cg_fovscale saved dvars
dvars::override::register_float("cg_fov", 65.f, 40.f, 200.f, game::DvarFlags::DVAR_FLAG_SAVED); dvars::override::register_float("cg_fov", 65.f, 40.f, 200.f, game::DvarFlags::DVAR_FLAG_SAVED);
dvars::override::register_float("cg_fovScale", 1.f, 0.1f, 2.f, game::DvarFlags::DVAR_FLAG_SAVED); dvars::override::register_float("cg_fovScale", 1.f, 0.1f, 2.f, game::DvarFlags::DVAR_FLAG_SAVED);
// Allow kbam input when gamepad is enabled
utils::hook::nop(SELECT_VALUE(0x14018797E, 0x14024EF60), 2);
utils::hook::nop(SELECT_VALUE(0x1401856DC, 0x14024C6B0), 6);
if (game::environment::is_mp()) if (game::environment::is_mp())
{ {
@ -182,10 +193,10 @@ namespace patches
utils::hook::call(0x1402BA26B, bsp_sys_error_stub); // H1(1.4) utils::hook::call(0x1402BA26B, bsp_sys_error_stub); // H1(1.4)
// client side aim assist dvar // client side aim assist dvar
//dvars::aimassist_enabled = game::Dvar_RegisterBool("aimassist_enabled", true, dvars::aimassist_enabled = dvars::register_bool("aimassist_enabled", true,
// game::DvarFlags::DVAR_FLAG_SAVED, game::DvarFlags::DVAR_FLAG_SAVED,
// "Enables aim assist for controllers"); true);
//utils::hook::call(0x140003609, aim_assist_add_to_target_list); utils::hook::call(0x14009EE9E, aim_assist_add_to_target_list);
// unlock all items // unlock all items
utils::hook::jump(0x140413E60, is_item_unlocked); // LiveStorage_IsItemUnlockedFromTable_LocalClient H1(1.4) utils::hook::jump(0x140413E60, is_item_unlocked); // LiveStorage_IsItemUnlockedFromTable_LocalClient H1(1.4)

View File

@ -0,0 +1,50 @@
#include <std_include.hpp>
#include "loader/component_loader.hpp"
#include "scheduler.hpp"
#include "dvars.hpp"
#include "game/game.hpp"
#include "game/dvars.hpp"
#include <utils/nt.hpp>
#include <utils/hook.hpp>
#include <utils/flags.hpp>
namespace shaders
{
namespace
{
game::dvar_t* disable_shader_caching = nullptr;
bool shader_should_show_dialog_stub()
{
return !disable_shader_caching->current.enabled;
}
}
class component final : public component_interface
{
public:
void post_unpack() override
{
if (!game::environment::is_mp())
{
return;
}
const auto has_flag = utils::flags::has_flag("noshadercaching");
disable_shader_caching = dvars::register_bool("disable_shader_caching", has_flag, game::DVAR_FLAG_SAVED, true);
if (has_flag)
{
dvars::override::set_bool("disable_shader_caching", 1);
dvars::override::set_from_string("disable_shader_caching", "1");
}
utils::hook::jump(0x14007E710, shader_should_show_dialog_stub);
}
};
}
REGISTER_COMPONENT(shaders::component)

View File

@ -9,15 +9,7 @@
namespace dvars namespace dvars
{ {
struct dvar_base game::dvar_t* aimassist_enabled = nullptr;
{
unsigned int flags{};
};
struct dvar_bool : dvar_base
{
bool value{};
};
game::dvar_t* con_inputBoxColor = nullptr; game::dvar_t* con_inputBoxColor = nullptr;
game::dvar_t* con_inputHintBoxColor = nullptr; game::dvar_t* con_inputHintBoxColor = nullptr;

View File

@ -6,6 +6,8 @@
namespace dvars namespace dvars
{ {
extern game::dvar_t* aimassist_enabled;
extern game::dvar_t* con_inputBoxColor; extern game::dvar_t* con_inputBoxColor;
extern game::dvar_t* con_inputHintBoxColor; extern game::dvar_t* con_inputHintBoxColor;
extern game::dvar_t* con_outputBarColor; extern game::dvar_t* con_outputBarColor;

View File

@ -18,6 +18,8 @@ namespace game
WEAK symbol<void(const char* text_in)> Cmd_TokenizeString{0x140344110, 0x1404046F0}; WEAK symbol<void(const char* text_in)> Cmd_TokenizeString{0x140344110, 0x1404046F0};
WEAK symbol<void()> Cmd_EndTokenizeString{0x140343630, 0x140403C20}; WEAK symbol<void()> Cmd_EndTokenizeString{0x140343630, 0x140403C20};
WEAK symbol<void(void*, void*)> AimAssist_AddToTargetList{0, 0x14009D0F0};
WEAK symbol<void()> Com_Frame_Try_Block_Function{0, 0x1400D8310}; WEAK symbol<void()> Com_Frame_Try_Block_Function{0, 0x1400D8310};
WEAK symbol<CodPlayMode()> Com_GetCurrentCoDPlayMode{0, 0x1405039A0}; WEAK symbol<CodPlayMode()> Com_GetCurrentCoDPlayMode{0, 0x1405039A0};
WEAK symbol<void(float, float, int)> Com_SetSlowMotion{0, 0x1400DB790}; WEAK symbol<void(float, float, int)> Com_SetSlowMotion{0, 0x1400DB790};

View File

@ -37,6 +37,7 @@ namespace utils::flags
if (!parsed) if (!parsed)
{ {
parse_flags(enabled_flags); parse_flags(enabled_flags);
parsed = true;
} }
for (const auto& entry : enabled_flags) for (const auto& entry : enabled_flags)