summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/items.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-29 14:14:04 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-29 14:14:04 +0000
commitf90424b8c2cb4d62ef5e34062cc6903918ecd37f (patch)
tree85a1868739f8ad9bb222cf527f823181af9e3153 /crawl-ref/source/items.cc
parenta2f0ab5525c06209f40a011bc7080c8b7d69b5e3 (diff)
downloadcrawl-ref-f90424b8c2cb4d62ef5e34062cc6903918ecd37f.tar.gz
crawl-ref-f90424b8c2cb4d62ef5e34062cc6903918ecd37f.zip
Force quiver to attempt to use the exact same item in inventory (slot
and all, if it still exists) before accepting any item that happens to have the same properties (base + subtype, plusses etc.) git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6220 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/items.cc')
-rw-r--r--crawl-ref/source/items.cc33
1 files changed, 18 insertions, 15 deletions
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index 690e072ed7..38ba9d2681 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -1297,33 +1297,23 @@ unsigned long ident_flags(const item_def &item)
return (flags);
}
-bool items_stack( const item_def &item1, const item_def &item2,
- bool force_merge )
+bool items_similar(const item_def &item1, const item_def &item2)
{
- // both items must be stackable
- if (!force_merge
- && (!is_stackable_item( item1 ) || !is_stackable_item( item2 )))
- {
- return (false);
- }
-
- // base and sub-types must always be the same to stack
+ // Base and sub-types must always be the same to stack.
if (item1.base_type != item2.base_type || item1.sub_type != item2.sub_type)
return (false);
- ASSERT(force_merge || item1.base_type != OBJ_WEAPONS);
-
if (item1.base_type == OBJ_GOLD)
return (true);
- // These classes also require pluses and special
+ // These classes also require pluses and special.
if (item1.base_type == OBJ_WEAPONS // only throwing weapons
|| item1.base_type == OBJ_MISSILES
|| item1.base_type == OBJ_MISCELLANY) // only runes
{
if (item1.plus != item2.plus
- || item1.plus2 != item2.plus2
- || item1.special != item2.special)
+ || item1.plus2 != item2.plus2
+ || item1.special != item2.special)
{
return (false);
}
@@ -1366,6 +1356,19 @@ bool items_stack( const item_def &item1, const item_def &item2,
return (true);
}
+bool items_stack( const item_def &item1, const item_def &item2,
+ bool force_merge )
+{
+ // Both items must be stackable.
+ if (!force_merge
+ && (!is_stackable_item( item1 ) || !is_stackable_item( item2 )))
+ {
+ return (false);
+ }
+
+ return items_similar(item1, item2);
+}
+
static int _userdef_find_free_slot(const item_def &i)
{
#ifdef CLUA_BINDINGS