From fc5688cee8dbb2808c7b843e9a1f024559f791b9 Mon Sep 17 00:00:00 2001 From: nhmall Date: Thu, 23 Nov 2023 13:55:09 -0500 Subject: [PATCH] minor tidy up of some macro placements A very small number of relatively recent macro definitions got placed in mondata.h, even though they had a 'struct monst *' argument, rather than a 'struct permonst *' argument. Relocate the macros with the 'struct monst *' argument to include/monst.h, leaving the macros with the 'struct permonst *' argument in include/mondata.h. --- include/mondata.h | 28 +++++++--------------------- include/monst.h | 20 ++++++++++++++++++++ include/permonst.h | 5 ----- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/include/mondata.h b/include/mondata.h index 13bfff15e..f777a1d6e 100644 --- a/include/mondata.h +++ b/include/mondata.h @@ -5,36 +5,17 @@ #ifndef MONDATA_H #define MONDATA_H +/* The macros in here take a permonst * as an argument */ + #define monsndx(ptr) ((ptr)->pmidx) #define verysmall(ptr) ((ptr)->msize < MZ_SMALL) #define bigmonst(ptr) ((ptr)->msize >= MZ_LARGE) #define pm_resistance(ptr, typ) (((ptr)->mresists & (typ)) != 0) -#define mon_resistancebits(mon) \ - ((mon)->data->mresists | (mon)->mextrinsics | (mon)->mintrinsics) -#define resists_fire(mon) \ - ((mon_resistancebits(mon) & MR_FIRE) != 0) -#define resists_cold(mon) \ - ((mon_resistancebits(mon) & MR_COLD) != 0) -#define resists_sleep(mon) \ - ((mon_resistancebits(mon) & MR_SLEEP) != 0) -#define resists_disint(mon) \ - ((mon_resistancebits(mon) & MR_DISINT) != 0) -#define resists_elec(mon) \ - ((mon_resistancebits(mon) & MR_ELEC) != 0) -#define resists_poison(mon) \ - ((mon_resistancebits(mon) & MR_POISON) != 0) -#define resists_acid(mon) \ - ((mon_resistancebits(mon) & MR_ACID) != 0) -#define resists_ston(mon) \ - ((mon_resistancebits(mon) & MR_STONE) != 0) - #define immune_poisongas(ptr) ((ptr) == &mons[PM_HEZROU] \ || (ptr) == &mons[PM_VROCK]) -#define is_lminion(mon) \ - (is_minion((mon)->data) && mon_aligntyp(mon) == A_LAWFUL) #define is_flyer(ptr) (((ptr)->mflags1 & M1_FLY) != 0L) #define is_floater(ptr) ((ptr)->mlet == S_EYE || (ptr)->mlet == S_LIGHT) /* clinger: piercers, mimics, wumpus -- generally don't fall down holes */ @@ -275,4 +256,9 @@ || objects[(obj)->otyp].oc_material == VEGGY \ || ((obj)->otyp == CORPSE && (obj)->corpsenm == PM_LICHEN)))) +#ifdef PMNAME_MACROS +#define pmname(ptr,g) ((((g) == MALE || (g) == FEMALE) && (ptr)->pmnames[g]) \ + ? (ptr)->pmnames[g] : (ptr)->pmnames[NEUTRAL]) +#endif + #endif /* MONDATA_H */ diff --git a/include/monst.h b/include/monst.h index d0cc55230..77160c8e8 100644 --- a/include/monst.h +++ b/include/monst.h @@ -264,5 +264,25 @@ struct monst { #ifdef PMNAME_MACROS #define Mgender(mon) ((mon)->female ? FEMALE : MALE) #endif +#define mon_resistancebits(mon) \ + ((mon)->data->mresists | (mon)->mextrinsics | (mon)->mintrinsics) +#define resists_fire(mon) \ + ((mon_resistancebits(mon) & MR_FIRE) != 0) +#define resists_cold(mon) \ + ((mon_resistancebits(mon) & MR_COLD) != 0) +#define resists_sleep(mon) \ + ((mon_resistancebits(mon) & MR_SLEEP) != 0) +#define resists_disint(mon) \ + ((mon_resistancebits(mon) & MR_DISINT) != 0) +#define resists_elec(mon) \ + ((mon_resistancebits(mon) & MR_ELEC) != 0) +#define resists_poison(mon) \ + ((mon_resistancebits(mon) & MR_POISON) != 0) +#define resists_acid(mon) \ + ((mon_resistancebits(mon) & MR_ACID) != 0) +#define resists_ston(mon) \ + ((mon_resistancebits(mon) & MR_STONE) != 0) +#define is_lminion(mon) \ + (is_minion((mon)->data) && mon_aligntyp(mon) == A_LAWFUL) #endif /* MONST_H */ diff --git a/include/permonst.h b/include/permonst.h index 2eea5d675..c48752257 100644 --- a/include/permonst.h +++ b/include/permonst.h @@ -84,9 +84,4 @@ extern NEARDATA struct permonst mons[NUMMONS + 1]; /* the master list of monster #define FAST_SPEED 15 #define VERY_FAST 24 -#ifdef PMNAME_MACROS -#define pmname(pm,g) ((((g) == MALE || (g) == FEMALE) && (pm)->pmnames[g]) \ - ? (pm)->pmnames[g] : (pm)->pmnames[NEUTRAL]) -#endif - #endif /* PERMONST_H */