summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-07-09 11:08:36 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-07-09 11:08:36 +0000
commit240d458d718fcae5faaffb6d49ee0da27b585465 (patch)
tree205bfd43fcf2eea3abf79e4ceb8f04599b1147ab /crawl-ref
parent2517b1cf2451cab3e9466a8b85623ccbafc48fdb (diff)
downloadcrawl-ref-240d458d718fcae5faaffb6d49ee0da27b585465.tar.gz
crawl-ref-240d458d718fcae5faaffb6d49ee0da27b585465.zip
More debug stats for maps.
level_range was segfaulting when compared against Abyss and Pan level_ids, fixed. Fixed level_id operator < (). Enabled use of vaults in non-Dungeon areas (Lair specific vaults were unused). These vaults are placed as extras, and are subject to the same constraints as branch entry vaults (the smaller the vault, the better the chance of being placed). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1811 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/debug.cc85
-rw-r--r--crawl-ref/source/dungeon.cc21
-rw-r--r--crawl-ref/source/initfile.cc1
-rw-r--r--crawl-ref/source/mapdef.cc2
-rw-r--r--crawl-ref/source/maps.cc5
-rw-r--r--crawl-ref/source/maps.h1
-rw-r--r--crawl-ref/source/travel.h14
7 files changed, 102 insertions, 27 deletions
diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc
index d3ba5f4e3c..061f856073 100644
--- a/crawl-ref/source/debug.cc
+++ b/crawl-ref/source/debug.cc
@@ -2131,11 +2131,34 @@ 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 bool mg_do_build_level(int niters)
+{
+ mesclr();
+ mprf("On %s (%d); %d levels, %d failed, %d errors%s, %d maps",
+ level_id::current().describe().c_str(), niters,
+ mg_levels_tried, mg_levels_failed, mapgen_errors.size(),
+ mapgen_last_error.empty()? ""
+ : (" (" + mapgen_last_error + ")").c_str(),
+ mapgen_use_count.size());
+
+ no_messages mx;
+ for (int i = 0; i < niters; ++i)
+ {
+ if (kbhit() && getch() == ESCAPE)
+ return (false);
+ ++mg_levels_tried;
+ if (!builder(you.your_level, you.level_type))
+ ++mg_levels_failed;
+ }
+ return (true);
+}
+
static void mg_build_levels(int niters)
{
mesclr();
mprf("Generating dungeon map stats");
-
+
for (int br = BRANCH_MAIN_DUNGEON; br < NUM_BRANCHES; ++br)
{
if (branches[br].depth == -1)
@@ -2148,25 +2171,19 @@ static void mg_build_levels(int niters)
you.where_are_you = branch;
you.level_type = LEVEL_DUNGEON;
- mesclr();
- mprf("On %s (%d); %d levels, %d failed, %d errors%s, %d maps",
- level_id::current().describe().c_str(), niters,
- mg_levels_tried, mg_levels_failed, mapgen_errors.size(),
- mapgen_last_error.empty()? ""
- : (" (" + mapgen_last_error + ")").c_str(),
- mapgen_use_count.size());
-
- no_messages mx;
- for (int i = 0; i < niters; ++i)
- {
- if (kbhit() && getch() == ESCAPE)
- return;
- ++mg_levels_tried;
- if (!builder(you.your_level, you.level_type))
- ++mg_levels_failed;
- }
+ if (!mg_do_build_level(niters))
+ return;
}
}
+
+ you.level_type = LEVEL_ABYSS;
+ if (!mg_do_build_level(niters))
+ return;
+ you.level_type = LEVEL_LABYRINTH;
+ if (!mg_do_build_level(niters))
+ return;
+ you.level_type = LEVEL_PANDEMONIUM;
+ mg_do_build_level(niters);
}
void mapgen_report_map_try(const map_def &map)
@@ -2186,6 +2203,12 @@ void mapgen_report_error(const map_def &map, const std::string &err)
mapgen_last_error = err;
}
+static void check_mapless(const level_id &lid, std::vector<level_id> &mapless)
+{
+ if (mapgen_level_mapsused.find(lid) == mapgen_level_mapsused.end())
+ mapless.push_back(lid);
+}
+
static void write_mapgen_stats()
{
FILE *outf = fopen("mapgen.log", "w");
@@ -2215,12 +2238,14 @@ static void write_mapgen_stats()
for (int dep = 1; dep <= branches[i].depth; ++dep)
{
const level_id lid(br, dep);
- if (mapgen_level_mapcounts.find(lid)
- == mapgen_level_mapcounts.end())
- mapless.push_back(lid);
+ check_mapless(lid, mapless);
}
}
+ check_mapless(level_id(LEVEL_ABYSS), mapless);
+ check_mapless(level_id(LEVEL_PANDEMONIUM), mapless);
+ check_mapless(level_id(LEVEL_LABYRINTH), mapless);
+
if (!mapless.empty())
{
fprintf(outf, "\n\nLevels with no maps:\n");
@@ -2228,6 +2253,24 @@ static void write_mapgen_stats()
fprintf(outf, "%3d) %s\n", i + 1, mapless[i].describe().c_str());
}
+ std::vector<std::string> unused_maps;
+ for (int i = 0, size = map_count(); i < size; ++i)
+ {
+ const map_def *map = map_by_index(i);
+ if (mapgen_try_count.find(map->name) == mapgen_try_count.end()
+ && !map->has_tag("dummy"))
+ {
+ unused_maps.push_back(map->name);
+ }
+ }
+
+ if (!unused_maps.empty())
+ {
+ fprintf(outf, "\n\nUnused maps:\n\n");
+ for (int i = 0, size = unused_maps.size(); i < size; ++i)
+ fprintf(outf, "%3d) %s\n", i + 1, unused_maps[i].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();
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc
index 7611428cb5..e385b628e4 100644
--- a/crawl-ref/source/dungeon.cc
+++ b/crawl-ref/source/dungeon.cc
@@ -116,6 +116,7 @@ static void place_specific_stair(dungeon_feature_type stair,
const std::string &tag = "",
int dl = 0);
static void place_branch_entrances(int dlevel, char level_type);
+static void place_extra_vaults();
static void place_special_minivaults(int level_number, int level_type);
static void place_traps( int level_number );
static void prepare_swamp();
@@ -205,6 +206,7 @@ typedef std::list<coord_def> coord_list;
// Places where monsters should not be randomly generated.
map_mask dgn_map_mask;
static dgn_region_list vault_zones;
+static int vault_chance = 9;
static std::vector<vault_placement> level_vaults;
static int minivault_chance = 3;
static bool dgn_level_vetoed = false;
@@ -284,6 +286,8 @@ static bool ensure_vault_placed(bool vault_success)
{
if (!vault_success)
dgn_level_vetoed = true;
+ else
+ vault_chance = 0;
return (vault_success);
}
@@ -541,6 +545,7 @@ static void build_dungeon_level(int level_number, int level_type)
prepare_shoals( level_number );
place_branch_entrances( level_number, level_type );
+ place_extra_vaults();
if (dgn_level_vetoed)
return;
@@ -1229,9 +1234,11 @@ static builder_rc_type builder_normal(int level_number, char level_type,
// Can't have vaults on you.where_are_you != BRANCH_MAIN_DUNGEON levels
if (vault == -1
- && player_in_branch( BRANCH_MAIN_DUNGEON )
- && one_chance_in(9))
+ && player_in_branch(BRANCH_MAIN_DUNGEON)
+ && one_chance_in(vault_chance))
+ {
vault = random_map_in_depth(level_id::current());
+ }
if (vault != -1)
{
@@ -1545,6 +1552,16 @@ static void place_specific_stair(dungeon_feature_type stair,
place_specific_feature(stair);
}
+static void place_extra_vaults()
+{
+ if (!player_in_branch(BRANCH_MAIN_DUNGEON) && one_chance_in(vault_chance))
+ {
+ const int vault = random_map_in_depth(level_id::current());
+ if (vault != -1 && build_secondary_vault(you.your_level, vault, -1))
+ vault_chance = 0;
+ }
+}
+
static void place_branch_entrances(int dlevel, char level_type)
{
int sx, sy;
diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc
index 82d888ed4f..2467cc8b60 100644
--- a/crawl-ref/source/initfile.cc
+++ b/crawl-ref/source/initfile.cc
@@ -2681,6 +2681,7 @@ bool parse_args( int argc, char **argv, bool rc_only )
SysEnv.map_gen_iters = 1;
else if (SysEnv.map_gen_iters > 10000)
SysEnv.map_gen_iters = 10000;
+ nextUsed = true;
}
else
SysEnv.map_gen_iters = 100;
diff --git a/crawl-ref/source/mapdef.cc b/crawl-ref/source/mapdef.cc
index 7324d3b964..17fa79c596 100644
--- a/crawl-ref/source/mapdef.cc
+++ b/crawl-ref/source/mapdef.cc
@@ -304,6 +304,8 @@ void level_range::reset()
bool level_range::matches(const level_id &lid) const
{
+ if (lid.level_type != LEVEL_DUNGEON)
+ return (false);
if (branch == NUM_BRANCHES)
return (matches(absdungeon_depth(lid.branch, lid.depth)));
else
diff --git a/crawl-ref/source/maps.cc b/crawl-ref/source/maps.cc
index 8e0c9f6864..089d616b2e 100644
--- a/crawl-ref/source/maps.cc
+++ b/crawl-ref/source/maps.cc
@@ -379,6 +379,11 @@ const map_def *map_by_index(int index)
return &vdefs[index];
}
+int map_count()
+{
+ return (vdefs.size());
+}
+
/////////////////////////////////////////////////////////////////////////////
// Reading maps from .des files.
diff --git a/crawl-ref/source/maps.h b/crawl-ref/source/maps.h
index dd38701b68..e096425577 100644
--- a/crawl-ref/source/maps.h
+++ b/crawl-ref/source/maps.h
@@ -40,6 +40,7 @@ int vault_main(map_type vgrid,
std::vector<vault_placement> *avoid_vaults = NULL);
const map_def *map_by_index(int index);
+int map_count();
int random_map_for_place(const level_id &place, bool mini = false);
int random_map_in_depth(const level_id &lid, bool want_minivault = false);
int random_map_for_tag(const std::string &tag, bool want_minivault,
diff --git a/crawl-ref/source/travel.h b/crawl-ref/source/travel.h
index 651d3072d5..4aeac12c68 100644
--- a/crawl-ref/source/travel.h
+++ b/crawl-ref/source/travel.h
@@ -166,6 +166,10 @@ public:
branch = NUM_BRANCHES;
}
}
+ level_id(const level_id &ot)
+ : branch(ot.branch), depth(ot.depth), level_type(ot.level_type)
+ {
+ }
level_id(level_area_type ltype)
: branch(BRANCH_MAIN_DUNGEON), depth(-1), level_type(ltype)
{
@@ -191,10 +195,9 @@ public:
bool operator == ( const level_id &id ) const
{
- return (level_type == LEVEL_DUNGEON?
- branch == id.branch && depth == id.depth
- && level_type == id.level_type
- : level_type == id.level_type);
+ return (level_type == id.level_type
+ && (level_type != LEVEL_DUNGEON
+ || (branch == id.branch && depth == id.depth)));
}
bool operator != ( const level_id &id ) const
@@ -206,6 +209,9 @@ public:
{
if (level_type != id.level_type)
return (level_type < id.level_type);
+
+ if (level_type != LEVEL_DUNGEON)
+ return (false);
return (branch < id.branch) || (branch==id.branch && depth < id.depth);
}