summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/maps.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-10-29 07:57:57 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-10-29 07:57:57 +0000
commite77b4926f95f192504f877d7f312efbcd90d774f (patch)
tree55084b727c918f40085a2de53c7bfccf3356a36b /crawl-ref/source/maps.cc
parent2c0a2b2364fbb07b596aba9c0b8e46dc524c27b3 (diff)
downloadcrawl-ref-e77b4926f95f192504f877d7f312efbcd90d774f.tar.gz
crawl-ref-e77b4926f95f192504f877d7f312efbcd90d774f.zip
Tweaked -mapstat to show random maps available by depth. Added a floating dummy vault to correct probabilities of vaults in non-dungeon branches.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2653 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/maps.cc')
-rw-r--r--crawl-ref/source/maps.cc77
1 files changed, 76 insertions, 1 deletions
diff --git a/crawl-ref/source/maps.cc b/crawl-ref/source/maps.cc
index dc1d66155d..02b45e4744 100644
--- a/crawl-ref/source/maps.cc
+++ b/crawl-ref/source/maps.cc
@@ -342,7 +342,6 @@ std::vector<std::string> find_map_matches(const std::string &name)
return (matches);
}
-
// Returns a map for which PLACE: matches the given place.
int random_map_for_place(const level_id &place, bool want_minivault)
{
@@ -717,3 +716,79 @@ void run_map_preludes()
}
}
}
+
+///////////////////////////////////////////////////////////////////////////
+// Debugging code
+
+#ifdef DEBUG_DIAGNOSTICS
+
+typedef std::pair<std::string, int> weighted_map_name;
+typedef std::vector<weighted_map_name> weighted_map_names;
+
+static weighted_map_names mg_find_random_vaults(
+ const level_id &place, bool wantmini)
+{
+ weighted_map_names wms;
+
+ if (!place.is_valid())
+ return (wms);
+
+ for (unsigned i = 0, size = vdefs.size(); i < size; ++i)
+ {
+ if (vdefs[i].is_minivault() == wantmini
+ && !vdefs[i].place.is_valid()
+ && vdefs[i].is_usable_in(place)
+ // Some tagged levels cannot be selected by depth. This is
+ // the only thing preventing Pandemonium demon vaults from
+ // showing up in the main dungeon.
+ && !vdefs[i].has_tag_suffix("entry")
+ && !vdefs[i].has_tag("pan")
+ && !vdefs[i].has_tag("unrand")
+ && !vdefs[i].has_tag("bazaar"))
+ {
+ wms.push_back(
+ weighted_map_name( vdefs[i].name, vdefs[i].chance ) );
+ }
+ }
+
+ return (wms);
+}
+
+static void mg_report_random_vaults(
+ FILE *outf, const level_id &place, bool wantmini)
+{
+ weighted_map_names wms = mg_find_random_vaults(place, wantmini);
+ int weightsum = 0;
+ for (int i = 0, size = wms.size(); i < size; ++i)
+ weightsum += wms[i].second;
+
+ std::string line;
+ for (int i = 0, size = wms.size(); i < size; ++i)
+ {
+ std::string curr =
+ make_stringf("%s (%.2f%%)",
+ wms[i].first.c_str(),
+ 100.0 * wms[i].second / weightsum);
+ if (i < size - 1)
+ curr += ", ";
+ if (line.length() + curr.length() > 80u)
+ {
+ fprintf(outf, "%s\n", line.c_str());
+ line.clear();
+ }
+
+ line += curr;
+ }
+ if (!line.empty())
+ fprintf(outf, "%s\n", line.c_str());
+}
+
+void mg_report_random_maps(FILE *outf, const level_id &place)
+{
+ fprintf(outf, "---------------- Mini\n");
+ mg_report_random_vaults(outf, place, true);
+ fprintf(outf, "------------- Regular\n");
+ mg_report_random_vaults(outf, place, false);
+}
+
+#endif