diff options
-rw-r--r-- | crawl-ref/source/acr.cc | 13 | ||||
-rw-r--r-- | crawl-ref/source/describe.cc | 3 | ||||
-rw-r--r-- | crawl-ref/source/mapdef.cc | 36 | ||||
-rw-r--r-- | crawl-ref/source/travel.cc | 27 | ||||
-rw-r--r-- | crawl-ref/source/travel.h | 7 |
5 files changed, 54 insertions, 32 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index 8db29f022c..7b0d2197b0 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -682,6 +682,19 @@ static void handle_wizard_command( void ) static_cast<dungeon_feature_type>( atoi(specs) ); break; + case ')': + mpr("Create which feature (by name)? ", MSGCH_PROMPT); + get_input_line(specs, sizeof specs); + if (*specs) + { + const dungeon_feature_type feat = dungeon_feature_by_name(specs); + if (feat == DNGN_UNSEEN) + canned_msg(MSG_OK); + else + grd(you.pos()) = feat; + } + break; + case ']': if (!debug_add_mutation()) mpr( "Failure to give mutation." ); diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc index 3229cb329a..5fff7420c0 100644 --- a/crawl-ref/source/describe.cc +++ b/crawl-ref/source/describe.cc @@ -4193,7 +4193,7 @@ void describe_god( god_type which_god, bool give_title ) have_any = true; cprintf( "%s supports the use of orcish gear." EOL, god_name(which_god)); - } + } // mv: No abilities (except divine protection) under penance if (!player_under_penance()) @@ -4202,7 +4202,6 @@ void describe_god( god_type which_god, bool give_title ) if ( you.piety >= piety_breakpoint(i) ) if (print_god_abil_desc(which_god, i)) have_any = true; - } if ( !have_any ) cprintf( "None." EOL ); diff --git a/crawl-ref/source/mapdef.cc b/crawl-ref/source/mapdef.cc index 65592df4b5..c80f243d60 100644 --- a/crawl-ref/source/mapdef.cc +++ b/crawl-ref/source/mapdef.cc @@ -1,7 +1,15 @@ +/* + * File: mapdef.cc + * Summary: Support code for Crawl des files. + * + * Modified for Crawl Reference by $Author: dshaligram $ on $Date: 2007-06-30T15:49:18.688054Z $ + */ + #include <iostream> #include <cstdarg> #include <cstdio> #include <cctype> +#include <algorithm> #include "AppHdr.h" #include "branch.h" @@ -41,19 +49,6 @@ const char *map_section_name(int msect) return map_section_names[msect]; } -template <typename V> -void scramble(V &v) -{ - V temp(v); - v.clear(); - while (!temp.empty()) - { - int i = random2(temp.size()); - v.push_back(temp[i]); - temp.erase(temp.begin() + i); - } -} - // Returns true if s contains tag 'tag', and strips out tag from s. bool strip_tag(std::string &s, const std::string &tag) { @@ -792,7 +787,7 @@ void map_lines::nsubst(nsubst_spec &spec) while ((pos = lines[y].find(spec.key, pos)) != std::string::npos) positions.push_back(coord_def(pos++, y)); } - scramble(positions); + std::random_shuffle(positions.begin(), positions.end(), random2); int pcount = 0; const int psize = positions.size(); @@ -824,17 +819,8 @@ int map_lines::apply_nsubst(std::vector<coord_def> &pos, std::string map_lines::block_shuffle(const std::string &s) { std::vector<std::string> segs = split_string("/", s); - - std::vector<std::string> shuffled; - for (int i = 0, size = segs.size(); i < size; ++i) - { - const int sel = random2(segs.size()); - - shuffled.push_back( segs[ sel ] ); - segs.erase( segs.begin() + sel ); - } - - return comma_separated_line(shuffled.begin(), shuffled.end(), "/", "/"); + std::random_shuffle(segs.begin(), segs.end(), random2); + return comma_separated_line(segs.begin(), segs.end(), "/", "/"); } std::string map_lines::shuffle(std::string s) 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)); diff --git a/crawl-ref/source/travel.h b/crawl-ref/source/travel.h index 334797391f..a5a964ef76 100644 --- a/crawl-ref/source/travel.h +++ b/crawl-ref/source/travel.h @@ -299,6 +299,8 @@ public: private: template <class C> void say_any(const C &coll, const char *stub) const; + template <class citer> bool has_duplicates(citer, citer) const; + std::string cleaned_feature_description(dungeon_feature_type feature) const; void add_item(const item_def &item); @@ -309,6 +311,11 @@ private: named_thing(const std::string &n, Z t) : name(n), thing(t) { } operator std::string () const { return name; } + + bool operator == (const named_thing<Z> &other) const + { + return (name == other.name); + } }; int es_flags; |