Skip to content

Commit

Permalink
Fix some reflection bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
FredrIQ committed Jul 12, 2017
1 parent 32e59e6 commit 8792701
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion libnethack/src/muse.c
Original file line number Diff line number Diff line change
Expand Up @@ -3038,6 +3038,16 @@ searches_for_item(struct monst *mon, struct obj *obj)
return FALSE;
}

/* Helper for mon_reflects */
static boolean
reflect_slot(unsigned reason, enum objslot rslot, enum objslot *slot)
{
if (!(reason & W_MASK(rslot)))
return FALSE;
*slot = rslot;
return TRUE;
}

/* magr = monster whose attack or reflection is being reflected or NULL if
the reflection wasn't caused by any monster (divine lightning zaps).
Expand All @@ -3054,7 +3064,7 @@ mon_reflects(const struct monst *mon, const struct monst *magr,
mon_s = (mon == &youmonst) ? "your" : s_suffix(mon_nam(mon));
enum objslot slot = os_invalid;
if (reflect_reason) {
#define refl(rslot) ((slot = rslot) && reflect_reason & W_MASK(rslot))
#define refl(rslot) (reflect_slot(reflect_reason, rslot, &slot))
if (fmt && str)
pline(combat_msgc(magr, mon, recursive ?
cr_miss : cr_immune),
Expand Down Expand Up @@ -3096,6 +3106,10 @@ mon_reflects(const struct monst *mon, const struct monst *magr,
} else if (slot != os_invalid && slot <= os_last_worn) {
/* which_armor also work for rings */
struct obj *arm = which_armor(mon, slot);
if (!arm) {
impossible("No armor for slot %d?", slot);
return TRUE;
}
learn_oprop(arm, opm_reflects);
}
#undef refl
Expand Down

0 comments on commit 8792701

Please sign in to comment.