]> git.pond.sub.org Git - empserver/commitdiff
(snxtsct): Iteration order for `*' disclosed the real origin. Fix.
authorMarkus Armbruster <armbru@pond.sub.org>
Thu, 20 Apr 2006 19:06:50 +0000 (19:06 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Thu, 20 Apr 2006 19:06:50 +0000 (19:06 +0000)
Mapping commands used to work around this bug, until map.c rev. 1.18,
rout.c 1.18, sct.c 1.17, surv.c 1.18 removed the work-around and thus
exposed the bug.

src/lib/subs/snxtsct.c

index 5a0f412856bec4607f42f148b17da5f4d41c04bb..75dbedb14638299592d03879aff224429432252f 100644 (file)
  * can select on either NS_ALL, NS_AREA, or NS_RANGE
  * iterate thru the "condarg" string looking
  * for arguments to compile into the nstr.
+ * Using this function for anything but command arguments is usually
+ * incorrect, because it respects conditionals.  Use the snxtsct_FOO()
+ * instead.
  */
 int
-snxtsct(struct nstr_sect *np, s_char *str)
+snxtsct(struct nstr_sect *np, char *str)
 {
     struct range range;
+    struct natstr *natp;
     coord cx, cy;
     int dist, n;
-    s_char buf[1024];
-    struct range wr;
+    char buf[1024];
 
     if (str == 0 || *str == 0) {
        if ((str = getstring("(sects)? ", buf)) == 0)
            return 0;
     }
-    wr.lx = -WORLD_X / 2;
-    wr.ly = -WORLD_Y / 2;
-    wr.hx = WORLD_X / 2;
-    wr.hy = WORLD_Y / 2;
-    wr.width = wr.height = 0;
     switch (sarg_type(str)) {
     case NS_AREA:
        if (!sarg_area(str, &range))
@@ -77,8 +75,17 @@ snxtsct(struct nstr_sect *np, s_char *str)
        snxtsct_dist(np, cx, cy, dist);
        break;
     case NS_ALL:
-       /* fake "all" by doing a world-sized area query */
-       snxtsct_area(np, &wr);
+       /*
+        * Can't use snxtsct_all(), as it would disclose the real
+        * origin.  Use a world-sized area instead.
+        */
+       natp = getnatp(player->cnum);
+       range.lx = xabs(natp, -WORLD_X / 2);
+       range.ly = yabs(natp, -WORLD_Y / 2);
+       range.hx = xabs(natp, WORLD_X / 2);
+       range.hy = yabs(natp, WORLD_Y / 2);
+       range.width = range.height = 0;
+       snxtsct_area(np, &range);
        break;
     default:
        return 0;