Use a macro for all foo_RES to MR_foo conversions

This makes it easier to understand what is happening in each of those
places, and also much easier to find the places that conversion between
hero and monster resistances happens (since you can now just grep for
"res_to_mr").  I think I got all the instances where the macro should be
used but I'm not 100% sure since there wasn't a single unique term to
search for to find them all.

I replaced the modifications to give_u_to_m_resistances made in the
previous commit, so that it now uses the same macro as other
conversions, since otherwise it would be much harder to find the
complete list of places where conversions between hero and monster
properties happen.
This commit is contained in:
Michael Meyer
2023-12-20 13:33:40 -05:00
committed by PatR
parent a71866d7d9
commit 4ac8241917
5 changed files with 17 additions and 27 deletions

View File

@@ -20,7 +20,10 @@ enum prop_types {
POISON_RES = 6,
ACID_RES = 7,
STONE_RES = 8,
/* note: for the first eight properties, MR_xxx == (1 << (xxx_RES - 1)) */
/* note: the first eight properties above are equivalent to MR_xxx bits
* MR_FIRE through MR_STONE, and can be directly converted to them: */
#define res_to_mr(r) \
((FIRE_RES <= (r) && (r) <= STONE_RES) ? (uchar) (1 << ((r) - 1)) : 0x00)
DRAIN_RES = 9,
SICK_RES = 10,
INVULNERABLE = 11,