shithub: choc

Download patch

ref: 22a8e37dbede0d879f15252830b93234a7483fb3
parent: df292a6dce27e7b20faa0c829aa0c58a3693f979
author: Simon Howard <[email protected]>
date: Sat Sep 17 09:44:58 EDT 2011

Fix ping calculation with LAN search.

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 2378

--- a/src/net_query.c
+++ b/src/net_query.c
@@ -242,10 +242,35 @@
         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)
     {