setmnotwielded should always MON_NOWEP
Instead of making the caller remember to use MON_NOWEP, make setmnotwielded handle that automatically. This fixes the "bad monster weapon restore" errors I've been seeing. Also adds sanity checks for this.
This commit is contained in:
@@ -1973,10 +1973,8 @@ long timeout; /* unused */
|
||||
stop_occupation();
|
||||
}
|
||||
} else if (obj->where == OBJ_MINVENT && obj->owornmask) {
|
||||
if (obj == MON_WEP(obj->ocarry)) {
|
||||
if (obj == MON_WEP(obj->ocarry))
|
||||
setmnotwielded(obj->ocarry, obj);
|
||||
MON_NOWEP(obj->ocarry);
|
||||
}
|
||||
} else if (obj->where == OBJ_MIGRATING) {
|
||||
/* clear destination flag so that obfree()'s check for
|
||||
freeing a worn object doesn't get a false hit */
|
||||
|
||||
12
src/mkobj.c
12
src/mkobj.c
@@ -2156,9 +2156,16 @@ struct monst *monlist;
|
||||
const char *mesg;
|
||||
{
|
||||
struct monst *mon;
|
||||
struct obj *obj;
|
||||
struct obj *obj, *mwep;
|
||||
|
||||
for (mon = monlist; mon; mon = mon->nmon)
|
||||
for (mon = monlist; mon; mon = mon->nmon) {
|
||||
mwep = MON_WEP(mon);
|
||||
if (mwep) {
|
||||
if (!mcarried(mwep))
|
||||
insane_object(mwep, mfmt1, mesg, mon);
|
||||
if (mwep->ocarry != mon)
|
||||
insane_object(mwep, mfmt2, mesg, mon);
|
||||
}
|
||||
for (obj = mon->minvent; obj; obj = obj->nobj) {
|
||||
if (obj->where != OBJ_MINVENT)
|
||||
insane_object(obj, mfmt1, mesg, mon);
|
||||
@@ -2166,6 +2173,7 @@ const char *mesg;
|
||||
insane_object(obj, mfmt2, mesg, mon);
|
||||
check_contained(obj, mesg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* This must stay consistent with the defines in obj.h. */
|
||||
|
||||
@@ -282,10 +282,8 @@ struct obj *obj; /* missile (or stack providing it) */
|
||||
|
||||
/* not possibly_unwield, which checks the object's */
|
||||
/* location, not its existence */
|
||||
if (MON_WEP(mon) == obj) {
|
||||
if (MON_WEP(mon) == obj)
|
||||
setmnotwielded(mon, obj);
|
||||
MON_NOWEP(mon);
|
||||
}
|
||||
obj_extract_self(obj);
|
||||
singleobj = obj;
|
||||
obj = (struct obj *) 0;
|
||||
|
||||
@@ -670,7 +670,6 @@ int thrown; /* HMON_xxx (0 => hand-to-hand, other => ranged) */
|
||||
* the percentage chance is (1/20)*(50/100).]
|
||||
*/
|
||||
setmnotwielded(mon, monwep);
|
||||
MON_NOWEP(mon);
|
||||
mon->weapon_check = NEED_WEAPON;
|
||||
pline("%s from the force of your blow!",
|
||||
Yobjnam2(monwep, "shatter"));
|
||||
@@ -1349,10 +1348,8 @@ struct attack *mattk;
|
||||
obj_extract_self(otmp);
|
||||
if ((unwornmask = otmp->owornmask) != 0L) {
|
||||
mdef->misc_worn_check &= ~unwornmask;
|
||||
if (otmp->owornmask & W_WEP) {
|
||||
if (otmp->owornmask & W_WEP)
|
||||
setmnotwielded(mdef, otmp);
|
||||
MON_NOWEP(mdef);
|
||||
}
|
||||
otmp->owornmask = 0L;
|
||||
update_mon_intrinsics(mdef, otmp, FALSE, FALSE);
|
||||
|
||||
|
||||
@@ -582,7 +582,6 @@ boolean polyspot;
|
||||
}
|
||||
if (!attacktype(mon->data, AT_WEAP)) {
|
||||
setmnotwielded(mon, mw_tmp);
|
||||
MON_NOWEP(mon);
|
||||
mon->weapon_check = NO_WEAPON_WANTED;
|
||||
obj_extract_self(obj);
|
||||
if (cansee(mon->mx, mon->my)) {
|
||||
@@ -735,7 +734,6 @@ struct monst *mon;
|
||||
|
||||
if (mwep) {
|
||||
setmnotwielded(mon, mwep);
|
||||
MON_NOWEP(mon);
|
||||
mon->weapon_check = NEED_WEAPON;
|
||||
}
|
||||
}
|
||||
@@ -1443,6 +1441,8 @@ register struct obj *obj;
|
||||
s_suffix(mon_nam(mon)), mbodypart(mon, HAND),
|
||||
otense(obj, "stop"));
|
||||
}
|
||||
if (MON_WEP(mon) == obj)
|
||||
MON_NOWEP(mon);
|
||||
obj->owornmask &= ~W_WEP;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user