Fix segfault when attacked while polyed into disenchanter
The pointer keeping tabs of monster's current weapon was not cleared. How to trigger: Get hit by a monster wielding a weapon, teleport to another level, poly into disenchanter, get hit by any monster with AD_PHYS attack and not wielding any weapon.
This commit is contained in:
18
src/mhitu.c
18
src/mhitu.c
@@ -5,7 +5,7 @@
|
|||||||
#include "hack.h"
|
#include "hack.h"
|
||||||
#include "artifact.h"
|
#include "artifact.h"
|
||||||
|
|
||||||
STATIC_VAR NEARDATA struct obj *otmp;
|
STATIC_VAR NEARDATA struct obj *mon_currwep = (struct obj *) 0;
|
||||||
|
|
||||||
STATIC_DCL boolean FDECL(u_slip_free, (struct monst *, struct attack *));
|
STATIC_DCL boolean FDECL(u_slip_free, (struct monst *, struct attack *));
|
||||||
STATIC_DCL int FDECL(passiveum, (struct permonst *, struct monst *,
|
STATIC_DCL int FDECL(passiveum, (struct permonst *, struct monst *,
|
||||||
@@ -646,6 +646,7 @@ register struct monst *mtmp;
|
|||||||
|
|
||||||
for (i = 0; i < NATTK; i++) {
|
for (i = 0; i < NATTK; i++) {
|
||||||
sum[i] = 0;
|
sum[i] = 0;
|
||||||
|
mon_currwep = (struct obj *)0;
|
||||||
mattk = getmattk(mtmp, &youmonst, i, sum, &alt_attk);
|
mattk = getmattk(mtmp, &youmonst, i, sum, &alt_attk);
|
||||||
if ((u.uswallow && mattk->aatyp != AT_ENGL)
|
if ((u.uswallow && mattk->aatyp != AT_ENGL)
|
||||||
|| (skipnonmagc && mattk->aatyp != AT_MAGC))
|
|| (skipnonmagc && mattk->aatyp != AT_MAGC))
|
||||||
@@ -747,18 +748,18 @@ register struct monst *mtmp;
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (foundyou) {
|
if (foundyou) {
|
||||||
otmp = MON_WEP(mtmp);
|
mon_currwep = MON_WEP(mtmp);
|
||||||
if (otmp) {
|
if (mon_currwep) {
|
||||||
hittmp = hitval(otmp, &youmonst);
|
hittmp = hitval(mon_currwep, &youmonst);
|
||||||
tmp += hittmp;
|
tmp += hittmp;
|
||||||
mswings(mtmp, otmp);
|
mswings(mtmp, mon_currwep);
|
||||||
}
|
}
|
||||||
if (tmp > (j = dieroll = rnd(20 + i)))
|
if (tmp > (j = dieroll = rnd(20 + i)))
|
||||||
sum[i] = hitmu(mtmp, mattk);
|
sum[i] = hitmu(mtmp, mattk);
|
||||||
else
|
else
|
||||||
missmu(mtmp, (tmp == j), mattk);
|
missmu(mtmp, (tmp == j), mattk);
|
||||||
/* KMH -- Don't accumulate to-hit bonuses */
|
/* KMH -- Don't accumulate to-hit bonuses */
|
||||||
if (otmp)
|
if (mon_currwep)
|
||||||
tmp -= hittmp;
|
tmp -= hittmp;
|
||||||
} else {
|
} else {
|
||||||
wildmiss(mtmp, mattk);
|
wildmiss(mtmp, mattk);
|
||||||
@@ -968,6 +969,7 @@ register struct attack *mattk;
|
|||||||
: "crushed");
|
: "crushed");
|
||||||
}
|
}
|
||||||
} else { /* hand to hand weapon */
|
} else { /* hand to hand weapon */
|
||||||
|
struct obj *otmp = mon_currwep;
|
||||||
if (mattk->aatyp == AT_WEAP && otmp) {
|
if (mattk->aatyp == AT_WEAP && otmp) {
|
||||||
int tmp;
|
int tmp;
|
||||||
|
|
||||||
@@ -2710,10 +2712,10 @@ register struct attack *mattk;
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
case AD_ENCH: /* KMH -- remove enchantment (disenchanter) */
|
case AD_ENCH: /* KMH -- remove enchantment (disenchanter) */
|
||||||
if (otmp) {
|
if (mon_currwep) {
|
||||||
/* by_you==True: passive counterattack to hero's action
|
/* by_you==True: passive counterattack to hero's action
|
||||||
is hero's fault */
|
is hero's fault */
|
||||||
(void) drain_item(otmp, TRUE);
|
(void) drain_item(mon_currwep, TRUE);
|
||||||
/* No message */
|
/* No message */
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user