Skip to content

Commit

Permalink
inventory overflow control
Browse files Browse the repository at this point in the history
     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.
  • Loading branch information
nethack.rankin committed Nov 3, 2006
1 parent 53060e3 commit 8ead488
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions doc/fixes34.4
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 15 additions & 6 deletions src/pickup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 8ead488

Please sign in to comment.