summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mapdef.h
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-03-27 08:50:19 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-03-27 08:50:19 +0000
commit9cfcde86bb92957d658e51d1955777f8db73cff1 (patch)
tree6510f2e31ac973c2a4479037b295c588abc96638 /crawl-ref/source/mapdef.h
parentcf748a307df35e7086db9ecc246a509a9312e708 (diff)
downloadcrawl-ref-9cfcde86bb92957d658e51d1955777f8db73cff1.tar.gz
crawl-ref-9cfcde86bb92957d658e51d1955777f8db73cff1.zip
Allow SHUFFLE: and SUBST: to be mixed freely; they will be applied in order of
declaration (used to be all shuffles first, then all substs). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1106 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/mapdef.h')
-rw-r--r--crawl-ref/source/mapdef.h46
1 files changed, 40 insertions, 6 deletions
diff --git a/crawl-ref/source/mapdef.h b/crawl-ref/source/mapdef.h
index 5c5ec9b810..c96d6df9bb 100644
--- a/crawl-ref/source/mapdef.h
+++ b/crawl-ref/source/mapdef.h
@@ -43,7 +43,16 @@ public:
typedef std::pair<int,int> glyph_weighted_replacement_t;
typedef std::vector<glyph_weighted_replacement_t> glyph_replacements_t;
-class subst_spec
+class map_lines;
+class map_transformer
+{
+public:
+ virtual ~map_transformer() = 0;
+ virtual void apply_transform(map_lines &map) = 0;
+ virtual map_transformer *clone() const = 0;
+};
+
+class subst_spec : public map_transformer
{
public:
subst_spec(int torepl, bool fix, const glyph_replacements_t &repls);
@@ -54,6 +63,9 @@ public:
}
int value();
+
+ void apply_transform(map_lines &map);
+ map_transformer *clone() const;
private:
int foo; // The thing to replace.
@@ -63,10 +75,27 @@ private:
glyph_replacements_t repl;
};
+struct shuffle_spec : public map_transformer
+{
+ std::string shuffle;
+
+ shuffle_spec(const std::string &spec)
+ : shuffle(spec)
+ {
+ }
+
+ void apply_transform(map_lines &map);
+ map_transformer *clone() const;
+};
+
class map_lines
{
public:
map_lines();
+ map_lines(const map_lines &);
+ ~map_lines();
+
+ map_lines &operator = (const map_lines &);
void add_line(const std::string &s);
std::string add_subst(const std::string &st);
@@ -81,9 +110,8 @@ public:
bool is_solid(int gly) const;
bool solid_borders(map_section_type border);
-
- void subst();
- void resolve_shuffles();
+
+ void apply_transforms();
// Make all lines the same length.
void normalise(char fillc = 'x');
@@ -98,8 +126,12 @@ public:
const std::vector<std::string> &get_lines() const;
private:
+ void init_from(const map_lines &map);
+ void release_transforms();
+
void resolve_shuffle(const std::string &shuffle);
void subst(std::string &s, subst_spec &spec);
+ void subst(subst_spec &);
void check_borders();
std::string shuffle(std::string s);
std::string block_shuffle(const std::string &s);
@@ -109,9 +141,11 @@ private:
std::string parse_glyph_replacements(std::string s,
glyph_replacements_t &gly);
+ friend class subst_spec;
+ friend class shuffle_spec;
+
private:
- std::vector<subst_spec> substitutions;
- std::vector<std::string> shuffles;
+ std::vector<map_transformer *> transforms;
std::vector<std::string> lines;
int map_width;
bool solid_north, solid_east, solid_south, solid_west;