diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-01-30 11:59:23 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-01-30 11:59:23 +0000 |
commit | 17d8bd89a7e6f4884334c0a8aa38907c43df5f81 (patch) | |
tree | afac3746a2146ac097c8d31426af07db1e7a1170 /crawl-ref/source/items.cc | |
parent | b92ab27580d7d18a9458e3478d85ff8b8633106c (diff) | |
download | crawl-ref-17d8bd89a7e6f4884334c0a8aa38907c43df5f81.tar.gz crawl-ref-17d8bd89a7e6f4884334c0a8aa38907c43df5f81.zip |
Added autopickup_exceptions option modeled on NetHack's, so that it's easy to
request stuff to pick up without inscribing with =g. ban_pickup is now
semi-deprecated.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@908 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/items.cc')
-rw-r--r-- | crawl-ref/source/items.cc | 49 |
1 files changed, 33 insertions, 16 deletions
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index 1c7e4681c3..a9093da5fa 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -2897,23 +2897,35 @@ static void autoinscribe_item( item_def& item ) /* if there's an inscription already do nothing */ if ( item.inscription.size() > 0 ) - return; + return; - for ( unsigned i = 0; i < Options.autoinscriptions.size(); ++i ) { - if ( Options.autoinscriptions[i].first.matches(iname) ) { - item.inscription += Options.autoinscriptions[i].second; - } + for ( unsigned i = 0; i < Options.autoinscriptions.size(); ++i ) + { + if ( Options.autoinscriptions[i].first.matches(iname) ) + { + item.inscription += Options.autoinscriptions[i].second; + } } } -static bool is_banned(const item_def &item) { - static char name[ITEMNAME_SIZE]; - item_name(item, DESC_INVENTORY, name, false); +static bool is_denied_autopickup(const item_def &item) +{ + std::string iname = item_name(item, DESC_PLAIN); + for (unsigned i = 0, size = Options.never_pickup.size(); i < size; ++i) + { + if (Options.never_pickup[i].matches(iname)) + return (true); + } + return false; +} - std::string iname = name; - for (unsigned i = 0; i < Options.banned_objects.size(); ++i) { - if (Options.banned_objects[i].matches(iname)) - return true; +static bool is_forced_autopickup(const item_def &item) +{ + std::string iname = item_name(item, DESC_PLAIN); + for (unsigned i = 0, size = Options.always_pickup.size(); i < size; ++i) + { + if (Options.always_pickup[i].matches(iname)) + return (true); } return false; } @@ -2933,15 +2945,20 @@ static void autoinscribe_items() bool item_needs_autopickup(const item_def &item) { - return (strstr(item.inscription.c_str(), "=g") != 0 - || ((item.flags & ISFLAG_THROWN) && Options.pickup_thrown) - || (((Options.autopickups & (1L << item.base_type)) + if (strstr(item.inscription.c_str(), "=g") != 0) + return (true); + + if ((item.flags & ISFLAG_THROWN) && Options.pickup_thrown) + return (true); + + return (((Options.autopickups & (1L << item.base_type)) + || is_forced_autopickup(item) #ifdef CLUA_BINDINGS || clua.callbooleanfn(false, "ch_autopickup", "u", &item) #endif ) && (Options.pickup_dropped || !(item.flags & ISFLAG_DROPPED)) - && !is_banned(item))); + && !is_denied_autopickup(item)); } bool can_autopickup() |