summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/items.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-07-11 09:56:56 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-07-11 09:56:56 +0000
commit8ee15e29f95da59fa00c59e22db79a4e104794f4 (patch)
tree3702f25e880318b75a4298ce70be345d7d02fc54 /crawl-ref/source/items.cc
parent4253009d0db24eb91b3daee9459f59a4a18f6142 (diff)
downloadcrawl-ref-8ee15e29f95da59fa00c59e22db79a4e104794f4.tar.gz
crawl-ref-8ee15e29f95da59fa00c59e22db79a4e104794f4.zip
[1737348] Allow stash.lua to annotate item names for autopickup so autopickup
can use matches like <Short Blades. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1832 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/items.cc')
-rw-r--r--crawl-ref/source/items.cc27
1 files changed, 18 insertions, 9 deletions
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index b83901bf6a..926876ead5 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -2615,9 +2615,16 @@ static void autoinscribe_item( item_def& item )
}
}
-static bool is_denied_autopickup(const item_def &item)
+static inline std::string autopickup_item_name(const item_def &item)
{
- const std::string iname = item.name(DESC_PLAIN);
+ return userdef_annotate_item(STASH_LUA_SEARCH_ANNOTATE, &item, true)
+ + item.name(DESC_PLAIN);
+}
+
+static bool is_denied_autopickup(const item_def &item, std::string &iname)
+{
+ if (iname.empty())
+ iname = autopickup_item_name(item);
for (unsigned i = 0, size = Options.never_pickup.size(); i < size; ++i)
{
if (Options.never_pickup[i].matches(iname))
@@ -2626,9 +2633,10 @@ static bool is_denied_autopickup(const item_def &item)
return false;
}
-static bool is_forced_autopickup(const item_def &item)
+static bool is_forced_autopickup(const item_def &item, std::string &iname)
{
- const std::string iname = item.name(DESC_PLAIN);
+ if (iname.empty())
+ iname = autopickup_item_name(item);
for (unsigned i = 0, size = Options.always_pickup.size(); i < size; ++i)
{
if (Options.always_pickup[i].matches(iname))
@@ -2658,14 +2666,15 @@ bool item_needs_autopickup(const item_def &item)
if ((item.flags & ISFLAG_THROWN) && Options.pickup_thrown)
return (true);
+ std::string itemname;
return (((Options.autopickups & (1L << item.base_type))
- || is_forced_autopickup(item)
+ || is_forced_autopickup(item, itemname)
#ifdef CLUA_BINDINGS
- || clua.callbooleanfn(false, "ch_autopickup", "u", &item)
+ || clua.callbooleanfn(false, "ch_autopickup", "u", &item)
#endif
- )
- && (Options.pickup_dropped || !(item.flags & ISFLAG_DROPPED))
- && !is_denied_autopickup(item));
+ )
+ && (Options.pickup_dropped || !(item.flags & ISFLAG_DROPPED))
+ && !is_denied_autopickup(item, itemname));
}
bool can_autopickup()