diff options
author | Jesse Luehrs <doy@tozt.net> | 2009-11-26 15:53:54 -0600 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2009-11-26 15:54:23 -0600 |
commit | ed9bd2a254234572bc1f4d18ab7ac7766ab3bc4c (patch) | |
tree | 37e13dafa63149d105858fe4b7093fe227206c0f /crawl-ref/source | |
parent | 4aefee616c2671431e91c35560fc298d7df5a44d (diff) | |
download | crawl-ref-ed9bd2a254234572bc1f4d18ab7ac7766ab3bc4c.tar.gz crawl-ref-ed9bd2a254234572bc1f4d18ab7ac7766ab3bc4c.zip |
fix slot selection for picked up items
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/items.cc | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index c516769db3..c794c01c0e 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -1420,21 +1420,22 @@ int find_free_slot(const item_def &i) { // This is the new default free slot search. We look for the last // available slot that does not leave a gap in the inventory. - bool accept_empty = false; for (slot = ENDOFPACK - 1; slot >= 0; --slot) { - if (slot == disliked) - continue; - - if (slot > 0 && you.inv[slot - 1].is_valid()) + if (you.inv[slot].is_valid()) { - if (!accept_empty && !you.inv[slot].is_valid()) - return slot; - accept_empty = true; + if (slot + 1 < ENDOFPACK && !you.inv[slot + 1].is_valid() + && slot + 1 != disliked) + { + return (slot + 1); + } } - else if (accept_empty) + else { - return slot; + if (slot + 1 < ENDOFPACK && you.inv[slot + 1].is_valid() + && slot != disliked) { + return (slot); + } } } } @@ -1448,7 +1449,7 @@ int find_free_slot(const item_def &i) return slot; // If the least preferred slot is the only choice, so be it. - if (disliked != -1 && you.inv[disliked].is_valid()) + if (disliked != -1 && !you.inv[disliked].is_valid()) return disliked; return (-1); |