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

@@ -260,6 +260,12 @@ if player creates any menu colors via 'O' while menucolors is off, issue a
reminder that it needs to be on in order for those to become effective
setting second or later named fruit to value beginning with two or more spaces
followed by non-space gave "singular of null?" warning
when blocking/unblocking of levitation or flying was updated due to walking
onto different terrain, the relevant status condition wasn't updated
on the screen until some other status update happened
if levitating hero poly'd into pass-wall creature jumped or teleported from
terrain that allowed levitation to terrain that didn't or vice versa,
blocking of levitation wasn't updated properly
Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 extern.h $NHDT-Date: 1543892214 2018/12/04 02:56:54 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.665 $ */
/* NetHack 3.6 extern.h $NHDT-Date: 1544401264 2018/12/10 00:21:04 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.666 $ */
/* Copyright (c) Steve Creps, 1988. */
/* NetHack may be freely redistributed. See license for details. */
@@ -854,6 +854,7 @@ E boolean NDECL(u_rooted);
E void NDECL(domove);
E boolean NDECL(overexertion);
E void NDECL(invocation_message);
E void NDECL(switch_terrain);
E boolean FDECL(pooleffects, (BOOLEAN_P));
E void FDECL(spoteffects, (BOOLEAN_P));
E char *FDECL(in_rooms, (XCHAR_P, XCHAR_P, int));

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 dothrow.c $NHDT-Date: 1543892215 2018/12/04 02:56:55 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.152 $ */
/* NetHack 3.6 dothrow.c $NHDT-Date: 1544401268 2018/12/10 00:21:08 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.153 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2013. */
/* NetHack may be freely redistributed. See license for details. */
@@ -707,6 +707,11 @@ int x, y;
newsym(ox, oy); /* update old position */
vision_recalc(1); /* update for new position */
flush_screen(1);
/* if terrain type changes, levitation or flying might become blocked
or unblocked; might issue message, so do this after map+vision has
been updated for new location instead of right after u_on_newpos() */
if (levl[u.ux][u.uy].typ != levl[ox][oy].typ)
switch_terrain();
if (is_pool(x, y) && !u.uinwater) {
if ((Is_waterlevel(&u.uz) && levl[x][y].typ == WATER)

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;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 teleport.c $NHDT-Date: 1523306912 2018/04/09 20:48:32 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.73 $ */
/* NetHack 3.6 teleport.c $NHDT-Date: 1544401270 2018/12/10 00:21:10 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.81 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2011. */
/* NetHack may be freely redistributed. See license for details. */
@@ -340,6 +340,11 @@ boolean allow_drag;
vision_full_recalc = 1;
nomul(0);
vision_recalc(0); /* vision before effects */
/* if terrain type changes, levitation or flying might become blocked
or unblocked; might issue message, so do this after map+vision has
been updated for new location instead of right after u_on_newpos() */
if (levl[u.ux][u.uy].typ != levl[u.ux0][u.uy0].typ)
switch_terrain();
if (telescroll) {
/* when teleporting by scroll, we need to handle discovery
now before getting feedback about any objects at our