From dc02eb3e4fdee69072d1080afddf0765a7fb14c6 Mon Sep 17 00:00:00 2001 From: PatR Date: Tue, 12 Dec 2023 20:15:50 -0800 Subject: [PATCH] more MUSE WAND_STRING (should be WAND_STRIKING) Reverse part of commit 8b5e9eadb1dc0e612bc690ea2f454a02ba95a7f5. 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. --- src/muse.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/muse.c b/src/muse.c index fe3a54de5..0a9deee67 100644 --- a/src/muse.c +++ b/src/muse.c @@ -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 */ - 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; }