]> granicus.if.org Git - nethack/commitdiff
Prevent branch stairs generating in unjoined room
authorPasi Kallinen <paxed@alt.org>
Tue, 21 Apr 2020 15:41:08 +0000 (18:41 +0300)
committerPasi Kallinen <paxed@alt.org>
Tue, 21 Apr 2020 15:41:08 +0000 (18:41 +0300)
src/mklev.c

index b4d9f8967f008b4b33cd76b33f1613fac5b4188f..71f6f4bef312dee62ab73a26ce031a2882b99ff7 100644 (file)
@@ -1165,26 +1165,10 @@ coord *mp;
     if (g.nroom == 0) {
         mazexy(mp); /* already verifies location */
     } else {
-        int cnt = 0;
-        /* not perfect - there may be only one stairway */
-        if (g.nroom > 2) {
-            int tryct = 0;
-
-            do
-                croom = &g.rooms[rn2(g.nroom)];
-            while ((croom == g.dnstairs_room || croom == g.upstairs_room
-                    || (croom->rtype != OROOM && croom->rtype != THEMEROOM))
-                   && (++tryct < 100));
-        } else
-            croom = &g.rooms[rn2(g.nroom)];
+        croom = generate_stairs_find_room();
 
-        do {
-            if (!somexy(croom, mp))
-                impossible("Can't place branch!");
-        } while ((occupied(mp->x, mp->y)
-                 || (levl[mp->x][mp->y].typ != CORR
-                     && levl[mp->x][mp->y].typ != ICE
-                     && levl[mp->x][mp->y].typ != ROOM)) && (++cnt < 1000));
+        if (!somexyspace(croom, mp))
+            impossible("Can't place branch!");
     }
     return croom;
 }