diff options
Diffstat (limited to 'crawl-ref/source/items.cc')
-rw-r--r-- | crawl-ref/source/items.cc | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index ab702c249e..35e84a18d9 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -1376,15 +1376,7 @@ int find_free_slot(const item_def &i) if (slotisfree(slot)) return slot; - if (searchforward) - { - // Return first free slot - for (slot = 0; slot < ENDOFPACK; ++slot) { - if (!is_valid_item(you.inv[slot])) - return slot; - } - } - else + if (!searchforward) { // This is the new default free slot search. We look for the last // available slot that does not leave a gap in the inventory. @@ -1405,6 +1397,16 @@ int find_free_slot(const item_def &i) } } } + + // Either searchforward is true, or search backwards failed and + // we re-try searching the oposite direction. + + // Return first free slot + for (slot = 0; slot < ENDOFPACK; ++slot) { + if (!is_valid_item(you.inv[slot])) + return slot; + } + return (-1); #undef slotisfree } |