Fixed patch not being enabled if data is already created

This commit is contained in:
Arthur 2024-08-30 17:59:31 +03:00
parent f08dad6c4e
commit fb808f2991
3 changed files with 11 additions and 6 deletions

View File

@ -35,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();
}
}
@ -44,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();
}
}

View File

@ -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;

View File

@ -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)
{