diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-07-06 08:34:09 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-07-06 08:34:09 +0000 |
commit | 862f907158311aa239b0a82fa4abb4a4e398861d (patch) | |
tree | de007cddafe6f022bb07b4451010ae3ba2e755da /crawl-ref/source/travel.cc | |
parent | 5aa579ca769a34f0af8a8093a2a94ba03b92ff3e (diff) | |
download | crawl-ref-862f907158311aa239b0a82fa4abb4a4e398861d.tar.gz crawl-ref-862f907158311aa239b0a82fa4abb4a4e398861d.zip |
[1748837] Fixed odd-looking messages when explore finds two or more identical
features.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1769 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/travel.cc')
-rw-r--r-- | crawl-ref/source/travel.cc | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc index 25ba95f66e..d579e0752d 100644 --- a/crawl-ref/source/travel.cc +++ b/crawl-ref/source/travel.cc @@ -3627,17 +3627,34 @@ void explore_discoveries::found_item(const coord_def &pos, const item_def &i) es_flags |= ES_ITEM; } +// Expensive O(n2) duplicate search, but we can live with that. +template <class citer> bool explore_discoveries::has_duplicates( + citer begin, citer end) const +{ + for (citer s = begin; s != end; ++s) + for (citer z = s + 1; z != end; ++z) + if (*s == *z) + return (true); + return (false); +} + template <class C> void explore_discoveries::say_any( const C &coll, const char *stub) const { if (coll.empty()) return; + + if (has_duplicates(coll.begin(), coll.end())) + { + mprf(stub, number_in_words(coll.size()).c_str()); + return; + } const std::string message = "Found " + comma_separated_line(coll.begin(), coll.end()) + "."; if ((int) message.length() >= get_number_of_cols()) - mprf(stub, coll.size()); + mprf(stub, number_in_words(coll.size()).c_str()); else mprf("%s", message.c_str()); } @@ -3647,10 +3664,10 @@ bool explore_discoveries::prompt_stop() const if (!es_flags) return (false); - say_any(items, "Found %u items."); - say_any(shops, "Found %u shops."); - say_any(altars, "Found %u altars."); - say_any(stairs, "Found %u stairs."); + say_any(items, "Found %s items."); + say_any(shops, "Found %s shops."); + say_any(altars, "Found %s altars."); + say_any(stairs, "Found %s stairs."); return ((Options.explore_stop_prompt & es_flags) != es_flags || prompt_stop_explore(es_flags)); |