level teleporters vs Ft.Ludios

From newsgroup discussion where slash'em changes have revealed a
latent nethack bug:  prevent placing level teleporters in single-
level branches.  The Knox level doesn't have any level teleporters
(or random traps) but wizard mode wishing could create them there.
They wouldn't do anything because the only possible destination
would be the same level.  Pushing a boulder onto one used to trigger
an infinite loop (and still does in slash'em, which has other
single-level branches besides Ft.Ludios) trying to relocate it.

Boulder pushing was changed 15 years ago to prevent the infinite
loop and to avoid giving "the boulder disappears" message when a
level teleporter failed, but rolling boulder traversal lacked that
same change--it wasn't vulnerable to looping but could give an
inaccurate message claiming that the boulder disappeared when it
actually didn't.  Fixing this is a bit late; rolling boulder trap
creation was recently changed to not choose a path that rolls over
teleportation or level tele traps any more.
This commit is contained in:
PatR
2021-04-12 13:25:52 -07:00
parent a8388c8cb5
commit 8bd08ebb71
7 changed files with 53 additions and 27 deletions

View File

@@ -178,6 +178,9 @@ moverock(void)
}
if (ttmp) {
int newlev = 0; /* lint suppression */
d_level dest;
/* if a trap operates on the boulder, don't attempt
to move any others at this location; return -1
if another boulder is in hero's way, or 0 if he
@@ -236,16 +239,14 @@ moverock(void)
newsym(rx, ry);
return sobj_at(BOULDER, sx, sy) ? -1 : 0;
case LEVEL_TELEP:
case TELEP_TRAP: {
int newlev = 0; /* lint suppression */
d_level dest;
if (ttmp->ttyp == LEVEL_TELEP) {
newlev = random_teleport_level();
if (newlev == depth(&u.uz) || In_endgame(&u.uz))
/* trap didn't work; skip "disappears" message */
goto dopush;
}
/* 20% chance of picking current level; 100% chance for
that if in single-level branch (Knox) or in endgame */
newlev = random_teleport_level();
/* if trap doesn't work, skip "disappears" message */
if (newlev == depth(&u.uz))
goto dopush;
/*FALLTHRU*/
case TELEP_TRAP:
if (u.usteed)
pline("%s pushes %s and suddenly it disappears!",
upstart(y_monnam(u.usteed)), the(xname(otmp)));
@@ -264,7 +265,6 @@ moverock(void)
}
seetrap(ttmp);
return sobj_at(BOULDER, sx, sy) ? -1 : 0;
}
default:
break; /* boulder not affected by this trap */
}