Add dvar & flag to disable shader caching
This commit is contained in:
parent
d4767230c5
commit
84687a6715
@ -105,8 +105,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)
|
||||||
{
|
{
|
||||||
|
@ -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,24 @@ 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)
|
||||||
|
{
|
||||||
|
printf("fucker\n");
|
||||||
|
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 +436,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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
50
src/client/component/shaders.cpp
Normal file
50
src/client/component/shaders.cpp
Normal 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)
|
Loading…
Reference in New Issue
Block a user