From 2ff3fe97a2047b6749af1ec427610126094802c7 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 27 Mar 2006 18:45:20 +0000 Subject: [PATCH] (unit_map): Don't use snxtsct(), it obeys conditionals. Use 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 | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/lib/common/maps.c b/src/lib/common/maps.c index b0fe28c38..4dd5a6356 100644 --- a/src/lib/common/maps.c +++ b/src/lib/common/maps.c @@ -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; } -- 2.43.0