diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-09-30 17:18:31 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-09-30 17:18:31 +0000 |
commit | 2d3f243d6828ab20789b6b95dc501806f903b927 (patch) | |
tree | ed5a2df8de1dc4670e6f8d6249def1a89f4c136c | |
parent | e2179589b89a1d9786aa3111286af81878d21219 (diff) | |
download | crawl-ref-2d3f243d6828ab20789b6b95dc501806f903b927.tar.gz crawl-ref-2d3f243d6828ab20789b6b95dc501806f903b927.zip |
Fixed regex escapes for "." stash search.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2266 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r-- | crawl-ref/source/files.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/place.cc | 5 | ||||
-rw-r--r-- | crawl-ref/source/place.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/stash.cc | 63 | ||||
-rw-r--r-- | crawl-ref/source/stash.h | 1 |
5 files changed, 43 insertions, 29 deletions
diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc index 190d75cb9c..9f07e5d0ce 100644 --- a/crawl-ref/source/files.cc +++ b/crawl-ref/source/files.cc @@ -831,8 +831,6 @@ static void _xom_check_lost_items(level_area_type old_level_type) if (old_level_type == LEVEL_DUNGEON) return; - int amusement = 0; - for (int i = 0; i < MAX_ITEMS; i++) { item_def& item(mitm[i]); diff --git a/crawl-ref/source/place.cc b/crawl-ref/source/place.cc index 0bc2fc8a60..67de365065 100644 --- a/crawl-ref/source/place.cc +++ b/crawl-ref/source/place.cc @@ -177,3 +177,8 @@ bool level_type_allows_followers(level_area_type type) { return (type == LEVEL_DUNGEON || type == LEVEL_PANDEMONIUM); } + +bool level_type_is_stash_trackable(level_area_type type) +{ + return (type != LEVEL_ABYSS && type != LEVEL_LABYRINTH); +} diff --git a/crawl-ref/source/place.h b/crawl-ref/source/place.h index b2bbc0f2b9..078db1f571 100644 --- a/crawl-ref/source/place.h +++ b/crawl-ref/source/place.h @@ -50,5 +50,6 @@ bool single_level_branch(branch_type branch); bool level_type_exits_up(level_area_type type); bool level_type_exits_down(level_area_type type); bool level_type_allows_followers(level_area_type type); +bool level_type_is_stash_trackable(level_area_type type); #endif diff --git a/crawl-ref/source/stash.cc b/crawl-ref/source/stash.cc index 86dc1c27d4..962883da9d 100644 --- a/crawl-ref/source/stash.cc +++ b/crawl-ref/source/stash.cc @@ -1365,20 +1365,32 @@ void StashTracker::update_visible_stashes( static std::string lastsearch; static input_history search_history(15); +void StashTracker::show_stash_search_prompt() +{ + std::vector<std::string> opts; + if (!lastsearch.empty()) + opts.push_back( + make_stringf("Enter for \"%s\"", lastsearch.c_str()) ); + if (level_type_is_stash_trackable(you.level_type) + && lastsearch != ".") + { + opts.push_back( + make_stringf("press . for all items on level")); + } + + std::string prompt_qual = + comma_separated_line(opts.begin(), opts.end(), ", or ", ", or "); + + if (!prompt_qual.empty()) + prompt_qual = " [" + prompt_qual + "]"; + + mprf(MSGCH_PROMPT, "Search for what%s?\n", prompt_qual.c_str()); +} + void StashTracker::search_stashes() { - char prompt[200]; - if (lastsearch.length()) - snprintf(prompt, sizeof prompt, - "Search for what [Enter for \"%s\"%s]?\n", - lastsearch.c_str(), lastsearch != "." ? - ", or press . for all items on level" : ""); - else - snprintf(prompt, sizeof prompt, - "Search for what [Press . for all items on level]?\n"); + show_stash_search_prompt(); - mpr(prompt, MSGCH_PROMPT); - char buf[400]; bool validline = !cancelable_get_line(buf, sizeof buf, 80, &search_history); @@ -1392,25 +1404,22 @@ void StashTracker::search_stashes() if (csearch == ".") { - if (you.level_type == LEVEL_DUNGEON) - { - snprintf(info, INFO_SIZE, "%s:%d", - branches[you.where_are_you].abbrevname, player_branch_depth()); - csearch = info; - } - else if (you.level_type == LEVEL_PORTAL_VAULT) - csearch = "{Port}"; - else if (you.level_type == LEVEL_PANDEMONIUM) - csearch = "{Pan}"; - // items in Abyss and Labyrinths are not tracked - else if (you.level_type == LEVEL_ABYSS - || you.level_type == LEVEL_LABYRINTH) + if (!level_type_is_stash_trackable(you.level_type)) { - mprf("Items in %s cannot be tracked.", - you.level_type == LEVEL_ABYSS ? "the Abyss" : "labyrinths"); - return; + mpr("Cannot track items on this level."); + return; } +#if defined(REGEX_PCRE) || defined(REGEX_POSIX) +#define RE_ESCAPE "\\" +#else +#define RE_ESCAPE "" +#endif + + csearch = (RE_ESCAPE "{") + + level_id::current().describe() + + (RE_ESCAPE "}"); } + std::vector<stash_search_result> results; base_pattern *search = NULL; diff --git a/crawl-ref/source/stash.h b/crawl-ref/source/stash.h index 8841911b74..3510d09b07 100644 --- a/crawl-ref/source/stash.h +++ b/crawl-ref/source/stash.h @@ -315,6 +315,7 @@ private: void get_matching_stashes(const base_pattern &search, std::vector<stash_search_result> &results) const; void display_search_results(std::vector<stash_search_result> &results); + void show_stash_search_prompt(); private: typedef std::map<level_id, LevelStashes> stash_levels_t; |