From 690e072a4930340c25dba90a79129b2eaa5b051a Mon Sep 17 00:00:00 2001 From: nhmall Date: Thu, 6 Feb 2020 12:09:24 -0500 Subject: [PATCH] is_elf(), is_dwarf(), is_gnome(), is_orc(), is_human() Those tests were only checking the permonst mflags2 field so anytime those tests were used in the code, they came up false for things like an elven ranger. An elven ranger should return true for an is_elf() test, as an example. That happens because the profession monsters in monst.c are defined with M2_HUMAN. This augments those is_*() race tests to also check for a matching player race as well. --- include/mondata.h | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/include/mondata.h b/include/mondata.h index e84a09272..65ad58eca 100644 --- a/include/mondata.h +++ b/include/mondata.h @@ -101,11 +101,21 @@ #define is_shapeshifter(ptr) (((ptr)->mflags2 & M2_SHAPESHIFTER) != 0L) #define is_undead(ptr) (((ptr)->mflags2 & M2_UNDEAD) != 0L) #define is_were(ptr) (((ptr)->mflags2 & M2_WERE) != 0L) -#define is_elf(ptr) (((ptr)->mflags2 & M2_ELF) != 0L) -#define is_dwarf(ptr) (((ptr)->mflags2 & M2_DWARF) != 0L) -#define is_gnome(ptr) (((ptr)->mflags2 & M2_GNOME) != 0L) -#define is_orc(ptr) (((ptr)->mflags2 & M2_ORC) != 0L) -#define is_human(ptr) (((ptr)->mflags2 & M2_HUMAN) != 0L) +#define is_elf(ptr) ((((ptr)->mflags2 & M2_ELF) != 0L) \ + || ((ptr) == g.youmonst.data && \ + !Upolyd && Race_if(PM_ELF))) +#define is_dwarf(ptr) ((((ptr)->mflags2 & M2_DWARF) != 0L) \ + || ((ptr) == g.youmonst.data && \ + !Upolyd && Race_if(PM_DWARF))) +#define is_gnome(ptr) ((((ptr)->mflags2 & M2_GNOME) != 0L) \ + || ((ptr) == g.youmonst.data && \ + !Upolyd && Race_if(PM_GNOME))) +#define is_orc(ptr) ((((ptr)->mflags2 & M2_ORC) != 0L) \ + || ((ptr) == g.youmonst.data && \ + !Upolyd && Race_if(PM_ORC))) +#define is_human(ptr) ((((ptr)->mflags2 & M2_HUMAN) != 0L) \ + || ((ptr) == g.youmonst.data && \ + !Upolyd && Race_if(PM_HUMAN))) #define your_race(ptr) (((ptr)->mflags2 & g.urace.selfmask) != 0L) #define is_bat(ptr) \ ((ptr) == &mons[PM_BAT] || (ptr) == &mons[PM_GIANT_BAT] \