displaying generic objects

Add 17 fake objects to objects[], one for each object class.  All
specific color as gray.  They're grouped at the start--actually near
the start since "strange object" is still objects[0]--rather than
being among the objects for each class.  init_object() knows to start
at [MAXOCLASSES] instead of [0]; other code that loops through every
object might need adjusting.

For potions, non-stone gems, and non-novel/non-Book_of_the_Dead
spellbooks that don't have obj->dknown set, display the corresponding
generic object rather the object itself.  Fixes the longstanding bug
of seeing color for not-yet-seen objects whose primary distinguishing
characteristic is their color.  Walking next to a generic object
while able to see its spot will set dknown and redraw as specific.
It's slightly disconcerting to have objects change as you reach them;
I hope it's just a matter of becoming used to that.  (If there is any
code still changing the hero's location manually instead of using
u_on_newpos(), it should be changed to use that routine.)

Most of the new tiles are just a big rendering of punctuation
characters.  The potion, gem, and spellbook ones could be cloned from
a specific object in their class and then have the color removed.  I
started out that way but wasn't happy with the result.  I'm not
artisticly inclined; hopefully someone else will do better.  Each of
them is preceded by a comment beginning with "#_"; the underscore
isn't required, just being used to make the comments stand out a bit.

Invalidates existing save and bones files.
This commit is contained in:
PatR
2023-01-10 14:33:21 -08:00
parent 3f3c581f65
commit 85c908cb03
13 changed files with 994 additions and 529 deletions

View File

@@ -388,7 +388,15 @@ enum glyphmap_change_triggers { gm_nochange, gm_newgame, gm_levelchange,
* ridden (female) Represents all female monsters being ridden.
* Count: NUMMONS
*
* object One for each object.
* object One for each type of object. The first entry is
* 'strange object', the next 1..MAXOCLASSES-1 entries
* are generic (one for each class, including one for
* strange object's 'illobj class'), the rest are
* regular objects. Some members of the generic
* subset are used to prevent color of potions, gems,
* and spellbooks from being revealed when obj->dknown
* hasn't been set, avoiding a bug which had been
* present since day one of color support.
* Count: NUM_OBJECTS
*
* Stone Stone
@@ -451,7 +459,8 @@ enum glyphmap_change_triggers { gm_nochange, gm_newgame, gm_levelchange,
* frosty explosions A set of nine.
* Count: MAXEXPCHAR
*
* warning A set of six representing the different warning levels.
* warning A set of six representing the different warning
* levels.
* Count: 6
*
* statues (male) One for each male monster.
@@ -749,7 +758,8 @@ enum glyph_offsets {
#define glyph_is_normal_female_monster(glyph) \
((glyph) >= GLYPH_MON_FEM_OFF && (glyph) < (GLYPH_MON_FEM_OFF + NUMMONS))
#define glyph_is_normal_monster(glyph) \
(glyph_is_normal_male_monster(glyph) || glyph_is_normal_female_monster(glyph))
(glyph_is_normal_male_monster(glyph) \
|| glyph_is_normal_female_monster(glyph))
#define glyph_is_female_pet(glyph) \
((glyph) >= GLYPH_PET_FEM_OFF && (glyph) < (GLYPH_PET_FEM_OFF + NUMMONS))
#define glyph_is_male_pet(glyph) \
@@ -799,10 +809,23 @@ enum glyph_offsets {
? ((glyph) - GLYPH_RIDDEN_MALE_OFF) \
: NUMMONS)
/* boulder hides pile except when on top of another boulder;
the otg_otmp assignment might occur multiple times in the same
expression but there will always be sequence points in between */
#define obj_is_piletop(obj) \
((obj)->where == OBJ_FLOOR \
/*&& gl.level.objects[(obj)->ox][(obj)->oy]*/ \
&& gl.level.objects[(obj)->ox][(obj)->oy]->nexthere)
&& (go.otg_otmp = gl.level.objects[(obj)->ox][(obj)->oy]->nexthere) != 0 \
&& ((obj)->otyp != BOULDER || go.otg_otmp->otyp == BOULDER))
/* used to hide info such as potion and gem color when not seen yet;
stones and rock are excluded for gem class; LAST_SPELL includes blank
spellbook but excludes novel and the Book of the Dead */
#define obj_is_generic(obj) \
(!(obj)->dknown \
&& ((obj)->oclass == POTION_CLASS \
|| ((obj)->otyp >= FIRST_REAL_GEM \
&& ((obj)->otyp <= LAST_GLASS_GEM)) \
|| ((obj)->otyp >= FIRST_SPELL \
&& ((obj)->otyp <= LAST_SPELL))))
#define glyph_is_body_piletop(glyph) \
(((glyph) >= GLYPH_BODY_PILETOP_OFF) \
@@ -827,17 +850,31 @@ enum glyph_offsets {
|| glyph_is_male_statue_piletop(glyph))
#define glyph_is_statue(glyph) \
(glyph_is_male_statue(glyph) || glyph_is_fem_statue(glyph))
/* note: 'strange object' gets [mis?]classified as generic here but that
shouldn't impact anything; to do it properly, glyph_is_normal_generic_obj()
and glyph_is_piletop_generic_obj() should use '>' rather than '>=', and
glyph_is_normal_object() and glyph_is_normal_piletop_obj() should include
(glyph == {GLYPH_OBJ_OFF,GLYPH_OBJ_PILETOP_OFF}) to test for object #0 */
#define glyph_is_normal_generic_obj(glyph) \
((glyph) >= GLYPH_OBJ_OFF && (glyph) < GLYPH_OBJ_OFF + MAXOCLASSES)
#define glyph_is_piletop_generic_obj(glyph) \
((glyph) >= GLYPH_OBJ_PILETOP_OFF \
&& (glyph) < GLYPH_OBJ_PILETOP_OFF + MAXOCLASSES)
#define glyph_is_generic_object(glyph) \
(glyph_is_normal_generic_obj(glyph) \
|| glyph_is_piletop_generic_obj(glyph))
#define glyph_is_normal_piletop_obj(glyph) \
(((glyph) >= GLYPH_OBJ_PILETOP_OFF) \
(((glyph) >= GLYPH_OBJ_PILETOP_OFF + MAXOCLASSES) \
&& ((glyph) < (GLYPH_OBJ_PILETOP_OFF + NUM_OBJECTS)))
#define glyph_is_normal_object(glyph) \
((((glyph) >= GLYPH_OBJ_OFF) \
((((glyph) >= GLYPH_OBJ_OFF + MAXOCLASSES) \
&& ((glyph) < (GLYPH_OBJ_OFF + NUM_OBJECTS))) \
|| glyph_is_normal_piletop_obj(glyph))
#if 0
#if 0 /* [note: out of date] */
#define glyph_is_object(glyph) \
((((glyph) >= GLYPH_OBJ_OFF) && ((glyph) < (GLYPH_OBJ_OFF + NUM_OBJECTS))) \
( (((glyph) >= GLYPH_OBJ_OFF) \
&& ((glyph) < (GLYPH_OBJ_OFF + NUM_OBJECTS))) \
|| (((glyph) >= GLYPH_OBJ_PILETOP_OFF) \
&& ((glyph) < (GLYPH_OBJ_PILETOP_OFF + NUM_OBJECTS))) \
|| (((glyph) >= GLYPH_STATUE_MALE_OFF) \
@@ -851,15 +888,16 @@ enum glyph_offsets {
|| (((glyph) >= GLYPH_BODY_OFF) \
&& ((glyph) < (GLYPH_BODY_OFF + NUMMONS))) \
|| (((glyph) >= GLYPH_BODY_PILETOP_OFF) \
&& ((glyph) < (GLYPH_BODY_PILETOP_OFF + NUMMONS))))
&& ((glyph) < (GLYPH_BODY_PILETOP_OFF + NUMMONS))) \
)
#endif
#define glyph_is_object(glyph) \
(glyph_is_normal_object(glyph) || glyph_is_statue(glyph) \
|| glyph_is_body(glyph))
(glyph_is_normal_object(glyph) || glyph_is_generic_object(glyph) \
|| glyph_is_statue(glyph) || glyph_is_body(glyph))
/* briefly used for Qt's "paper doll" inventory which shows map tiles for
equipped objects; those vary like floor items during hallucination now
so this isn't used anywhere */
so this isn't used anywhere [note: out of date since generic objs added] */
#define obj_to_true_glyph(obj) \
(((obj)->otyp == STATUE) \
? ((int) (obj)->corpsenm \
@@ -881,10 +919,14 @@ enum glyph_offsets {
#define glyph_to_obj(glyph) \
(glyph_is_body(glyph) ? CORPSE \
: glyph_is_statue(glyph) ? STATUE \
: glyph_is_normal_object(glyph) \
: glyph_is_generic_object(glyph) \
? ((glyph) - (glyph_is_piletop_generic_obj(glyph) \
? GLYPH_OBJ_PILETOP_OFF \
: GLYPH_OBJ_OFF)) \
: glyph_is_normal_object(glyph) \
? ((glyph) - (glyph_is_normal_piletop_obj(glyph) \
? GLYPH_OBJ_PILETOP_OFF \
: GLYPH_OBJ_OFF)) \
? GLYPH_OBJ_PILETOP_OFF \
: GLYPH_OBJ_OFF)) \
: NUM_OBJECTS)
#define glyph_to_body_corpsenm(glyph) \
@@ -903,27 +945,21 @@ enum glyph_offsets {
? ((glyph) - GLYPH_STATUE_MALE_OFF) \
: NO_GLYPH)
/* These have 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(rng) \
((go.otg_temp = random_object(rng)) == CORPSE \
(((go.otg_temp = random_object(rng)) == CORPSE) \
? (random_monster(rng) + GLYPH_BODY_OFF) \
: (go.otg_temp + GLYPH_OBJ_OFF))
#define corpse_to_glyph(obj) \
((int) ((obj)->corpsenm + (obj_is_piletop(obj) \
? GLYPH_BODY_PILETOP_OFF \
: GLYPH_BODY_OFF)))
/* Paraphrased rationale from the original commit for the boulder
exception: If a boulder is the topmost item on a pile, then it is
not mapped to a piletop glyph; mainly because boulders are "solid";
boulders dropped by monsters are nearly always over other objects;
also done so that special levels such a Sokoban can "hide" items
under the boulders. */
((int) ((obj)->corpsenm \
+ (obj_is_piletop(obj) ? GLYPH_BODY_PILETOP_OFF : GLYPH_BODY_OFF)))
#define generic_obj_to_glyph(obj) \
((int) ((obj)->oclass \
+ (obj_is_piletop(obj) ? GLYPH_OBJ_PILETOP_OFF : GLYPH_OBJ_OFF)))
#define normal_obj_to_glyph(obj) \
((int) ((obj)->otyp + ((obj_is_piletop(obj) && ((obj)->otyp != BOULDER)) \
? GLYPH_OBJ_PILETOP_OFF \
: GLYPH_OBJ_OFF)))
((int) ((obj)->otyp \
+ (obj_is_piletop(obj) ? GLYPH_OBJ_PILETOP_OFF : GLYPH_OBJ_OFF)))
/* MRKR: Statues now have glyphs corresponding to the monster they */
/* represent and look like monsters when you are hallucinating. */
@@ -942,13 +978,11 @@ enum glyph_offsets {
: GLYPH_STATUE_MALE_OFF))))
#define obj_to_glyph(obj, rng) \
(((obj)->otyp == STATUE) \
? statue_to_glyph(obj, rng) \
: ((Hallucination) \
? random_obj_to_glyph(rng) \
: (((obj)->otyp == CORPSE) \
? corpse_to_glyph(obj) \
: normal_obj_to_glyph(obj))))
(((obj)->otyp == STATUE) ? statue_to_glyph(obj, rng) \
: (Hallucination) ? random_obj_to_glyph(rng) \
: ((obj)->otyp == CORPSE) ? corpse_to_glyph(obj) \
: obj_is_generic(obj) ? generic_obj_to_glyph(obj) \
: normal_obj_to_glyph(obj))
#define GLYPH_TRAP_OFF \
(GLYPH_CMAP_B_OFF + (S_arrow_trap - S_grave))
@@ -963,8 +997,10 @@ enum glyph_offsets {
#if 0
#define glyph_is_piletop(glyph) \
(glyph_is_body_piletop(glyph) || glyph_is_statue_piletop(glyph) \
|| glyph_is_obj_piletop(glyph))
(glyph_is_body_piletop(glyph) \
|| glyph_is_statue_piletop(glyph) \
|| glyph_is_piletop_generic_obj(glyph) \
|| glyph_is_obj_piletop(glyph))
#endif
/* mgflags for altering map_glyphinfo() internal behavior */