|
|
|
@ -155,6 +155,13 @@ ServerNetworkGameSocketHandler::ServerNetworkGameSocketHandler(SOCKET s) : Netwo
|
|
|
|
|
this->status = STATUS_INACTIVE;
|
|
|
|
|
this->client_id = _network_client_id++;
|
|
|
|
|
this->receive_limit = _settings_client.network.bytes_per_frame_burst;
|
|
|
|
|
|
|
|
|
|
/* The Socket and Info pools need to be the same in size. After all,
|
|
|
|
|
* each Socket will be associated with at most one Info object. As
|
|
|
|
|
* such if the Socket was allocated the Info object can as well. */
|
|
|
|
|
assert_compile(NetworkClientSocketPool::MAX_SIZE == NetworkClientInfoPool::MAX_SIZE);
|
|
|
|
|
assert(NetworkClientInfo::CanAllocateItem());
|
|
|
|
|
|
|
|
|
|
NetworkClientInfo *ci = new NetworkClientInfo(this->client_id);
|
|
|
|
|
this->SetInfo(ci);
|
|
|
|
|
ci->client_playas = COMPANY_INACTIVE_CLIENT;
|
|
|
|
@ -250,7 +257,13 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::CloseConnection(NetworkRecvSta
|
|
|
|
|
/* static */ bool ServerNetworkGameSocketHandler::AllowConnection()
|
|
|
|
|
{
|
|
|
|
|
extern byte _network_clients_connected;
|
|
|
|
|
return _network_clients_connected < MAX_CLIENTS && _network_game_info.clients_on < _settings_client.network.max_clients;
|
|
|
|
|
bool accept = _network_clients_connected < MAX_CLIENTS && _network_game_info.clients_on < _settings_client.network.max_clients;
|
|
|
|
|
|
|
|
|
|
/* We can't go over the MAX_CLIENTS limit here. However, the
|
|
|
|
|
* pool must have place for all clients and ourself. */
|
|
|
|
|
assert_compile(NetworkClientSocketPool::MAX_SIZE == MAX_CLIENTS + 1);
|
|
|
|
|
assert(ServerNetworkGameSocketHandler::CanAllocateItem());
|
|
|
|
|
return accept;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Send the packets for the server sockets. */
|
|
|
|
|