summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/maps.cc31
-rw-r--r--crawl-ref/source/maps.h6
2 files changed, 37 insertions, 0 deletions
diff --git a/crawl-ref/source/maps.cc b/crawl-ref/source/maps.cc
index 1d27c6bddc..f60732d7a2 100644
--- a/crawl-ref/source/maps.cc
+++ b/crawl-ref/source/maps.cc
@@ -557,6 +557,37 @@ std::vector<std::string> find_map_matches(const std::string &name)
return (matches);
}
+std::vector<map_def> find_maps_for_tag (const std::string tag, bool check_depth,
+ bool check_used)
+{
+ std::vector<map_def> maps;
+ level_id place = level_id::current();
+
+ for (unsigned i = 0, size = vdefs.size(); i < size; ++i)
+ {
+ map_def mapdef = vdefs[i];
+ if (mapdef.has_tag(tag)
+ && (!check_depth || !mapdef.has_depth()
+ || mapdef.is_usable_in(place))
+ && (!check_used || vault_unforbidden(mapdef)))
+ {
+ maps.push_back(mapdef);
+ }
+ }
+
+ return (maps);
+}
+
+int weight_map_vector (std::vector<map_def> maps)
+{
+ int weights = 0;
+
+ for (std::vector<map_def>::iterator mi = maps.begin(); mi != maps.end(); ++mi)
+ weights += mi->weight;
+
+ return (weights);
+}
+
struct map_selector {
private:
enum select_type
diff --git a/crawl-ref/source/maps.h b/crawl-ref/source/maps.h
index 37f0f22841..3626db6dd5 100644
--- a/crawl-ref/source/maps.h
+++ b/crawl-ref/source/maps.h
@@ -41,6 +41,12 @@ void add_parsed_map(const map_def &md);
std::vector<std::string> find_map_matches(const std::string &name);
+std::vector<map_def> find_maps_for_tag (const std::string tag,
+ bool check_depth = false,
+ bool check_used = true);
+
+int weight_map_vector (std::vector<map_def> maps);
+
void read_maps();
void read_map(const std::string &file);
void run_map_preludes();