diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-07-08 21:40:41 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-07-08 21:40:41 +0000 |
commit | 9daed15a2ae8a8cf8c2330dc57f64c6afea09bea (patch) | |
tree | aac7f1ba97e14518056f9a1ba109e8bb5c9b9811 /crawl-ref/source | |
parent | ccd8ab9d731d18d9fa3d6c29ed6bb9c8ab220c5d (diff) | |
download | crawl-ref-9daed15a2ae8a8cf8c2330dc57f64c6afea09bea.tar.gz crawl-ref-9daed15a2ae8a8cf8c2330dc57f64c6afea09bea.zip |
Tweak map stat output, fixed a couple of bugs.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1806 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/debug.cc | 49 | ||||
-rw-r--r-- | crawl-ref/source/dungeon.cc | 10 | ||||
-rw-r--r-- | crawl-ref/source/maps.cc | 9 |
3 files changed, 51 insertions, 17 deletions
diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc index 92dfd46534..933a400151 100644 --- a/crawl-ref/source/debug.cc +++ b/crawl-ref/source/debug.cc @@ -2123,11 +2123,12 @@ void debug_card() // Map statistics generation. -std::map<std::string, int> mapgen_try_count; -std::map<std::string, int> mapgen_use_count; -std::map<level_id, int> mapgen_level_maps; -std::map<std::string, std::string> mapgen_errors; -std::string mapgen_last_error; +static std::map<std::string, int> mapgen_try_count; +static std::map<std::string, int> mapgen_use_count; +static std::map<level_id, int> mapgen_level_mapcounts; +static std::map< level_id, std::set<std::string> > mapgen_level_mapsused; +static std::map<std::string, std::string> mapgen_errors; +static std::string mapgen_last_error; static int mg_levels_tried = 0, mg_levels_failed = 0; static void mg_build_levels(int niters) @@ -2171,12 +2172,13 @@ static void mg_build_levels(int niters) void mapgen_report_map_try(const map_def &map) { mapgen_try_count[map.name]++; - mapgen_level_maps[level_id::current()]++; } void mapgen_report_map_use(const map_def &map) { mapgen_use_count[map.name]++; + mapgen_level_mapcounts[level_id::current()]++; + mapgen_level_mapsused[level_id::current()].insert(map.name); } void mapgen_report_error(const map_def &map, const std::string &err) @@ -2210,10 +2212,11 @@ static void write_mapgen_stats() continue; const branch_type br = static_cast<branch_type>(i); - for (int dep = 1; dep <= branches[i].depth; ++i) + for (int dep = 1; dep <= branches[i].depth; ++dep) { const level_id lid(br, dep); - if (mapgen_level_maps.find(lid) == mapgen_level_maps.end()) + if (mapgen_level_mapcounts.find(lid) + == mapgen_level_mapcounts.end()) mapless.push_back(lid); } } @@ -2222,7 +2225,35 @@ static void write_mapgen_stats() { fprintf(outf, "\n\nLevels with no maps:\n"); for (int i = 0, size = mapless.size(); i < size; ++i) - fprintf(outf, "%d) %s\n", i + 1, mapless[i].describe().c_str()); + fprintf(outf, "%3d) %s\n", i + 1, mapless[i].describe().c_str()); + } + + fprintf(outf, "\n\nMaps by level:\n\n"); + for (std::map<level_id, std::set<std::string> >::const_iterator i = + mapgen_level_mapsused.begin(); i != mapgen_level_mapsused.end(); + ++i) + { + std::string line = + make_stringf("%-10s: ", i->first.describe().c_str()); + const std::set<std::string> &maps = i->second; + bool unfinished = false; + for (std::set<std::string>::const_iterator j = maps.begin(); + j != maps.end(); ++j) + { + if (j != maps.begin()) + line += ", "; + line += *j; + if (line.length() > 79) + { + unfinished = true; + break; + } + } + + const unsigned margin = unfinished? 74 : 79; + if (line.length() > margin) + line = line.substr(0, margin); + fprintf(outf, "%s%s\n", line.c_str(), unfinished? ", ..." : ""); } fprintf(outf, "\n\nMaps used:\n\n"); diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc index b7229487e3..bef7c19ec7 100644 --- a/crawl-ref/source/dungeon.cc +++ b/crawl-ref/source/dungeon.cc @@ -2665,6 +2665,11 @@ static bool build_minivaults(int level_number, int force_vault) vault_zones.push_back( dgn_region(place.x, place.y, place.width, place.height)); +#ifdef DEBUG_DIAGNOSTICS + if (crawl_state.map_stat_gen) + mapgen_report_map_use(place.map); +#endif + apply_place_masks(place); // these two are throwaways: @@ -3087,6 +3092,11 @@ static bool build_vaults(int level_number, int force_vault, int rune_subst, vault_zones.push_back( dgn_region(place.x, place.y, place.width, place.height)); +#ifdef DEBUG_DIAGNOSTICS + if (crawl_state.map_stat_gen) + mapgen_report_map_use(place.map); +#endif + // If the map takes the whole screen or we were only requested to // build, our work is done. if (gluggy == MAP_ENCOMPASS || build_only) diff --git a/crawl-ref/source/maps.cc b/crawl-ref/source/maps.cc index a71392ce46..8e0c9f6864 100644 --- a/crawl-ref/source/maps.cc +++ b/crawl-ref/source/maps.cc @@ -80,14 +80,7 @@ int vault_main( // Return value of zero forces dungeon.cc to regenerate the level, except // for branch entry vaults where dungeon.cc just rejects the vault and // places a vanilla entry. - const int result = write_vault( vdefs[which_vault], vgrid, place, avoid ); - -#ifdef DEBUG_DIAGNOSTICS - if (crawl_state.map_stat_gen && result > 0) - mapgen_report_map_use(vdefs[which_vault]); -#endif - - return (result); + return (write_vault( vdefs[which_vault], vgrid, place, avoid )); } static int write_vault(map_def &mdef, map_type map, |