summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2008-09-02 17:03:12 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2008-09-02 17:03:12 +0000
commitbbc3d962b7793b2a54e0e723049ecb706f945153 (patch)
treec01938f884b6026720b914f1427f5a02735ffc30 /crawl-ref
parent72e13186eedbbfd04cf493e06db8cfd139627e4d (diff)
downloadcrawl-ref-bbc3d962b7793b2a54e0e723049ecb706f945153.tar.gz
crawl-ref-bbc3d962b7793b2a54e0e723049ecb706f945153.zip
Trunk->0.4 r6868: [2029973] Saner autopickup exceptions (doy).
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup-0.4@6869 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/externs.h3
-rw-r--r--crawl-ref/source/initfile.cc18
-rw-r--r--crawl-ref/source/items.cc39
3 files changed, 23 insertions, 37 deletions
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h
index fdd48acfbb..922b15d9e9 100644
--- a/crawl-ref/source/externs.h
+++ b/crawl-ref/source/externs.h
@@ -1723,8 +1723,7 @@ public:
std::vector<std::pair<int, int> > mp_colour;
std::string map_file_name; // name of mapping file to use
- std::vector<text_pattern> never_pickup; // Objects we'll never pick up
- std::vector<text_pattern> always_pickup; // Stuff we always pick up
+ std::vector<std::pair<text_pattern, bool> > force_autopickup;
std::vector<text_pattern> note_monsters; // Interesting monsters
std::vector<text_pattern> note_messages; // Interesting messages
std::vector<std::pair<text_pattern, std::string> > autoinscriptions;
diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc
index 98db34eaeb..b589964586 100644
--- a/crawl-ref/source/initfile.cc
+++ b/crawl-ref/source/initfile.cc
@@ -884,8 +884,7 @@ void game_options::reset_options()
mp_colour.push_back(std::pair<int, int>(50, YELLOW));
mp_colour.push_back(std::pair<int, int>(25, RED));
- never_pickup.clear();
- always_pickup.clear();
+ force_autopickup.clear();
note_monsters.clear();
note_messages.clear();
autoinscriptions.clear();
@@ -2381,7 +2380,14 @@ void game_options::read_option_line(const std::string &str, bool runscript)
}
else if (key == "ban_pickup")
{
- append_vector(never_pickup, split_string(",", field));
+ std::vector<std::string> args = split_string(",", field);
+ for (int i = 0, size = args.size(); i < size; ++i)
+ {
+ const std::string &s = args[i];
+ if (s.empty())
+ continue;
+ force_autopickup.push_back(std::make_pair(s, false));
+ }
}
else if (key == "autopickup_exceptions")
{
@@ -2393,11 +2399,11 @@ void game_options::read_option_line(const std::string &str, bool runscript)
continue;
if (s[0] == '>')
- never_pickup.push_back( s.substr(1) );
+ force_autopickup.push_back(std::make_pair(s.substr(1), false));
else if (s[0] == '<')
- always_pickup.push_back( s.substr(1) );
+ force_autopickup.push_back(std::make_pair(s.substr(1), true));
else
- never_pickup.push_back( s );
+ force_autopickup.push_back(std::make_pair(s, false));
}
}
else if (key == "note_items")
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index 4fd9dc21c7..2c1a077769 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -2182,34 +2182,14 @@ static inline std::string _autopickup_item_name(const item_def &item)
+ item.name(DESC_PLAIN);
}
-static bool _is_denied_autopickup(const item_def &item, std::string &iname)
+static bool _is_option_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))
- return (true);
-
-#ifdef CLUA_BINDINGS
- if (clua.callbooleanfn(false, "ch_deny_autopickup", "us",
- &item, iname.c_str()))
- {
- return (true);
- }
-#endif
-
- return (false);
-}
-
-static bool _is_forced_autopickup(const item_def &item, std::string &iname)
-{
- 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))
- return (true);
+ for (unsigned i = 0, size = Options.force_autopickup.size(); i < size; ++i)
+ if (Options.force_autopickup[i].first.matches(iname))
+ return Options.force_autopickup[i].second;
#ifdef CLUA_BINDINGS
if (clua.callbooleanfn(false, "ch_force_autopickup", "us",
@@ -2219,7 +2199,7 @@ static bool _is_forced_autopickup(const item_def &item, std::string &iname)
}
#endif
- return (false);
+ return (Options.autopickups & (1L << item.base_type));
}
bool item_needs_autopickup(const item_def &item)
@@ -2233,11 +2213,12 @@ bool item_needs_autopickup(const item_def &item)
if ((item.flags & ISFLAG_THROWN) && Options.pickup_thrown)
return (true);
+ if ((item.flags & ISFLAG_DROPPED) && !Options.pickup_dropped) {
+ return (false);
+ }
+
std::string itemname;
- return ((Options.autopickups & (1L << item.base_type)
- || _is_forced_autopickup(item, itemname))
- && (Options.pickup_dropped || !(item.flags & ISFLAG_DROPPED))
- && !_is_denied_autopickup(item, itemname));
+ return _is_option_autopickup(item, itemname);
}
bool can_autopickup()