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:
@@ -1498,20 +1498,14 @@ monstunseesu(unsigned long seenres)
|
||||
void
|
||||
give_u_to_m_resistances(struct monst *mtmp)
|
||||
{
|
||||
const struct {
|
||||
int u;
|
||||
unsigned short m;
|
||||
} u_to_m_res[] = {
|
||||
{ FIRE_RES, MR_FIRE }, { COLD_RES, MR_COLD },
|
||||
{ SLEEP_RES, MR_SLEEP }, { DISINT_RES, MR_DISINT },
|
||||
{ SHOCK_RES, MR_ELEC }, { POISON_RES, MR_POISON },
|
||||
{ ACID_RES, MR_ACID }, { STONE_RES, MR_STONE },
|
||||
};
|
||||
int i;
|
||||
int intr;
|
||||
|
||||
for (i = 0; i < SIZE(u_to_m_res); i++) {
|
||||
if ((u.uprops[u_to_m_res[i].u].intrinsic & INTRINSIC) != 0L) {
|
||||
mtmp->mintrinsics |= u_to_m_res[i].m;
|
||||
/* convert the hero's current set of intrinsics to their monster
|
||||
equivalents -- FIRE_RES to MR_FIRE, COLD_RES to MR_COLD, etc -- and
|
||||
add each to the mintrinsics field for the given monster */
|
||||
for (intr = FIRE_RES; intr <= STONE_RES; intr++) {
|
||||
if ((u.uprops[intr].intrinsic & INTRINSIC) != 0L) {
|
||||
mtmp->mintrinsics |= (unsigned short) res_to_mr(intr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user