This repository has been archived on 2026-11-07. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
my-first-apex-internal/inc/rspn/netvar.h
T
2026-11-05 02:19:09 +01:00

64 lines
1.1 KiB
C++

#pragma once
struct netvar_t
{
char name[128];
ulong offset;
};
struct netvar_table_t
{
char name[128];
stl::c_linked_list<netvar_t> props;
};
class c_netvar_manager
{
public:
bool initialize();
bool is_prop_garbage(const char* name);
void process_table(respawn::recv_table* table);
void process_prop(respawn::recv_table* table, respawn::recv_prop* prop, stl::c_linked_list<netvar_t>& list);
ulong get(const char* table_name, const char* prop_name) noexcept
{
stl::c_linked_list<netvar_t>* props_head = nullptr;
for (auto i = 0ull; i < m_list.count(); i++)
{
auto* const table = m_list[i];
if (table == nullptr)
continue;
if (stl::strcmp(table_name, table->name))
continue;
props_head = &table->props;
}
if (props_head == nullptr)
return 0;
ulong result{};
for (auto i = 0ull; i < props_head->count(); i++)
{
auto* const prop = (*props_head)[i];
if (!stl::strcmp(prop_name, prop->name))
{
result = prop->offset;
break;
}
}
return result;
}
private:
stl::c_linked_list<netvar_table_t> m_list;
};
#define NETVAR(TABLE, NAME) g::p::netvar_mgr.get(_XS(TABLE), _XS(NAME))