From f14ea87e44977326cedb9bf22cd13d93d7591003 Mon Sep 17 00:00:00 2001 From: FutureRave Date: Sat, 13 May 2023 17:26:17 +0100 Subject: [PATCH] maint: clean client_t struct --- src/client/component/auth.cpp | 8 ++++---- src/client/game/structs.hpp | 12 +++++++++++- src/client/game/utils.cpp | 4 ++-- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/client/component/auth.cpp b/src/client/component/auth.cpp index 26c31a33..b52b9eb0 100644 --- a/src/client/component/auth.cpp +++ b/src/client/component/auth.cpp @@ -98,7 +98,7 @@ namespace auth { static const auto is_first = [] { - static utils::nt::handle<> mutex = CreateMutexA(nullptr, FALSE, "boiii_mutex"); + static utils::nt::handle mutex = CreateMutexA(nullptr, FALSE, "boiii_mutex"); return mutex && GetLastError() != ERROR_ALREADY_EXISTS; }(); @@ -134,9 +134,9 @@ namespace auth const auto& fragment_packet = packet_buffer.get_buffer(); - game::NET_OutOfBandData( - sock, adr, fragment_packet.data(), - static_cast(fragment_packet.size())); + game::NET_OutOfBandData(sock, adr, + fragment_packet.data(), + static_cast(fragment_packet.size())); }); } diff --git a/src/client/game/structs.hpp b/src/client/game/structs.hpp index bc861685..56aac009 100644 --- a/src/client/game/structs.hpp +++ b/src/client/game/structs.hpp @@ -1579,9 +1579,19 @@ namespace game SV_CMD_RELIABLE_0 = 0x1, }; + enum + { + CS_FREE = 0x0, + CS_ZOMBIE = 0x1, + CS_RECONNECTING = 0x2, + CS_CONNECTED = 0x3, + CS_CLIENTLOADING = 0x4, + CS_ACTIVE = 0x5, + }; + struct client_s { - int client_state; + int state; char __pad0[0x28]; netadr_t address; char __pad1[20468]; diff --git a/src/client/game/utils.cpp b/src/client/game/utils.cpp index 4f6fb99a..5ebe4131 100644 --- a/src/client/game/utils.cpp +++ b/src/client/game/utils.cpp @@ -205,7 +205,7 @@ namespace game } auto& client = client_states[index]; - if (client.client_state <= 0) + if (client.state == CS_FREE) { return false; } @@ -238,7 +238,7 @@ namespace game { foreach_client([&](client_s& client, const size_t index) { - if (client.client_state > 0) + if (client.state != CS_FREE) { callback(client, index); }