From 4c5c3809dea65983966d591877b1f150dc2244fb Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Wed, 12 Sep 2007 15:29:36 +0000 Subject: Applying Matthew's stacking patch. (1793051) git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2076 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/items.cc | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'crawl-ref/source/items.cc') diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index 812a42632d..a4146a1475 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -1212,10 +1212,16 @@ bool items_stack( const item_def &item1, const item_def &item2, if (ident_flags(item1) != ident_flags(item2)) return false; - // Check the non-ID flags - if ((item1.flags & (~ISFLAG_IDENT_MASK)) != - (item2.flags & (~ISFLAG_IDENT_MASK))) + // Check the non-ID flags, but ignore dropped, thrown, cosmetic, + // and note flags +#define NON_IDENT_FLAGS ~(ISFLAG_IDENT_MASK | ISFLAG_COSMETIC_MASK | \ + ISFLAG_DROPPED | ISFLAG_THROWN | \ + ISFLAG_NOTED_ID | ISFLAG_NOTED_GET) + if ((item1.flags & NON_IDENT_FLAGS) != + (item2.flags & NON_IDENT_FLAGS)) + { return false; + } // Thanks to mummy cursing, we can have potions of decay // that don't look alike... so we don't stack potions @@ -1226,6 +1232,14 @@ bool items_stack( const item_def &item1, const item_def &item2, return false; } + // The inscriptions can differ if one of them is blank, but if they + // are differing non-blank inscriptions then don't stack. + if (item1.inscription != item2.inscription + && item1.inscription != "" && item2.inscription != "") + { + return false; + } + return (true); } @@ -1362,6 +1376,15 @@ int move_item_to_player( int obj, int quant_got, bool quiet ) check_note_item(mitm[obj]); + // If the object on the ground is inscribed, but not + // the one in inventory, then the inventory object + // picks up the other's inscription. + if (mitm[obj].inscription != "" + && you.inv[m].inscription == "") + { + you.inv[m].inscription = mitm[obj].inscription; + } + inc_inv_item_quantity( m, quant_got ); dec_mitm_item_quantity( obj, quant_got ); burden_change(); -- cgit v1.2.3-54-g00ecf