fix #H7708 - change in terrain not noticed

Jumping or teleporting while levitating in xorn form wouldn't toggle
blocking of levitation when moving from open spots to wall/stone and
unblocking of same when moving the opposite way.

This handles those cases but there are no doubt others.  The only
other one I checked was when failed #untrap moves hero onto trap.
That case works correctly--at least after this fix is in place.

Noticed while working on it:  change of terrain didn't always update
the status line.  When levitation became blocked, it still said Lev
and when unblocked, didn't say that.  Next status update got status
condition back in sync.
This commit is contained in:
PatR
2018-12-09 16:22:27 -08:00
parent fe1b27e774
commit b40868a74f
5 changed files with 28 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 hack.c $NHDT-Date: 1543972190 2018/12/05 01:09:50 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.200 $ */
/* NetHack 3.6 hack.c $NHDT-Date: 1544401269 2018/12/10 00:21:09 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.201 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Derek S. Ray, 2015. */
/* NetHack may be freely redistributed. See license for details. */
@@ -13,7 +13,6 @@ STATIC_DCL int FDECL(still_chewing, (XCHAR_P, XCHAR_P));
STATIC_DCL void NDECL(dosinkfall);
STATIC_DCL boolean FDECL(findtravelpath, (int));
STATIC_DCL boolean FDECL(trapmove, (int, int, struct trap *));
STATIC_DCL void NDECL(switch_terrain);
STATIC_DCL struct monst *FDECL(monstinroom, (struct permonst *, int));
STATIC_DCL boolean FDECL(doorless_door, (int, int));
STATIC_DCL void FDECL(move_update, (BOOLEAN_P));
@@ -1935,12 +1934,13 @@ invocation_message()
/* moving onto different terrain;
might be going into solid rock, inhibiting levitation or flight,
or coming back out of such, reinstating levitation/flying */
STATIC_OVL void
void
switch_terrain()
{
struct rm *lev = &levl[u.ux][u.uy];
boolean blocklev = (IS_ROCK(lev->typ) || closed_door(u.ux, u.uy)
|| (Is_waterlevel(&u.uz) && lev->typ == WATER));
|| (Is_waterlevel(&u.uz) && lev->typ == WATER)),
was_levitating = !!Levitation, was_flying = !!Flying;
if (blocklev) {
/* called from spoteffects(), stop levitating but skip float_down() */
@@ -1968,6 +1968,8 @@ switch_terrain()
if (Flying)
You("start flying.");
}
if ((!Levitation ^ was_levitating) || (!Flying ^ was_flying))
context.botl = TRUE; /* update Lev/Fly status condition */
}
/* extracted from spoteffects; called by spoteffects to check for entering or
@@ -2828,12 +2830,13 @@ const char *msg_override;
else if (!nomovemsg)
nomovemsg = You_can_move_again;
if (*nomovemsg)
pline1(nomovemsg);
pline("%s", nomovemsg);
nomovemsg = 0;
u.usleep = 0;
multi_reason = NULL;
if (afternmv) {
int NDECL((*f)) = afternmv;
/* clear afternmv before calling it (to override the
encumbrance hack for levitation--see weight_cap()) */
afternmv = (int NDECL((*))) 0;