]> granicus.if.org Git - nethack/commitdiff
Show stinking cloud valid positions
authorPasi Kallinen <paxed@alt.org>
Sun, 5 Apr 2015 10:47:59 +0000 (13:47 +0300)
committerPasi Kallinen <paxed@alt.org>
Sun, 5 Apr 2015 10:51:30 +0000 (13:51 +0300)
doc/fixes35.0
src/display.c
src/read.c

index 5fa64755d3e0a6142d61aac54483a7007529507e..4e81689eeda5e6cfcb2c97e32e90715b4b3c6e08 100644 (file)
@@ -887,13 +887,13 @@ show object symbols in menu headings in menus where those object symbols
        act as menu accelerators, toggleable via "menu_objsyms" option
 show t-shirt text at end of game inventory disclose
 hitting with a polearm remembers the position of the last monster you hit
-allow showing legal polearm positions when asked for location to hit
 add messages for trying to pick up some terrain features
 boomerang makes noise when hitting a sink
 non-pet rust monsters would eat rust-proofed non-digestibles but ignore
        those non-digestibles otherwise
 kicking a grave may topple the gravestone
-allow showing legal jumping positions when asked for location to jump to
+allow showing legal positions for stinking cloud, jumping and polearms
+       when asked for a location
 
 
 Platform- and/or Interface-Specific Fixes
index 87658aefaaf61b89dc1ae160991b21469f5ae626..da5c194e75d4d5581b99d421d3ef3ba9ff578602 100644 (file)
@@ -829,8 +829,10 @@ shieldeff(x,y)
  * DISP_ALWAYS- Like DISP_FLASH, but vision is not taken into account.
  */
 
+#define TMP_AT_MAX_GLYPHS (COLNO*2)
+
 static struct tmp_glyph {
-    coord saved[COLNO];        /* previously updated positions */
+    coord saved[TMP_AT_MAX_GLYPHS];    /* previously updated positions */
     int sidx;          /* index of next unused slot in saved[] */
     int style;         /* either DISP_BEAM or DISP_FLASH or DISP_ALWAYS */
     int glyph;         /* glyph to use when printing */
@@ -900,7 +902,7 @@ tmp_at(x, y)
        default:        /* do it */
            if (tglyph->style == DISP_BEAM || tglyph->style == DISP_ALL) {
                if (tglyph->style != DISP_ALL && !cansee(x,y)) break;
-               if (tglyph->sidx >= COLNO) break; /* too many locations */
+               if (tglyph->sidx >= TMP_AT_MAX_GLYPHS) break; /* too many locations */
                /* save pos for later erasing */
                tglyph->saved[tglyph->sidx].x = x;
                tglyph->saved[tglyph->sidx].y = y;
index 7d35620bc94af7d21484935590a9b8b460f9c133..d20c2560609231345fe6a1156955cd128fe48582 100644 (file)
@@ -868,6 +868,39 @@ struct obj *sobj;
        return 0;
 }
 
+boolean
+is_valid_stinking_cloud_pos(x,y, showmsg)
+int x,y;
+boolean showmsg;
+{
+    if (!cansee(x, y) || !ACCESSIBLE(levl[x][y].typ) || distu(x, y) >= 32) {
+       if (showmsg) You("smell rotten eggs.");
+       return FALSE;
+    }
+    return TRUE;
+}
+
+void
+display_stinking_cloud_positions(state)
+     int state;
+{
+    if (state == 0) {
+       tmp_at(DISP_BEAM, cmap_to_glyph(S_flashbeam));
+    } else if (state == 1) {
+       int x,y, dx, dy;
+       int dist = 6;
+       for (dx = -dist; dx <= dist; dx++)
+           for (dy = -dist; dy <= dist; dy++) {
+               x = u.ux + dx;
+               y = u.uy + dy;
+               if (isok(x,y) && is_valid_stinking_cloud_pos(x,y, FALSE))
+                   tmp_at(x,y);
+           }
+    } else {
+       tmp_at(DISP_END, 0);
+    }
+}
+
 /* scroll effects; return 1 if we use up the scroll and possibly make it
    become discovered, 0 if caller should take care of those side-effects */
 int
@@ -1613,14 +1646,13 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
                      already_known ? "stinking " : "");
                cc.x = u.ux;
                cc.y = u.uy;
+               getpos_sethilite(display_stinking_cloud_positions);
                if (getpos(&cc, TRUE, "the desired position") < 0) {
                    pline1(Never_mind);
                    break;
                }
-               if (!cansee(cc.x, cc.y) || distu(cc.x, cc.y) >= 32) {
-                   You("smell rotten eggs.");
+               if (!is_valid_stinking_cloud_pos(cc.x, cc.y, TRUE))
                    break;
-               }
                (void) create_gas_cloud(cc.x, cc.y, 3+bcsign(sobj),
                                                8+4*bcsign(sobj));
                break;