Changed all game struct suffixes from _s to _t.

This commit is contained in:
Caball
2024-12-30 23:05:06 +01:00
parent 0090d894c4
commit d0003da606
18 changed files with 135 additions and 135 deletions

View File

@ -82,7 +82,7 @@ namespace auth
return key;
}
int send_connect_data_stub(game::netsrc_t sock, game::netadr_s* adr, const char* format, const int len)
int send_connect_data_stub(game::netsrc_t sock, game::netadr_t* adr, const char* format, const int len)
{
std::string connect_string(format, len);
game::SV_Cmd_TokenizeString(connect_string.data());
@ -116,7 +116,7 @@ namespace auth
return true;
}
void direct_connect(game::netadr_s* from, game::msg_t* msg)
void direct_connect(game::netadr_t* from, game::msg_t* msg)
{
const auto offset = sizeof("connect") + 4;

View File

@ -144,7 +144,7 @@ namespace bots
{
bot_names_received = false;
game::netadr_s master{};
game::netadr_t master{};
if (server_list::get_master_server(master))
{
console::info("Getting bots...\n");
@ -198,9 +198,9 @@ namespace bots
parse_bot_names_from_file();
}
network::on("getbotsResponse", [](const game::netadr_s& target, const std::string& data)
network::on("getbotsResponse", [](const game::netadr_t& target, const std::string& data)
{
game::netadr_s master{};
game::netadr_t master{};
if (server_list::get_master_server(master) && !bot_names_received && target == master)
{
bot_names = utils::string::split(data, '\n');

View File

@ -194,7 +194,7 @@ namespace command
void add_raw(const char* name, void (*callback)())
{
game::Cmd_AddCommandInternal(name, callback, utils::memory::get_allocator()->allocate<game::cmd_function_s>());
game::Cmd_AddCommandInternal(name, callback, utils::memory::get_allocator()->allocate<game::cmd_function_t>());
}
void add(const char* name, const std::function<void(const params&)>& callback)
@ -318,7 +318,7 @@ namespace command
}
console::info("================================ COMMAND DUMP =====================================\n");
game::cmd_function_s* cmd = *game::cmd_functions;
game::cmd_function_t* cmd = *game::cmd_functions;
auto i = 0;
while (cmd)
{

View File

@ -110,7 +110,7 @@ namespace dedicated
return;
}
game::netadr_s target{};
game::netadr_t target{};
if (server_list::get_master_server(target))
{
network::send(target, "heartbeat", "IW6");

View File

@ -71,7 +71,7 @@ namespace discord
discord_presence.state = host_name;
discord_presence.partyMax = party::server_client_count();
std::hash<game::netadr_s> hash_fn;
std::hash<game::netadr_t> hash_fn;
static const auto nonce = utils::cryptography::random::get_integer();
const auto& address = party::get_target();

View File

@ -110,7 +110,7 @@ namespace dvar_cheats
a.jmp(0x1404F0D74);
});
void cg_set_client_dvar_from_server(const int local_client_num, game::mp::cg_s* cg, const char* dvar_id, const char* value)
void cg_set_client_dvar_from_server(const int local_client_num, game::mp::cg_t* cg, const char* dvar_id, const char* value)
{
if (dvar_id == "cg_fov"s || dvar_id == "com_maxfps"s)
{

View File

@ -674,7 +674,7 @@ namespace game_console
}
}
game::cmd_function_s* cmd = (*game::cmd_functions);
game::cmd_function_t* cmd = (*game::cmd_functions);
while (cmd)
{
if (cmd->name)

View File

@ -133,7 +133,7 @@ namespace gameplay
return jump_height;
}
void jump_apply_slowdown_stub(game::mp::playerState_s* ps)
void jump_apply_slowdown_stub(game::mp::playerState_t* ps)
{
assert(ps->pm_flags & game::PMF_JUMPING);
@ -163,7 +163,7 @@ namespace gameplay
}
}
float jump_get_slowdown_friction(game::mp::playerState_s* ps)
float jump_get_slowdown_friction(game::mp::playerState_t* ps)
{
assert(ps->pm_flags & game::PMF_JUMPING);
assert(ps->pm_time <= game::JUMP_LAND_SLOWDOWN_TIME);
@ -181,7 +181,7 @@ namespace gameplay
return 2.5f;
}
float jump_reduce_friction_stub(game::mp::playerState_s* ps)
float jump_reduce_friction_stub(game::mp::playerState_t* ps)
{
float control;
@ -199,7 +199,7 @@ namespace gameplay
return control;
}
float jump_get_land_factor(game::mp::playerState_s* ps)
float jump_get_land_factor(game::mp::playerState_t* ps)
{
assert(ps->pm_flags & game::PMF_JUMPING);
assert(ps->pm_time <= game::JUMP_LAND_SLOWDOWN_TIME);
@ -219,9 +219,9 @@ namespace gameplay
void jump_start_stub(game::pmove_t* pm, game::pml_t* pml, float height)
{
static_assert(offsetof(game::mp::playerState_s, groundEntityNum) == 0x70);
static_assert(offsetof(game::mp::playerState_s, pm_time) == 0x8);
static_assert(offsetof(game::mp::playerState_s, sprintState.sprintButtonUpRequired) == 0x240);
static_assert(offsetof(game::mp::playerState_t, groundEntityNum) == 0x70);
static_assert(offsetof(game::mp::playerState_t, pm_time) == 0x8);
static_assert(offsetof(game::mp::playerState_t, sprintState.sprintButtonUpRequired) == 0x240);
static_assert(offsetof(game::pml_t, frametime) == 0x24);
static_assert(offsetof(game::pml_t, walking) == 0x2C);
static_assert(offsetof(game::pml_t, groundPlane) == 0x30);
@ -229,9 +229,9 @@ namespace gameplay
float factor;
float velocity_sqrd;
game::mp::playerState_s* ps;
game::mp::playerState_t* ps;
ps = static_cast<game::mp::playerState_s*>(pm->ps);
ps = static_cast<game::mp::playerState_t*>(pm->ps);
assert(ps);
@ -295,7 +295,7 @@ namespace gameplay
}
}
void pm_weapon_use_ammo_stub(game::playerState_s* ps, game::Weapon weapon,
void pm_weapon_use_ammo_stub(game::playerState_t* ps, game::Weapon weapon,
bool is_alternate, int amount, game::PlayerHandIndex hand)
{
if (!dvars::player_sustainAmmo->current.enabled)
@ -304,10 +304,10 @@ namespace gameplay
}
}
game::mp::gentity_s* weapon_rocket_launcher_fire_stub(game::mp::gentity_s* ent, game::Weapon weapon, float spread, game::weaponParms* wp,
game::mp::gentity_t* weapon_rocket_launcher_fire_stub(game::mp::gentity_t* ent, game::Weapon weapon, float spread, game::weaponParms* wp,
const float* gun_vel, game::mp::missileFireParms* fire_parms, bool magic_bullet)
{
auto* result = utils::hook::invoke<game::mp::gentity_s*>(0x1403DB8A0, ent, weapon, spread, wp, gun_vel, fire_parms, magic_bullet);
auto* result = utils::hook::invoke<game::mp::gentity_t*>(0x1403DB8A0, ent, weapon, spread, wp, gun_vel, fire_parms, magic_bullet);
if (ent->client != nullptr && wp->weapDef->inventoryType != game::WEAPINVENTORY_EXCLUSIVE)
{

View File

@ -20,7 +20,7 @@ namespace network
return callbacks;
}
bool handle_command(game::netadr_s* address, const char* command, game::msg_t* message)
bool handle_command(game::netadr_t* address, const char* command, game::msg_t* message)
{
const auto cmd_string = utils::string::to_lower(command);
auto& callbacks = get_callbacks();
@ -61,7 +61,7 @@ namespace network
a.jmp(0x1402C64EE);
}
int net_compare_base_address(const game::netadr_s* a1, const game::netadr_s* a2)
int net_compare_base_address(const game::netadr_t* a1, const game::netadr_t* a2)
{
if (a1->type == a2->type)
{
@ -83,12 +83,12 @@ namespace network
return false;
}
int net_compare_address(const game::netadr_s* a1, const game::netadr_s* a2)
int net_compare_address(const game::netadr_t* a1, const game::netadr_t* a2)
{
return net_compare_base_address(a1, a2) && a1->port == a2->port;
}
void reconnect_migrated_client(game::mp::client_t*, game::netadr_s* from, const int, const int, const char*, const char*, bool)
void reconnect_migrated_client(game::mp::client_t*, game::netadr_t* from, const int, const int, const char*, const char*, bool)
{
// This happens when a client tries to rejoin after being recently disconnected, OR by a duplicated guid
// We don't want this to do anything. It decides to crash seemingly randomly
@ -107,14 +107,14 @@ namespace network
get_callbacks()[utils::string::to_lower(command)] = callback;
}
int dw_send_to_stub(const int size, const char* src, game::netadr_s* addr)
int dw_send_to_stub(const int size, const char* src, game::netadr_t* addr)
{
sockaddr s = {};
game::NetadrToSockadr(addr, &s);
return sendto(*game::query_socket, src, size, 0, &s, 16) >= 0;
}
void send(const game::netadr_s& address, const std::string& command, const std::string& data, const char separator)
void send(const game::netadr_t& address, const std::string& command, const std::string& data, const char separator)
{
std::string packet = "\xFF\xFF\xFF\xFF";
packet.append(command);
@ -124,7 +124,7 @@ namespace network
send_data(address, packet);
}
void send_data(const game::netadr_s& address, const std::string& data)
void send_data(const game::netadr_t& address, const std::string& data)
{
if (address.type == game::NA_LOOPBACK)
{
@ -136,12 +136,12 @@ namespace network
}
}
bool are_addresses_equal(const game::netadr_s& a, const game::netadr_s& b)
bool are_addresses_equal(const game::netadr_t& a, const game::netadr_t& b)
{
return net_compare_address(&a, &b);
}
const char* net_adr_to_string(const game::netadr_s& a)
const char* net_adr_to_string(const game::netadr_t& a)
{
if (a.type == game::NA_LOOPBACK)
{
@ -286,7 +286,7 @@ namespace network
if (!game::environment::is_dedi())
{
// we need this on the client for RCon
on("print", [](const game::netadr_s& address, const std::string& message)
on("print", [](const game::netadr_t& address, const std::string& message)
{
if (address != party::get_target())
{

View File

@ -2,23 +2,23 @@
namespace network
{
using callback = std::function<void(const game::netadr_s&, const std::string&)>;
using callback = std::function<void(const game::netadr_t&, const std::string&)>;
void on(const std::string& command, const callback& callback);
void send(const game::netadr_s& address, const std::string& command, const std::string& data = {}, char separator = ' ');
void send_data(const game::netadr_s& address, const std::string& data);
void send(const game::netadr_t& address, const std::string& command, const std::string& data = {}, char separator = ' ');
void send_data(const game::netadr_t& address, const std::string& data);
bool are_addresses_equal(const game::netadr_s& a, const game::netadr_s& b);
bool are_addresses_equal(const game::netadr_t& a, const game::netadr_t& b);
const char* net_adr_to_string(const game::netadr_s& a);
const char* net_adr_to_string(const game::netadr_t& a);
}
inline bool operator==(const game::netadr_s& a, const game::netadr_s& b)
inline bool operator==(const game::netadr_t& a, const game::netadr_t& b)
{
return network::are_addresses_equal(a, b); //
}
inline bool operator!=(const game::netadr_s& a, const game::netadr_s& b)
inline bool operator!=(const game::netadr_t& a, const game::netadr_t& b)
{
return !(a == b); //
}
@ -26,20 +26,20 @@ inline bool operator!=(const game::netadr_s& a, const game::netadr_s& b)
namespace std
{
template <>
struct equal_to<game::netadr_s>
struct equal_to<game::netadr_t>
{
using result_type = bool;
bool operator()(const game::netadr_s& lhs, const game::netadr_s& rhs) const
bool operator()(const game::netadr_t& lhs, const game::netadr_t& rhs) const
{
return network::are_addresses_equal(lhs, rhs);
}
};
template <>
struct hash<game::netadr_s>
struct hash<game::netadr_t>
{
size_t operator()(const game::netadr_s& x) const noexcept
size_t operator()(const game::netadr_t& x) const noexcept
{
return hash<uint32_t>()(*reinterpret_cast<const uint32_t*>(&x.ip[0])) ^ hash<uint16_t>()(x.port);
}

View File

@ -26,7 +26,7 @@ namespace party
{
struct
{
game::netadr_s host{};
game::netadr_t host{};
std::string challenge{};
bool hostDefined{false};
} connect_state;
@ -37,7 +37,7 @@ namespace party
int sv_maxclients;
void connect_to_party(const game::netadr_s& target, const std::string& mapname, const std::string& gametype)
void connect_to_party(const game::netadr_t& target, const std::string& mapname, const std::string& gametype)
{
if (game::environment::is_sp())
{
@ -58,7 +58,7 @@ namespace party
// CL_ConnectFromParty
char session_info[0x100] = {};
reinterpret_cast<void(*)(int, char*, const game::netadr_s*, const char*, const char*)>(0x1402C5700)(
reinterpret_cast<void(*)(int, char*, const game::netadr_t*, const char*, const char*)>(0x1402C5700)(
0, session_info, &target, mapname.data(), gametype.data());
}
@ -146,7 +146,7 @@ namespace party
return count;
}
game::netadr_s& get_target()
game::netadr_t& get_target()
{
return connect_state.host;
}
@ -175,7 +175,7 @@ namespace party
return -1;
}
void connect(const game::netadr_s& target)
void connect(const game::netadr_t& target)
{
if (game::environment::is_sp())
{
@ -252,7 +252,7 @@ namespace party
return;
}
game::netadr_s target{};
game::netadr_t target{};
if (game::NET_StringToAdr(params[1], &target))
{
connect(target);
@ -405,7 +405,7 @@ namespace party
console::info("%s\n", message.data());
});
network::on("getInfo", [](const game::netadr_s& target, const std::string& data)
network::on("getInfo", [](const game::netadr_t& target, const std::string& data)
{
utils::info_string info;
info.set("challenge", data);
@ -430,7 +430,7 @@ namespace party
return;
}
network::on("infoResponse", [](const game::netadr_s& target, const std::string& data)
network::on("infoResponse", [](const game::netadr_t& target, const std::string& data)
{
const utils::info_string info(data);
server_list::handle_info_response(target, info);

View File

@ -7,7 +7,7 @@ namespace party
void reset_connect_state();
void connect(const game::netadr_s& target);
void connect(const game::netadr_t& target);
void map_restart();
[[nodiscard]] int server_client_count();
@ -15,5 +15,5 @@ namespace party
[[nodiscard]] int get_client_count();
[[nodiscard]] int get_bot_count();
[[nodiscard]] game::netadr_s& get_target();
[[nodiscard]] game::netadr_t& get_target();
}

View File

@ -150,7 +150,7 @@ namespace patches
return 0;
}
game::Font_s* get_chat_font_handle()
game::Font_t* get_chat_font_handle()
{
return game::R_RegisterFont("fonts/bigFont");
}
@ -187,7 +187,7 @@ namespace patches
}
utils::hook::detour cmd_lui_notify_server_hook;
void cmd_lui_notify_server_stub(game::mp::gentity_s* ent)
void cmd_lui_notify_server_stub(game::mp::gentity_t* ent)
{
command::params_sv params{};
const auto menu_id = atoi(params.get(1));

View File

@ -14,11 +14,11 @@ namespace rcon
namespace
{
bool is_redirecting_ = false;
game::netadr_s redirect_target_ = {};
game::netadr_t redirect_target_ = {};
std::string redirect_buffer = {};
std::recursive_mutex redirect_lock;
void setup_redirect(const game::netadr_s& target)
void setup_redirect(const game::netadr_t& target)
{
std::lock_guard<std::recursive_mutex> $(redirect_lock);
@ -92,7 +92,7 @@ namespace rcon
if (*reinterpret_cast<std::int32_t*>(0x1419E1AE0) >= 5) //clientUIActive.connectionState >= CA_CONNECTED
{
const auto target = *reinterpret_cast<game::netadr_s*>(0x141CB535C);
const auto target = *reinterpret_cast<game::netadr_t*>(0x141CB535C);
const auto buffer = password + " " + data;
network::send(target, "rcon", buffer);
}
@ -170,7 +170,7 @@ namespace rcon
}
else
{
network::on("rcon", [](const game::netadr_s& addr, const std::string& data)
network::on("rcon", [](const game::netadr_t& addr, const std::string& data)
{
const auto pos = data.find_first_of(" ");
if (pos == std::string::npos)

View File

@ -33,14 +33,14 @@ namespace server_list
std::string map_name;
std::string game_type;
char in_game;
game::netadr_s address;
game::netadr_t address;
};
struct
{
game::netadr_s address{};
game::netadr_t address{};
volatile bool requesting = false;
std::unordered_map<game::netadr_s, int> queued_servers{};
std::unordered_map<game::netadr_t, int> queued_servers{};
} master_state;
volatile bool update_server_list = false;
@ -307,12 +307,12 @@ namespace server_list
}
}
bool get_master_server(game::netadr_s& address)
bool get_master_server(game::netadr_t& address)
{
return game::NET_StringToAdr("server.alterware.dev:20810", &address);
}
void handle_info_response(const game::netadr_s& address, const utils::info_string& info)
void handle_info_response(const game::netadr_t& address, const utils::info_string& info)
{
int start_time{};
const auto now = game::Sys_Milliseconds();
@ -436,7 +436,7 @@ namespace server_list
scheduler::loop(do_frame_work, scheduler::pipeline::main);
network::on("getServersResponse", [](const game::netadr_s& target, const std::string& data)
network::on("getServersResponse", [](const game::netadr_t& target, const std::string& data)
{
{
std::lock_guard<std::mutex> _(mutex);
@ -469,7 +469,7 @@ namespace server_list
break;
}
game::netadr_s address{};
game::netadr_t address{};
address.type = game::NA_IP;
address.localNetID = game::NS_CLIENT1;
std::memcpy(&address.ip[0], data.data() + i + 0, 4);

View File

@ -3,8 +3,8 @@
namespace server_list
{
bool get_master_server(game::netadr_s& address);
void handle_info_response(const game::netadr_s& address, const utils::info_string& info);
bool get_master_server(game::netadr_t& address);
void handle_info_response(const game::netadr_t& address, const utils::info_string& info);
bool sl_key_event(int key, int down);
}