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:
PatR
2018-12-23 12:37:26 -08:00
parent df5dc6050d
commit 7bc36ddef4
11 changed files with 68 additions and 47 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 do.c $NHDT-Date: 1545043771 2018/12/17 10:49:31 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.181 $ */
/* NetHack 3.6 do.c $NHDT-Date: 1545597418 2018/12/23 20:36:58 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.182 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Derek S. Ray, 2015. */
/* NetHack may be freely redistributed. See license for details. */
@@ -612,7 +612,7 @@ register struct obj *obj;
if (obj->oclass == COIN_CLASS)
context.botl = 1;
freeinv(obj);
hitfloor(obj);
hitfloor(obj, TRUE);
if (levhack)
float_down(I_SPECIAL | TIMEOUT, W_ARTI | W_ART);
return 1;