]> granicus.if.org Git - nethack/commitdiff
temporary? fix for github issue #730 - stairs \
authorPatR <rankin@nethack.org>
Thu, 14 Apr 2022 17:50:23 +0000 (10:50 -0700)
committerPatR <rankin@nethack.org>
Thu, 14 Apr 2022 17:50:23 +0000 (10:50 -0700)
placed on lava spot on Valkyrie goal level

Reported by k2, arriving at the final level of the Valkyrie quest
can issue a recently added impossible
| mkstairs: placing stairs up on molten lava at <68,13>
The report said it was easy to reproduce, but it took me multiple
tries (so not hard to do, but not a sure thing on any given attempt).

The stairs on that level are placed at specific coordinates that
are outside the pre-mapped area, so there's no guarantee that their
spot will be suitable for stairs.  The underlying terrian changes
from lava to stair, but only after the warning about molten lava.

This hack solves that particular level but is not a general solution
for this type of thing.  When about to make stairs on a lava spot,
change that spot to normal floor first.  Plus 50:50 chance to change
each adjacent lava spot to floor too so that there's decent chance
for some elbow room upon arrival.

Also, turn the no-flip attribute off for that level so that 'fixed'
location of the stairs can occur in four different places.

Fixes #730

dat/Val-goal.lua
doc/fixes3-7-0.txt
src/sp_lev.c

index 4971822cf80a6ed398affc58b1ad114f5b198b62..2753afaa37bd80e49799b6fb92abc2275315474f 100644 (file)
@@ -5,7 +5,7 @@
 --
 des.level_init({ style = "solidfill", fg = "L" });
 
-des.level_flags("mazelevel", "icedpools", "noflip")
+des.level_flags("mazelevel", "icedpools")
 
 des.level_init({ style="mines", fg=".", bg="L", smoothed=true, joined=true, lit=1, walled=false })
 
index a3ba2e1c8686f40011a4a88c12f00052e0fa98f6..cfa314fa156a93bf97d774cb65a70b4e291fc6c5 100644 (file)
@@ -1147,6 +1147,8 @@ sequencing confusion: picking an item when viewing inventory and picking an
        action to do with it caused the inventory command to use time, then
        on next turn the action was performed without taking any time
 program would access freed memory if charging caused a ring to explode
+arriving on Valkyrie quest final level could produce impossible warning
+       "mkstairs: placing stairs up on molten lava at <68,13>"
 
 curses: 'msg_window' option wasn't functional for curses unless the binary
        also included tty support
index fcaa021e4fc8b2e206f21b19cd8f49a2adc26f88..4b5d9b201945a4d99bc3ab6b57956af626a5f0a1 100644 (file)
@@ -96,8 +96,8 @@ static void sel_set_door(int, int, genericptr_t);
 static void sel_set_feature(int, int, genericptr_t);
 static void levregion_add(lev_region *);
 static void get_table_xy_or_coord(lua_State *, lua_Integer *, lua_Integer *);
-static int get_table_region(lua_State *, const char *, lua_Integer *, lua_Integer *, lua_Integer *,
-                            lua_Integer *, boolean);
+static int get_table_region(lua_State *, const char *, lua_Integer *,
+                        lua_Integer *, lua_Integer *, lua_Integer *, boolean);
 static void set_wallprop_in_selection(lua_State *, int);
 static xchar random_wdir(void);
 static int floodfillchk_match_under(int, int);
@@ -1085,7 +1085,10 @@ rndtrap(void)
  *      created underwater, or eels on dry land.
  */
 static void
-get_location(xchar *x, xchar *y, getloc_flags_t humidity, struct mkroom* croom)
+get_location(
+    xchar *x, xchar *y,
+    getloc_flags_t humidity,
+    struct mkroom *croom)
 {
     int cpt = 0;
     int mx, my, sx, sy;
@@ -1220,7 +1223,7 @@ void
 get_location_coord(
     xchar *x, xchar *y,
     int humidity,
-    struct mkroomcroom,
+    struct mkroom *croom,
     long crd)
 {
     unpacked_coord c;
@@ -1238,9 +1241,8 @@ get_location_coord(
  * Get a relative position inside a room.
  * negative values for x or y means RANDOM!
  */
-
 static void
-get_room_loc(xchar* x, xchar* y, struct mkroom* croom)
+get_room_loc(xchar *x, xchar *y, struct mkroom *croom)
 {
     coord c;
 
@@ -1265,7 +1267,10 @@ get_room_loc(xchar* x, xchar* y, struct mkroom* croom)
  * negative values for x or y means RANDOM!
  */
 static void
-get_free_room_loc(xchar* x, xchar* y, struct mkroom* croom, packed_coord pos)
+get_free_room_loc(
+    xchar *x, xchar *y,
+    struct mkroom *croom,
+    packed_coord pos)
 {
     xchar try_x, try_y;
     register int trycnt = 0;
@@ -1284,7 +1289,10 @@ get_free_room_loc(xchar* x, xchar* y, struct mkroom* croom, packed_coord pos)
 }
 
 boolean
-check_room(xchar* lowx, xchar* ddx, xchar* lowy, xchar* ddy, boolean vault)
+check_room(
+    xchar *lowx, xchar *ddx,
+    xchar *lowy, xchar *ddy,
+    boolean vault)
 {
     register int x, y, hix = *lowx + *ddx, hiy = *lowy + *ddy;
     register struct rm *lev;
@@ -3897,6 +3905,21 @@ l_create_stairway(lua_State *L, boolean using_ladder)
             levl[x][y].ladder = LA_DOWN;
         }
     } else {
+        /* hack for Valkyrie goal level where upstairs are at a fixed
+           location outside the mapped area; make sure they don't get
+           placed on a lava spot */
+        if (levl[x][y].typ == LAVAPOOL) {
+            int tx, ty;
+
+            for (tx = x - 1; tx <= x + 1; ++tx)
+                for (ty = y - 1; ty <= y + 1; ++ty)
+                    if (isok(tx, ty) && levl[tx][ty].typ == LAVAPOOL
+                        && ((tx == x && ty == y) || !rn2(2))) {
+                        levl[tx][ty].typ = ROOM;
+                        SpLev_Map[tx][ty] = 1;
+                    }
+        }
+
         mkstairs(x, y, (char) up, g.coder->croom);
     }
     return 0;
@@ -5792,7 +5815,9 @@ lspo_mazewalk(lua_State *L)
     static const char *const mwdirs[] = {
         "north", "south", "east", "west", "random", NULL
     };
-    static const int mwdirs2i[] = { W_NORTH, W_SOUTH, W_EAST, W_WEST, W_RANDOM, -2 };
+    static const int mwdirs2i[] = {
+        W_NORTH, W_SOUTH, W_EAST, W_WEST, W_RANDOM, -2
+    };
     xchar x, y;
     lua_Integer mx, my;
     xchar ftyp = ROOM;