]> granicus.if.org Git - nethack/commitdiff
fix github issue #842 - lamp/lantern feedback
authorPatR <rankin@nethack.org>
Sat, 13 Aug 2022 22:55:10 +0000 (15:55 -0700)
committerPatR <rankin@nethack.org>
Sat, 13 Aug 2022 22:55:10 +0000 (15:55 -0700)
Issue reported by GorillaSapiens:  you get notified if a lamp burns
out even if you're blind at the time.

That is intended behavior; you can feel the heat or lack of heat
from a lamp or candle.  But the comment from copperwater pointed out
that you shouldn't be able to feel that for a brass lantern.

This suppresses the "power has run out" feedback if blind at the
time.  However, applying a lantern to turn it on or off still gives
the on/off feedback on the assumption that there's a switch and you
can feel its position.  When hero is blind and lantern is out of
power, trying to turn it on yields "nothing seems to happen".  It's
not completely consistent since you would feel the switch in its On
position but claiming that the lantern is on would be a lie.

The basic on and off messages referred to "lamp" even when using a
brass lantern.  I thought that that had been fixed a long time ago.

Fixes #842

doc/fixes3-7-0.txt
src/apply.c
src/timeout.c

index c401de5979d0501364f2eb5b93c3c030e7ae620c..9c25299238ff6deda26f5e67407f47455ef7c5a9 100644 (file)
@@ -996,6 +996,9 @@ chances of random item being an artifact depends on already existing artifacts
 monsters can zap wands of teleportation at hero
 piranhas devour corpses
 turn on menucolors boolean automatically if any menucolors are defined
+blind hero was notified when brass lantern burned out even though it isn't
+       warm enough to detect that by touch; manually switching the lantern
+       on or off can be determined that way so still gives on/off message
 
 
 Fixes to 3.7.0-x Problems that Were Exposed Via git Repository
index d5da393f184fb8ff7e4ad557ad7e3eb32b997b98..b2c7b5e152975d136cb71bdc366ac1df820cec4c 100644 (file)
@@ -47,6 +47,7 @@ static boolean get_valid_jump_position(coordxy, coordxy);
 static boolean get_valid_polearm_position(coordxy, coordxy);
 static boolean find_poleable_mon(coord *, int, int);
 
+static const char Nothing_seems_to_happen[] = "Nothing seems to happen.";
 static const char no_elbow_room[] =
     "don't have enough elbow-room to maneuver.";
 
@@ -995,7 +996,7 @@ use_mirror(struct obj *obj)
         if (!Blind)
             pline_The("%s fogs up and doesn't reflect!", mirror);
         else
-            pline("Nothing seems to happen.");
+            pline("%s", Nothing_seems_to_happen);
         return ECMD_TIME;
     }
     if (!u.dx && !u.dy && !u.dz) {
@@ -1567,15 +1568,25 @@ catch_lit(struct obj *obj)
     return FALSE;
 }
 
+/* light a lamp or candle */
 static void
 use_lamp(struct obj *obj)
 {
     char buf[BUFSZ];
+    const char *lamp = (obj->otyp == OIL_LAMP
+                        || obj->otyp == MAGIC_LAMP) ? "lamp"
+                       : (obj->otyp == BRASS_LANTERN) ? "lantern"
+                         : NULL;
+
+    /*
+     * When blind, lamps' and candles' on/off state can be distinguished
+     * by heat.  For brass lantern assume that there is an on/off switch
+     * that can be felt.
+     */
 
     if (obj->lamplit) {
-        if (obj->otyp == OIL_LAMP || obj->otyp == MAGIC_LAMP
-            || obj->otyp == BRASS_LANTERN)
-            pline("%slamp is now off.", Shk_Your(buf, obj));
+        if (lamp) /* lamp or lantern */
+            pline("%s%s is now off.", Shk_Your(buf, obj), lamp);
         else
             You("snuff out %s.", yname(obj));
         end_burn(obj, TRUE);
@@ -1589,10 +1600,14 @@ use_lamp(struct obj *obj)
     /* magic lamps with an spe == 0 (wished for) cannot be lit */
     if ((!Is_candle(obj) && obj->age == 0)
         || (obj->otyp == MAGIC_LAMP && obj->spe == 0)) {
-        if (obj->otyp == BRASS_LANTERN)
-            Your("lantern is out of power.");
-        else
+        if (obj->otyp == BRASS_LANTERN) {
+            if (!Blind)
+                Your("lantern is out of power.");
+            else
+                pline("%s", Nothing_seems_to_happen);
+        } else {
             pline("This %s has no oil.", xname(obj));
+        }
         return;
     }
     if (obj->cursed && !rn2(2)) {
@@ -1600,14 +1615,16 @@ use_lamp(struct obj *obj)
             pline_The("lamp spills and covers your %s with oil.",
                       fingers_or_gloves(TRUE));
             make_glib((int) (Glib & TIMEOUT) + d(2, 10));
-        } else if (!Blind)
+        } else if (!Blind) {
             pline("%s for a moment, then %s.", Tobjnam(obj, "flicker"),
                   otense(obj, "die"));
+        } else {
+            pline("%s", Nothing_seems_to_happen);
+        }
     } else {
-        if (obj->otyp == OIL_LAMP || obj->otyp == MAGIC_LAMP
-            || obj->otyp == BRASS_LANTERN) {
+        if (lamp) { /* lamp or lantern */
             check_unpaid(obj);
-            pline("%slamp is now on.", Shk_Your(buf, obj));
+            pline("%s%s is now on.", Shk_Your(buf, obj), lamp);
         } else { /* candle(s) */
             pline("%s flame%s %s%s", s_suffix(Yname2(obj)), plur(obj->quan),
                   otense(obj, "burn"), Blind ? "." : " brightly!");
@@ -2170,7 +2187,7 @@ use_unicorn_horn(struct obj **optr)
             break;
         case 6:
             if (Deaf) /* make_deaf() won't give feedback when already deaf */
-                pline("Nothing seems to happen.");
+                pline("%s", Nothing_seems_to_happen);
             make_deaf((HDeaf & TIMEOUT) + lcount, TRUE);
             break;
         }
@@ -2261,7 +2278,7 @@ use_unicorn_horn(struct obj **optr)
     if (did_prop)
         g.context.botl = TRUE;
     else
-        pline("Nothing seems to happen.");
+        pline("%s", Nothing_seems_to_happen);
 
 #undef PROP_COUNT
 #undef prop_trouble
@@ -3444,7 +3461,7 @@ use_royal_jelly(struct obj *obj)
         if (eobj->timed || eobj->corpsenm != oldcorpsenm)
             pline("The %s %s feebly.", xname(eobj), otense(eobj, "quiver"));
         else
-            pline("Nothing seems to happen.");
+            pline("%s", Nothing_seems_to_happen);
         kill_egg(eobj);
         goto useup_jelly;
     }
@@ -3463,7 +3480,7 @@ use_royal_jelly(struct obj *obj)
         || eobj->corpsenm != oldcorpsenm)
         pline("The %s %s briefly.", xname(eobj), otense(eobj, "quiver"));
     else
-        pline("Nothing seems to happen.");
+        pline("%s", Nothing_seems_to_happen);
 
  useup_jelly:
     /* not useup() because we've already done freeinv() */
index 096e20b27a97dbee59c3098025de5e4f049725b9..ed3a8ed38668e826696c61e83da865e0d08d2252 100644 (file)
@@ -1178,7 +1178,7 @@ slip_or_trip(void)
     }
 }
 
-/* Print a lamp flicker message with tailer. */
+/* Print a lamp flicker message with tailer.  Only called if seen. */
 static void
 see_lamp_flicker(struct obj *obj, const char *tailer)
 {
@@ -1193,7 +1193,7 @@ see_lamp_flicker(struct obj *obj, const char *tailer)
     }
 }
 
-/* Print a dimming message for brass lanterns. */
+/* Print a dimming message for brass lanterns.  Only called if seen. */
 static void
 lantern_message(struct obj *obj)
 {
@@ -1221,7 +1221,7 @@ void
 burn_object(anything *arg, long timeout)
 {
     struct obj *obj = arg->a_obj;
-    boolean canseeit, many, menorah, need_newsym, need_invupdate;
+    boolean canseeit, many, menorah, need_newsym, need_invupdate, bytouch;
     coordxy x, y;
     char whose[BUFSZ];
 
@@ -1269,6 +1269,11 @@ burn_object(anything *arg, long timeout)
     } else {
         canseeit = FALSE;
     }
+    /* when carrying the light source, you can feel the heat from lit lamp
+       or candle so you'll be notified when it burns out even if blind at
+       the time; brass lantern doesn't radiate sufficient heat for that
+       (however, inventory formatting drops "(lit)" so player can tell) */
+    bytouch = (obj->where == OBJ_INVENT && obj->otyp != BRASS_LANTERN);
     need_newsym = need_invupdate = FALSE;
 
     /* obj->age is the age remaining at this point.  */
@@ -1320,9 +1325,9 @@ burn_object(anything *arg, long timeout)
 
         case 25:
             if (canseeit) {
-                if (obj->otyp == BRASS_LANTERN)
+                if (obj->otyp == BRASS_LANTERN) {
                     lantern_message(obj);
-                else {
+                else {
                     switch (obj->where) {
                     case OBJ_INVENT:
                     case OBJ_MINVENT:
@@ -1338,7 +1343,7 @@ burn_object(anything *arg, long timeout)
 
         case 0:
             /* even if blind you'll know if holding it */
-            if (canseeit || obj->where == OBJ_INVENT) {
+            if (canseeit || bytouch) {
                 switch (obj->where) {
                 case OBJ_INVENT:
                     need_invupdate = TRUE;
@@ -1416,7 +1421,7 @@ burn_object(anything *arg, long timeout)
 
         case 0:
             /* we know even if blind and in our inventory */
-            if (canseeit || obj->where == OBJ_INVENT) {
+            if (canseeit || bytouch) {
                 if (menorah) {
                     switch (obj->where) {
                     case OBJ_INVENT:
@@ -1462,8 +1467,10 @@ burn_object(anything *arg, long timeout)
             end_burn(obj, FALSE);
 
             if (menorah) {
-                obj->spe = 0;
+                obj->spe = 0; /* no candles */
                 obj->owt = weight(obj);
+                if (carried(obj))
+                    need_invupdate = TRUE;
             } else {
                 if (carried(obj)) {
                     useupall(obj);