From e48ea79eb19b130f2aa569401f57e460d6417091 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 17 Sep 2006 18:01:16 +0000 Subject: Fix local LAN queries. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 611 --- src/net_query.c | 50 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 6 deletions(-) (limited to 'src/net_query.c') diff --git a/src/net_query.c b/src/net_query.c index d4955061..07d947b5 100644 --- a/src/net_query.c +++ b/src/net_query.c @@ -37,10 +37,40 @@ #include "net_query.h" #include "net_sdl.h" -static net_addr_t *first_response_addr; static net_context_t *query_context; +static net_addr_t **responders; static int num_responses; +// Add a new address to the list of hosts that has responded + +static void NET_Query_AddResponder(net_addr_t *addr) +{ + responders = realloc(responders, + sizeof(net_addr_t *) * (num_responses + 1)); + responders[num_responses] = addr; + ++num_responses; +} + +// Returns true if the reply is from a host that has not previously +// responded. + +static boolean NET_Query_CheckResponder(net_addr_t *addr) +{ + int i; + + for (i=0; i 0) + return responders[0]; + else + return NULL; } void NET_Query_Init(void) @@ -207,7 +245,7 @@ void NET_Query_Init(void) NET_AddModule(query_context, &net_sdl_module); net_sdl_module.InitClient(); - first_response_addr = NULL; + responders = NULL; num_responses = 0; } -- cgit v1.2.3