Improved does_script_exist() and local editor (#1265)
This commit is contained in:
@ -19,13 +19,7 @@ namespace big
|
||||
|
||||
bool locals_service::does_script_exist(std::string script_name)
|
||||
{
|
||||
// TODO: find a better way to check script validity
|
||||
|
||||
for (auto s : all_script_names)
|
||||
if (script_name == s)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return SCRIPT::DOES_SCRIPT_WITH_NAME_HASH_EXIST(rage::joaat(script_name));
|
||||
}
|
||||
|
||||
std::filesystem::path locals_service::get_path()
|
||||
@ -48,14 +42,15 @@ namespace big
|
||||
{
|
||||
if (!l.key().empty())
|
||||
{
|
||||
local new_local{"", "", 0, 0, 0, 0};
|
||||
local new_local{"", "", 0, 0, 0, 0, 0};
|
||||
new_local.m_base_address = j[l.key()]["base_address"];
|
||||
std::string script_name = j[l.key()]["script_thread_name"];
|
||||
strcpy(new_local.m_script_thread_name, script_name.data());
|
||||
new_local.m_freeze = j[l.key()]["freeze"];
|
||||
std::string name = j[l.key()]["name"];
|
||||
strcpy(new_local.m_name, name.data());
|
||||
new_local.m_value = j[l.key()]["value"];
|
||||
new_local.m_value = j[l.key()]["value"];
|
||||
new_local.m_edit_mode = j[l.key()].value<int>("editmode", 0);
|
||||
if (!j[l.key()]["offsets"].is_null())
|
||||
{
|
||||
for (const auto& offset : j[l.key()]["offsets"].items())
|
||||
@ -101,6 +96,7 @@ namespace big
|
||||
j[l.first]["freeze"] = l.second.m_freeze;
|
||||
j[l.first]["name"] = l.second.m_name;
|
||||
j[l.first]["value"] = l.second.m_value;
|
||||
j[l.first]["editmode"] = l.second.m_edit_mode;
|
||||
|
||||
for (int i = 0; i < l.second.m_offsets.size(); i++)
|
||||
{
|
||||
|
@ -33,10 +33,14 @@ namespace big
|
||||
char m_name[200];
|
||||
std::vector<local_offset> m_offsets;
|
||||
int m_value;
|
||||
int m_freeze_value;
|
||||
int m_freeze_value_int;
|
||||
float m_freeze_value_float;
|
||||
Vector3 m_freeze_value_vector3;
|
||||
int* m_internal_address;
|
||||
Vector3* m_internal_address_vector3;
|
||||
int m_edit_mode = 0;
|
||||
|
||||
local(const char* script_thread_name, const char* name, const int base_address, const bool freeze, const int (*offsets)[2], int offset_count)
|
||||
local(const char* script_thread_name, const char* name, const int base_address, const bool freeze, const int (*offsets)[2], int offset_count, int edit_mode = 0)
|
||||
{
|
||||
m_internal_id = ++m_instance_count;
|
||||
|
||||
@ -49,6 +53,8 @@ namespace big
|
||||
for (int i = 0; i < offset_count; i++)
|
||||
m_offsets.push_back(local_offset(offsets[i][0], offsets[i][1]));
|
||||
|
||||
m_edit_mode = edit_mode;
|
||||
|
||||
fetch_local_pointer();
|
||||
}
|
||||
|
||||
@ -73,13 +79,28 @@ namespace big
|
||||
actual_local = actual_local.at(offset.m_offset);
|
||||
}
|
||||
|
||||
m_internal_address = actual_local.as<int*>();
|
||||
m_internal_address = actual_local.as<int*>();
|
||||
m_internal_address_vector3 = actual_local.as<Vector3*>();
|
||||
|
||||
return m_internal_address;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char* get_local_chain_text()
|
||||
{
|
||||
static char offsetschain[200] = "";
|
||||
strcpy(offsetschain, "");
|
||||
strcat(offsetschain, std::to_string(m_base_address).data());
|
||||
for (auto o : m_offsets)
|
||||
{
|
||||
strcat(offsetschain, std::string(".f_" + std::to_string(o.m_offset)).data());
|
||||
if (o.m_size)
|
||||
strcat(offsetschain, std::string("/" + std::to_string(o.m_size)).data());
|
||||
}
|
||||
return offsetschain;
|
||||
}
|
||||
|
||||
private:
|
||||
inline static int m_instance_count;
|
||||
int m_internal_id;
|
||||
|
Reference in New Issue
Block a user