summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-01-04 12:56:06 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-01-04 12:56:06 +0000
commita595b7fd82f3d7c054f4a28f6b2d5770e6aade15 (patch)
treed50a7f556066af8760486ccef7957b462a8c7013
parent6289e90146bed25695d5e792302ada00caa9e734 (diff)
downloadcrawl-ref-a595b7fd82f3d7c054f4a28f6b2d5770e6aade15.tar.gz
crawl-ref-a595b7fd82f3d7c054f4a28f6b2d5770e6aade15.zip
[1626830] Fixed non-stacking potions.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@782 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/itemname.cc21
-rw-r--r--crawl-ref/source/items.cc19
2 files changed, 31 insertions, 9 deletions
diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc
index 56f477c5ca..6b54bce4ed 100644
--- a/crawl-ref/source/itemname.cc
+++ b/crawl-ref/source/itemname.cc
@@ -66,7 +66,6 @@ static bool is_tried_type( int basetype, int subtype )
}
}
-
bool is_vowel( const char chr )
{
const char low = tolower( chr );
@@ -74,11 +73,25 @@ bool is_vowel( const char chr )
return (low == 'a' || low == 'e' || low == 'i' || low == 'o' || low == 'u');
}
+item_type_id_type objtype_to_idtype(int base_type)
+{
+ switch (base_type)
+ {
+ case OBJ_WANDS: return (IDTYPE_WANDS);
+ case OBJ_SCROLLS: return (IDTYPE_SCROLLS);
+ case OBJ_JEWELLERY: return (IDTYPE_JEWELLERY);
+ case OBJ_POTIONS: return (IDTYPE_POTIONS);
+ default: return (NUM_IDTYPE);
+ }
+}
+
bool item_type_known( const item_def &item )
{
- return item_ident(item, ISFLAG_KNOW_TYPE)
- || (item.base_type == OBJ_JEWELLERY
- && id[IDTYPE_JEWELLERY][item.sub_type] == ID_KNOWN_TYPE);
+ if (item_ident(item, ISFLAG_KNOW_TYPE))
+ return (true);
+
+ const item_type_id_type idt = objtype_to_idtype(item.base_type);
+ return (idt != NUM_IDTYPE? id[idt][item.sub_type] == ID_KNOWN_TYPE : false);
}
// it_name() and in_name() are now somewhat obsolete now that itemname
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index dcab9825a2..ff8ed47ef2 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -1308,6 +1308,16 @@ bool is_stackable_item( const item_def &item )
return (false);
}
+int ident_flags(const item_def &item)
+{
+ int flags = item.flags & full_ident_mask(item);
+
+ if (!(flags & ISFLAG_KNOW_TYPE) && item_type_known(item))
+ flags |= ISFLAG_KNOW_TYPE;
+
+ return (flags);
+}
+
bool items_stack( const item_def &item1, const item_def &item2 )
{
// both items must be stackable
@@ -1334,8 +1344,7 @@ bool items_stack( const item_def &item1, const item_def &item2 )
}
// Check the ID flags
- if ( (item1.flags & full_ident_mask(item1)) !=
- (item2.flags & full_ident_mask(item2)) )
+ if (ident_flags(item1) != ident_flags(item2))
return false;
// Check the non-ID flags
@@ -1343,14 +1352,14 @@ bool items_stack( const item_def &item1, const item_def &item2 )
(item2.flags & (~ISFLAG_IDENT_MASK)))
return false;
-
// Thanks to mummy cursing, we can have potions of decay
// that don't look alike... so we don't stack potions
// if either isn't identified and they look different. -- bwr
if (item1.base_type == OBJ_POTIONS && item1.special != item2.special &&
- (!item_ident(item1, ISFLAG_KNOW_TYPE) ||
- !item_ident(item2, ISFLAG_KNOW_TYPE )))
+ (!item_type_known(item1) || !item_type_known(item2)))
+ {
return false;
+ }
return (true);
}