diff options
author | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-12-27 06:41:37 +0000 |
---|---|---|
committer | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-12-27 06:41:37 +0000 |
commit | 9ac7d2a9a5befa37c2099c58a28aef883b652815 (patch) | |
tree | 96753e6189fceff3f78a323544a9b5a9c0ca6f3b /crawl-ref/source/stash.cc | |
parent | 85e414e4994cf99cde5ab43c420902bdb6b6427a (diff) | |
download | crawl-ref-9ac7d2a9a5befa37c2099c58a28aef883b652815.tar.gz crawl-ref-9ac7d2a9a5befa37c2099c58a28aef883b652815.zip |
The stash_filter option can now accept strings (full item names, not
regexes). init.txt filters out the useless scrolls and jewelry.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7989 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/stash.cc')
-rw-r--r-- | crawl-ref/source/stash.cc | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/crawl-ref/source/stash.cc b/crawl-ref/source/stash.cc index e2840eb12c..76f4884a2a 100644 --- a/crawl-ref/source/stash.cc +++ b/crawl-ref/source/stash.cc @@ -180,22 +180,33 @@ void Stash::filter(const std::string &str) { std::string base = str; - base.erase(base.find_last_not_of(" \n\t") + 1); - base.erase(0, base.find_first_not_of(" \n\t")); - unsigned char subc = 255; + std::string subs = ""; std::string::size_type cpos = base.find(":", 0); if (cpos != std::string::npos) { - std::string subs = base.substr(cpos + 1); subc = atoi(subs.c_str()); base = base.substr(0, cpos); } - const object_class_type basec = - static_cast<object_class_type>(atoi(base.c_str())); - filter(basec, subc); + const int base_num = atoi(base.c_str()); + if (base_num == 0 && base != "0" || subc == 0 && subs != "0") + { + item_types_pair pair = item_types_by_name(str); + if (pair.base_type == OBJ_UNASSIGNED) + { + Options.report_error("Invalid stash filter '" + str + "'"); + return; + } + filter(pair.base_type, pair.sub_type); + } + else + { + const object_class_type basec = + static_cast<object_class_type>(base_num); + filter(basec, subc); + } } void Stash::filter(object_class_type base, unsigned char sub) @@ -216,6 +227,8 @@ bool Stash::is_filtered(const item_def &item) && (filter.sub_type == 255 || item.sub_type == filter.sub_type)) { + if (filter.sub_type != 255 && !item_type_known(item)) + return (false); return (true); } } |