89 lines
1.7 KiB
C++
89 lines
1.7 KiB
C++
#include <include.h>
|
|
|
|
bool c_netvar_manager::initialize()
|
|
{
|
|
auto* const head = ix::base_client->get_all_classes();
|
|
|
|
if (head == nullptr)
|
|
return false;
|
|
|
|
log_info_("initializing the netvar table.");
|
|
|
|
for (auto* client_class = head; client_class != nullptr; client_class = client_class->next)
|
|
{
|
|
auto* const table = client_class->table;
|
|
|
|
if (table == nullptr)
|
|
continue;
|
|
|
|
process_table(table);
|
|
}
|
|
|
|
log_info("netvar table was set up, there is a total of %i tables.", m_list.count());
|
|
|
|
return true;
|
|
}
|
|
|
|
bool c_netvar_manager::is_prop_garbage(const char* name)
|
|
{
|
|
if (stl::strstr(name, _XS("baseclass")) ||
|
|
stl::strstr(name, _XS("0")) ||
|
|
stl::strstr(name, _XS("1")) ||
|
|
stl::strstr(name, _XS("2")))
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
void c_netvar_manager::process_table(respawn::recv_table* table)
|
|
{
|
|
auto** const head = table->props;
|
|
|
|
if (head == nullptr)
|
|
return;
|
|
|
|
netvar_table_t table_entry{};
|
|
|
|
stl::strcpy(table_entry.name, table->name);
|
|
|
|
for (auto i = 0ull; i < table->num_props; i++)
|
|
{
|
|
auto* const prop = head[i];
|
|
|
|
//
|
|
// validate the prop pointer, at first.
|
|
//
|
|
if (prop == nullptr)
|
|
continue;
|
|
|
|
//
|
|
// validate that the prop is not garbage data.
|
|
//
|
|
if (is_prop_garbage(prop->name))
|
|
continue;
|
|
|
|
//
|
|
// process the actual prop here.
|
|
//
|
|
process_prop(table, prop, table_entry.props);
|
|
|
|
//
|
|
// if this prop has a table, then recursively process it.
|
|
//
|
|
if (prop->data_table != nullptr)
|
|
process_table(prop->data_table);
|
|
}
|
|
|
|
m_list.insert(table_entry);
|
|
}
|
|
|
|
void c_netvar_manager::process_prop(respawn::recv_table* table, respawn::recv_prop* prop, stl::c_linked_list<netvar_t>& list)
|
|
{
|
|
netvar_t entry{};
|
|
|
|
stl::strcpy(entry.name, prop->name);
|
|
entry.offset = prop->offset;
|
|
|
|
list.insert(entry);
|
|
}
|