diff options
author | Chris Campbell <chriscampbell89@gmail.com> | 2014-07-02 18:53:54 +0100 |
---|---|---|
committer | Chris Campbell <chriscampbell89@gmail.com> | 2014-07-02 18:54:28 +0100 |
commit | ed3dc989f9b3c80e3cca87b4f1296106cebe2af0 (patch) | |
tree | f41db082847ba3cf4a15c8aad51a22c293dbad72 /crawl-ref/source/items.cc | |
parent | a37b6925ebd20230feb22c95b93c2510ab5a6d15 (diff) | |
download | crawl-ref-ed3dc989f9b3c80e3cca87b4f1296106cebe2af0.tar.gz crawl-ref-ed3dc989f9b3c80e3cca87b4f1296106cebe2af0.zip |
Fix a crash when picking up part of an item stack under Gozag wrath (|amethyst)
(Hopefully). Still has incorrect messaging when picking up only part of a
stack.
Diffstat (limited to 'crawl-ref/source/items.cc')
-rw-r--r-- | crawl-ref/source/items.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index 74aeb86ca2..cccb342c21 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -1751,12 +1751,13 @@ int move_item_to_player(int obj, int quant_got, bool quiet) prob = 1.0; int goldify = 0; - for (int i = 0; i < it.quantity; i++) + for (int i = 0; i < quant_got; i++) if (bernoulli(1.0, prob)) goldify++; if (goldify > 0) { + // XXX: Gives the wrong message when only picking up part of a stack. string msg = get_desc_quantity(goldify, quant_got, "the") + " " + it.name(DESC_PLAIN); if (goldify > 1) @@ -1776,7 +1777,8 @@ int move_item_to_player(int obj, int quant_got, bool quiet) if (dec_mitm_item_quantity(obj, goldify)) return goldify; - quant_got -= goldify; + if ((quant_got -= goldify) == 0) + return 1; } } |