summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/maps.cc
diff options
context:
space:
mode:
authorJude Brown <bookofjude@users.sourceforge.net>2009-12-06 19:50:53 +1000
committerJude Brown <bookofjude@users.sourceforge.net>2009-12-06 20:00:48 +1000
commita20b45352d9e5e389f5d6116fcbdbaa70b907878 (patch)
tree82dae5e3f1ff230d5466fd929363a785993a4f40 /crawl-ref/source/maps.cc
parentc2a93a39ecbbc995c42275a344e32175339d3adf (diff)
downloadcrawl-ref-a20b45352d9e5e389f5d6116fcbdbaa70b907878.tar.gz
crawl-ref-a20b45352d9e5e389f5d6116fcbdbaa70b907878.zip
Unique placement-related function find_maps_for_tag.
Generates a vector of map_defs that have the relevant tag. Can check depth (defaults to false) as well as whether or not a vault has previously been placed (defaults to true). Convenience function weight_map_vector returns an integer corresponding to the total weight of all of the maps contained within the vector. These functions will be used to re-do unique placement as per dpeg's design (see c-r-d email).
Diffstat (limited to 'crawl-ref/source/maps.cc')
-rw-r--r--crawl-ref/source/maps.cc31
1 files changed, 31 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