]> granicus.if.org Git - nethack/commitdiff
refine blocked levitation/flight (trunk only)
authornethack.rankin <nethack.rankin>
Sat, 22 Oct 2011 23:26:17 +0000 (23:26 +0000)
committernethack.rankin <nethack.rankin>
Sat, 22 Oct 2011 23:26:17 +0000 (23:26 +0000)
     Levitation side-effects get skipped if Levitation toggles while it
is blocked, so BFlying (the reason Flying is blocked) could become stale
in some situations.  Enlightment feedback about latent flight capability
was the only thing affected.

include/extern.h
src/cmd.c
src/do_wear.c
src/hack.c
src/polyself.c
src/potion.c

index 20faeb00b5d9bd31ee21d58eea344adfd9e36ffd..ed0cdb78b72ef77a753d869b32095aa0ac64bbff 100644 (file)
@@ -1750,6 +1750,7 @@ E void NDECL(self_invis_message);
 /* ### polyself.c ### */
 
 E void NDECL(set_uasmon);
+E void NDECL(float_vs_flight);
 E void NDECL(change_sex);
 E void FDECL(polyself, (int));
 E int FDECL(polymon, (int));
index 3feac20cfd6704d62d1ef3d5fffc907c8db4a70b..c894bc30c5dad6dab04bdcc9fa50ae1c2ac34b12 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -1775,16 +1775,13 @@ int final;
            long save_BFly = BFlying;
 
            BFlying = 0L;
-           if (Flying) {
-               Sprintf(buf, "%s%s%s",
-                       (save_BFly & I_SPECIAL) ?
-                               " if you weren't levitating" : "",
-                       ((save_BFly & (FROMOUTSIDE|I_SPECIAL)) ==
-                               (FROMOUTSIDE|I_SPECIAL)) ? " and" : "",
-                       (save_BFly & FROMOUTSIDE) ?
-                               if_surroundings_permitted : (const char *)"");
-               enl_msg(You_, "would fly", "would have flown", buf, "");
-           }
+           if (Flying)
+               enl_msg(You_, "would fly", "would have flown",
+                       Levitation ? "if you weren't levitating" :
+                         (save_BFly == FROMOUTSIDE) ?
+                           if_surroundings_permitted :
+                           /* both surroundings and [latent] levitation */
+                           " if circumstances permitted", "");
            BFlying = save_BFly;
        }
        /* actively walking on water handled earlier as a status condition */
index 9555671039a807e31da55b5d7d4c6f18c8ec6617..0607b019022f7de18092409263dad84a8c460101 100644 (file)
@@ -194,6 +194,8 @@ Boots_on(VOID_ARGS)
                        makeknown(uarmf->otyp);
                        float_up();
                        spoteffects(FALSE);
+               } else {
+                   float_vs_flight(); /* maybe toggle (BFlying & I_SPECIAL) */
                }
                break;
        default: impossible(unknown_type, c_boots, uarmf->otyp);
@@ -245,6 +247,8 @@ Boots_off(VOID_ARGS)
                    !context.takeoff.cancelled_don) {
                        (void) float_down(0L, 0L);
                        makeknown(otyp);
+               } else {
+                   float_vs_flight(); /* maybe toggle (BFlying & I_SPECIAL) */
                }
                break;
        case LOW_BOOTS:
@@ -880,6 +884,8 @@ register struct obj *obj;
                    float_up();
                    learnring(obj, TRUE);
                    spoteffects(FALSE); /* for sinks */
+               } else {
+                   float_vs_flight(); /* maybe toggle (BFlying & I_SPECIAL) */
                }
                break;
        case RIN_GAIN_STRENGTH:
@@ -991,6 +997,8 @@ boolean gone;
                if (!BLevitation) {
                    (void) float_down(0L, 0L);
                    if (!Levitation) learnring(obj, TRUE);
+               } else {
+                   float_vs_flight(); /* maybe toggle (BFlying & I_SPECIAL) */
                }
                break;
        case RIN_GAIN_STRENGTH:
index 65526c64a74320b80348a5e84dae8612603cd1a7..ce3e2ae6b1c6c23a807d7b8752d02ea45f8763b9 100644 (file)
@@ -543,6 +543,9 @@ dosinkfall()
            off_msg(obj);
        }
        HLevitation--;
+       /* probably moot; we're either still levitating or went
+          through float_down(), but make sure BFlying is up to date */
+       float_vs_flight();
 }
 #endif
 
@@ -1665,9 +1668,7 @@ switch_terrain()
        BFlying |= FROMOUTSIDE;
     } else if (BFlying) {
        BFlying &= ~FROMOUTSIDE;
-       /* in case BFlying got set due to levitation which then went away
-          while blocked; there'd be no float_down() with reset of BFlying */
-       if (!HLevitation && !ELevitation) BFlying &= ~I_SPECIAL;
+       float_vs_flight();      /* maybe toggle (BFlying & I_SPECIAL) */
        /* [minor bug: we don't know whether this is beginning flight or
           resuming it; that could be tracked so that this message could
           be adjusted to "resume flying", but isn't worth the effort...] */
index 66b95b3a047b4c5985ae135728255fa55cd8d33e..2090f1c9c47f59486cf8de319bb74f297c542b5c 100644 (file)
@@ -88,11 +88,8 @@ set_uasmon()
        PROPSET(PASSES_WALLS, passes_walls(mdat));
        PROPSET(REGENERATION, regenerates(mdat));
        PROPSET(REFLECTING, (mdat == &mons[PM_SILVER_DRAGON]));
-       /* levitation overrides flight */
-       if (HLevitation || ELevitation)
-           BFlying |= I_SPECIAL;
-       else
-           BFlying &= ~I_SPECIAL;
+
+       float_vs_flight(); /* maybe toggle (BFlying & I_SPECIAL) */
 
 #undef PROPSET
 
@@ -101,6 +98,18 @@ set_uasmon()
 #endif
 }
 
+/* Levitation overrides Flying; set or clear BFlying|I_SPECIAL */
+void
+float_vs_flight()
+{
+       /* floating overrides flight; normally float_up() and float_down()
+          handle this, but sometimes they're skipped */
+       if (HLevitation || ELevitation)
+           BFlying |= I_SPECIAL;
+       else
+           BFlying &= ~I_SPECIAL;
+}
+
 /* for changing into form that's immune to strangulation */
 STATIC_OVL void
 check_strangling(on)
index 7a4413e754dfe2eec166d630cd771ef56f957b42..804c46d4170c0d4422aa51e7d8a72af00a74ae49 100644 (file)
@@ -934,6 +934,7 @@ peffects(otmp)
                } else
                    incr_itimeout(&HLevitation, rn1(140,10));
                if (Levitation) spoteffects(FALSE);     /* for sinks */
+               float_vs_flight();
                break;
        case POT_GAIN_ENERGY:                   /* M. Stephenson */
                {       register int num;