From 22a8e37dbede0d879f15252830b93234a7483fb3 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 17 Sep 2011 13:44:58 +0000 Subject: Fix ping calculation with LAN search. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2378 --- src/net_query.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/net_query.c b/src/net_query.c index 2797ea2e..24af1863 100644 --- a/src/net_query.c +++ b/src/net_query.c @@ -242,10 +242,35 @@ static void NET_Query_ParseResponse(net_addr_t *addr, net_packet_t *packet, return; } - // Find the target that responded, or potentially add a new target - // if it was not already known (for LAN broadcast search) + // Find the target that responded. - target = GetTargetForAddr(addr, true); + target = GetTargetForAddr(addr, false); + + // If the target is not found, it may be because we are doing + // a LAN broadcast search, in which case we need to create a + // target for the new responder. + + if (target == NULL) + { + query_target_t *broadcast_target; + + broadcast_target = GetTargetForAddr(NULL, false); + + // Not in broadcast mode, unexpected response that came out + // of nowhere. Ignore. + + if (broadcast_target == NULL + || broadcast_target->state != QUERY_TARGET_QUERIED) + { + return; + } + + // Create new target. + + target = GetTargetForAddr(addr, true); + target->state = QUERY_TARGET_QUERIED; + target->query_time = broadcast_target->query_time; + } if (target->state != QUERY_TARGET_RESPONDED) { -- cgit v1.2.3