diff --git a/src/muse.c b/src/muse.c index 83bafe2df..fe3a54de5 100644 --- a/src/muse.c +++ b/src/muse.c @@ -1652,26 +1652,21 @@ mbhit( } ltyp = levl[gb.bhitpos.x][gb.bhitpos.y].typ; dbx = x, dby = y; - if (otyp == WAN_STRIKING && find_drawbridge(&dbx, &dby)) { + if (otyp == WAN_STRIKING + /* if levl[x][y].typ is DRAWBRIDGE_UP then the zap is passing + over the moat in front of a closed drawbridge and doesn't + hit any part of the bridge's mechanism */ + && ltyp != DRAWBRIDGE_UP && find_drawbridge(&dbx, &dby)) { /* this might kill mon and destroy obj; mon will remain accessible even if dead but obj could be deleted */ destroy_drawbridge(dbx, dby); - 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; + 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 */ + /*obj = NULL;*/ break; } } else if (IS_DOOR(ltyp) || ltyp == SDOOR) { @@ -1701,10 +1696,6 @@ mbhit( break; } } - /* 'obj' was set of Null when it couldn't be found, but isn't used again; - however, someday that might change, so we want it set to Null; give it - a fake use to pacify potential "set but not used"-type warnings */ - nhUse(obj); } /* Perform an offensive action for a monster. Must be called immediately