]> granicus.if.org Git - nethack/commitdiff
ignitable() macro
authorPatR <rankin@nethack.org>
Tue, 3 Nov 2020 22:25:06 +0000 (14:25 -0800)
committerPatR <rankin@nethack.org>
Tue, 3 Nov 2020 22:25:06 +0000 (14:25 -0800)
ignitable() was excluding magic lamp and then every place that
used it did so as 'ignitable(obj) || obj->otyp == MAGIC_LAMP'
so just include magic lamp.

I noticed that while hunting for an explanation for report #K2734
where returning to a previously visited level triggered the
warning "begin_burn: unexpected eggs".  I've decided that the
zombie apocalypse is probably the cause.  It inserted a new type
of timer in the list of such but it didn't bump EDITLEVEL to
invalidate save and bones files which relied on indices into the
old list.  I'm not sure whether we should bump that now.

include/obj.h
src/apply.c
src/light.c
src/trap.c

index 88c4902d01bc97a63e3a2dfc92d976dd17dcecf4..69ab173f8589552c58cacbc0cce84db0aea80f9b 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 obj.h   $NHDT-Date: 1596498552 2020/08/03 23:49:12 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.76 $ */
+/* NetHack 3.7 obj.h   $NHDT-Date: 1604442292 2020/11/03 22:24:52 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.78 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Michael Allison, 2006. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -308,22 +308,26 @@ struct obj {
     (otmp->otyp == TALLOW_CANDLE || otmp->otyp == WAX_CANDLE)
 #define MAX_OIL_IN_FLASK 400 /* maximum amount of oil in a potion of oil */
 
-/* MAGIC_LAMP intentionally excluded below */
-/* age field of this is relative age rather than absolute */
-#define age_is_relative(otmp)                                       \
+/* age field of this is relative age rather than absolute; does not include
+   magic lamp */
+#define age_is_relative(otmp) \
     ((otmp)->otyp == BRASS_LANTERN || (otmp)->otyp == OIL_LAMP      \
      || (otmp)->otyp == CANDELABRUM_OF_INVOCATION                   \
      || (otmp)->otyp == TALLOW_CANDLE || (otmp)->otyp == WAX_CANDLE \
      || (otmp)->otyp == POT_OIL)
-/* object can be ignited */
-#define ignitable(otmp)                                             \
+/* object can be ignited; magic lamp used to excluded here too but all
+   usage of this macro ended up testing
+     (ignitable(obj) || obj->otyp == MAGIC_LAMP)
+   so include it; brass lantern can be lit but not by fire */
+#define ignitable(otmp) \
     ((otmp)->otyp == BRASS_LANTERN || (otmp)->otyp == OIL_LAMP      \
+     || ((otmp)->otyp == MAGIC_LAMP && (otmp)->spe > 0)             \
      || (otmp)->otyp == CANDELABRUM_OF_INVOCATION                   \
      || (otmp)->otyp == TALLOW_CANDLE || (otmp)->otyp == WAX_CANDLE \
      || (otmp)->otyp == POT_OIL)
 
 /* things that can be read */
-#define is_readable(otmp)                                                    \
+#define is_readable(otmp) \
     ((otmp)->otyp == FORTUNE_COOKIE || (otmp)->otyp == T_SHIRT               \
      || (otmp)->otyp == ALCHEMY_SMOCK || (otmp)->otyp == CREDIT_CARD         \
      || (otmp)->otyp == CAN_OF_GREASE || (otmp)->otyp == MAGIC_MARKER        \
index a43e3b73070475a09550df87bde40fbeaef6946e..9c742959c35b50cb849600527918066fae76ffc2 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 apply.c $NHDT-Date: 1602270122 2020/10/09 19:02:02 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.328 $ */
+/* NetHack 3.7 apply.c $NHDT-Date: 1604442295 2020/11/03 22:24:55 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.330 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2012. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -1404,14 +1404,14 @@ struct obj *obj;
 }
 
 /* Called when potentially lightable object is affected by fire_damage().
-   Return TRUE if object was lit and FALSE otherwise --ALI */
+   Return TRUE if object becomes lit and FALSE otherwise --ALI */
 boolean
 catch_lit(obj)
 struct obj *obj;
 {
     xchar x, y;
 
-    if (!obj->lamplit && (obj->otyp == MAGIC_LAMP || ignitable(obj))) {
+    if (!obj->lamplit && ignitable(obj)) {
         if ((obj->otyp == MAGIC_LAMP
              || obj->otyp == CANDELABRUM_OF_INVOCATION) && obj->spe == 0)
             return FALSE;
index d3fce655eb4c28b1eff148f3208075ed2a6a86cd..02ddaf03f7bccb2ac771ab10feee47e9b097ea76 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 light.c $NHDT-Date: 1596498173 2020/08/03 23:42:53 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.45 $ */
+/* NetHack 3.7 light.c $NHDT-Date: 1604442297 2020/11/03 22:24:57 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.46 $ */
 /* Copyright (c) Dean Luick, 1994                                       */
 /* NetHack may be freely redistributed.  See license for details.       */
 
@@ -691,8 +691,7 @@ boolean
 obj_is_burning(obj)
 struct obj *obj;
 {
-    return (boolean) (obj->lamplit && (obj->otyp == MAGIC_LAMP
-                                       || ignitable(obj)
+    return (boolean) (obj->lamplit && (ignitable(obj)
                                        || artifact_light(obj)));
 }
 
index 5ba5bdc74ab0c01bc7f20c0362863abc40ec8363..01c7a80fe9f8f7ccbd73a4e19eb602db227f0fa1 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 trap.c  $NHDT-Date: 1602270123 2020/10/09 19:02:03 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.364 $ */
+/* NetHack 3.7 trap.c  $NHDT-Date: 1604442297 2020/11/03 22:24:57 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.365 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2013. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -5563,9 +5563,9 @@ boolean override;
     return defsyms[trap_to_defsym(ttyp)].explanation;
 }
 
-/* Ignite ignitable items in the given object chain, due to some external source
- * of fire. The object chain should be somewhere exposed, like someone's open
- * inventory or the floor.
+/* Ignite ignitable items in the given object chain, due to some external
+ * source of fire.  The object chain should be somewhere exposed, like
+ * someone's open inventory or the floor.
  * This is modeled after destroy_item() somewhat and hopefully will be able to
  * merge into it in the future.
  */
@@ -5590,7 +5590,7 @@ struct obj *objchn;
     }
 
     for (obj = objchn; obj; obj = obj->nobj) {
-        if (!(ignitable(obj) || obj->otyp == MAGIC_LAMP)
+        if (!ignitable(obj)
             /* The Candelabrum requires intention to be lit */
             || obj->otyp == CANDELABRUM_OF_INVOCATION
             || obj->otyp == BRASS_LANTERN /* doesn't ignite via fire */