summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mapdef.h
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-01-29 16:57:10 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-01-29 16:57:10 +0000
commit1b87b6c8d4c8fb34b16eb8ddc4787f6421068222 (patch)
treecab50e8c0b765a98d81e577848ac230d058c64e1 /crawl-ref/source/mapdef.h
parent9295e4fb393749bedc6ccdbe99c5147435949d35 (diff)
downloadcrawl-ref-1b87b6c8d4c8fb34b16eb8ddc4787f6421068222.tar.gz
crawl-ref-1b87b6c8d4c8fb34b16eb8ddc4787f6421068222.zip
Allow maps to use SHUFFLE: directive to shuffle symbols in the map definition
(David). For instance, SHUFFLE: def will shuffle its argument (to "efd", for instance) and replace each occurrence of the symbols in its argument with the corresponding symbol in the shuffled list (so all d will be replaced with e, all e with f, and all f with d in the example). Multiple SHUFFLE: lines can be used, and each shuffle will be applied independently. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@906 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/mapdef.h')
-rw-r--r--crawl-ref/source/mapdef.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/crawl-ref/source/mapdef.h b/crawl-ref/source/mapdef.h
index 52ce7ecf3d..25f3b7ef5a 100644
--- a/crawl-ref/source/mapdef.h
+++ b/crawl-ref/source/mapdef.h
@@ -45,9 +45,6 @@ class map_lines
public:
map_lines();
- // NULL-terminated list of map lines.
- map_lines(int nlines, ...);
-
void add_line(const std::string &s);
void set_orientation(const std::string &s);
@@ -60,6 +57,7 @@ public:
bool solid_borders(map_section_type border);
void resolve(const std::string &fillins);
+ void resolve_shuffles(const std::vector<std::string> &shuffles);
// Make all lines the same length.
void normalise(char fillc = 'x');
@@ -74,8 +72,16 @@ public:
const std::vector<std::string> &get_lines() const;
private:
+ typedef FixedVector<short, 128> symbol_frequency_t;
+
+ void resolve_shuffle(const symbol_frequency_t &,
+ const std::string &shuffle);
void resolve(std::string &s, const std::string &fill);
void check_borders();
+ void calc_symbol_frequencies(symbol_frequency_t &f);
+ std::string remove_unreferenced(const symbol_frequency_t &freq,
+ std::string s);
+ std::string shuffle(std::string s);
private:
std::vector<std::string> lines;
@@ -211,6 +217,7 @@ public:
item_list items;
std::string random_symbols;
+ std::vector<std::string> shuffles;
public:
void init();
@@ -221,6 +228,8 @@ public:
void resolve();
void fixup();
+ void add_shuffle(const std::string &s);
+
bool can_dock(map_section_type) const;
coord_def dock_pos(map_section_type) const;
coord_def float_dock();