summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mapdef.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-02-19 18:54:42 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-02-19 18:54:42 +0000
commita191a19ff4afeae3cbc76f120463152c5ebfc2ea (patch)
treeb6cb038b12e26ba5b1b3f69867ef1701ae60d533 /crawl-ref/source/mapdef.cc
parente9b1a504be1d94eab7a724ba5935aaf48fe9e4cb (diff)
downloadcrawl-ref-a191a19ff4afeae3cbc76f120463152c5ebfc2ea.tar.gz
crawl-ref-a191a19ff4afeae3cbc76f120463152c5ebfc2ea.zip
Updated entry vaults (David).
Level compiler is stricter with MAP sections. Block SHUFFLE: now uses / as a separator to avoid confusion. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@955 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/mapdef.cc')
-rw-r--r--crawl-ref/source/mapdef.cc64
1 files changed, 44 insertions, 20 deletions
diff --git a/crawl-ref/source/mapdef.cc b/crawl-ref/source/mapdef.cc
index 1fb3da0255..2ddacf61f9 100644
--- a/crawl-ref/source/mapdef.cc
+++ b/crawl-ref/source/mapdef.cc
@@ -229,15 +229,9 @@ void map_lines::resolve(const std::string &fillins)
resolve(lines[i], fillins);
}
-std::string map_lines::clean(std::string s)
-{
- return replace_all_of(s, " \t", "");
-}
-
std::string map_lines::block_shuffle(const std::string &s)
{
- std::vector<std::string> segs = split_string(",", s);
- unsigned seglen = 0;
+ std::vector<std::string> segs = split_string("/", s);
std::vector<std::string> shuffled;
for (int i = 0, size = segs.size(); i < size; ++i)
@@ -246,24 +240,16 @@ std::string map_lines::block_shuffle(const std::string &s)
shuffled.push_back( segs[ sel ] );
segs.erase( segs.begin() + sel );
-
- if (!seglen)
- seglen = shuffled[i].length();
- else if (seglen != shuffled[i].length())
- {
- mprf(MSGCH_DIAGNOSTICS, "Bad shuffle parameter: %s", s.c_str());
- return ("");
- }
}
- return comma_separated_line(shuffled.begin(), shuffled.end(), ",", ",");
+ return comma_separated_line(shuffled.begin(), shuffled.end(), "/", "/");
}
std::string map_lines::shuffle(std::string s)
{
std::string result;
- if (s.find(',') != std::string::npos)
+ if (s.find('/') != std::string::npos)
return block_shuffle(s);
// Inefficient brute-force shuffle.
@@ -279,7 +265,7 @@ std::string map_lines::shuffle(std::string s)
void map_lines::resolve_shuffle(const std::string &shufflage)
{
- std::string toshuffle = clean(shufflage);
+ std::string toshuffle = shufflage;
std::string shuffled = shuffle(toshuffle);
if (toshuffle.empty() || shuffled.empty())
@@ -407,9 +393,47 @@ void map_def::init()
mons.clear();
}
-void map_def::add_shuffle(const std::string &s)
+std::string map_def::clean_shuffle(std::string s)
+{
+ return replace_all_of(s, " \t", "");
+}
+
+std::string map_def::check_block_shuffle(const std::string &s)
+{
+ const std::vector<std::string> segs = split_string("/", s);
+ const unsigned seglen = segs[0].length();
+
+ for (int i = 1, size = segs.size(); i < size; ++i)
+ {
+ if (seglen != segs[i].length())
+ return ("block shuffle segment length mismatch");
+ }
+
+ return ("");
+}
+
+std::string map_def::check_shuffle(std::string &s)
+{
+ if (s.find(',') != std::string::npos)
+ return ("use / for block shuffle, or multiple SHUFFLE: lines");
+
+ s = clean_shuffle(s);
+
+ if (s.find('/') != std::string::npos)
+ return check_block_shuffle(s);
+
+ return ("");
+}
+
+std::string map_def::add_shuffle(const std::string &raws)
{
- shuffles.push_back(s);
+ std::string s = raws;
+ const std::string err = check_shuffle(s);
+
+ if (err.empty())
+ shuffles.push_back(s);
+
+ return (err);
}
bool map_def::is_minivault() const