diff options
author | pauldubois <pauldubois@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-03-17 10:02:06 +0000 |
---|---|---|
committer | pauldubois <pauldubois@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-03-17 10:02:06 +0000 |
commit | 775337dbac8f614e6152ae0c0ea37757cc4d344e (patch) | |
tree | 94dff19d2a1ae1bc98c2bb837c4a2aaf7e7e0e36 /crawl-ref | |
parent | 4b6ac5613a20ec0d64a43f3b2ea99dae0eceaf47 (diff) | |
download | crawl-ref-775337dbac8f614e6152ae0c0ea37757cc4d344e.tar.gz crawl-ref-775337dbac8f614e6152ae0c0ea37757cc4d344e.zip |
desc_search bugs (1905764)
- Fix: error for too many matches is not displayed
- Fix: rakshasa cannot be looked up (duplicate entries in Mon_Name_Cache)
- Fix: can't look up monster by the symbol ' '
- Didn't fix: can't look up plain draconians. mon_global_level() for them
returns 0, so they're getting filtered out by monster_filter. But I don't
know why the filter checks for 0, so I don't want to remove it.
- Didn't fix: simulacrum lookup
The monster name in mon-data.h is "large simulacrum" and "small simulacrum".
However, name in the DB is "simulacrum". The regexp matches the db key
"simulacrum", then tries to look up the monster id and matches nothing.
I think the right fix is to change the db? But I'm not sure right now.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3688 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r-- | crawl-ref/source/command.cc | 53 | ||||
-rw-r--r-- | crawl-ref/source/mon-util.cc | 29 |
2 files changed, 52 insertions, 30 deletions
diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc index a72f8a4b50..404de4b0cc 100644 --- a/crawl-ref/source/command.cc +++ b/crawl-ref/source/command.cc @@ -651,9 +651,6 @@ help_file help_files[] = { { NULL, 0, false } }; -static std::string list_commands_err = ""; - - static bool compare_mon_names(MenuEntry *entry_a, MenuEntry* entry_b) { monster_type *a = static_cast<monster_type*>( entry_a->data ); @@ -963,13 +960,15 @@ static bool do_description(std::string key, std::string footer = "") return (true); } -static bool find_description(bool &again) +static bool find_description(bool &again, std::string& error_inout) { again = true; clrscr(); viewwindow(true, false); + if (! error_inout.empty()) + mpr(error_inout.c_str(), MSGCH_PROMPT); mpr("Describe a (M)onster, (S)pell, (I)tem, (F)eature, (G)od " "or (B)ranch?", MSGCH_PROMPT); @@ -1028,7 +1027,7 @@ static bool find_description(bool &again) break; default: - list_commands_err = "Okay, then."; + error_inout = "Okay, then."; again = false; return (false); } @@ -1044,15 +1043,18 @@ static bool find_description(bool &again) char buf[80]; if (cancelable_get_line(buf, sizeof(buf)) || buf[0] == '\0') { - list_commands_err = "Okay, then."; + error_inout = "Okay, then."; return (false); } - regex = trimmed_string(buf); + if (strlen(buf) == 1) + regex = buf; + else + regex = trimmed_string(buf); if (regex == "") { - list_commands_err = "Description must contain at least " + error_inout = "Description must contain at least " "one non-space."; return (false); } @@ -1094,21 +1096,21 @@ static bool find_description(bool &again) { if (by_mon_symbol) { - list_commands_err = "No monsters with symbol '"; - list_commands_err += regex; - list_commands_err += "'"; + error_inout = "No monsters with symbol '"; + error_inout += regex; + error_inout += "'"; } else if (by_item_symbol) { - list_commands_err = "No items with symbol '"; - list_commands_err += regex; - list_commands_err += "'"; + error_inout = "No items with symbol '"; + error_inout += regex; + error_inout += "'"; } else { - list_commands_err = "No matching "; - list_commands_err += type; - list_commands_err += "s"; + error_inout = "No matching "; + error_inout += type; + error_inout += "s"; } return (false); } @@ -1116,16 +1118,16 @@ static bool find_description(bool &again) { if (by_mon_symbol) { - list_commands_err = "Too many monsters with symbol '"; - list_commands_err += regex; - list_commands_err += "' to display"; + error_inout = "Too many monsters with symbol '"; + error_inout += regex; + error_inout += "' to display"; } else { std::ostringstream os; os << "Too many matching " << type << "s (" << key_list.size() << ") to display."; - list_commands_err = os.str(); + error_inout = os.str(); } return (false); } @@ -1243,12 +1245,15 @@ static int keyhelp_keyfilter(int ch) case '/': { bool again = false; + std::string error; do { - if (find_description(again)) + if (find_description(again, error)) if ( getch() == 0 ) getch(); if (again) + { mesclr(true); + } } while(again); viewwindow(true, false); @@ -1630,7 +1635,6 @@ void list_commands(bool wizard, int hotkey, bool do_redraw_screen) true, true, cmdhelp_textfilter); - list_commands_err = ""; show_keyhelp_menu(cols.formatted_lines(), true, false, hotkey); if (do_redraw_screen) @@ -1638,9 +1642,6 @@ void list_commands(bool wizard, int hotkey, bool do_redraw_screen) clrscr(); redraw_screen(); } - - if (list_commands_err != "") - mpr(list_commands_err.c_str()); } void list_tutorial_help() diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 958f6bcd8d..7a1ce78f93 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -160,7 +160,7 @@ monster_type random_monster_at_grid(dungeon_feature_type grid) } typedef std::map<std::string, unsigned> mon_name_map; -static mon_name_map mon_name_cache; +static mon_name_map Mon_Name_Cache; void init_mon_name_cache() { @@ -172,7 +172,28 @@ void init_mon_name_cache() const int mtype = mondata[i].mc; const monster_type mon = monster_type(mtype); - mon_name_cache[name] = mon; + // Deal sensibly with duplicate entries; refuse or allow the insert, + // depending on which should take precedence. Mostly we don't care, + // except looking up "rakshasa" and getting _FAKE breaks ?/M rakshasa. + if (Mon_Name_Cache.find(name) != Mon_Name_Cache.end()) + { + if (mon == MONS_RAKSHASA_FAKE || + mon == MONS_ARMOUR_MIMIC || + mon == MONS_SCROLL_MIMIC || + mon == MONS_POTION_MIMIC || + mon == MONS_ABOMINATION_LARGE) + { + // keep previous entry + continue; + } + else + { + DEBUGSTR("Un-handled duplicate monster name: %s", name.c_str()); + ASSERT(false); + } + } + + Mon_Name_Cache[name] = mon; } } @@ -182,9 +203,9 @@ monster_type get_monster_by_name(std::string name, bool exact) if (exact) { - mon_name_map::iterator i = mon_name_cache.find(name); + mon_name_map::iterator i = Mon_Name_Cache.find(name); - if (i != mon_name_cache.end()) + if (i != Mon_Name_Cache.end()) return static_cast<monster_type>(i->second); return MONS_PROGRAM_BUG; |