mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2024-12-22 20:17:24 +08:00
Fixed a race condition with scr_patch's destructor. (#3639)
* Fixed a race condition caused by disabling and enabling a Lua script with scr_patch more than once. * Fixed patch not being enabled if data is already created --------- Co-authored-by: Arthur <121949966+ShinyWasabi@users.noreply.github.com>
This commit is contained in:
parent
707f2004ff
commit
706e6f7fc0
@ -27,7 +27,6 @@ namespace lua::scr_patch
|
||||
|
||||
scr_patch::~scr_patch()
|
||||
{
|
||||
disable();
|
||||
big::g_script_patcher_service->remove_patch(m_patch_name);
|
||||
}
|
||||
|
||||
@ -36,7 +35,7 @@ namespace lua::scr_patch
|
||||
if (!m_enable)
|
||||
{
|
||||
m_enable = true;
|
||||
big::g_script_patcher_service->update_all_patches_for_script(m_script);
|
||||
big::g_script_patcher_service->update();
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,7 +44,7 @@ namespace lua::scr_patch
|
||||
if (m_enable)
|
||||
{
|
||||
m_enable = false;
|
||||
big::g_script_patcher_service->update_all_patches_for_script(m_script);
|
||||
big::g_script_patcher_service->update();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,10 @@ namespace big
|
||||
{
|
||||
auto result = get_code_location_by_pattern(data, m_pattern);
|
||||
if (!result.has_value())
|
||||
{
|
||||
LOG(FATAL) << "Failed to find pattern: " << m_name;
|
||||
return;
|
||||
}
|
||||
|
||||
m_ip = result.value() + m_offset;
|
||||
|
||||
|
@ -87,12 +87,14 @@ namespace big
|
||||
|
||||
void script_patcher_service::on_script_load(rage::scrProgram* program)
|
||||
{
|
||||
if (get_data_for_script(program->m_name_hash) == nullptr && does_script_have_patches(program->m_name_hash))
|
||||
{
|
||||
if (!does_script_have_patches(program->m_name_hash))
|
||||
return;
|
||||
|
||||
if (get_data_for_script(program->m_name_hash) == nullptr)
|
||||
create_data_for_script(program);
|
||||
|
||||
update_all_patches_for_script(program->m_name_hash);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t** script_patcher_service::get_script_bytecode(rage::joaat_t script)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user