TmpMenu/src/script_function.cpp

30 lines
700 B
C++
Raw Normal View History

2022-12-06 16:12:02 +00:00
#include "script_function.hpp"
2022-12-06 16:12:02 +00:00
namespace big
{
script_function::script_function(const std::string& name, const rage::joaat_t script, const std::string& pattern) :
m_name(name),
m_script(script),
m_pattern(pattern),
m_ip(0)
2022-12-06 16:12:02 +00:00
{
}
uint32_t script_function::get_ip(rage::scrProgram* program)
2022-12-06 16:12:02 +00:00
{
if (m_ip != 0)
return m_ip;
2022-12-06 16:12:02 +00:00
if (auto location = scripts::get_code_location_by_pattern(program, m_pattern))
{
m_ip = *location;
LOG(VERBOSE) << "Found pattern " << m_name << " at " << HEX_TO_UPPER(m_ip) << " in script " << program->m_name;
2022-12-06 16:12:02 +00:00
}
else
2022-12-06 16:12:02 +00:00
{
LOG(FATAL) << "Failed to find pattern " << m_name << " in script " << program->m_name;
2022-12-06 16:12:02 +00:00
}
return m_ip;
2022-12-06 16:12:02 +00:00
}
}