more MUSE WAND_STRING (should be WAND_STRIKING)

Reverse part of commit 8b5e9eadb1.
Shouldn't use get_obj_location(obj,...) to try to figure out if obj
has been deleted.  That routine uses obj->where rather than scanning
the various object lists and doing that when obj has been deleted
would access stale memory.
This commit is contained in:
PatR
2023-12-12 20:15:50 -08:00
parent c3f9d8cde2
commit dc02eb3e4f

View File

@@ -1660,12 +1660,21 @@ mbhit(
/* this might kill mon and destroy obj; mon will remain
accessible even if dead but obj could be deleted */
destroy_drawbridge(dbx, dby);
if (!get_obj_location(obj, &dbx, &dbx, /* reuse <dbx,dby> */
CONTAINED_TOO | BURIED_TOO)) {
/* couldn't find obj, so assume that it has been destroyed
and end the zap; not really correct behavior but we can't
continue without the wand because fhitm (mbhitm) and fhito
(bhito) would want it at forthcoming spots in zap path */
for (otmp = mon->minvent; otmp; otmp = otmp->nobj)
if (otmp == obj)
break;
if (!otmp) {
for (otmp = gl.level.objects[x][y]; otmp;
otmp = otmp->nexthere)
if (otmp == obj)
break;
}
/* if otmp is Null, mon isn't carrying obj anymore and didn't
just drop it here; assume that it was destroyed and stop
the zap; not really correct behavior but we can't continue
without the responsible object because fhitm (mbhitm) and
fhito (bhito) will want it at forthcoming spots in zap path */
if (!otmp) {
/*obj = NULL;*/
break;
}