From 8ead488b632775cbd3a76b0e54595d63d70e6d5f Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Fri, 3 Nov 2006 04:41:30 +0000 Subject: [PATCH] inventory overflow control Prevent heroes in giant form from picking up boulders once they run out of available inventory slots to avoid an uncontrolled number of '#' entries. There is an exception: if not already carrying any boulders, they can put one into the '#' slot. Loadstones are treated the same way, although since they stack and are rare to begin with, someone would have to have gone far out of their way to have gotten many # entries with them. Assuming that you can get something other than a boulder or loadstone into the # slot (which is definitely possible, I just can't remember how), you could relatively easily get three total # entries by picking up a loadstone and polying into a giant and picking up a boulder. But I don't think there's anything wrong with that. --- doc/fixes34.4 | 1 + src/pickup.c | 21 +++++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/doc/fixes34.4 b/doc/fixes34.4 index 6e3348a13..83de25b47 100644 --- a/doc/fixes34.4 +++ b/doc/fixes34.4 @@ -264,6 +264,7 @@ fireproof containers should not burn in lava fix invalid pointer dereference after applying a wielded cream pie avoid drowned in a drowning and burned by burning if life-saving is inadequate reveal hidden monsters who change levels or are magically summoned +hero can't carry an unlimited number of boulders when poly'd into a giant Platform- and/or Interface-Specific Fixes diff --git a/src/pickup.c b/src/pickup.c index bb72fbb99..b119efe7a 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -1185,19 +1185,28 @@ boolean telekinesis; body_part(HAND), xname(obj)); return -1; } + /* override weight consideration for loadstone picked up by anybody + and for boulder picked up by hero poly'd into a giant; override + availability of open inventory slot iff not already carrying one */ if (obj->otyp == LOADSTONE || - (obj->otyp == BOULDER && throws_rocks(youmonst.data))) - return 1; /* lift regardless of current situation */ + (obj->otyp == BOULDER && throws_rocks(youmonst.data))) { + if (inv_cnt() < 52 || !carrying(obj->otyp) || merge_choice(invent, obj)) + return 1; /* lift regardless of current situation */ + /* if we reach here, we're out of slots and already have at least + one of these, so treat this one more like a normal item */ + You("are carrying too much stuff to pick up %s %s.", + (obj->quan == 1L) ? "another" : "more", simpleonames(obj)); + return -1; + } *cnt_p = carry_count(obj, container, *cnt_p, telekinesis, &old_wt, &new_wt); if (*cnt_p < 1L) { result = -1; /* nothing lifted */ + } else if ( #ifndef GOLDOBJ - } else if (obj->oclass != COIN_CLASS && inv_cnt() >= 52 && - !merge_choice(invent, obj)) { -#else - } else if (inv_cnt() >= 52 && !merge_choice(invent, obj)) { + obj->oclass != COIN_CLASS && #endif + inv_cnt() >= 52 && !merge_choice(invent, obj)) { Your("knapsack cannot accommodate any more items."); result = -1; /* nothing lifted */ } else {