fix #H6942 - dropx vs hold_another_object
Dropping an existing fragile item while levitating will usually break it. Getting a new wished-for fragile item and dropping it because of fumbling or overfull inventory never would. Some callers of hold_another_object() held on to its return value, others discarded that. That return value was unsafe if the item was dropped and fell down a hole (or broke [after this change]). Return Null if we can't be sure of the value, and make sure all callers are prepared to deal with Null.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 uhitm.c $NHDT-Date: 1544840256 2018/12/15 02:17:36 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.196 $ */
|
||||
/* NetHack 3.6 uhitm.c $NHDT-Date: 1545597432 2018/12/23 20:37:12 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.197 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Robert Patrick Rankin, 2012. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -1546,7 +1546,8 @@ struct attack *mattk;
|
||||
/* give the object to the character */
|
||||
otmp = hold_another_object(otmp, "You snatched but dropped %s.",
|
||||
doname(otmp), "You steal: ");
|
||||
if (otmp->where != OBJ_INVENT)
|
||||
/* might have dropped otmp, and it might have broken or left level */
|
||||
if (!otmp || otmp->where != OBJ_INVENT)
|
||||
continue;
|
||||
if (theft_petrifies(otmp))
|
||||
break; /* stop thieving even though hero survived */
|
||||
|
||||
Reference in New Issue
Block a user