header files sym.h and defsym.h

There were multiple symbol-related lists that had to be kept
in sync in various places.

Consolidate some of that into a single new file
    defsym.h
with a set of morphing macros that can be custom-called from
the various places that use the sym info without maintaining
multiple occurrences. Most maintenance can be done there.

Rename monsym.h to sym.h since it looks after some
symbols not related to monsters now too.

The defsym.h header file is included in multiple places to
produce different code depending on its use and the controlling
macro definitions in place prior to including it.

Its purpose is to have a definitive source for
pchar, objclass and mon symbol maintenance.

The controlling macros used to morph the resulting code are
used in these places:
  - in include/sym.h for enums of some S_ symbol values
    (define PCHAR_ENUM, MONSYMS_ENUM prior to #include defsym.h)
  - in include/objclass.h for enums of some S_ symbol values
    (define OBJCLASS_ENUM prior to #include defsym.h)
  - in src/symbols.c for parsing S_ entries in config files
    (define PCHAR_PARSE, MONSYMS_PARSE, OBJCLASS_PARSE prior
    to #include defsym.h)
  - in src/drawing.c for initializing some data structures/arrays
    (define PCHAR_DRAWING, MONSYMS_DRAWING, OBJCLASS_DRAWING prior
    to #include defsym.h)
  - in win/share/tilemap.c for processing a tile file
    (define PCHAR_TILES prior to #include defsym.h).
This commit is contained in:
nhmall
2021-08-08 12:29:46 -04:00
parent f5b617eaca
commit 2baadd6a29
28 changed files with 747 additions and 955 deletions

View File

@@ -106,218 +106,6 @@ enum levl_typ_types {
#define IS_AIR(typ) ((typ) == AIR || (typ) == CLOUD)
#define IS_SOFT(typ) ((typ) == AIR || (typ) == CLOUD || IS_POOL(typ))
/*
* The screen symbols may be the default or defined at game startup time.
* See drawing.c for defaults.
* Note: {ibm|dec|curses}_graphics[] arrays (also in drawing.c) must be kept in
* synch.
*/
/* begin dungeon characters */
enum screen_symbols {
S_stone = 0,
S_vwall = 1,
S_hwall = 2,
S_tlcorn = 3,
S_trcorn = 4,
S_blcorn = 5,
S_brcorn = 6,
S_crwall = 7,
S_tuwall = 8,
S_tdwall = 9,
S_tlwall = 10,
S_trwall = 11,
S_ndoor = 12,
S_vodoor = 13,
S_hodoor = 14,
S_vcdoor = 15, /* closed door, vertical wall */
S_hcdoor = 16, /* closed door, horizontal wall */
S_bars = 17, /* KMH -- iron bars */
S_tree = 18, /* KMH */
S_room = 19,
S_darkroom = 20,
S_corr = 21,
S_litcorr = 22,
S_upstair = 23,
S_dnstair = 24,
S_upladder = 25,
S_dnladder = 26,
S_brupstair = 27,
S_brdnstair = 28,
S_brupladder= 29,
S_brdnladder= 30,
S_altar = 31,
S_grave = 32,
S_throne = 33,
S_sink = 34,
S_fountain = 35,
S_pool = 36,
S_ice = 37,
S_lava = 38,
S_vodbridge = 39,
S_hodbridge = 40,
S_vcdbridge = 41, /* closed drawbridge, vertical wall */
S_hcdbridge = 42, /* closed drawbridge, horizontal wall */
S_air = 43,
S_cloud = 44,
S_water = 45,
/* end dungeon characters, begin traps */
S_arrow_trap = 46,
S_dart_trap = 47,
S_falling_rock_trap = 48,
S_squeaky_board = 49,
S_bear_trap = 50,
S_land_mine = 51,
S_rolling_boulder_trap = 52,
S_sleeping_gas_trap = 53,
S_rust_trap = 54,
S_fire_trap = 55,
S_pit = 56,
S_spiked_pit = 57,
S_hole = 58,
S_trap_door = 59,
S_teleportation_trap = 60,
S_level_teleporter = 61,
S_magic_portal = 62,
S_web = 63,
S_statue_trap = 64,
S_magic_trap = 65,
S_anti_magic_trap = 66,
S_polymorph_trap = 67,
S_vibrating_square = 68, /* for display rather than any trap effect */
/* end traps, begin special effects */
S_vbeam = 69, /* The 4 zap beam symbols. Do NOT separate. */
S_hbeam = 70, /* To change order or add, see function */
S_lslant = 71, /* zapdir_to_glyph() in display.c. */
S_rslant = 72,
S_digbeam = 73, /* dig beam symbol */
S_flashbeam = 74, /* camera flash symbol */
S_boomleft = 75, /* thrown boomerang, open left, e.g ')' */
S_boomright = 76, /* thrown boomerang, open right, e.g. '(' */
S_ss1 = 77, /* 4 magic shield ("resistance sparkle") glyphs */
S_ss2 = 78,
S_ss3 = 79,
S_ss4 = 80,
S_poisoncloud = 81,
S_goodpos = 82, /* valid position for targeting via getpos() */
/* The 8 swallow symbols. Do NOT separate. To change order or add, */
/* see the function swallow_to_glyph() in display.c. */
S_sw_tl = 83, /* swallow top left [1] */
S_sw_tc = 84, /* swallow top center [2] Order: */
S_sw_tr = 85, /* swallow top right [3] */
S_sw_ml = 86, /* swallow middle left [4] 1 2 3 */
S_sw_mr = 87, /* swallow middle right [6] 4 5 6 */
S_sw_bl = 88, /* swallow bottom left [7] 7 8 9 */
S_sw_bc = 89, /* swallow bottom center [8] */
S_sw_br = 90, /* swallow bottom right [9] */
S_explode1 = 91, /* explosion top left */
S_explode2 = 92, /* explosion top center */
S_explode3 = 93, /* explosion top right Ex. */
S_explode4 = 94, /* explosion middle left */
S_explode5 = 95, /* explosion middle center /-\ */
S_explode6 = 96, /* explosion middle right |@| */
S_explode7 = 97, /* explosion bottom left \-/ */
S_explode8 = 98, /* explosion bottom center */
S_explode9 = 99, /* explosion bottom right */
/* end effects */
MAXPCHARS = 100 /* maximum number of mapped characters */
};
#define MAXDCHARS (S_water - S_stone + 1) /* mapped dungeon characters */
#define MAXTCHARS (S_vibrating_square - S_arrow_trap + 1) /* trap chars */
#define MAXECHARS (S_explode9 - S_vbeam + 1) /* mapped effects characters */
#define MAXEXPCHARS 9 /* number of explosion characters */
#define DARKROOMSYM (Is_rogue_level(&u.uz) ? S_stone : S_darkroom)
#define is_cmap_trap(i) ((i) >= S_arrow_trap && (i) <= S_polymorph_trap)
#define is_cmap_drawbridge(i) ((i) >= S_vodbridge && (i) <= S_hcdbridge)
#define is_cmap_door(i) ((i) >= S_vodoor && (i) <= S_hcdoor)
#define is_cmap_wall(i) ((i) >= S_stone && (i) <= S_trwall)
#define is_cmap_room(i) ((i) >= S_room && (i) <= S_darkroom)
#define is_cmap_corr(i) ((i) >= S_corr && (i) <= S_litcorr)
#define is_cmap_furniture(i) ((i) >= S_upstair && (i) <= S_fountain)
#define is_cmap_water(i) ((i) == S_pool || (i) == S_water)
#define is_cmap_lava(i) ((i) == S_lava)
#define is_cmap_stairs(i) ((i) == S_upstair || (i) == S_dnstair || \
(i) == S_upladder || (i) == S_dnladder)
struct symdef {
uchar sym;
const char *explanation;
#ifdef TEXTCOLOR
uchar color;
#endif
};
struct symparse {
unsigned range;
#define SYM_CONTROL 1 /* start/finish markers */
#define SYM_PCHAR 2 /* index into showsyms */
#define SYM_OC 3 /* index into oc_syms */
#define SYM_MON 4 /* index into monsyms */
#define SYM_OTH 5 /* misc */
int idx;
const char *name;
};
/* misc symbol definitions */
#define SYM_NOTHING 0
#define SYM_UNEXPLORED 1
#define SYM_BOULDER 2
#define SYM_INVISIBLE 3
#define SYM_PET_OVERRIDE 4
#define SYM_HERO_OVERRIDE 5
#define MAXOTHER 6
/* linked list of symsets and their characteristics */
struct symsetentry {
struct symsetentry *next; /* next in list */
char *name; /* ptr to symset name */
char *desc; /* ptr to description */
int idx; /* an index value */
int handling; /* known handlers value */
Bitfield(nocolor, 1); /* don't use color if set */
Bitfield(primary, 1); /* restricted for use as primary set */
Bitfield(rogue, 1); /* restricted for use as rogue lev set */
Bitfield(explicitly, 1); /* explicit symset set */
/* 4 free bits */
};
/*
* Graphics sets for display symbols
*/
#define DEFAULT_GRAPHICS 0 /* regular characters: '-', '+', &c */
#define PRIMARY 0 /* primary graphics set */
#define ROGUESET 1 /* rogue graphics set */
#define NUM_GRAPHICS 2
/*
* special symbol set handling types ( for invoking callbacks, etc.)
* Must match the order of the known_handlers strings
* in drawing.c
*/
#define H_UNK 0
#define H_IBM 1
#define H_DEC 2
#define H_CURS 3
#define H_MAC 4 /* obsolete; needed so that the listing of available
* symsets by 'O' can skip it for !MAC_GRAPHICS_ENV */
extern const struct symdef defsyms[MAXPCHARS]; /* defaults */
#define WARNCOUNT 6 /* number of different warning levels */
extern const struct symdef def_warnsyms[WARNCOUNT];
#define SYMHANDLING(ht) (g.symset[g.currentgraphics].handling == (ht))
/*
* Note: secret doors (SDOOR) want to use both rm.doormask and
* rm.wall_info but those both overload rm.flags. SDOOR only