Re-fix altar compiler warning
Implement a better fix for commit2f4f7d22d("Fix align type mixup wth align mask") which was reverted in commit4e35e8b5a("Revert "Fix align type mixup wth align mask""). In the present code, the field align in both struct altar and struct monster is not an aligntyp, but an align mask with extra flags. Change the type to match its actual use and improve the naming. Consolidate duplicated code into a single routine. Change the return type of induced_align() to be unsigned to match amask usage. Change the special level align mask values to be separate from the normal align mask values.
This commit is contained in:
@@ -24,20 +24,21 @@ typedef struct align { /* alignment & record */
|
||||
#define A_COALIGNED 1
|
||||
#define A_OPALIGNED (-1)
|
||||
|
||||
#define AM_NONE 0
|
||||
#define AM_CHAOTIC 1
|
||||
#define AM_NEUTRAL 2
|
||||
#define AM_LAWFUL 4
|
||||
/* align masks */
|
||||
#define AM_NONE 0x00
|
||||
#define AM_CHAOTIC 0x01
|
||||
#define AM_NEUTRAL 0x02
|
||||
#define AM_LAWFUL 0x04
|
||||
#define AM_MASK 0x07 /* mask for "normal" alignment values */
|
||||
|
||||
#define AM_MASK 7
|
||||
/* Some altars are considered as shrines, so we need a flag for that
|
||||
/* Some altars are considered shrines, add a flag for that
|
||||
for the altarmask field of struct rm. */
|
||||
#define AM_SHRINE 8
|
||||
#define AM_SHRINE 0x08
|
||||
|
||||
/* special level flags, gone by the time the level has been loaded */
|
||||
#define AM_SPLEV_CO 3 /* co-aligned: force alignment to match hero's */
|
||||
#define AM_SPLEV_NONCO 7 /* non-co-aligned: force alignment to not match */
|
||||
#define AM_SPLEV_RANDOM 8
|
||||
#define AM_SPLEV_CO 0x10 /* co-aligned: force alignment to match hero's */
|
||||
#define AM_SPLEV_NONCO 0x20 /* non-co-aligned: force alignment to not match */
|
||||
#define AM_SPLEV_RANDOM 0x40
|
||||
|
||||
#define Amask2align(x) \
|
||||
((aligntyp) ((((x) & AM_MASK) == 0) ? A_NONE \
|
||||
|
||||
Reference in New Issue
Block a user