]> git.pond.sub.org Git - empserver/commitdiff
(unit_map): Don't use snxtsct(), it obeys conditionals. Use
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 27 Mar 2006 18:45:20 +0000 (18:45 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Mon, 27 Mar 2006 18:45:20 +0000 (18:45 +0000)
snxtsct_area().  Callers march() and navi() clearly don't want it to
use conditionals.  navi() used to zap them (just removed).  march()
doesn't, which was a bug similar to #785447.  It's less clear for
caller map().  I'd argue that conditionals apply to map's argument,
the unit number, not to the map itself.  draw_map() zaps them anyway.

src/lib/common/maps.c

index b0fe28c38fb163a07797aacd7adacca84a7a25a0..4dd5a6356a8f58944049798968d8e133cf1b70ba 100644 (file)
@@ -307,35 +307,32 @@ unit_map(int unit_type, int uid, struct nstr_sect *nsp, s_char *originp)
     struct shpstr origs;
     struct lndstr origl;
     struct plnstr origp;
-    s_char what[64];
-    struct natstr *np;
+    struct genitem *gp;
+    struct range range;
 
-    np = getnatp(player->cnum);
     if (unit_type == EF_LAND) {
        if (!getland(uid, &origl) || !player->owner || origl.lnd_own == 0)
            return RET_FAIL;
-       sprintf(what, "%d:%d,%d:%d", xrel(np, origl.lnd_x - 10),
-               xrel(np, origl.lnd_x + 10),
-               yrel(np, origl.lnd_y - 5), yrel(np, origl.lnd_y + 5));
+       gp = (struct genitem *)&origl;
        *originp = *lchr[(int)origl.lnd_type].l_name;
     } else if (unit_type == EF_PLANE) {
        if (!getplane(uid, &origp) || !player->owner || origp.pln_own == 0)
            return RET_FAIL;
-       sprintf(what, "%d:%d,%d:%d", xrel(np, origp.pln_x - 10),
-               xrel(np, origp.pln_x + 10),
-               yrel(np, origp.pln_y - 5), yrel(np, origp.pln_y + 5));
+       gp = (struct genitem *)&origp;
        *originp = *plchr[(int)origp.pln_type].pl_name;
     } else {
        if (!getship(uid, &origs) || !player->owner || origs.shp_own == 0)
            return RET_FAIL;
-       sprintf(what, "%d:%d,%d:%d", xrel(np, origs.shp_x - 10),
-               xrel(np, origs.shp_x + 10),
-               yrel(np, origs.shp_y - 5), yrel(np, origs.shp_y + 5));
-       unit_type = EF_SHIP;
+       gp = (struct genitem *)&origs;
        *originp = *mchr[(int)origs.shp_type].m_name;
     }
-    if (!snxtsct(nsp, what))
-       return RET_FAIL;
+
+    range.lx = xnorm(gp->x - 10);
+    range.hx = xnorm(gp->x + 11);
+    range.ly = ynorm(gp->y - 5);
+    range.hy = ynorm(gp->y + 6);
+    xysize_range(&range);
+    snxtsct_area(nsp, &range);
     return RET_OK;
 }