diff options
author | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-01-16 07:05:32 +0000 |
---|---|---|
committer | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-01-16 07:05:32 +0000 |
commit | 3c4a60908487170145e20d7a7e298496bef1666f (patch) | |
tree | 3282b642e80dfa2b1bc208e54692ac4bc084b00f /crawl-ref/source/items.cc | |
parent | c4968d0089d5c0d165b38b8f3c3e3f7983d0e191 (diff) | |
download | crawl-ref-3c4a60908487170145e20d7a7e298496bef1666f.tar.gz crawl-ref-3c4a60908487170145e20d7a7e298496bef1666f.zip |
Fix bug #2510110: blood potions coagulating while in a monster's inventory
was causing crashes.
Get rid of drop_blood_potions_stack() and pick_up_blood_potions_stack(),
replace with the more general merge_blood_potion_stacks() and
merge_item_stacks().
When creating blood potions via debug command you can now specify how many
turns away from coagulating/rotting it should be.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8471 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/items.cc')
-rw-r--r-- | crawl-ref/source/items.cc | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index 5e4fe0129b..ca2dcb11f6 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -1408,6 +1408,17 @@ bool items_stack( const item_def &item1, const item_def &item2, return items_similar(item1, item2); } +void merge_item_stacks(item_def &source, item_def &dest, int quant) +{ + if (quant == -1) + quant = source.quantity; + + ASSERT(quant > 0 && quant <= source.quantity); + + if (is_blood_potion(source) && is_blood_potion(dest)) + merge_blood_potion_stacks(source, dest, quant); +} + static int _userdef_find_free_slot(const item_def &i) { #ifdef CLUA_BINDINGS @@ -1599,8 +1610,7 @@ int move_item_to_player( int obj, int quant_got, bool quiet, "god gift", ""); } - if (is_blood_potion(mitm[obj])) - pick_up_blood_potions_stack(mitm[obj], quant_got); + merge_item_stacks(mitm[obj], you.inv[m], quant_got); inc_inv_item_quantity( m, quant_got ); dec_mitm_item_quantity( obj, quant_got ); @@ -1745,6 +1755,7 @@ bool move_item_to_grid( int *const obj, const coord_def& p ) // Add quantity to item already here, and dispose // of obj, while returning the found item. -- bwr inc_mitm_item_quantity( si->index(), item.quantity ); + merge_item_stacks(item, *si); destroy_item( ob ); ob = si->index(); return (true); @@ -1837,12 +1848,8 @@ bool copy_item_to_grid( const item_def &item, const coord_def& p, if (items_stack( item, *si )) { inc_mitm_item_quantity( si->index(), quant_drop ); - - if (is_blood_potion(item)) - { - item_def help = item; - drop_blood_potions_stack(help, quant_drop, p); - } + item_def copy = item; + merge_item_stacks(copy, *si, quant_drop); // If the items on the floor already have a nonzero slot, // leave it as such, otherwise set the slot. |