]> granicus.if.org Git - nethack/commitdiff
fix #H8237 - corpse on an invalid trap
authorPatR <rankin@nethack.org>
Fri, 22 Feb 2019 01:53:19 +0000 (17:53 -0800)
committerPatR <rankin@nethack.org>
Fri, 22 Feb 2019 01:53:19 +0000 (17:53 -0800)
It's possible to get a rolling boulder trap which doesn't have any
boulder.  That isn't invalid, but if/when it happens on a shallow
level it shouldn't be covered by the corpse of a fake adventurer
since such a trap won't kill anyone.

doc/fixes36.2
src/mklev.c

index 0d7c7a64b6010e4113606872eaf1896d99ac82ab..7c2cb092f76b2d00d12ec9cf72d4670a57ab6ff7 100644 (file)
@@ -1,4 +1,4 @@
-$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.260 $ $NHDT-Date: 1550784489 2019/02/21 21:28:09 $
+$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.261 $ $NHDT-Date: 1550800390 2019/02/22 01:53:10 $
 
 This fixes36.2 file is here to capture information about updates in the 3.6.x
 lineage following the release of 3.6.1 in April 2018. Please note, however,
@@ -378,6 +378,8 @@ after using 'f' to fire/throw with autoquiver enabled and numpad off, then
        suitable to autoquiver it would pick the item in the inventory slot
        corresponding to the direction letter from preceding 'fire' (and if
        there was such an item, then ask for direction since ^A data ran out)
+early rolling boulder trap lacking any boulder might still have the corpse
+       of a dead adventurer
 
 
 Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository
index e2048aec8f3bb9218b89202d3be82b0998738cbc..d0e3ab987c55ee1bd1251748ea4a321806fffbaf 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 mklev.c $NHDT-Date: 1511681724 2017/11/26 07:35:24 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.47 $ */
+/* NetHack 3.6 mklev.c $NHDT-Date: 1550800390 2019/02/22 01:53:10 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.59 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Alex Smith, 2017. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -89,7 +89,7 @@ xchar xl, yl, xh, yh;
     /* cannot find something reasonable -- strange */
     x = xl;
     y = yh;
-gotit:
+ gotit:
     cc->x = x;
     cc->y = y;
     return;
@@ -99,11 +99,12 @@ void
 sort_rooms()
 {
 #if defined(SYSV) || defined(DGUX)
-    qsort((genericptr_t) rooms, (unsigned) nroom, sizeof(struct mkroom),
-          do_comp);
+#define CAST_nroom (unsigned) nroom
 #else
-    qsort((genericptr_t) rooms, nroom, sizeof(struct mkroom), do_comp);
+#define CAST_nroom nroom /*as-is*/
 #endif
+    qsort((genericptr_t) rooms, CAST_nroom, sizeof (struct mkroom), do_comp);
+#undef CAST_nroom
 }
 
 STATIC_OVL void
@@ -728,11 +729,12 @@ makelevel()
     /* make a secret treasure vault, not connected to the rest */
     if (do_vault()) {
         xchar w, h;
+
         debugpline0("trying to make a vault...");
         w = 1;
         h = 1;
         if (check_room(&vault_x, &w, &vault_y, &h, TRUE)) {
       fill_vault:
+ fill_vault:
             add_room(vault_x, vault_y, vault_x + w, vault_y + h, TRUE, VAULT,
                      FALSE);
             level.flags.has_vault = 1;
@@ -785,7 +787,7 @@ makelevel()
             mkroom(COCKNEST);
     }
 
-skip0:
+ skip0:
     /* Place multi-dungeon branch. */
     place_branch(branchp, 0, 0);
 
@@ -848,6 +850,7 @@ skip0:
         if (!rn2(27 + 3 * abs(depth(&u.uz)))) {
             char buf[BUFSZ];
             const char *mesg = random_engraving(buf);
+
             if (mesg) {
                 do {
                     x = somex(croom);
@@ -859,7 +862,7 @@ skip0:
             }
         }
 
   skip_nonrogue:
+ skip_nonrogue:
         if (!rn2(3)) {
             (void) mkobj_at(0, somex(croom), somey(croom), TRUE);
             tryct = 0;
@@ -1259,6 +1262,7 @@ struct mkroom *croom;
 coord *tm;
 {
     register int kind;
+    struct trap *t;
     unsigned lvl = level_difficulty();
     coord m;
 
@@ -1367,7 +1371,11 @@ coord *tm;
                  || (avoid_boulder && sobj_at(BOULDER, m.x, m.y)));
     }
 
-    (void) maketrap(m.x, m.y, kind);
+    t = maketrap(m.x, m.y, kind);
+    /* we should always get type of trap we're asking for (occupied() test
+       should prevent cases where that might not happen) but be paranoid */
+    kind = t ? t->ttyp : NO_TRAP;
+
     if (kind == WEB)
         (void) makemon(&mons[PM_GIANT_SPIDER], m.x, m.y, NO_MM_FLAGS);
 
@@ -1392,8 +1400,13 @@ coord *tm;
        lethal, and tend not to generate on shallower levels anyway.
        Finally, pits are excluded because it's weird to see an item
        in a pit and yet not be able to identify that the pit is there. */
-    if (lvl <= (unsigned) rnd(4)
+    if (kind != NO_TRAP && lvl <= (unsigned) rnd(4)
         && kind != SQKY_BOARD && kind != RUST_TRAP
+        /* rolling bounder trap might not have a boulder if there was no
+           viable path (such as when placed in the corner of a room), in
+           which case tx,ty==launch.x,y; no boulder => no dead predecessor */
+        && !(kind == ROLLING_BOULDER_TRAP
+             && t->launch.x == t->tx && t->launch.y == t->ty)
         && !is_pit(kind) && kind < HOLE) {
         /* Object generated by the trap; initially NULL, stays NULL if
            we fail to generate an object or if the trap doesn't