]> granicus.if.org Git - nethack/commitdiff
Prevent wizmode panic
authorPasi Kallinen <paxed@alt.org>
Tue, 10 Mar 2020 06:02:08 +0000 (08:02 +0200)
committerPasi Kallinen <paxed@alt.org>
Tue, 10 Mar 2020 06:02:12 +0000 (08:02 +0200)
In wizard mode, if you angered your quest leader and got expelled from
the quest (which removes the quest portal from the dungeon), then used
the wizmode level teleport menu to teleport back to the quest start and
talked with the angry leader, you would get booted back to the dungeon,
and the game panicked because the dungeon end of the portal didn't
exist anymore.

src/do.c

index 114cfe03afa6658e64c1e2c2498db150ffd6157f..cb7480e6828cc8806ba6bb8995b8701672b97e3e 100644 (file)
--- a/src/do.c
+++ b/src/do.c
@@ -1506,10 +1506,21 @@ boolean at_stairs, falling, portal;
             if (ttrap->ttyp == MAGIC_PORTAL)
                 break;
 
-        if (!ttrap)
-            panic("goto_level: no corresponding portal!");
-        seetrap(ttrap);
-        u_on_newpos(ttrap->tx, ttrap->ty);
+        if (!ttrap) {
+            if (u.uevent.qexpelled && Is_qstart(&u.uz0)) {
+                /* we're coming back from the quest home level, after
+                   already getting expelled once. The portal back doesn't
+                   exist anymore - see expulsion(). This can only happen
+                   in wizmode.
+                 */
+                u_on_rndspot(0);
+            } else {
+                panic("goto_level: no corresponding portal!");
+            }
+        } else {
+            seetrap(ttrap);
+            u_on_newpos(ttrap->tx, ttrap->ty);
+        }
     } else if (at_stairs && !In_endgame(&u.uz)) {
         if (up) {
             if (g.at_ladder)