summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mapdef.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-07-06 08:34:09 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-07-06 08:34:09 +0000
commit862f907158311aa239b0a82fa4abb4a4e398861d (patch)
treede007cddafe6f022bb07b4451010ae3ba2e755da /crawl-ref/source/mapdef.cc
parent5aa579ca769a34f0af8a8093a2a94ba03b92ff3e (diff)
downloadcrawl-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/mapdef.cc')
-rw-r--r--crawl-ref/source/mapdef.cc36
1 files changed, 11 insertions, 25 deletions
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)