Add overridedvarint & removedvarintoverride
This commit is contained in:
parent
2245d9812a
commit
899f8d27a6
@ -22,6 +22,8 @@ namespace scripting
|
||||
std::unordered_map<std::string, std::unordered_map<std::string, const char*>> script_function_table;
|
||||
utils::concurrency::container<shared_table_t> shared_table;
|
||||
|
||||
std::unordered_map<std::string, int> get_dvar_int_overrides;
|
||||
|
||||
namespace
|
||||
{
|
||||
utils::hook::detour vm_notify_hook;
|
||||
@ -79,6 +81,7 @@ namespace scripting
|
||||
|
||||
void clear_scheduled_notifies()
|
||||
{
|
||||
get_dvar_int_overrides.clear();
|
||||
scheduled_notifies.access([](notify_list& list)
|
||||
{
|
||||
list.clear();
|
||||
@ -218,6 +221,20 @@ namespace scripting
|
||||
|
||||
scr_run_current_threads_hook.invoke<void>();
|
||||
}
|
||||
|
||||
utils::hook::detour scr_get_dvar_int_hook;
|
||||
void scr_get_dvar_int_stub()
|
||||
{
|
||||
const auto dvar = game::Scr_GetString(0);
|
||||
|
||||
if (get_dvar_int_overrides.find(dvar) != get_dvar_int_overrides.end())
|
||||
{
|
||||
game::Scr_AddInt(get_dvar_int_overrides[dvar]);
|
||||
return;
|
||||
}
|
||||
|
||||
scr_get_dvar_int_hook.invoke<void>();
|
||||
}
|
||||
}
|
||||
|
||||
class component final : public component_interface
|
||||
@ -241,6 +258,8 @@ namespace scripting
|
||||
|
||||
scr_run_current_threads_hook.create(0x1405C8370, scr_run_current_threads_stub);
|
||||
|
||||
scr_get_dvar_int_hook.create(0x1404F0730, scr_get_dvar_int_stub);
|
||||
|
||||
scheduler::loop([]()
|
||||
{
|
||||
lua::engine::run_frame();
|
||||
|
@ -8,4 +8,6 @@ namespace scripting
|
||||
extern std::unordered_map<int, std::unordered_map<std::string, int>> fields_table;
|
||||
extern std::unordered_map<std::string, std::unordered_map<std::string, const char*>> script_function_table;
|
||||
extern utils::concurrency::container<shared_table_t> shared_table;
|
||||
|
||||
extern std::unordered_map<std::string, int> get_dvar_int_overrides;
|
||||
}
|
@ -766,6 +766,16 @@ namespace scripting::lua
|
||||
{
|
||||
localized_strings::override(string, value, true);
|
||||
};
|
||||
|
||||
game_type["overridedvarint"] = [](const game&, const std::string& dvar, const int value)
|
||||
{
|
||||
scripting::get_dvar_int_overrides[dvar] = value;
|
||||
};
|
||||
|
||||
game_type["removedvarintoverride"] = [](const game&, const std::string& dvar)
|
||||
{
|
||||
scripting::get_dvar_int_overrides.erase(dvar);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,6 +111,8 @@ namespace game
|
||||
WEAK symbol<void(unsigned int id, scr_string_t stringValue, unsigned int paramcount)> Scr_NotifyId{0x1405C8240};
|
||||
WEAK symbol<unsigned int(unsigned int threadId)> Scr_GetSelf{0x1405C57C0};
|
||||
WEAK symbol<void()> Scr_ErrorInternal{0x1405C6EC0};
|
||||
WEAK symbol<const char*(unsigned int index)> Scr_GetString{0x1405C7C20};
|
||||
WEAK symbol<void(int value)> Scr_AddInt{0x1405C69A0};
|
||||
|
||||
WEAK symbol<unsigned int(unsigned int localId, const char* pos, unsigned int paramcount)> VM_Execute{0x1405C8DB0};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user