shrink_glob bug when when glob is totally gone

When a wielded glob shrank away to nothing, an impossible warning:
"obfree: deleting worn obj" would be issued.

If a glob is quivered or wielded or set up as swap weapon when it
shrinks away to nothing, clear the relevant weapon slot before
destroying the glob.

Won't happen for monsters since they never wield globs.  Also won't
happen for migrating objects (which overload obj->owornmask) because
they have to have arrived somewhere in order to have their shrink
timer execute.
This commit is contained in:
PatR
2021-12-10 20:16:30 -08:00
parent 8aa90bdbac
commit ba255875cd
3 changed files with 25 additions and 17 deletions

View File

@@ -1996,19 +1996,13 @@ rot_corpse(anything *arg, long timeout)
Your("%s%s %s away%c", obj == uwep ? "wielded " : "", cname,
otense(obj, "rot"), obj == uwep ? '!' : '.');
}
if (obj == uwep) {
uwepgone(); /* now bare handed */
stop_occupation();
} else if (obj == uswapwep) {
uswapwepgone();
stop_occupation();
} else if (obj == uquiver) {
uqwepgone();
if (obj->owornmask) {
remove_worn_item(obj, TRUE);
stop_occupation();
}
} else if (obj->where == OBJ_MINVENT && obj->owornmask) {
if (obj == MON_WEP(obj->ocarry))
setmnotwielded(obj->ocarry, obj);
} else if (obj->where == OBJ_MINVENT) {
if (obj->owornmask && obj == MON_WEP(obj->ocarry))
setmnotwielded(obj->ocarry, obj); /* clears owornmask */
} 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 */