display.h reformatting

A couple of macros with comments in the midst of their expansions got
badly mangled by the automated reformat and one ended up with a line
that was over 150 characters wide.
This commit is contained in:
PatR
2015-11-16 18:57:11 -08:00
parent fa8ac8a2ce
commit 1f3253541a
+112 -111
View File
@@ -1,6 +1,6 @@
/* 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 */ /* 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. */ /* NetHack may be freely redistributed. See license for details. */
#ifndef DISPLAY_H #ifndef DISPLAY_H
@@ -27,14 +27,16 @@
* Returns true if the hero can sense the given monster. This includes * Returns true if the hero can sense the given monster. This includes
* monsters that are hiding or mimicing other monsters. * monsters that are hiding or mimicing other monsters.
*/ */
#define tp_sensemon(mon) \ #define tp_sensemon(mon) \
(/* The hero can always sense a monster IF: */ \ (/* The hero can always sense a monster IF: */ \
(!mindless(mon->data)) && /* 1. the monster has a brain to sense AND */ \ /* 1. the monster has a brain to sense */ \
((Blind && Blind_telepat) \ (!mindless(mon->data)) \
|| /* 2a. hero is blind and telepathic OR */ /* 2b. hero is using a \ /* AND 2a. hero is blind and telepathic */ \
telepathy inducing */ /* object and in range */ \ && ((Blind && Blind_telepat) \
(Unblind_telepat \ /* OR 2b. hero is using a telepathy inducing */ \
&& (distu(mon->mx, mon->my) <= (BOLT_LIM * BOLT_LIM))))) /* object and in range */ \
|| (Unblind_telepat \
&& (distu(mon->mx, mon->my) <= (BOLT_LIM * BOLT_LIM)))))
#define sensemon(mon) \ #define sensemon(mon) \
(tp_sensemon(mon) || Detect_monsters || MATCH_WARN_OF_MON(mon)) (tp_sensemon(mon) || Detect_monsters || MATCH_WARN_OF_MON(mon))
@@ -56,12 +58,11 @@
* vobj_at() returns a pointer to an object that the hero can see there. * vobj_at() returns a pointer to an object that the hero can see there.
* Infravision is not taken into account. * Infravision is not taken into account.
*/ */
#define mon_visible(mon) \ #define mon_visible(mon) \
(/* The hero can see the monster */ /* IF the monster */ \ (/* The hero can see the monster IF the monster */ \
(!mon->minvis || See_invisible) && /* 1. is not invisible AND */ \ (!mon->minvis || See_invisible) /* 1. is not invisible */ \
(!mon->mundetected) && /* 2. not an undetected hider */ \ && !mon->mundetected /* AND 2. not an undetected hider */ \
(!(mon->mburied || u.uburied)) /* 3. neither you or it is buried */ \ && !(mon->mburied || u.uburied)) /* AND 3. neither you nor it is buried */
)
/* /*
* see_with_infrared() * see_with_infrared()
@@ -99,7 +100,7 @@
/* knowninvisible(mon) /* knowninvisible(mon)
* This one checks to see if you know a monster is both there and invisible. * 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 * 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.) * Nethack were really inconsistent on this.)
* 2) If you can't see the monster, but can see its location and you have * 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 * telepathy that works when you can see, you can tell that there is a
@@ -116,7 +117,7 @@
/* /*
* is_safepet(mon) * 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. * definition here is convenient.
*/ */
#define is_safepet(mon) \ #define is_safepet(mon) \
@@ -176,13 +177,12 @@
/* /*
* tmp_at() control calls. * tmp_at() control calls.
*/ */
#define DISP_BEAM (-1) /* Keep all glyphs showing & clean up at end. */ #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_ALL (-2) /* Like beam, but still displayed if not visible. */
#define DISP_FLASH (-3) /* Clean up each glyph before displaying new one. */ #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_ALWAYS (-4) /* Like flash, but still displayed if not visible. */
*/ #define DISP_CHANGE (-5) /* Change glyph. */
#define DISP_CHANGE (-5) /* Change glyph. */ #define DISP_END (-6) /* Clean up. */
#define DISP_END (-6) /* Clean up. */
#define DISP_FREEMEM (-7) /* Free all memory during exit only. */ #define DISP_FREEMEM (-7) /* Free all memory during exit only. */
/* Total number of cmap indices in the shield_static[] array. */ /* Total number of cmap indices in the shield_static[] array. */
@@ -198,17 +198,16 @@
((u.usteed && mon_visible(u.usteed)) ? ridden_mon_to_glyph(u.usteed) \ ((u.usteed && mon_visible(u.usteed)) ? ridden_mon_to_glyph(u.usteed) \
: (otherwise_self)) : (otherwise_self))
#define display_self() \ #define display_self() \
show_glyph(u.ux, u.uy, \ show_glyph(u.ux, u.uy, \
maybe_display_usteed( \ maybe_display_usteed((youmonst.m_ap_type == M_AP_NOTHING) \
youmonst.m_ap_type == M_AP_NOTHING \ ? hero_glyph \
? hero_glyph \ : (youmonst.m_ap_type == M_AP_FURNITURE) \
: youmonst.m_ap_type == M_AP_FURNITURE \ ? cmap_to_glyph(youmonst.mappearance) \
? cmap_to_glyph(youmonst.mappearance) \ : (youmonst.m_ap_type == M_AP_OBJECT) \
: youmonst.m_ap_type == M_AP_OBJECT \ ? objnum_to_glyph(youmonst.mappearance) \
? objnum_to_glyph(youmonst.mappearance) \ /* else M_AP_MONSTER */ \
: /* else M_AP_MONSTER */ \ : monnum_to_glyph(youmonst.mappearance)))
monnum_to_glyph(youmonst.mappearance)))
/* /*
* A glyph is an abstraction that represents a _unique_ monster, object, * A glyph is an abstraction that represents a _unique_ monster, object,
@@ -222,62 +221,61 @@
* *
* Glyphs are grouped for easy accessibility: * 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 * cmap One for each entry in the character map. The character map
* is the dungeon features and other miscellaneous things. * is the dungeon features and other miscellaneous things.
* Count: MAXPCHARS * 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. * dark, noxious, muddy, wet, magical, fiery, frosty.
* The nine positions represent those surrounding the hero. * 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. * 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 * The beam type is shifted over 2 positions and the direction
* is stored in the lower 2 bits. Count: NUM_ZAP << 2 * is stored in the lower 2 bits. Count: NUM_ZAP << 2
* *
* swallow A set of eight for each monster. The eight positions rep- * swallow A set of eight for each monster. The eight positions rep-
* resent those surrounding the hero. The monster number is * resent those surrounding the hero. The monster number is
* shifted over 3 positions and the swallow position is stored * shifted over 3 positions and the swallow position is stored
* in the lower three bits. Count: NUMMONS << 3 * 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. * The following are offsets used to convert to and from a glyph.
*/ */
#define NUM_ZAP 8 /* number of zap beam types */ #define NUM_ZAP 8 /* number of zap beam types */
#define GLYPH_MON_OFF 0 #define GLYPH_MON_OFF 0
#define GLYPH_PET_OFF (NUMMONS + GLYPH_MON_OFF) #define GLYPH_PET_OFF (NUMMONS + GLYPH_MON_OFF)
#define GLYPH_INVIS_OFF (NUMMONS + GLYPH_PET_OFF) #define GLYPH_INVIS_OFF (NUMMONS + GLYPH_PET_OFF)
#define GLYPH_DETECT_OFF (1 + GLYPH_INVIS_OFF) #define GLYPH_DETECT_OFF (1 + GLYPH_INVIS_OFF)
#define GLYPH_BODY_OFF (NUMMONS + GLYPH_DETECT_OFF) #define GLYPH_BODY_OFF (NUMMONS + GLYPH_DETECT_OFF)
#define GLYPH_RIDDEN_OFF (NUMMONS + GLYPH_BODY_OFF) #define GLYPH_RIDDEN_OFF (NUMMONS + GLYPH_BODY_OFF)
#define GLYPH_OBJ_OFF (NUMMONS + GLYPH_RIDDEN_OFF) #define GLYPH_OBJ_OFF (NUMMONS + GLYPH_RIDDEN_OFF)
#define GLYPH_CMAP_OFF (NUM_OBJECTS + GLYPH_OBJ_OFF) #define GLYPH_CMAP_OFF (NUM_OBJECTS + GLYPH_OBJ_OFF)
#define GLYPH_EXPLODE_OFF ((MAXPCHARS - MAXEXPCHARS) + GLYPH_CMAP_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_SWALLOW_OFF ((NUM_ZAP << 2) + GLYPH_ZAP_OFF)
#define GLYPH_WARNING_OFF ((NUMMONS << 3) + GLYPH_SWALLOW_OFF) #define GLYPH_WARNING_OFF ((NUMMONS << 3) + GLYPH_SWALLOW_OFF)
#define GLYPH_STATUE_OFF (WARNCOUNT + GLYPH_WARNING_OFF) #define GLYPH_STATUE_OFF (WARNCOUNT + GLYPH_WARNING_OFF)
#define MAX_GLYPH (NUMMONS + GLYPH_STATUE_OFF) #define MAX_GLYPH (NUMMONS + GLYPH_STATUE_OFF)
#define NO_GLYPH MAX_GLYPH #define NO_GLYPH MAX_GLYPH
#define GLYPH_INVISIBLE GLYPH_INVIS_OFF
#define GLYPH_INVISIBLE GLYPH_INVIS_OFF
#define warning_to_glyph(mwarnlev) ((mwarnlev) + GLYPH_WARNING_OFF) #define warning_to_glyph(mwarnlev) ((mwarnlev) + GLYPH_WARNING_OFF)
#define mon_to_glyph(mon) \ #define mon_to_glyph(mon) \
@@ -289,23 +287,24 @@
#define pet_to_glyph(mon) \ #define pet_to_glyph(mon) \
((int) what_mon(monsndx((mon)->data)) + GLYPH_PET_OFF) ((int) what_mon(monsndx((mon)->data)) + GLYPH_PET_OFF)
/* This has the unfortunate side effect of needing a global variable */ /* This has the unfortunate side effect of needing a global variable */
/* to store a result. 'otg_temp' is defined and declared in decl.{ch}. */ /* to store a result. 'otg_temp' is defined and declared in decl.{ch}. */
#define random_obj_to_glyph() \ #define random_obj_to_glyph() \
((otg_temp = random_object()) == CORPSE \ ((otg_temp = random_object()) == CORPSE \
? random_monster() + GLYPH_BODY_OFF \ ? random_monster() + GLYPH_BODY_OFF \
: otg_temp + GLYPH_OBJ_OFF) : otg_temp + GLYPH_OBJ_OFF)
#define obj_to_glyph(obj) \ #define obj_to_glyph(obj) \
((obj)->otyp == STATUE \ (((obj)->otyp == STATUE) \
? statue_to_glyph(obj) \ ? statue_to_glyph(obj) \
: Hallucination ? random_obj_to_glyph() \ : Hallucination \
: (obj)->otyp == CORPSE \ ? random_obj_to_glyph() \
? (int) (obj)->corpsenm + GLYPH_BODY_OFF \ : ((obj)->otyp == CORPSE) \
: (int) (obj)->otyp + GLYPH_OBJ_OFF) ? (int) (obj)->corpsenm + GLYPH_BODY_OFF \
: (int) (obj)->otyp + GLYPH_OBJ_OFF)
/* MRKR: Statues now have glyphs corresponding to the monster they */ /* 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) \ #define statue_to_glyph(obj) \
(Hallucination ? random_monster() + GLYPH_MON_OFF \ (Hallucination ? random_monster() + GLYPH_MON_OFF \
@@ -313,7 +312,7 @@
#define cmap_to_glyph(cmap_idx) ((int) (cmap_idx) + GLYPH_CMAP_OFF) #define cmap_to_glyph(cmap_idx) ((int) (cmap_idx) + GLYPH_CMAP_OFF)
#define explosion_to_glyph(expltype, idx) \ #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) \ #define trap_to_glyph(trap) \
cmap_to_glyph(trap_to_defsym(what_trap((trap)->ttyp))) cmap_to_glyph(trap_to_defsym(what_trap((trap)->ttyp)))
@@ -337,43 +336,45 @@
/* /*
* Change the given glyph into it's given type. Note: * Change the given glyph into it's given type. Note:
* 1) Pets, detected, and ridden monsters are animals and are converted * 1) Pets, detected, and ridden monsters are animals and are converted
* to the proper monster number. * to the proper monster number.
* 2) Bodies are all mapped into the generic CORPSE object * 2) Bodies are all mapped into the generic CORPSE object
* 3) If handed a glyph out of range for the type, these functions * 3) If handed a glyph out of range for the type, these functions
* will return NO_GLYPH (see exception below) * will return NO_GLYPH (see exception below)
* 4) glyph_to_swallow() does not return a showsyms[] index, but an * 4) glyph_to_swallow() does not return a showsyms[] index, but an
* offset from the first swallow symbol. If handed something * offset from the first swallow symbol. If handed something
* out of range, it will return zero (for lack of anything better * out of range, it will return zero (for lack of anything better
* to return). * to return).
*/ */
#define glyph_to_mon(glyph) \ #define glyph_to_mon(glyph) \
(glyph_is_normal_monster(glyph) \ (glyph_is_normal_monster(glyph) \
? ((glyph) -GLYPH_MON_OFF) \ ? ((glyph) - GLYPH_MON_OFF) \
: glyph_is_pet(glyph) \ : glyph_is_pet(glyph) \
? ((glyph) -GLYPH_PET_OFF) \ ? ((glyph) - GLYPH_PET_OFF) \
: glyph_is_detected_monster(glyph) \ : glyph_is_detected_monster(glyph) \
? ((glyph) -GLYPH_DETECT_OFF) \ ? ((glyph) - GLYPH_DETECT_OFF) \
: glyph_is_ridden_monster(glyph) \ : glyph_is_ridden_monster(glyph) \
? ((glyph) -GLYPH_RIDDEN_OFF) \ ? ((glyph) - GLYPH_RIDDEN_OFF) \
: glyph_is_statue(glyph) \ : glyph_is_statue(glyph) \
? ((glyph) -GLYPH_STATUE_OFF) \ ? ((glyph) - GLYPH_STATUE_OFF) \
: NO_GLYPH) : NO_GLYPH)
#define glyph_to_obj(glyph) \ #define glyph_to_obj(glyph) \
(glyph_is_body(glyph) ? CORPSE : glyph_is_statue(glyph) \ (glyph_is_body(glyph) \
? STATUE \ ? CORPSE \
: glyph_is_normal_object(glyph) \ : glyph_is_statue(glyph) \
? ((glyph) -GLYPH_OBJ_OFF) \ ? STATUE \
: NO_GLYPH) : glyph_is_normal_object(glyph) \
#define glyph_to_trap(glyph) \ ? ((glyph) - GLYPH_OBJ_OFF) \
(glyph_is_trap(glyph) ? ((int) defsym_to_trap((glyph) -GLYPH_CMAP_OFF)) \ : NO_GLYPH)
#define glyph_to_trap(glyph) \
(glyph_is_trap(glyph) ? ((int) defsym_to_trap((glyph) - GLYPH_CMAP_OFF)) \
: NO_GLYPH) : NO_GLYPH)
#define glyph_to_cmap(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) \ #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) \ #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 * Return true if the given glyph is what we want. Note that bodies are