fix #K4026 - "object lost" panic during theft

"object lost" panic occurred when hero's worn amulet of magical
breathing was stolen.  This prevents drown() -> emergency_disrobe()
from dropping an item while in the midst of it being stolen, avoiding
the possibility of it no longer being in inventory when the theft
completes.  There may be variations other than drowning that lead to
unwear -> drop-or-destroy that are still vulnerable, and this fix can
potentially cause items to vanish from hangup save files.

It also has a side-effect of not being able to drop levitation boots
to lighten encumbrance enough to crawl out of water if the drowning
occurs while they are being taken off, not just when being stolen,
even though they should be easily droppable in such circumstance.  The
hero will just need to drop other things instead.
This commit is contained in:
PatR
2023-11-01 01:54:32 -07:00
parent c8a84acfa5
commit fa0f3751a3
3 changed files with 41 additions and 3 deletions

View File

@@ -4634,14 +4634,16 @@ emergency_disrobe(boolean *lostsome)
* Undroppables are: body armor, boots, gloves,
* amulets, and rings because of the time and effort
* in removing them + loadstone and other cursed stuff
* for obvious reasons.
* for obvious reasons. Also, any item in the midst
* of being taken off or stolen.
*/
if (!((obj->otyp == LOADSTONE && obj->cursed) || obj == uamul
|| obj == uleft || obj == uright || obj == ublindf
|| obj == uarm || obj == uarmc || obj == uarmg
|| obj == uarmf || obj == uarmu
|| (obj->cursed && (obj == uarmh || obj == uarms))
|| welded(obj)))
|| welded(obj)
|| obj->o_id == gs.stealoid || obj->in_use))
otmp = obj;
/* reached the mark and found some stuff to drop? */
if (--i < 0 && otmp)