mirror of https://github.com/OpenTTD/OpenTTD
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.pull/13512/head
parent
47721edb1d
commit
d55b9cff9d
|
@ -17,7 +17,7 @@
|
|||
#include "../timer/timer_game_economy.h"
|
||||
|
||||
/** Type for the pool with client information. */
|
||||
using NetworkClientInfoPool = Pool<NetworkClientInfo, ClientPoolID, 8, MAX_CLIENT_SLOTS, PoolType::NetworkClient>;
|
||||
using NetworkClientInfoPool = Pool<NetworkClientInfo, ClientPoolID, 8, ClientPoolID::End().base(), PoolType::NetworkClient>;
|
||||
extern NetworkClientInfoPool _networkclientinfo_pool;
|
||||
|
||||
/** Container for all information known about a client. */
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -17,7 +17,7 @@ class ServerNetworkGameSocketHandler;
|
|||
/** Make the code look slightly nicer/simpler. */
|
||||
typedef ServerNetworkGameSocketHandler NetworkClientSocket;
|
||||
/** Pool with all client sockets. */
|
||||
using NetworkClientSocketPool = Pool<NetworkClientSocket, ClientPoolID, 8, MAX_CLIENT_SLOTS, PoolType::NetworkClient>;
|
||||
using NetworkClientSocketPool = Pool<NetworkClientSocket, ClientPoolID, 8, ClientPoolID::End().base(), PoolType::NetworkClient>;
|
||||
extern NetworkClientSocketPool _networkclientsocket_pool;
|
||||
|
||||
/** Class for handling the server side of the game connection. */
|
||||
|
|
|
@ -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<uint16_t, struct ClientPoolIDTag, MAX_CLIENTS + 1 /* dedicated server. */, 0xFFFF>;
|
||||
|
||||
/** Indices into the admin tables. */
|
||||
using AdminID = PoolID<uint8_t, struct AdminIDTag, 16, 0xFF>;
|
||||
|
|
Loading…
Reference in New Issue