From d55b9cff9d9bd196400d7eb7d563210ca588024c Mon Sep 17 00:00:00 2001 From: Rubidium Date: Sat, 1 Feb 2025 09:46:29 +0100 Subject: [PATCH] Codechange: strongly type ClientPoolID Also remove some of the artifical documented limits as they are not true; the ClientPoolID was not sent over the network, so its size isn't of concern. --- src/network/network_base.h | 2 +- src/network/network_server.cpp | 6 ++---- src/network/network_server.h | 2 +- src/network/network_type.h | 9 +-------- 4 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/network/network_base.h b/src/network/network_base.h index c5ba8cf68f..ce3768237b 100644 --- a/src/network/network_base.h +++ b/src/network/network_base.h @@ -17,7 +17,7 @@ #include "../timer/timer_game_economy.h" /** Type for the pool with client information. */ -using NetworkClientInfoPool = Pool; +using NetworkClientInfoPool = Pool; extern NetworkClientInfoPool _networkclientinfo_pool; /** Container for all information known about a client. */ diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index 446a0e13e9..22a5aa5034 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -47,9 +47,7 @@ DECLARE_INCREMENT_DECREMENT_OPERATORS(ClientID) static ClientID _network_client_id = CLIENT_ID_FIRST; /** Make very sure the preconditions given in network_type.h are actually followed */ -static_assert(MAX_CLIENT_SLOTS > MAX_CLIENTS); -/** Yes... */ -static_assert(NetworkClientSocketPool::MAX_SIZE == MAX_CLIENT_SLOTS); +static_assert(NetworkClientSocketPool::MAX_SIZE > MAX_CLIENTS); /** The pool with clients. */ NetworkClientSocketPool _networkclientsocket_pool("NetworkClientSocket"); @@ -920,7 +918,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_IDENTIFY(Packet ci->client_name = client_name; ci->client_playas = playas; ci->public_key = this->peer_public_key; - Debug(desync, 1, "client: {:08x}; {:02x}; {:02x}; {:02x}", TimerGameEconomy::date, TimerGameEconomy::date_fract, (int)ci->client_playas, (int)ci->index); + Debug(desync, 1, "client: {:08x}; {:02x}; {:02x}; {:02x}", TimerGameEconomy::date, TimerGameEconomy::date_fract, (int)ci->client_playas, ci->index); /* Make sure companies to which people try to join are not autocleaned */ Company *c = Company::GetIfValid(playas); diff --git a/src/network/network_server.h b/src/network/network_server.h index 91ccb3c27f..13226fc775 100644 --- a/src/network/network_server.h +++ b/src/network/network_server.h @@ -17,7 +17,7 @@ class ServerNetworkGameSocketHandler; /** Make the code look slightly nicer/simpler. */ typedef ServerNetworkGameSocketHandler NetworkClientSocket; /** Pool with all client sockets. */ -using NetworkClientSocketPool = Pool; +using NetworkClientSocketPool = Pool; extern NetworkClientSocketPool _networkclientsocket_pool; /** Class for handling the server side of the game connection. */ diff --git a/src/network/network_type.h b/src/network/network_type.h index 2b7fd96501..23fbdd7195 100644 --- a/src/network/network_type.h +++ b/src/network/network_type.h @@ -16,13 +16,6 @@ /** How many clients can we have */ static const uint MAX_CLIENTS = 255; -/** - * The number of slots; must be at least 1 more than MAX_CLIENTS. It must - * furthermore be less than or equal to 256 as client indices (sent over - * the network) are 8 bits. It needs 1 more for the dedicated server. - */ -static const uint MAX_CLIENT_SLOTS = 256; - /** * Vehicletypes in the order they are send in info packets. */ @@ -54,7 +47,7 @@ enum ClientID : uint32_t { }; /** Indices into the client related pools */ -typedef uint8_t ClientPoolID; +using ClientPoolID = PoolID; /** Indices into the admin tables. */ using AdminID = PoolID;