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

@@ -31,8 +31,10 @@ shuffle_tiles(void)
short tmp_tilemap[2][NUM_OBJECTS];
for (i = 0; i < NUM_OBJECTS; i++) {
tmp_tilemap[0][i] = glyphmap[objects[i].oc_descr_idx + GLYPH_OBJ_OFF].tileidx;
tmp_tilemap[1][i] = glyphmap[objects[i].oc_descr_idx + GLYPH_OBJ_PILETOP_OFF].tileidx;
tmp_tilemap[0][i] = glyphmap[objects[i].oc_descr_idx
+ GLYPH_OBJ_OFF].tileidx;
tmp_tilemap[1][i] = glyphmap[objects[i].oc_descr_idx
+ GLYPH_OBJ_PILETOP_OFF].tileidx;
}
for (i = 0; i < NUM_OBJECTS; i++) {
glyphmap[i + GLYPH_OBJ_OFF].tileidx = tmp_tilemap[0][i];
@@ -122,17 +124,19 @@ init_objects(void)
#define COPY_OBJ_DESCR(o_dst, o_src) o_dst.oc_descr_idx = o_src.oc_descr_idx
#endif
/* bug fix to prevent "initialization error" abort on Intel Xenix.
* reported by mikew@semike
*/
for (i = 0; i <= MAXOCLASSES; i++)
for (i = 0; i <= MAXOCLASSES; i++) {
gb.bases[i] = 0;
if (i > 0 && i < MAXOCLASSES && objects[i].oc_class != i)
panic(
"init_objects: class for generic object #%d doesn't match (%d)",
i, objects[i].oc_class);
}
/* initialize object descriptions */
for (i = 0; i < NUM_OBJECTS; i++)
objects[i].oc_name_idx = objects[i].oc_descr_idx = i;
/* init base; if probs given check that they add up to 1000,
otherwise compute probs */
first = 0;
first = MAXOCLASSES;
prevoclass = -1;
while (first < NUM_OBJECTS) {
oclass = objects[first].oc_class;
@@ -188,7 +192,7 @@ init_objects(void)
gb.bases[last] = gb.bases[last + 1];
/* check objects[].oc_name_known */
for (i = 0; i < NUM_OBJECTS; ++i) {
for (i = MAXOCLASSES; i < NUM_OBJECTS; ++i) {
int nmkn = objects[i].oc_name_known != 0;
if (!OBJ_DESCR(objects[i]) ^ nmkn) {