wizard mode buglet: simultaneous Lev+Fly timeout

Noticed while working on Qt status highlighting:  if levitation
and flying timed out at the same time, first Lev timeout called
float_down() which reported
 You have stopped levitating and are now flying.
and then Fly timeout left stale "Fly" on the status line due to
an optimization which got subverted.  ('was_flying' flag was
False due to Fly being blocked by Lev; that's correct behavior,
but the flag is effectively a cached value that becomes stale
when the Lev timeout code executes.)

The bug was wizard mode only because #wizintrinsic is the only
way to get timed flying.
This commit is contained in:
PatR
2020-11-24 10:43:12 -08:00
parent 018d838eb9
commit 7e87abb66f
2 changed files with 21 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.361 $ $NHDT-Date: 1606033928 2020/11/22 08:32:08 $ NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.362 $ $NHDT-Date: 1606243387 2020/11/24 18:43:07 $
General Fixes and Modified Features General Fixes and Modified Features
----------------------------------- -----------------------------------
@@ -305,6 +305,9 @@ wand/scroll of create monster or bag of tricks that makes a new monster which
concealed mimic seen as furniture or an object concealed mimic seen as furniture or an object
'showscore' could be used to determine how much gold was inside a container 'showscore' could be used to determine how much gold was inside a container
whose contents were unknown whose contents were unknown
wizard mode (only way to get timed flying): if levitation and flying time out
on same turn, player was told "You have stopped levitating and are
now flying."; status line wasn't updated to remove stale Fly condition
Fixes to 3.7.0-x Problems that Were Exposed Via git Repository Fixes to 3.7.0-x Problems that Were Exposed Via git Repository

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 timeout.c $NHDT-Date: 1598570054 2020/08/27 23:14:14 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.119 $ */ /* NetHack 3.7 timeout.c $NHDT-Date: 1606243387 2020/11/24 18:43:07 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.122 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2018. */ /*-Copyright (c) Robert Patrick Rankin, 2018. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -46,11 +46,16 @@ const struct propname {
{ DETECT_MONSTERS, "monster detection" }, { DETECT_MONSTERS, "monster detection" },
{ SEE_INVIS, "see invisible" }, { SEE_INVIS, "see invisible" },
{ INVIS, "invisible" }, { INVIS, "invisible" },
{ DISPLACED, "displaced" }, /* timed amount possible via eating a /* timed displacement is possible via eating a displacer beast corpse */
* displacer beast corpse */ { DISPLACED, "displaced" },
/* properties beyond here don't have timed values during normal play, /* timed pass-walls is a potential prayer result if surrounded by stone
so there's not much point in trying to order them sensibly; with nowhere to be safely teleported to */
they're either on or off based on equipment, role, actions, &c */ { PASSES_WALLS, "pass thru walls" },
/*
* Properties beyond here don't have timed values during normal play,
* so there's not much point in trying to order them sensibly.
* They're either on or off based on equipment, role, actions, &c.
*/
{ FIRE_RES, "fire resistance" }, { FIRE_RES, "fire resistance" },
{ COLD_RES, "cold resistance" }, { COLD_RES, "cold resistance" },
{ SLEEP_RES, "sleep resistance" }, { SLEEP_RES, "sleep resistance" },
@@ -81,7 +86,6 @@ const struct propname {
{ WWALKING, "water walking" }, { WWALKING, "water walking" },
{ SWIMMING, "swimming" }, { SWIMMING, "swimming" },
{ MAGICAL_BREATHING, "magical breathing" }, { MAGICAL_BREATHING, "magical breathing" },
{ PASSES_WALLS, "pass thru walls" },
{ SLOW_DIGESTION, "slow digestion" }, { SLOW_DIGESTION, "slow digestion" },
{ HALF_SPDAM, "half spell damage" }, { HALF_SPDAM, "half spell damage" },
{ HALF_PHDAM, "half physical damage" }, { HALF_PHDAM, "half physical damage" },
@@ -676,6 +680,12 @@ nh_timeout()
} }
break; break;
case LEVITATION: case LEVITATION:
/* timed Flying is via #wizintrinsic only; still, we want to
avoid float_down() reporting "you have stopped levitating
and are now flying" if both are timing out together;
relies on knowing that Lev timeout is handled before Fly */
if ((HFlying & TIMEOUT) == 1L)
--HFlying; /* bypass pending 'case FLYING' */
(void) float_down(I_SPECIAL | TIMEOUT, 0L); (void) float_down(I_SPECIAL | TIMEOUT, 0L);
break; break;
case FLYING: case FLYING: