]> granicus.if.org Git - nethack/commitdiff
Use more enums
authorPasi Kallinen <paxed@alt.org>
Sat, 31 Mar 2018 05:57:22 +0000 (08:57 +0300)
committerPasi Kallinen <paxed@alt.org>
Sat, 31 Mar 2018 05:57:22 +0000 (08:57 +0300)
include/monst.h
include/you.h
src/artifact.c

index d918897de7f95c1cccfe62b8b432ee0f794342b5..e323f80cca4490c46fed7b002cf81f374ac44dc0 100644 (file)
  * that there are enough situations which might make a monster change its
  * weapon that this is impractical.  --KAA
  */
-#define NO_WEAPON_WANTED   0
-#define NEED_WEAPON        1
-#define NEED_RANGED_WEAPON 2
-#define NEED_HTH_WEAPON    3
-#define NEED_PICK_AXE      4
-#define NEED_AXE           5
-#define NEED_PICK_OR_AXE   6
+enum wpn_chk_flags {
+    NO_WEAPON_WANTED = 0,
+    NEED_WEAPON,
+    NEED_RANGED_WEAPON,
+    NEED_HTH_WEAPON,
+    NEED_PICK_AXE,
+    NEED_AXE,
+    NEED_PICK_OR_AXE
+};
 
 /* The following flags are used for the second argument to display_minventory
  * in invent.c:
 #define MINV_NOLET    0x04
 #define MINV_ALL      0x08
 
+enum m_ap_types {
+    M_AP_NOTHING = 0, /* mappearance unused--monster appears as itself */
+    M_AP_FURNITURE,   /* stairs, a door, an altar, etc. */
+    M_AP_OBJECT,      /* an object */
+    M_AP_MONSTER      /* a monster */
+};
+
 struct monst {
     struct monst *nmon;
     struct permonst *data;
@@ -56,11 +65,7 @@ struct monst {
     coord mtrack[MTSZ];   /* monster track */
     int mhp, mhpmax;
     unsigned mappearance; /* for undetected mimics and the wiz */
-    uchar m_ap_type;      /* what mappearance is describing: */
-#define M_AP_NOTHING   0  /* mappearance unused--monster appears as itself */
-#define M_AP_FURNITURE 1  /* stairs, a door, an altar, etc. */
-#define M_AP_OBJECT    2  /* an object */
-#define M_AP_MONSTER   3  /* a monster */
+    uchar m_ap_type;      /* what mappearance is describing, m_ap_types */
 
     schar mtame;                /* level of tameness, implies peaceful */
     unsigned short mintrinsics; /* low 8 correspond to mresists */
index 336545ade8c2743ff81a7eac322ee57d0238a9cf..79210605fa030387bb70e755e5c9094baa87668f 100644 (file)
@@ -254,6 +254,15 @@ struct Align {
 
 extern const struct Align aligns[]; /* table of available alignments */
 
+enum utraptypes {
+    TT_BEARTRAP = 0,
+    TT_PIT,
+    TT_WEB,
+    TT_LAVA,
+    TT_INFLOOR,
+    TT_BURIEDBALL
+};
+
 /*** Information about the player ***/
 struct you {
     xchar ux, uy;       /* current map coordinates */
@@ -270,13 +279,7 @@ struct you {
     int ulevel;         /* 1 to MAXULEV */
     int ulevelmax;
     unsigned utrap;     /* trap timeout */
-    unsigned utraptype; /* defined if utrap nonzero */
-#define TT_BEARTRAP   0
-#define TT_PIT        1
-#define TT_WEB        2
-#define TT_LAVA       3
-#define TT_INFLOOR    4
-#define TT_BURIEDBALL 5
+    unsigned utraptype; /* defined if utrap nonzero. one of utraptypes */
     char urooms[5];         /* rooms (roomno + 3) occupied now */
     char urooms0[5];        /* ditto, for previous position */
     char uentered[5];       /* rooms (roomno + 3) entered this turn */
index a7678551a9105669bab68c9167f1ec45258dae8b..377a533b49fb8c4759f89366d8330f84c00b444b 100644 (file)
@@ -940,15 +940,21 @@ winid tmpwin; /* supplied by dodiscover() */
  * stun attack.  As of 3.4.1, those effects can occur but
  * will be slightly less likely than they were in 3.3.x.]
  */
+
+enum mb_effect_indices {
+    MB_INDEX_PROBE = 0,
+    MB_INDEX_STUN,
+    MB_INDEX_SCARE,
+    MB_INDEX_CANCEL,
+
+    NUM_MB_INDICES
+};
+
 #define MB_MAX_DIEROLL 8 /* rolls above this aren't magical */
-static const char *const mb_verb[2][4] = {
+static const char *const mb_verb[2][NUM_MB_INDICES] = {
     { "probe", "stun", "scare", "cancel" },
     { "prod", "amaze", "tickle", "purge" },
 };
-#define MB_INDEX_PROBE 0
-#define MB_INDEX_STUN 1
-#define MB_INDEX_SCARE 2
-#define MB_INDEX_CANCEL 3
 
 /* called when someone is being hit by Magicbane */
 STATIC_OVL boolean