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 ++++++++++++++++++++++++++++++++++++++++++++------ src/net_sdl.c | 5 +++-- 2 files changed, 47 insertions(+), 8 deletions(-) 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; } diff --git a/src/net_sdl.c b/src/net_sdl.c index 4ccc6067..820c9ca9 100644 --- a/src/net_sdl.c +++ b/src/net_sdl.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: net_sdl.c 543 2006-05-29 20:04:08Z fraggle $ +// $Id: net_sdl.c 611 2006-09-17 18:01:16Z fraggle $ // // Copyright(C) 2005 Simon Howard // @@ -221,7 +221,8 @@ static void NET_SDL_SendPacket(net_addr_t *addr, net_packet_t *packet) if (addr == &net_broadcast_addr) { - SDLNet_ResolveHost(&ip, NULL, DEFAULT_PORT); + SDLNet_ResolveHost(&ip, NULL, port); + ip.host = INADDR_BROADCAST; } else { -- cgit v1.2.3