encumbrance feedback fix
Wishing for an item uses hold_another_object to put it into inventory and hold_another_object wasn't reporting changes in encumbrance. That feedback would happen at start of next turn so its lack usually wasn't noticeable, but encumbrance could be off for remainder of the current turn which might include additional move(s). Report indicated that dropping something seemed to increase encumbrance instead of decrease it, but it was dropped on an extra move and actually a delayed report of the increase that hold_another_object failed to show. I fixed a couple of other things with hold_another_object: it would add an item to inventory, which triggered an update of persistent inventory if that was enabled, then remove it from inventory in order to drop it if fumbling or inventory had too many items or encumbrance was going to become too high, triggering a second update of persistent inventory to reverse the first one. Also, "encumbrance becoming too high" was using hardcoded Stressed instead of the 'pickup_burden' option that manages the same situation during pickup. Not because hold_another_object isn't pickup, but because its use of hardcoded Stressed predated implementation of that option. There was another fix for hold_another_object recently and I've moved the fixes entry for that one to group it with the new ones. Also, update an obsolete (from !GOLDOBJ config) comment in makewish().
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
$NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.218 $ $NHDT-Date: 1589323704 2020/05/12 22:48:24 $
|
||||
$NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.219 $ $NHDT-Date: 1589491665 2020/05/14 21:27:45 $
|
||||
|
||||
General Fixes and Modified Features
|
||||
-----------------------------------
|
||||
@@ -166,8 +166,6 @@ change light radius of stack of candles to square root
|
||||
could get redundate "mon hits other-mon" messages when mon wields an artifact
|
||||
failed untrap while mounted that moved hero onto the trap would leave steed
|
||||
with stale coordinates, triggering warnings if 'sanity_check' is On
|
||||
when hold_another_object() fails while hero is swallowed, drop the item into
|
||||
swallower's inventory instead of onto the floor
|
||||
when digging a pit results in it being filled by adjacent pool or lava, any
|
||||
objects at the spot weren't subjected to water or fire damage;
|
||||
also, riding hero's steed wasn't subjected to immersion either
|
||||
@@ -179,6 +177,16 @@ falling while going down stairs and dropping items due to encumbrance or
|
||||
punishment wasn't subject fragile ones to breakage
|
||||
objects scattered by an explosion which land on water or lava weren't affected
|
||||
by the water or lava
|
||||
hold_another_object (for wishing, horn of plenty, theft while poly'd, other
|
||||
non-pickup actions giving hero another inventory item) wasn't
|
||||
reporting change in encumbrance; that would catch up on next turn but
|
||||
could be off during additional move(s) for current turn
|
||||
hold_another_object added item to inventory first, then maybe removed and
|
||||
dropped it, resulting in spurious add and remove perm_invent updates
|
||||
hold_another_object used hardcoded Stressed to limit carrying instead of
|
||||
using the 'pickup_burden' option for that
|
||||
when hold_another_object fails while hero is swallowed, drop the item into
|
||||
swallower's inventory instead of onto the floor
|
||||
|
||||
|
||||
Fixes to 3.7.0-x Problems that Were Exposed Via git Repository
|
||||
|
||||
36
src/invent.c
36
src/invent.c
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 invent.c $NHDT-Date: 1588189423 2020/04/29 19:43:43 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.297 $ */
|
||||
/* NetHack 3.7 invent.c $NHDT-Date: 1589491665 2020/05/14 21:27:45 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.298 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Derek S. Ray, 2015. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -19,7 +19,8 @@ static int FDECL(invletter_value, (CHAR_P));
|
||||
static int FDECL(CFDECLSPEC sortloot_cmp, (const genericptr,
|
||||
const genericptr));
|
||||
static void NDECL(reorder_invent);
|
||||
static struct obj *FDECL(addinv_core0, (struct obj *, struct obj *));
|
||||
static struct obj *FDECL(addinv_core0, (struct obj *, struct obj *,
|
||||
BOOLEAN_P));
|
||||
static void FDECL(noarmor, (BOOLEAN_P));
|
||||
static void FDECL(invdisp_nothing, (const char *, const char *));
|
||||
static boolean FDECL(worn_wield_only, (struct obj *));
|
||||
@@ -875,8 +876,9 @@ struct obj *obj;
|
||||
* Adjust hero attributes as necessary.
|
||||
*/
|
||||
static struct obj *
|
||||
addinv_core0(obj, other_obj)
|
||||
addinv_core0(obj, other_obj, update_perm_invent)
|
||||
struct obj *obj, *other_obj;
|
||||
boolean update_perm_invent;
|
||||
{
|
||||
struct obj *otmp, *prev;
|
||||
int saved_otyp = (int) obj->otyp; /* for panic */
|
||||
@@ -950,7 +952,8 @@ struct obj *obj, *other_obj;
|
||||
added:
|
||||
addinv_core2(obj);
|
||||
carry_obj_effects(obj); /* carrying affects the obj */
|
||||
update_inventory();
|
||||
if (update_perm_invent)
|
||||
update_inventory();
|
||||
return obj;
|
||||
}
|
||||
|
||||
@@ -959,7 +962,7 @@ struct obj *
|
||||
addinv(obj)
|
||||
struct obj *obj;
|
||||
{
|
||||
return addinv_core0(obj, (struct obj *) 0);
|
||||
return addinv_core0(obj, (struct obj *) 0, TRUE);
|
||||
}
|
||||
|
||||
/* add obj to the hero's inventory by inserting in front of a specific item */
|
||||
@@ -967,7 +970,7 @@ struct obj *
|
||||
addinv_before(obj, other_obj)
|
||||
struct obj *obj, *other_obj;
|
||||
{
|
||||
return addinv_core0(obj, other_obj);
|
||||
return addinv_core0(obj, other_obj, TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1034,22 +1037,26 @@ const char *drop_fmt, *drop_arg, *hold_msg;
|
||||
}
|
||||
if (Fumbling) {
|
||||
obj->nomerge = 1;
|
||||
obj = addinv(obj); /* dropping expects obj to be in invent */
|
||||
/* dropping expects obj to be in invent */
|
||||
obj = addinv_core0(obj, (struct obj *) 0, FALSE);
|
||||
goto drop_it;
|
||||
} else {
|
||||
long oquan = obj->quan;
|
||||
int prev_encumbr = near_capacity(); /* before addinv() */
|
||||
|
||||
/* encumbrance only matters if it would now become worse
|
||||
than max( current_value, stressed ) */
|
||||
if (prev_encumbr < MOD_ENCUMBER)
|
||||
prev_encumbr = MOD_ENCUMBER;
|
||||
/* encumbrance limit is max( current_state, pickup_burden );
|
||||
this used to use hardcoded MOD_ENCUMBER (stressed) instead
|
||||
of the 'pickup_burden' option (which defaults to stressed) */
|
||||
if (prev_encumbr < flags.pickup_burden)
|
||||
prev_encumbr = flags.pickup_burden;
|
||||
/* addinv() may redraw the entire inventory, overwriting
|
||||
drop_arg when it comes from something like doname() */
|
||||
drop_arg when it is kept in an 'obuf' from doname();
|
||||
[should no longer be necessary now that perm_invent update is
|
||||
suppressed, but it's cheap to keep as a paranoid precaution] */
|
||||
if (drop_arg)
|
||||
drop_arg = strcpy(buf, drop_arg);
|
||||
|
||||
obj = addinv(obj);
|
||||
obj = addinv_core0(obj, (struct obj *) 0, FALSE);
|
||||
if (inv_cnt(FALSE) > 52 || ((obj->otyp != LOADSTONE || !obj->cursed)
|
||||
&& near_capacity() > prev_encumbr)) {
|
||||
/* undo any merge which took place */
|
||||
@@ -1063,6 +1070,9 @@ const char *drop_fmt, *drop_arg, *hold_msg;
|
||||
setuqwep(obj);
|
||||
if (hold_msg || drop_fmt)
|
||||
prinv(hold_msg, obj, oquan);
|
||||
/* obj made it into inventory and is staying there */
|
||||
update_inventory();
|
||||
encumber_msg();
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 zap.c $NHDT-Date: 1586633039 2020/04/11 19:23:59 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.335 $ */
|
||||
/* NetHack 3.6 zap.c $NHDT-Date: 1589491666 2020/05/14 21:27:46 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.340 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Robert Patrick Rankin, 2013. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -5365,9 +5365,8 @@ makewish()
|
||||
}
|
||||
/*
|
||||
* Note: if they wished for and got a non-object successfully,
|
||||
* otmp == &cg.zeroobj. That includes gold, or an artifact that
|
||||
* has been denied. Wishing for "nothing" requires a separate
|
||||
* value to remain distinct.
|
||||
* otmp == &zeroobj. That includes an artifact which has been denied.
|
||||
* Wishing for "nothing" requires a separate value to remain distinct.
|
||||
*/
|
||||
otmp = readobjnam(buf, ¬hing);
|
||||
if (!otmp) {
|
||||
|
||||
Reference in New Issue
Block a user