From 6727d54e95153c083acbba5ab77f1f9bce92b331 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Tue, 7 Dec 2010 22:35:17 +0000 Subject: Assign the oldest client to be the controller, not the first found in the clients[] array. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2201 --- src/net_server.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/net_server.c b/src/net_server.c index 43584170..4307e2e2 100644 --- a/src/net_server.c +++ b/src/net_server.c @@ -69,6 +69,11 @@ typedef struct int last_send_time; char *name; + // Time that this client connected to the server. + // This is used to determine the controller (oldest client). + + unsigned int connect_time; + // Last time new gamedata was received from this client int last_gamedata_time; @@ -381,19 +386,29 @@ static void NET_SV_AdvanceWindow(void) static net_client_t *NET_SV_Controller(void) { + net_client_t *best; int i; - // first client in the list is the controller + // Find the oldest client (first to connect). + + best = NULL; for (i=0; iconnect_time) + { + best = &clients[i]; } } - return NULL; + return best; } // Given an address, find the corresponding client @@ -433,6 +448,7 @@ static void NET_SV_InitNewClient(net_client_t *client, char *player_name) { client->active = true; + client->connect_time = I_GetTimeMS(); NET_Conn_InitServer(&client->connection, addr); client->addr = addr; client->last_send_time = -1; -- cgit v1.2.3