OSDN Git Service

upgrade to 3.6.2
[jnethack/source.git] / include / display.h
index 4bd8cf9..9da288d 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 display.h       $NHDT-Date: 1447729027 2015/11/17 02:57:07 $  $NHDT-Branch: master $:$NHDT-Revision: 1.26 $ */
+/* NetHack 3.6 display.h       $NHDT-Date: 1546212620 2018/12/30 23:30:20 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.29 $ */
 /* Copyright (c) Dean Luick, with acknowledgements to Kevin Darcy */
 /* and Dave Cohrs, 1990.                                          */
 /* NetHack may be freely redistributed.  See license for details. */
  *
  * Respectively return a random monster, object, or trap number.
  */
-#define random_monster() rn2(NUMMONS)
-#define random_object() rn1(NUM_OBJECTS - 1, 1)
-#define random_trap() rn1(TRAPNUM - 1, 1)
+#define random_monster(rng) rng(NUMMONS)
+#define random_object(rng) (rng(NUM_OBJECTS - 1) + 1)
+#define random_trap(rng) (rng(TRAPNUM - 1) + 1)
 
 /*
  * what_obj()
  * what_trap()
  *
  * If hallucinating, choose a random object/monster, otherwise, use the one
- * given.
+ * given. Use the given rng to handle hallucination.
  */
-#define what_obj(obj) (Hallucination ? random_object() : obj)
-#define what_mon(mon) (Hallucination ? random_monster() : mon)
-#define what_trap(trp) (Hallucination ? random_trap() : trp)
+#define what_obj(obj, rng) (Hallucination ? random_object(rng) : obj)
+#define what_mon(mon, rng) (Hallucination ? random_monster(rng) : mon)
+#define what_trap(trp, rng) (Hallucination ? random_trap(rng) : trp)
+
+/*
+ * newsym_rn2
+ *
+ * An appropriate random number generator for use with newsym(), when
+ * randomness is needed there. This is currently hardcoded as
+ * rn2_on_display_rng, but is futureproofed for cases where we might
+ * want to prevent display-random objects entering the character's
+ * memory (this isn't important at present but may be if we need
+ * reproducible gameplay for some reason).
+ */
+#define newsym_rn2 rn2_on_display_rng
 
 /*
  * covers_objects()
  */
 #define DISP_BEAM    (-1) /* Keep all glyphs showing & clean up at end. */
 #define DISP_ALL     (-2) /* Like beam, but still displayed if not visible. */
-#define DISP_FLASH   (-3) /* Clean up each glyph before displaying new one. */
-#define DISP_ALWAYS  (-4) /* Like flash, but still displayed if not visible. */
-#define DISP_CHANGE  (-5) /* Change glyph. */
-#define DISP_END     (-6) /* Clean up. */
-#define DISP_FREEMEM (-7) /* Free all memory during exit only. */
+#define DISP_TETHER  (-3) /* Like beam, but tether glyph differs from final */
+#define DISP_FLASH   (-4) /* Clean up each glyph before displaying new one. */
+#define DISP_ALWAYS  (-5) /* Like flash, but still displayed if not visible. */
+#define DISP_CHANGE  (-6) /* Change glyph. */
+#define DISP_END     (-7) /* Clean up. */
+#define DISP_FREEMEM (-8) /* Free all memory during exit only. */
 
 /* Total number of cmap indices in the shield_static[] array. */
 #define SHIELD_COUNT 21
+#define BACKTRACK (-1)    /* flag for DISP_END to display each prior location */
 
 /*
  * display_self()
  * Display the hero.  It is assumed that all checks necessary to determine
  * _if_ the hero can be seen have already been done.
  */
-#define maybe_display_usteed(otherwise_self)                             \
-    ((u.usteed && mon_visible(u.usteed)) ? ridden_mon_to_glyph(u.usteed) \
-                                         : (otherwise_self))
+#define maybe_display_usteed(otherwise_self)                            \
+    ((u.usteed && mon_visible(u.usteed))                                \
+     ? ridden_mon_to_glyph(u.usteed, rn2_on_display_rng)                \
+     : (otherwise_self))
 
 #define display_self() \
     show_glyph(u.ux, u.uy,                                                  \
-           maybe_display_usteed((youmonst.m_ap_type == M_AP_NOTHING)        \
+           maybe_display_usteed((U_AP_TYPE == M_AP_NOTHING)                 \
                                 ? hero_glyph                                \
-                                : (youmonst.m_ap_type == M_AP_FURNITURE)    \
+                                : (U_AP_TYPE == M_AP_FURNITURE)             \
                                   ? cmap_to_glyph(youmonst.mappearance)     \
-                                  : (youmonst.m_ap_type == M_AP_OBJECT)     \
+                                  : (U_AP_TYPE == M_AP_OBJECT)              \
                                     ? objnum_to_glyph(youmonst.mappearance) \
-                                    /* else M_AP_MONSTER */                 \
+                                    /* else U_AP_TYPE == M_AP_MONSTER */    \
                                     : monnum_to_glyph(youmonst.mappearance)))
 
 /*
  *
  * warning      A set of six representing the different warning levels.
  *
+ * statue       One for each monster.  Count: NUMMONS
+ *
  * The following are offsets used to convert to and from a glyph.
  */
 #define NUM_ZAP 8 /* number of zap beam types */
 #define GLYPH_INVISIBLE   GLYPH_INVIS_OFF
 
 #define warning_to_glyph(mwarnlev) ((mwarnlev) + GLYPH_WARNING_OFF)
-#define mon_to_glyph(mon) \
-    ((int) what_mon(monsndx((mon)->data)) + GLYPH_MON_OFF)
-#define detected_mon_to_glyph(mon) \
-    ((int) what_mon(monsndx((mon)->data)) + GLYPH_DETECT_OFF)
-#define ridden_mon_to_glyph(mon) \
-    ((int) what_mon(monsndx((mon)->data)) + GLYPH_RIDDEN_OFF)
-#define pet_to_glyph(mon) \
-    ((int) what_mon(monsndx((mon)->data)) + GLYPH_PET_OFF)
+#define mon_to_glyph(mon, rng)                                      \
+    ((int) what_mon(monsndx((mon)->data), rng) + GLYPH_MON_OFF)
+#define detected_mon_to_glyph(mon, rng)                             \
+    ((int) what_mon(monsndx((mon)->data), rng) + GLYPH_DETECT_OFF)
+#define ridden_mon_to_glyph(mon, rng)                               \
+    ((int) what_mon(monsndx((mon)->data), rng) + GLYPH_RIDDEN_OFF)
+#define pet_to_glyph(mon, rng)                                      \
+    ((int) what_mon(monsndx((mon)->data), rng) + GLYPH_PET_OFF)
 
 /* This has the unfortunate side effect of needing a global variable    */
 /* to store a result. 'otg_temp' is defined and declared in decl.{ch}.  */
-#define random_obj_to_glyph()                \
-    ((otg_temp = random_object()) == CORPSE  \
-         ? random_monster() + GLYPH_BODY_OFF \
+#define random_obj_to_glyph(rng)                \
+    ((otg_temp = random_object(rng)) == CORPSE  \
+         ? random_monster(rng) + GLYPH_BODY_OFF \
          : otg_temp + GLYPH_OBJ_OFF)
 
-#define obj_to_glyph(obj) \
+#define obj_to_glyph(obj, rng)                                          \
     (((obj)->otyp == STATUE)                                            \
-         ? statue_to_glyph(obj)                                         \
+         ? statue_to_glyph(obj, rng)                                    \
          : Hallucination                                                \
-               ? random_obj_to_glyph()                                  \
+               ? random_obj_to_glyph(rng)                               \
                : ((obj)->otyp == CORPSE)                                \
                      ? (int) (obj)->corpsenm + GLYPH_BODY_OFF           \
                      : (int) (obj)->otyp + GLYPH_OBJ_OFF)
 /* MRKR: Statues now have glyphs corresponding to the monster they    */
 /*       represent and look like monsters when you are hallucinating. */
 
-#define statue_to_glyph(obj)                          \
-    (Hallucination ? random_monster() + GLYPH_MON_OFF \
+#define statue_to_glyph(obj, rng)                              \
+    (Hallucination ? random_monster(rng) + GLYPH_MON_OFF       \
                    : (int) (obj)->corpsenm + GLYPH_STATUE_OFF)
 
 #define cmap_to_glyph(cmap_idx) ((int) (cmap_idx) + GLYPH_CMAP_OFF)
 #define explosion_to_glyph(expltype, idx) \
     ((((expltype) * MAXEXPCHARS) + ((idx) - S_explode1)) + GLYPH_EXPLODE_OFF)
 
-#define trap_to_glyph(trap) \
-    cmap_to_glyph(trap_to_defsym(what_trap((trap)->ttyp)))
+#define trap_to_glyph(trap, rng)                                \
+    cmap_to_glyph(trap_to_defsym(what_trap((trap)->ttyp, rng)))
 
 /* Not affected by hallucination.  Gives a generic body for CORPSE */
 /* MRKR: ...and the generic statue */