]> git.pond.sub.org Git - empserver/commitdiff
(explore_map, nav_map, move_map, fly_map): Don't use snxtsct(), it
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 27 Mar 2006 18:20:25 +0000 (18:20 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Mon, 27 Mar 2006 18:20:25 +0000 (18:20 +0000)
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
src/lib/commands/navi.c
src/lib/subs/move.c

index 7127186f00a9d60ddd98a2be2528a0238b66ee79..a2cab884d75ef5903832ce5af26ab0fc737bc7ed 100644 (file)
@@ -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, &sect)) {
+       /* Nasty: this relies on the iteration order */
        view[i] = dchr[sect.sct_type].d_mnem;
        switch (sect.sct_type) {
        case SCT_WATER:
index 154efaab411ff3c5b3f15b480ffabee67ceb0133..7a14c9563e03a4aa87ec052c41680a5934b2a34f 100644 (file)
@@ -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, &sect)) {
        ptr = &wmap[ns.dy][ns.dx];
        *ptr = dchr[sect.sct_type].d_mnem;
index 833199db3cc68ae632dc3ae590e8498520d20e3e..e2fe6cf1751293a4eebc971b228fe1b288bb77fe 100644 (file)
@@ -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, &sect)) {
+       /* 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, &sect)) {
+       /* Nasty: this relies on the iteration order */
        if (!(view[i] = player->bmap[sctoff(ns.x, ns.y)]))
            view[i] = ' ';
        i++;