diff options
author | Adam Borowski <kilobyte@angband.pl> | 2009-10-07 01:28:45 +0200 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2009-10-07 01:31:13 +0200 |
commit | 36868a5a6d3e63816d9e7a2b0bfc15f8c358883d (patch) | |
tree | 9fd9655b07d54c1d22551ab39eeb9aef50e08d0b /crawl-ref/source/items.cc | |
parent | f408bf9c354f827c64e1416279b338a921545ff0 (diff) | |
download | crawl-ref-36868a5a6d3e63816d9e7a2b0bfc15f8c358883d.tar.gz crawl-ref-36868a5a6d3e63816d9e7a2b0bfc15f8c358883d.zip |
Stack identified and unidentified ammo when picking it up. (mesilliac)
If you have a stack of +0 stones, identical stones will auto-id.
Diffstat (limited to 'crawl-ref/source/items.cc')
-rw-r--r-- | crawl-ref/source/items.cc | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index 66453cda37..d6bcc32ed1 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -1304,7 +1304,7 @@ unsigned long ident_flags(const item_def &item) return (flags); } -bool items_similar(const item_def &item1, const item_def &item2) +bool items_similar(const item_def &item1, const item_def &item2, bool ignore_ident) { // Base and sub-types must always be the same to stack. if (item1.base_type != item2.base_type || item1.sub_type != item2.sub_type) @@ -1327,7 +1327,7 @@ bool items_similar(const item_def &item1, const item_def &item2) } // Check the ID flags. - if (ident_flags(item1) != ident_flags(item2)) + if (!ignore_ident && ident_flags(item1) != ident_flags(item2)) return (false); // Check the non-ID flags, but ignore dropped, thrown, cosmetic, @@ -1364,7 +1364,7 @@ bool items_similar(const item_def &item1, const item_def &item2) } bool items_stack( const item_def &item1, const item_def &item2, - bool force_merge ) + bool force_merge, bool ignore_ident ) { // Both items must be stackable. if (!force_merge @@ -1373,7 +1373,7 @@ bool items_stack( const item_def &item1, const item_def &item2, return (false); } - return items_similar(item1, item2); + return items_similar(item1, item2, ignore_ident); } void merge_item_stacks(item_def &source, item_def &dest, int quant) @@ -1542,7 +1542,7 @@ int move_item_to_player( int obj, int quant_got, bool quiet, { for (int m = 0; m < ENDOFPACK; m++) { - if (items_stack( you.inv[m], mitm[obj] )) + if (items_stack( you.inv[m], mitm[obj], false, true )) { if (!quiet && partial_pickup) mpr("You can only carry some of what is here."); @@ -1577,6 +1577,18 @@ int move_item_to_player( int obj, int quant_got, bool quiet, "god gift", ""); } + // If only one of the stacks is identified, + // identify the other to a similar extent. + if (ident_flags(mitm[obj]) != ident_flags(you.inv[m])) + { + if (!quiet) + mpr("These items seem quite similar!"); + mitm[obj].flags |= + ident_flags(you.inv[m]) & you.inv[m].flags; + you.inv[m].flags |= + ident_flags(mitm[obj]) & mitm[obj].flags; + } + merge_item_stacks(mitm[obj], you.inv[m], quant_got); inc_inv_item_quantity( m, quant_got ); |