(svn r20923) -Codechange: prepare creating sub-classes of NetworkClientSocket for server and client side

This commit is contained in:
rubidium
2010-10-15 13:22:00 +00:00
parent 951b725b8c
commit 8eb07d097e
7 changed files with 73 additions and 42 deletions

View File

@@ -43,8 +43,6 @@
bool _ddc_fastforward = true;
#endif /* DEBUG_DUMP_COMMANDS */
DECLARE_POSTFIX_INCREMENT(ClientID)
assert_compile(NetworkClientInfoPool::MAX_SIZE == NetworkClientSocketPool::MAX_SIZE);
NetworkClientInfoPool _networkclientinfo_pool("NetworkClientInfo");
@@ -94,8 +92,6 @@ static SocketList _listensockets;
/* The amount of clients connected */
static byte _network_clients_connected = 0;
/* The identifier counter for new clients (is never decreased) */
static ClientID _network_client_id = CLIENT_ID_FIRST;
/* Some externs / forwards */
extern void StateGameLoop();
@@ -483,31 +479,19 @@ void ParseConnectionString(const char **company, const char **port, char *connec
* Used both by the server and the client */
static NetworkClientSocket *NetworkAllocClient(SOCKET s)
{
if (_network_server) {
/* Can we handle a new client? */
if (_network_clients_connected >= MAX_CLIENTS) return NULL;
if (_network_game_info.clients_on >= _settings_client.network.max_clients) return NULL;
/* Register the login */
_network_clients_connected++;
if (!_network_server) {
return new ClientNetworkGameSocketHandler(s);
}
NetworkClientSocket *cs = new NetworkClientSocket(INVALID_CLIENT_ID);
cs->sock = s;
cs->last_frame = _frame_counter;
cs->last_frame_server = _frame_counter;
/* Can we handle a new client? */
if (_network_clients_connected >= MAX_CLIENTS) return NULL;
if (_network_game_info.clients_on >= _settings_client.network.max_clients) return NULL;
if (_network_server) {
cs->client_id = _network_client_id++;
NetworkClientInfo *ci = new NetworkClientInfo(cs->client_id);
cs->SetInfo(ci);
ci->client_playas = COMPANY_INACTIVE_CLIENT;
ci->join_date = _date;
/* Register the login */
_network_clients_connected++;
SetWindowDirty(WC_CLIENT_LIST, 0);
}
return cs;
SetWindowDirty(WC_CLIENT_LIST, 0);
return new ServerNetworkGameSocketHandler(s);
}
/* Close a connection */