From: Pasi Kallinen Date: Mon, 10 Oct 2016 13:18:14 +0000 (+0300) Subject: Use more enums X-Git-Tag: NetHack-3.6.1_RC01~575 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=552647fb36c94bcff68ac8b1900635b42e810b8c;p=nethack Use more enums We're already using enums, so convert some already existing defines. --- diff --git a/include/attrib.h b/include/attrib.h index ed2c5d86c..fe97a9fb2 100644 --- a/include/attrib.h +++ b/include/attrib.h @@ -7,14 +7,16 @@ #ifndef ATTRIB_H #define ATTRIB_H -#define A_STR 0 -#define A_INT 1 -#define A_WIS 2 -#define A_DEX 3 -#define A_CON 4 -#define A_CHA 5 - -#define A_MAX 6 /* used in rn2() selection of attrib */ +enum attrib_types { + A_STR = 0, + A_INT, + A_WIS, + A_DEX, + A_CON, + A_CHA, + + A_MAX /* used in rn2() selection of attrib */ +}; #define ABASE(x) (u.acurr.a[x]) #define ABON(x) (u.abon.a[x]) diff --git a/include/dungeon.h b/include/dungeon.h index 23965e6ce..43452d908 100644 --- a/include/dungeon.h +++ b/include/dungeon.h @@ -35,13 +35,15 @@ typedef struct stairway { /* basic stairway identifier */ } stairway; /* level region types */ -#define LR_DOWNSTAIR 0 -#define LR_UPSTAIR 1 -#define LR_PORTAL 2 -#define LR_BRANCH 3 -#define LR_TELE 4 -#define LR_UPTELE 5 -#define LR_DOWNTELE 6 +enum level_region_types { + LR_DOWNSTAIR = 0, + LR_UPSTAIR, + LR_PORTAL, + LR_BRANCH, + LR_TELE, + LR_UPTELE, + LR_DOWNTELE +}; typedef struct dest_area { /* non-stairway level change identifier */ xchar lx, ly; /* "lower" left corner (near [0,0]) */ diff --git a/include/flag.h b/include/flag.h index 642c680be..b28b0e673 100644 --- a/include/flag.h +++ b/include/flag.h @@ -378,26 +378,30 @@ extern NEARDATA struct sysflag sysflags; #endif extern NEARDATA struct instance_flags iflags; -/* last_msg values */ -#define PLNMSG_UNKNOWN 0 /* arbitrary */ -#define PLNMSG_ONE_ITEM_HERE 1 /* "you see here" */ -#define PLNMSG_TOWER_OF_FLAME 2 /* scroll of fire */ -#define PLNMSG_CAUGHT_IN_EXPLOSION 3 /* explode() feedback */ -#define PLNMSG_OBJ_GLOWS 4 /* "the glows " */ -#define PLNMSG_OBJNAM_ONLY 5 /* xname/doname only, for #tip */ - /* Usage: - * pline("some message"); - * pline: vsprintf + putstr + iflags.last_msg = PLNMSG_UNKNOWN; - * iflags.last_msg = PLNMSG_some_message; - * and subsequent code can adjust the next message if it is affected - * by some_message. The next message will clear iflags.last_msg. - */ +/* last_msg values + * Usage: + * pline("some message"); + * pline: vsprintf + putstr + iflags.last_msg = PLNMSG_UNKNOWN; + * iflags.last_msg = PLNMSG_some_message; + * and subsequent code can adjust the next message if it is affected + * by some_message. The next message will clear iflags.last_msg. + */ +enum plnmsg_types { + PLNMSG_UNKNOWN = 0, /* arbitrary */ + PLNMSG_ONE_ITEM_HERE, /* "you see here" */ + PLNMSG_TOWER_OF_FLAME, /* scroll of fire */ + PLNMSG_CAUGHT_IN_EXPLOSION, /* explode() feedback */ + PLNMSG_OBJ_GLOWS, /* "the glows " */ + PLNMSG_OBJNAM_ONLY /* xname/doname only, for #tip */ +}; /* runmode options */ -#define RUN_TPORT 0 /* don't update display until movement stops */ -#define RUN_LEAP 1 /* update display every 7 steps */ -#define RUN_STEP 2 /* update display every single step */ -#define RUN_CRAWL 3 /* walk w/ extra delay after each update */ +enum runmode_types { + RUN_TPORT = 0, /* don't update display until movement stops */ + RUN_LEAP, /* update display every 7 steps */ + RUN_STEP, /* update display every single step */ + RUN_CRAWL /* walk w/ extra delay after each update */ +}; /* paranoid confirmation prompting */ /* any yes confirmations also require explicit no (or ESC) to reject */ diff --git a/include/hack.h b/include/hack.h index 45da184a9..cc878942c 100644 --- a/include/hack.h +++ b/include/hack.h @@ -22,24 +22,28 @@ } /* symbolic names for capacity levels */ -#define UNENCUMBERED 0 -#define SLT_ENCUMBER 1 /* Burdened */ -#define MOD_ENCUMBER 2 /* Stressed */ -#define HVY_ENCUMBER 3 /* Strained */ -#define EXT_ENCUMBER 4 /* Overtaxed */ -#define OVERLOADED 5 /* Overloaded */ +enum encumbrance_types { + UNENCUMBERED = 0, + SLT_ENCUMBER, /* Burdened */ + MOD_ENCUMBER, /* Stressed */ + HVY_ENCUMBER, /* Strained */ + EXT_ENCUMBER, /* Overtaxed */ + OVERLOADED /* Overloaded */ +}; /* weight increment of heavy iron ball */ #define IRON_BALL_W_INCR 160 /* hunger states - see hu_stat in eat.c */ -#define SATIATED 0 -#define NOT_HUNGRY 1 -#define HUNGRY 2 -#define WEAK 3 -#define FAINTING 4 -#define FAINTED 5 -#define STARVED 6 +enum hunger_state_types { + SATIATED = 0, + NOT_HUNGRY, + HUNGRY, + WEAK, + FAINTING, + FAINTED, + STARVED +}; /* Macros for how a rumor was delivered in outrumor() */ #define BY_ORACLE 0 @@ -48,13 +52,15 @@ #define BY_OTHER 9 /* Macros for why you are no longer riding */ -#define DISMOUNT_GENERIC 0 -#define DISMOUNT_FELL 1 -#define DISMOUNT_THROWN 2 -#define DISMOUNT_POLY 3 -#define DISMOUNT_ENGULFED 4 -#define DISMOUNT_BONES 5 -#define DISMOUNT_BYCHOICE 6 +enum dismount_types { + DISMOUNT_GENERIC = 0, + DISMOUNT_FELL, + DISMOUNT_THROWN, + DISMOUNT_POLY, + DISMOUNT_ENGULFED, + DISMOUNT_BONES, + DISMOUNT_BYCHOICE +}; /* Special returns from mapglyph() */ #define MG_CORPSE 0x01 @@ -73,25 +79,27 @@ #define SELL_DONTSELL (2) /* alteration types--keep in synch with costly_alteration(mkobj.c) */ -#define COST_CANCEL 0 /* standard cancellation */ -#define COST_DRAIN 1 /* drain life upon an object */ -#define COST_UNCHRG 2 /* cursed charging */ -#define COST_UNBLSS 3 /* unbless (devalues holy water) */ -#define COST_UNCURS 4 /* uncurse (devalues unholy water) */ -#define COST_DECHNT 5 /* disenchant weapons or armor */ -#define COST_DEGRD 6 /* removal of rustproofing, dulling via engraving */ -#define COST_DILUTE 7 /* potion dilution */ -#define COST_ERASE 8 /* scroll or spellbook blanking */ -#define COST_BURN 9 /* dipped into flaming oil */ -#define COST_NUTRLZ 10 /* neutralized via unicorn horn */ -#define COST_DSTROY 11 /* wand breaking (bill first, useup later) */ -#define COST_SPLAT 12 /* cream pie to own face (ditto) */ -#define COST_BITE 13 /* start eating food */ -#define COST_OPEN 14 /* open tin */ -#define COST_BRKLCK 15 /* break box/chest's lock */ -#define COST_RUST 16 /* rust damage */ -#define COST_ROT 17 /* rotting attack */ -#define COST_CORRODE 18 /* acid damage */ +enum cost_alteration_types { + COST_CANCEL = 0, /* standard cancellation */ + COST_DRAIN, /* drain life upon an object */ + COST_UNCHRG, /* cursed charging */ + COST_UNBLSS, /* unbless (devalues holy water) */ + COST_UNCURS, /* uncurse (devalues unholy water) */ + COST_DECHNT, /* disenchant weapons or armor */ + COST_DEGRD, /* removal of rustproofing, dulling via engraving */ + COST_DILUTE, /* potion dilution */ + COST_ERASE, /* scroll or spellbook blanking */ + COST_BURN, /* dipped into flaming oil */ + COST_NUTRLZ, /* neutralized via unicorn horn */ + COST_DSTROY, /* wand breaking (bill first, useup later) */ + COST_SPLAT, /* cream pie to own face (ditto) */ + COST_BITE, /* start eating food */ + COST_OPEN, /* open tin */ + COST_BRKLCK, /* break box/chest's lock */ + COST_RUST, /* rust damage */ + COST_ROT, /* rotting attack */ + COST_CORRODE /* acid damage */ +}; /* bitmask flags for corpse_xname(); PFX_THE takes precedence over ARTICLE, NO_PFX takes precedence over both */ @@ -115,22 +123,24 @@ enum getpos_retval { * in end.c and topten.c will need to be changed. Some parts of the * code assume that PANIC separates the deaths from the non-deaths. */ -#define DIED 0 -#define CHOKING 1 -#define POISONING 2 -#define STARVING 3 -#define DROWNING 4 -#define BURNING 5 -#define DISSOLVED 6 -#define CRUSHING 7 -#define STONING 8 -#define TURNED_SLIME 9 -#define GENOCIDED 10 -#define PANICKED 11 -#define TRICKED 12 -#define QUIT 13 -#define ESCAPED 14 -#define ASCENDED 15 +enum game_end_types { + DIED = 0, + CHOKING, + POISONING, + STARVING, + DROWNING, + BURNING, + DISSOLVED, + CRUSHING, + STONING, + TURNED_SLIME, + GENOCIDED, + PANICKED, + TRICKED, + QUIT, + ESCAPED, + ASCENDED +}; #include "align.h" #include "dungeon.h" @@ -146,18 +156,22 @@ enum getpos_retval { NEARDATA extern coord bhitpos; /* place where throw or zap hits or stops */ /* types of calls to bhit() */ -#define ZAPPED_WAND 0 -#define THROWN_WEAPON 1 -#define KICKED_WEAPON 2 -#define FLASHED_LIGHT 3 -#define INVIS_BEAM 4 +enum bhit_call_types { + ZAPPED_WAND = 0, + THROWN_WEAPON, + KICKED_WEAPON, + FLASHED_LIGHT, + INVIS_BEAM +}; /* attack mode for hmon() */ -#define HMON_MELEE 0 /* hand-to-hand */ -#define HMON_THROWN 1 /* normal ranged (or spitting while poly'd) */ -#define HMON_KICKED 2 /* alternate ranged */ -#define HMON_APPLIED 3 /* polearm, treated as ranged */ -#define HMON_DRAGGED 4 /* attached iron ball, pulled into mon */ +enum hmon_atkmode_types { + HMON_MELEE = 0, /* hand-to-hand */ + HMON_THROWN, /* normal ranged (or spitting while poly'd) */ + HMON_KICKED, /* alternate ranged */ + HMON_APPLIED, /* polearm, treated as ranged */ + HMON_DRAGGED /* attached iron ball, pulled into mon */ +}; #define MATCH_WARN_OF_MON(mon) \ (Warn_of_mon && ((context.warntype.obj \ @@ -315,14 +329,16 @@ NEARDATA extern coord bhitpos; /* place where throw or zap hits or stops */ #define LAUNCH_KNOWN 0x80 /* the hero caused this by explicit action */ /* Macros for explosion types */ -#define EXPL_DARK 0 -#define EXPL_NOXIOUS 1 -#define EXPL_MUDDY 2 -#define EXPL_WET 3 -#define EXPL_MAGICAL 4 -#define EXPL_FIERY 5 -#define EXPL_FROSTY 6 -#define EXPL_MAX 7 +enum explosion_types { + EXPL_DARK = 0, + EXPL_NOXIOUS, + EXPL_MUDDY, + EXPL_WET, + EXPL_MAGICAL, + EXPL_FIERY, + EXPL_FROSTY, + EXPL_MAX +}; /* enlightenment control flags */ #define BASICENLIGHTENMENT 1 /* show mundane stuff */ @@ -344,25 +360,27 @@ NEARDATA extern coord bhitpos; /* place where throw or zap hits or stops */ #define XKILL_NOCONDUCT 4 /* Macros for messages referring to hands, eyes, feet, etc... */ -#define ARM 0 -#define EYE 1 -#define FACE 2 -#define FINGER 3 -#define FINGERTIP 4 -#define FOOT 5 -#define HAND 6 -#define HANDED 7 -#define HEAD 8 -#define LEG 9 -#define LIGHT_HEADED 10 -#define NECK 11 -#define SPINE 12 -#define TOE 13 -#define HAIR 14 -#define BLOOD 15 -#define LUNG 16 -#define NOSE 17 -#define STOMACH 18 +enum bodypart_types { + ARM = 0, + EYE, + FACE, + FINGER, + FINGERTIP, + FOOT, + HAND, + HANDED, + HEAD, + LEG, + LIGHT_HEADED, + NECK, + SPINE, + TOE, + HAIR, + BLOOD, + LUNG, + NOSE, + STOMACH +}; /* indices for some special tin types */ #define ROTTEN_TIN 0 diff --git a/include/mextra.h b/include/mextra.h index e69d137df..c92a79f4d 100644 --- a/include/mextra.h +++ b/include/mextra.h @@ -144,14 +144,16 @@ struct emin { ** formerly edog.h -- pet extension */ /* various types of pet food, the lower, the better liked */ -#define DOGFOOD 0 -#define CADAVER 1 -#define ACCFOOD 2 -#define MANFOOD 3 -#define APPORT 4 -#define POISON 5 -#define UNDEF 6 -#define TABU 7 +enum dogfood_types { + DOGFOOD = 0, + CADAVER, + ACCFOOD, + MANFOOD, + APPORT, + POISON, + UNDEF, + TABU +}; struct edog { long droptime; /* moment dog dropped object */ diff --git a/include/mkroom.h b/include/mkroom.h index 1141f3616..ef20a1d5d 100644 --- a/include/mkroom.h +++ b/include/mkroom.h @@ -51,33 +51,36 @@ extern struct mkroom *dnstairs_room, *upstairs_room, *sstairs_room; extern NEARDATA coord doors[DOORMAX]; /* values for rtype in the room definition structure */ -#define OROOM 0 /* ordinary room */ -#define COURT 2 /* contains a throne */ -#define SWAMP 3 /* contains pools */ -#define VAULT 4 /* contains piles of gold */ -#define BEEHIVE 5 /* contains killer bees and royal jelly */ -#define MORGUE 6 /* contains corpses, undead and ghosts */ -#define BARRACKS 7 /* contains soldiers and their gear */ -#define ZOO 8 /* floor covered with treasure and monsters */ -#define DELPHI 9 /* contains Oracle and peripherals */ -#define TEMPLE 10 /* contains a shrine */ -#define LEPREHALL 11 /* leprechaun hall (Tom Proudfoot) */ -#define COCKNEST 12 /* cockatrice nest (Tom Proudfoot) */ -#define ANTHOLE 13 /* ants (Tom Proudfoot) */ -#define SHOPBASE 14 /* everything above this is a shop */ -#define ARMORSHOP 15 /* specific shop defines for level compiler */ -#define SCROLLSHOP 16 -#define POTIONSHOP 17 -#define WEAPONSHOP 18 -#define FOODSHOP 19 -#define RINGSHOP 20 -#define WANDSHOP 21 -#define TOOLSHOP 22 -#define BOOKSHOP 23 -#define FODDERSHOP 24 /* health food store */ -#define UNIQUESHOP 25 /* shops here & below not randomly gen'd. */ -#define CANDLESHOP 25 -#define MAXRTYPE 25 /* maximum valid room type */ +enum roomtype_types { + OROOM = 0, /* ordinary room */ + COURT = 2, /* contains a throne */ + SWAMP, /* contains pools */ + VAULT, /* contains piles of gold */ + BEEHIVE, /* contains killer bees and royal jelly */ + MORGUE, /* contains corpses, undead and ghosts */ + BARRACKS, /* contains soldiers and their gear */ + ZOO, /* floor covered with treasure and monsters */ + DELPHI, /* contains Oracle and peripherals */ + TEMPLE, /* contains a shrine */ + LEPREHALL, /* leprechaun hall (Tom Proudfoot) */ + COCKNEST, /* cockatrice nest (Tom Proudfoot) */ + ANTHOLE, /* ants (Tom Proudfoot) */ + SHOPBASE, /* everything above this is a shop */ + ARMORSHOP, /* specific shop defines for level compiler */ + SCROLLSHOP, + POTIONSHOP, + WEAPONSHOP, + FOODSHOP, + RINGSHOP, + WANDSHOP, + TOOLSHOP, + BOOKSHOP, + FODDERSHOP, /* health food store */ + CANDLESHOP +}; + +#define MAXRTYPE (CANDLESHOP) /* maximum valid room type */ +#define UNIQUESHOP (CANDLESHOP) /* shops here & above not randomly gen'd. */ /* Special type for search_special() */ #define ANY_TYPE (-1) diff --git a/include/monsym.h b/include/monsym.h index 9a781012a..4aec7c2a2 100644 --- a/include/monsym.h +++ b/include/monsym.h @@ -10,71 +10,71 @@ * them. Monster class 0 is not used or defined so we can use it as a * NULL character. */ -/* clang-format off */ -#define S_ANT 1 -#define S_BLOB 2 -#define S_COCKATRICE 3 -#define S_DOG 4 -#define S_EYE 5 -#define S_FELINE 6 -#define S_GREMLIN 7 -#define S_HUMANOID 8 -#define S_IMP 9 -#define S_JELLY 10 -#define S_KOBOLD 11 -#define S_LEPRECHAUN 12 -#define S_MIMIC 13 -#define S_NYMPH 14 -#define S_ORC 15 -#define S_PIERCER 16 -#define S_QUADRUPED 17 -#define S_RODENT 18 -#define S_SPIDER 19 -#define S_TRAPPER 20 -#define S_UNICORN 21 -#define S_VORTEX 22 -#define S_WORM 23 -#define S_XAN 24 -#define S_LIGHT 25 -#define S_ZRUTY 26 -#define S_ANGEL 27 -#define S_BAT 28 -#define S_CENTAUR 29 -#define S_DRAGON 30 -#define S_ELEMENTAL 31 -#define S_FUNGUS 32 -#define S_GNOME 33 -#define S_GIANT 34 -#define S_invisible 35 /* non-class present in def_monsyms[] */ -#define S_JABBERWOCK 36 -#define S_KOP 37 -#define S_LICH 38 -#define S_MUMMY 39 -#define S_NAGA 40 -#define S_OGRE 41 -#define S_PUDDING 42 -#define S_QUANTMECH 43 -#define S_RUSTMONST 44 -#define S_SNAKE 45 -#define S_TROLL 46 -#define S_UMBER 47 -#define S_VAMPIRE 48 -#define S_WRAITH 49 -#define S_XORN 50 -#define S_YETI 51 -#define S_ZOMBIE 52 -#define S_HUMAN 53 -#define S_GHOST 54 -#define S_GOLEM 55 -#define S_DEMON 56 -#define S_EEL 57 -#define S_LIZARD 58 +enum mon_class_types { + S_ANT = 1, + S_BLOB, + S_COCKATRICE, + S_DOG, + S_EYE, + S_FELINE, + S_GREMLIN, + S_HUMANOID, + S_IMP, + S_JELLY, + S_KOBOLD, + S_LEPRECHAUN, + S_MIMIC, + S_NYMPH, + S_ORC, + S_PIERCER, + S_QUADRUPED, + S_RODENT, + S_SPIDER, + S_TRAPPER, + S_UNICORN, + S_VORTEX, + S_WORM, + S_XAN, + S_LIGHT, + S_ZRUTY, + S_ANGEL, + S_BAT, + S_CENTAUR, + S_DRAGON, + S_ELEMENTAL, + S_FUNGUS, + S_GNOME, + S_GIANT, + S_invisible, /* non-class present in def_monsyms[] */ + S_JABBERWOCK, + S_KOP, + S_LICH, + S_MUMMY, + S_NAGA, + S_OGRE, + S_PUDDING, + S_QUANTMECH, + S_RUSTMONST, + S_SNAKE, + S_TROLL, + S_UMBER, + S_VAMPIRE, + S_WRAITH, + S_XORN, + S_YETI, + S_ZOMBIE, + S_HUMAN, + S_GHOST, + S_GOLEM, + S_DEMON, + S_EEL, + S_LIZARD, -#define S_WORM_TAIL 59 -#define S_MIMIC_DEF 60 -/* clang-format on */ + S_WORM_TAIL, + S_MIMIC_DEF, -#define MAXMCLASSES 61 /* number of monster classes */ + MAXMCLASSES /* number of monster classes */ +}; /* * Default characters for monsters. These correspond to the monster classes diff --git a/include/objclass.h b/include/objclass.h index b968cd246..3f7218092 100644 --- a/include/objclass.h +++ b/include/objclass.h @@ -131,25 +131,28 @@ extern NEARDATA struct objdescr obj_descr[]; * All objects have a class. Make sure that all classes have a corresponding * symbol below. */ -#define RANDOM_CLASS 0 /* used for generating random objects */ -#define ILLOBJ_CLASS 1 -#define WEAPON_CLASS 2 -#define ARMOR_CLASS 3 -#define RING_CLASS 4 -#define AMULET_CLASS 5 -#define TOOL_CLASS 6 -#define FOOD_CLASS 7 -#define POTION_CLASS 8 -#define SCROLL_CLASS 9 -#define SPBOOK_CLASS 10 /* actually SPELL-book */ -#define WAND_CLASS 11 -#define COIN_CLASS 12 -#define GEM_CLASS 13 -#define ROCK_CLASS 14 -#define BALL_CLASS 15 -#define CHAIN_CLASS 16 -#define VENOM_CLASS 17 -#define MAXOCLASSES 18 +enum obj_class_types { + RANDOM_CLASS = 0, /* used for generating random objects */ + ILLOBJ_CLASS, + WEAPON_CLASS, + ARMOR_CLASS, + RING_CLASS, + AMULET_CLASS, + TOOL_CLASS, + FOOD_CLASS, + POTION_CLASS, + SCROLL_CLASS, + SPBOOK_CLASS, /* actually SPELL-book */ + WAND_CLASS, + COIN_CLASS, + GEM_CLASS, + ROCK_CLASS, + BALL_CLASS, + CHAIN_CLASS, + VENOM_CLASS, + + MAXOCLASSES +}; #define ALLOW_COUNT (MAXOCLASSES + 1) /* Can be used in the object class */ #define ALL_CLASSES (MAXOCLASSES + 2) /* input to getobj(). */ diff --git a/include/rm.h b/include/rm.h index 3e85f2e2d..d7a494196 100644 --- a/include/rm.h +++ b/include/rm.h @@ -34,45 +34,47 @@ defines array type_names[] which contains an entry for each of these, so needs to be kept in sync if any new types are added or existing ones renumbered.] */ -#define STONE 0 -#define VWALL 1 -#define HWALL 2 -#define TLCORNER 3 -#define TRCORNER 4 -#define BLCORNER 5 -#define BRCORNER 6 -#define CROSSWALL 7 /* For pretty mazes and special levels */ -#define TUWALL 8 -#define TDWALL 9 -#define TLWALL 10 -#define TRWALL 11 -#define DBWALL 12 -#define TREE 13 /* KMH */ -#define SDOOR 14 -#define SCORR 15 -#define POOL 16 -#define MOAT 17 /* pool that doesn't boil, adjust messages */ -#define WATER 18 -#define DRAWBRIDGE_UP 19 -#define LAVAPOOL 20 -#define IRONBARS 21 /* KMH */ -#define DOOR 22 -#define CORR 23 -#define ROOM 24 -#define STAIRS 25 -#define LADDER 26 -#define FOUNTAIN 27 -#define THRONE 28 -#define SINK 29 -#define GRAVE 30 -#define ALTAR 31 -#define ICE 32 -#define DRAWBRIDGE_DOWN 33 -#define AIR 34 -#define CLOUD 35 - -#define MAX_TYPE 36 -#define INVALID_TYPE 127 +enum levl_typ_types { + STONE = 0, + VWALL, + HWALL, + TLCORNER, + TRCORNER, + BLCORNER, + BRCORNER, + CROSSWALL, /* For pretty mazes and special levels */ + TUWALL, + TDWALL, + TLWALL, + TRWALL, + DBWALL, + TREE, /* KMH */ + SDOOR, + SCORR, + POOL, + MOAT, /* pool that doesn't boil, adjust messages */ + WATER, + DRAWBRIDGE_UP, + LAVAPOOL, + IRONBARS, /* KMH */ + DOOR, + CORR, + ROOM, + STAIRS, + LADDER, + FOUNTAIN, + THRONE, + SINK, + GRAVE, + ALTAR, + ICE, + DRAWBRIDGE_DOWN, + AIR, + CLOUD, + + MAX_TYPE, + INVALID_TYPE = 127 +}; /* * Avoid using the level types in inequalities: diff --git a/include/sp_lev.h b/include/sp_lev.h index 78ace02ab..be3e92164 100644 --- a/include/sp_lev.h +++ b/include/sp_lev.h @@ -34,11 +34,13 @@ generate ways to escape from them */ /* different level layout initializers */ -#define LVLINIT_NONE 0 -#define LVLINIT_SOLIDFILL 1 -#define LVLINIT_MAZEGRID 2 -#define LVLINIT_MINES 3 -#define LVLINIT_ROGUE 4 +enum lvlinit_types { + LVLINIT_NONE = 0, + LVLINIT_SOLIDFILL, + LVLINIT_MAZEGRID, + LVLINIT_MINES, + LVLINIT_ROGUE +}; /* max. layers of object containment */ #define MAX_CONTAINMENT 10 diff --git a/include/trap.h b/include/trap.h index 4b83f1996..ce4f4696d 100644 --- a/include/trap.h +++ b/include/trap.h @@ -53,30 +53,33 @@ extern struct trap *ftrap; /* Note: if adding/removing a trap, adjust trap_engravings[] in mklev.c */ /* unconditional traps */ -#define NO_TRAP 0 -#define ARROW_TRAP 1 -#define DART_TRAP 2 -#define ROCKTRAP 3 -#define SQKY_BOARD 4 -#define BEAR_TRAP 5 -#define LANDMINE 6 -#define ROLLING_BOULDER_TRAP 7 -#define SLP_GAS_TRAP 8 -#define RUST_TRAP 9 -#define FIRE_TRAP 10 -#define PIT 11 -#define SPIKED_PIT 12 -#define HOLE 13 -#define TRAPDOOR 14 -#define TELEP_TRAP 15 -#define LEVEL_TELEP 16 -#define MAGIC_PORTAL 17 -#define WEB 18 -#define STATUE_TRAP 19 -#define MAGIC_TRAP 20 -#define ANTI_MAGIC 21 -#define POLY_TRAP 22 -#define VIBRATING_SQUARE 23 -#define TRAPNUM 24 +enum trap_types { + NO_TRAP = 0, + ARROW_TRAP, + DART_TRAP, + ROCKTRAP, + SQKY_BOARD, + BEAR_TRAP, + LANDMINE, + ROLLING_BOULDER_TRAP, + SLP_GAS_TRAP, + RUST_TRAP, + FIRE_TRAP, + PIT, + SPIKED_PIT, + HOLE, + TRAPDOOR, + TELEP_TRAP, + LEVEL_TELEP, + MAGIC_PORTAL, + WEB, + STATUE_TRAP, + MAGIC_TRAP, + ANTI_MAGIC, + POLY_TRAP, + VIBRATING_SQUARE, + + TRAPNUM +}; #endif /* TRAP_H */ diff --git a/include/wintype.h b/include/wintype.h index e15e6725e..3dbcc0500 100644 --- a/include/wintype.h +++ b/include/wintype.h @@ -29,24 +29,24 @@ typedef union any { /* (buggy old Ultrix compiler) */ /* symbolic names for the data types housed in anything */ -/* clang-format off */ -#define ANY_VOID 1 -#define ANY_OBJ 2 /* struct obj */ -#define ANY_MONST 3 /* struct monst (not used) */ -#define ANY_INT 4 /* int */ -#define ANY_CHAR 5 /* char */ -#define ANY_UCHAR 6 /* unsigned char */ -#define ANY_SCHAR 7 /* signed char */ -#define ANY_UINT 8 /* unsigned int */ -#define ANY_LONG 9 /* long */ -#define ANY_ULONG 10 /* unsigned long */ -#define ANY_IPTR 11 /* pointer to int */ -#define ANY_UPTR 12 /* pointer to unsigned int */ -#define ANY_LPTR 13 /* pointer to long */ -#define ANY_ULPTR 14 /* pointer to unsigned long */ -#define ANY_STR 15 /* pointer to null-terminated char string */ -#define ANY_MASK32 16 /* 32-bit mask (stored as unsigned long) */ -/* clang-format on */ +enum any_types { + ANY_VOID = 1, + ANY_OBJ, /* struct obj */ + ANY_MONST, /* struct monst (not used) */ + ANY_INT, /* int */ + ANY_CHAR, /* char */ + ANY_UCHAR, /* unsigned char */ + ANY_SCHAR, /* signed char */ + ANY_UINT, /* unsigned int */ + ANY_LONG, /* long */ + ANY_ULONG, /* unsigned long */ + ANY_IPTR, /* pointer to int */ + ANY_UPTR, /* pointer to unsigned int */ + ANY_LPTR, /* pointer to long */ + ANY_ULPTR, /* pointer to unsigned long */ + ANY_STR, /* pointer to null-terminated char string */ + ANY_MASK32 /* 32-bit mask (stored as unsigned long) */ +}; /* menu return list */ typedef struct mi {