-/* NetHack 3.6 display.h $NHDT-Date: 1432512777 2015/05/25 00:12:57 $ $NHDT-Branch: master $:$NHDT-Revision: 1.24 $ */
+/* NetHack 3.6 display.h $NHDT-Date: 1447729027 2015/11/17 02:57:07 $ $NHDT-Branch: master $:$NHDT-Revision: 1.26 $ */
/* Copyright (c) Dean Luick, with acknowledgements to Kevin Darcy */
-/* and Dave Cohrs, 1990. */
+/* and Dave Cohrs, 1990. */
/* NetHack may be freely redistributed. See license for details. */
#ifndef DISPLAY_H
* Returns true if the hero can sense the given monster. This includes
* monsters that are hiding or mimicing other monsters.
*/
-#define tp_sensemon(mon) \
- (/* The hero can always sense a monster IF: */ \
- (!mindless(mon->data)) && /* 1. the monster has a brain to sense AND */ \
- ((Blind && Blind_telepat) \
- || /* 2a. hero is blind and telepathic OR */ /* 2b. hero is using a \
- telepathy inducing */ /* object and in range */ \
- (Unblind_telepat \
- && (distu(mon->mx, mon->my) <= (BOLT_LIM * BOLT_LIM)))))
+#define tp_sensemon(mon) \
+ (/* The hero can always sense a monster IF: */ \
+ /* 1. the monster has a brain to sense */ \
+ (!mindless(mon->data)) \
+ /* AND 2a. hero is blind and telepathic */ \
+ && ((Blind && Blind_telepat) \
+ /* OR 2b. hero is using a telepathy inducing */ \
+ /* object and in range */ \
+ || (Unblind_telepat \
+ && (distu(mon->mx, mon->my) <= (BOLT_LIM * BOLT_LIM)))))
#define sensemon(mon) \
(tp_sensemon(mon) || Detect_monsters || MATCH_WARN_OF_MON(mon))
* vobj_at() returns a pointer to an object that the hero can see there.
* Infravision is not taken into account.
*/
-#define mon_visible(mon) \
- (/* The hero can see the monster */ /* IF the monster */ \
- (!mon->minvis || See_invisible) && /* 1. is not invisible AND */ \
- (!mon->mundetected) && /* 2. not an undetected hider */ \
- (!(mon->mburied || u.uburied)) /* 3. neither you or it is buried */ \
- )
+#define mon_visible(mon) \
+ (/* The hero can see the monster IF the monster */ \
+ (!mon->minvis || See_invisible) /* 1. is not invisible */ \
+ && !mon->mundetected /* AND 2. not an undetected hider */ \
+ && !(mon->mburied || u.uburied)) /* AND 3. neither you nor it is buried */
/*
* see_with_infrared()
/* knowninvisible(mon)
* This one checks to see if you know a monster is both there and invisible.
* 1) If you can see the monster and have see invisible, it is assumed the
- * monster is transparent, but visible in some manner. (Earlier versions of
+ * monster is transparent, but visible in some manner. (Earlier versions of
* Nethack were really inconsistent on this.)
* 2) If you can't see the monster, but can see its location and you have
* telepathy that works when you can see, you can tell that there is a
/*
* is_safepet(mon)
*
- * A special case check used in attack() and domove(). Placing the
+ * A special case check used in attack() and domove(). Placing the
* definition here is convenient.
*/
#define is_safepet(mon) \
/*
* tmp_at() control calls.
*/
-#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_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. */
/* Total number of cmap indices in the shield_static[] array. */
((u.usteed && mon_visible(u.usteed)) ? ridden_mon_to_glyph(u.usteed) \
: (otherwise_self))
-#define display_self() \
- show_glyph(u.ux, u.uy, \
- maybe_display_usteed( \
- youmonst.m_ap_type == M_AP_NOTHING \
- ? hero_glyph \
- : youmonst.m_ap_type == M_AP_FURNITURE \
- ? cmap_to_glyph(youmonst.mappearance) \
- : youmonst.m_ap_type == M_AP_OBJECT \
- ? objnum_to_glyph(youmonst.mappearance) \
- : /* else M_AP_MONSTER */ \
- monnum_to_glyph(youmonst.mappearance)))
+#define display_self() \
+ show_glyph(u.ux, u.uy, \
+ maybe_display_usteed((youmonst.m_ap_type == M_AP_NOTHING) \
+ ? hero_glyph \
+ : (youmonst.m_ap_type == M_AP_FURNITURE) \
+ ? cmap_to_glyph(youmonst.mappearance) \
+ : (youmonst.m_ap_type == M_AP_OBJECT) \
+ ? objnum_to_glyph(youmonst.mappearance) \
+ /* else M_AP_MONSTER */ \
+ : monnum_to_glyph(youmonst.mappearance)))
/*
* A glyph is an abstraction that represents a _unique_ monster, object,
*
* Glyphs are grouped for easy accessibility:
*
- * monster Represents all the wild (not tame) monsters. Count: NUMMONS.
+ * monster Represents all the wild (not tame) monsters. Count: NUMMONS.
*
- * pet Represents all of the tame monsters. Count: NUMMONS
+ * pet Represents all of the tame monsters. Count: NUMMONS
*
- * invisible Invisible monster placeholder. Count: 1
+ * invisible Invisible monster placeholder. Count: 1
*
- * detect Represents all detected monsters. Count: NUMMONS
+ * detect Represents all detected monsters. Count: NUMMONS
*
- * corpse One for each monster. Count: NUMMONS
+ * corpse One for each monster. Count: NUMMONS
*
- * ridden Represents all monsters being ridden. Count: NUMMONS
+ * ridden Represents all monsters being ridden. Count: NUMMONS
*
- * object One for each object. Count: NUM_OBJECTS
+ * object One for each object. Count: NUM_OBJECTS
*
- * cmap One for each entry in the character map. The character map
- * is the dungeon features and other miscellaneous things.
- * Count: MAXPCHARS
+ * cmap One for each entry in the character map. The character map
+ * is the dungeon features and other miscellaneous things.
+ * Count: MAXPCHARS
*
- * explosions A set of nine for each of the following seven explosion types:
+ * explosions A set of nine for each of the following seven explosion types:
* dark, noxious, muddy, wet, magical, fiery, frosty.
* The nine positions represent those surrounding the hero.
- * Count: MAXEXPCHARS * EXPL_MAX (EXPL_MAX is defined in hack.h)
+ * Count: MAXEXPCHARS * EXPL_MAX (EXPL_MAX is defined in hack.h)
*
- * zap beam A set of four (there are four directions) for each beam type.
- * The beam type is shifted over 2 positions and the direction
- * is stored in the lower 2 bits. Count: NUM_ZAP << 2
+ * zap beam A set of four (there are four directions) for each beam type.
+ * The beam type is shifted over 2 positions and the direction
+ * is stored in the lower 2 bits. Count: NUM_ZAP << 2
*
- * swallow A set of eight for each monster. The eight positions rep-
- * resent those surrounding the hero. The monster number is
- * shifted over 3 positions and the swallow position is stored
- * in the lower three bits. Count: NUMMONS << 3
+ * swallow A set of eight for each monster. The eight positions rep-
+ * resent those surrounding the hero. The monster number is
+ * shifted over 3 positions and the swallow position is stored
+ * in the lower three bits. Count: NUMMONS << 3
*
- * warning A set of six representing the different warning levels.
+ * warning A set of six representing the different warning levels.
*
* The following are offsets used to convert to and from a glyph.
*/
#define NUM_ZAP 8 /* number of zap beam types */
-#define GLYPH_MON_OFF 0
-#define GLYPH_PET_OFF (NUMMONS + GLYPH_MON_OFF)
-#define GLYPH_INVIS_OFF (NUMMONS + GLYPH_PET_OFF)
-#define GLYPH_DETECT_OFF (1 + GLYPH_INVIS_OFF)
-#define GLYPH_BODY_OFF (NUMMONS + GLYPH_DETECT_OFF)
-#define GLYPH_RIDDEN_OFF (NUMMONS + GLYPH_BODY_OFF)
-#define GLYPH_OBJ_OFF (NUMMONS + GLYPH_RIDDEN_OFF)
-#define GLYPH_CMAP_OFF (NUM_OBJECTS + GLYPH_OBJ_OFF)
+#define GLYPH_MON_OFF 0
+#define GLYPH_PET_OFF (NUMMONS + GLYPH_MON_OFF)
+#define GLYPH_INVIS_OFF (NUMMONS + GLYPH_PET_OFF)
+#define GLYPH_DETECT_OFF (1 + GLYPH_INVIS_OFF)
+#define GLYPH_BODY_OFF (NUMMONS + GLYPH_DETECT_OFF)
+#define GLYPH_RIDDEN_OFF (NUMMONS + GLYPH_BODY_OFF)
+#define GLYPH_OBJ_OFF (NUMMONS + GLYPH_RIDDEN_OFF)
+#define GLYPH_CMAP_OFF (NUM_OBJECTS + GLYPH_OBJ_OFF)
#define GLYPH_EXPLODE_OFF ((MAXPCHARS - MAXEXPCHARS) + GLYPH_CMAP_OFF)
-#define GLYPH_ZAP_OFF ((MAXEXPCHARS * EXPL_MAX) + GLYPH_EXPLODE_OFF)
+#define GLYPH_ZAP_OFF ((MAXEXPCHARS * EXPL_MAX) + GLYPH_EXPLODE_OFF)
#define GLYPH_SWALLOW_OFF ((NUM_ZAP << 2) + GLYPH_ZAP_OFF)
#define GLYPH_WARNING_OFF ((NUMMONS << 3) + GLYPH_SWALLOW_OFF)
-#define GLYPH_STATUE_OFF (WARNCOUNT + GLYPH_WARNING_OFF)
-#define MAX_GLYPH (NUMMONS + GLYPH_STATUE_OFF)
+#define GLYPH_STATUE_OFF (WARNCOUNT + GLYPH_WARNING_OFF)
+#define MAX_GLYPH (NUMMONS + GLYPH_STATUE_OFF)
-#define NO_GLYPH MAX_GLYPH
-
-#define GLYPH_INVISIBLE GLYPH_INVIS_OFF
+#define NO_GLYPH MAX_GLYPH
+#define GLYPH_INVISIBLE GLYPH_INVIS_OFF
#define warning_to_glyph(mwarnlev) ((mwarnlev) + GLYPH_WARNING_OFF)
#define mon_to_glyph(mon) \
#define pet_to_glyph(mon) \
((int) what_mon(monsndx((mon)->data)) + 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}. */
+/* 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 \
: otg_temp + GLYPH_OBJ_OFF)
-#define obj_to_glyph(obj) \
- ((obj)->otyp == STATUE \
+#define obj_to_glyph(obj) \
+ (((obj)->otyp == STATUE) \
? statue_to_glyph(obj) \
- : Hallucination ? random_obj_to_glyph() \
- : (obj)->otyp == CORPSE \
- ? (int) (obj)->corpsenm + GLYPH_BODY_OFF \
- : (int) (obj)->otyp + GLYPH_OBJ_OFF)
+ : Hallucination \
+ ? random_obj_to_glyph() \
+ : ((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 */
-/* brepresent and look like monsters when you are hallucinating. */
+/* represent and look like monsters when you are hallucinating. */
#define statue_to_glyph(obj) \
(Hallucination ? random_monster() + GLYPH_MON_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)
+ ((((expltype) * MAXEXPCHARS) + ((idx) - S_explode1)) + GLYPH_EXPLODE_OFF)
#define trap_to_glyph(trap) \
cmap_to_glyph(trap_to_defsym(what_trap((trap)->ttyp)))
/*
* Change the given glyph into it's given type. Note:
- * 1) Pets, detected, and ridden monsters are animals and are converted
- * to the proper monster number.
- * 2) Bodies are all mapped into the generic CORPSE object
- * 3) If handed a glyph out of range for the type, these functions
- * will return NO_GLYPH (see exception below)
- * 4) glyph_to_swallow() does not return a showsyms[] index, but an
- * offset from the first swallow symbol. If handed something
- * out of range, it will return zero (for lack of anything better
- * to return).
+ * 1) Pets, detected, and ridden monsters are animals and are converted
+ * to the proper monster number.
+ * 2) Bodies are all mapped into the generic CORPSE object
+ * 3) If handed a glyph out of range for the type, these functions
+ * will return NO_GLYPH (see exception below)
+ * 4) glyph_to_swallow() does not return a showsyms[] index, but an
+ * offset from the first swallow symbol. If handed something
+ * out of range, it will return zero (for lack of anything better
+ * to return).
*/
-#define glyph_to_mon(glyph) \
- (glyph_is_normal_monster(glyph) \
- ? ((glyph) -GLYPH_MON_OFF) \
- : glyph_is_pet(glyph) \
- ? ((glyph) -GLYPH_PET_OFF) \
- : glyph_is_detected_monster(glyph) \
- ? ((glyph) -GLYPH_DETECT_OFF) \
- : glyph_is_ridden_monster(glyph) \
- ? ((glyph) -GLYPH_RIDDEN_OFF) \
- : glyph_is_statue(glyph) \
- ? ((glyph) -GLYPH_STATUE_OFF) \
+#define glyph_to_mon(glyph) \
+ (glyph_is_normal_monster(glyph) \
+ ? ((glyph) - GLYPH_MON_OFF) \
+ : glyph_is_pet(glyph) \
+ ? ((glyph) - GLYPH_PET_OFF) \
+ : glyph_is_detected_monster(glyph) \
+ ? ((glyph) - GLYPH_DETECT_OFF) \
+ : glyph_is_ridden_monster(glyph) \
+ ? ((glyph) - GLYPH_RIDDEN_OFF) \
+ : glyph_is_statue(glyph) \
+ ? ((glyph) - GLYPH_STATUE_OFF) \
: NO_GLYPH)
-#define glyph_to_obj(glyph) \
- (glyph_is_body(glyph) ? CORPSE : glyph_is_statue(glyph) \
- ? STATUE \
- : glyph_is_normal_object(glyph) \
- ? ((glyph) -GLYPH_OBJ_OFF) \
- : NO_GLYPH)
-#define glyph_to_trap(glyph) \
- (glyph_is_trap(glyph) ? ((int) defsym_to_trap((glyph) -GLYPH_CMAP_OFF)) \
+#define glyph_to_obj(glyph) \
+ (glyph_is_body(glyph) \
+ ? CORPSE \
+ : glyph_is_statue(glyph) \
+ ? STATUE \
+ : glyph_is_normal_object(glyph) \
+ ? ((glyph) - GLYPH_OBJ_OFF) \
+ : NO_GLYPH)
+#define glyph_to_trap(glyph) \
+ (glyph_is_trap(glyph) ? ((int) defsym_to_trap((glyph) - GLYPH_CMAP_OFF)) \
: NO_GLYPH)
#define glyph_to_cmap(glyph) \
- (glyph_is_cmap(glyph) ? ((glyph) -GLYPH_CMAP_OFF) : NO_GLYPH)
+ (glyph_is_cmap(glyph) ? ((glyph) - GLYPH_CMAP_OFF) : NO_GLYPH)
#define glyph_to_swallow(glyph) \
- (glyph_is_swallow(glyph) ? (((glyph) -GLYPH_SWALLOW_OFF) & 0x7) : 0)
+ (glyph_is_swallow(glyph) ? (((glyph) - GLYPH_SWALLOW_OFF) & 0x7) : 0)
#define glyph_to_warning(glyph) \
- (glyph_is_warning(glyph) ? ((glyph) -GLYPH_WARNING_OFF) : NO_GLYPH);
+ (glyph_is_warning(glyph) ? ((glyph) - GLYPH_WARNING_OFF) : NO_GLYPH);
/*
* Return true if the given glyph is what we want. Note that bodies are