From 707e1aad72790957b1d8a09a608a28d76f3f0090 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 27 Mar 2006 18:20:25 +0000 Subject: [PATCH] (explore_map, nav_map, move_map, fly_map): Don't use snxtsct(), it obeys conditionals. Use snxtsct_dist(). Closes #785447. Only march and test were actually broken, the other uses zapped conditionals. (move_map, fly_map, nav_map, navi): Don't zap conditionals. --- src/lib/commands/expl.c | 14 +++----------- src/lib/commands/navi.c | 21 +++++++-------------- src/lib/subs/move.c | 39 ++++++--------------------------------- 3 files changed, 16 insertions(+), 58 deletions(-) diff --git a/src/lib/commands/expl.c b/src/lib/commands/expl.c index 7127186f0..a2cab884d 100644 --- a/src/lib/commands/expl.c +++ b/src/lib/commands/expl.c @@ -280,23 +280,15 @@ static int explore_map(s_char *what, coord curx, coord cury, s_char *arg) { struct nstr_sect ns; - struct natstr *np; struct sctstr sect; - coord rel_x, rel_y; - s_char range[128]; - s_char view[7]; + char view[7]; int i; int changed = 0; - np = getnatp(player->cnum); - rel_x = xrel(np, curx); - rel_y = yrel(np, cury); - sprintf(range, "%d:%d,%d:%d", rel_x - 2, rel_x + 2, rel_y - 1, - rel_y + 1); - if (!snxtsct(&ns, range)) - return RET_FAIL; + snxtsct_dist(&ns, curx, cury, 1); i = 0; while (i < 7 && nxtsct(&ns, §)) { + /* Nasty: this relies on the iteration order */ view[i] = dchr[sect.sct_type].d_mnem; switch (sect.sct_type) { case SCT_WATER: diff --git a/src/lib/commands/navi.c b/src/lib/commands/navi.c index 154efaab4..7a14c9563 100644 --- a/src/lib/commands/navi.c +++ b/src/lib/commands/navi.c @@ -72,7 +72,6 @@ navi(void) return RET_SYN; shp_sel(&ni_ship, &ship_list); shp_nav(&ship_list, &minmob, &maxmob, &together, player->cnum); - player->condarg = 0; /* conditions don't apply to nav_map() */ if (QEMPTY(&ship_list)) { pr("No ships\n"); return RET_FAIL; @@ -216,7 +215,7 @@ navi(void) int nav_map(int x, int y, int show_designations) { - s_char *ptr; + char *ptr; struct nstr_sect ns; struct natstr *np; struct sctstr sect; @@ -225,20 +224,14 @@ nav_map(int x, int y, int show_designations) /* Note this is not re-entrant anyway, so we keep the buffers around */ static unsigned char *bitmap = NULL; - static s_char *wmapbuf = NULL; - static s_char **wmap = NULL; - s_char what[64]; + static char *wmapbuf = NULL; + static char **wmap = NULL; int changed = 0; - np = getnatp(player->cnum); - sprintf(what, "%d:%d,%d:%d", xrel(np, x - 2), xrel(np, x + 2), - yrel(np, y - 1), yrel(np, y + 1)); - if (!snxtsct(&ns, what)) - return RET_FAIL; if (!wmapbuf) wmapbuf = malloc(WORLD_Y * MAPWIDTH(1)); if (!wmap) { - wmap = malloc(WORLD_Y * sizeof(s_char *)); + wmap = malloc(WORLD_Y * sizeof(*wmap)); if (wmap && wmapbuf) { for (i = 0; i < WORLD_Y; i++) wmap[i] = &wmapbuf[MAPWIDTH(1) * i]; @@ -255,10 +248,10 @@ nav_map(int x, int y, int show_designations) return RET_FAIL; } memset(bitmap, 0, (WORLD_X * WORLD_Y) / 8); - /* zap any conditionals */ - ns.ncond = 0; + snxtsct_dist(&ns, x, y, 1); + np = getnatp(player->cnum); xyrelrange(np, &ns.range, &range); - blankfill((s_char *)wmapbuf, &ns.range, 1); + blankfill(wmapbuf, &ns.range, 1); while (nxtsct(&ns, §)) { ptr = &wmap[ns.dy][ns.dx]; *ptr = dchr[sect.sct_type].d_mnem; diff --git a/src/lib/subs/move.c b/src/lib/subs/move.c index 833199db3..e2fe6cf17 100644 --- a/src/lib/subs/move.c +++ b/src/lib/subs/move.c @@ -253,28 +253,15 @@ static int move_map(s_char *what, coord curx, coord cury, s_char *arg) { struct nstr_sect ns; - struct natstr *np; struct sctstr sect; - coord rel_x, rel_y; - s_char range[128]; - s_char view[7]; + char view[7]; int i; int changed = 0; - np = getnatp(player->cnum); - rel_x = xrel(np, curx); - rel_y = yrel(np, cury); - sprintf(range, "%d:%d,%d:%d", rel_x - 2, rel_x + 2, rel_y - 1, - rel_y + 1); - player->condarg = 0; - /* This is necessary, otherwise move_map would attempt to pay */ - /* attention to the conditional arguments left behind by such */ - /* a command as "tran p -1,-1 ?eff=100".. It'd then only see */ - /* 100% efficienct sects, and get all screwed up --ts */ - if (!snxtsct(&ns, range)) - return RET_FAIL; + snxtsct_dist(&ns, curx, cury, 1); i = 0; while (i < 7 && nxtsct(&ns, §)) { + /* Nasty: this relies on the iteration order */ view[i] = dchr[sect.sct_type].d_mnem; switch (sect.sct_type) { case SCT_WATER: @@ -310,28 +297,14 @@ int fly_map(coord curx, coord cury) { struct nstr_sect ns; - struct natstr *np; struct sctstr sect; - coord rel_x, rel_y; - s_char view[7]; + char view[7]; int i; - s_char range[128]; - - np = getnatp(player->cnum); - rel_x = xrel(np, curx); - rel_y = yrel(np, cury); - sprintf(range, "%d:%d,%d:%d", rel_x - 2, rel_x + 2, rel_y - 1, - rel_y + 1); - player->condarg = 0; - /* This is necessary, otherwise move_map would attempt to pay */ - /* attention to the conditional arguments left behind by such */ - /* a command as "tran p -1,-1 ?eff=100".. It'd then only see */ - /* 100% efficienct sects, and get all screwed up --ts */ - if (!snxtsct(&ns, range)) - return RET_FAIL; + snxtsct_dist(&ns, curx, cury, 1); i = 0; while (i < 7 && nxtsct(&ns, §)) { + /* Nasty: this relies on the iteration order */ if (!(view[i] = player->bmap[sctoff(ns.x, ns.y)])) view[i] = ' '; i++; -- 2.43.0