summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2008-11-23 20:17:08 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2008-11-23 20:17:08 +0000
commit9007dee72716b25f791d49beabe2d5b662086f7b (patch)
tree12afc734a1f8b4903c1ce42c70079387c95ac86e /crawl-ref
parent6866898a809acc4a7d89f2a82bebf2357423142e (diff)
downloadcrawl-ref-9007dee72716b25f791d49beabe2d5b662086f7b.tar.gz
crawl-ref-9007dee72716b25f791d49beabe2d5b662086f7b.zip
Clean up legacy cruft involved in placing vaults.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7557 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/dat/clua/ziggurat.lua16
-rw-r--r--crawl-ref/source/dungeon.cc147
-rw-r--r--crawl-ref/source/mapdef.cc52
-rw-r--r--crawl-ref/source/mapdef.h1
-rw-r--r--crawl-ref/source/maps.cc90
-rw-r--r--crawl-ref/source/maps.h8
6 files changed, 144 insertions, 170 deletions
diff --git a/crawl-ref/source/dat/clua/ziggurat.lua b/crawl-ref/source/dat/clua/ziggurat.lua
index 0adb72f9fb..3696a99d3b 100644
--- a/crawl-ref/source/dat/clua/ziggurat.lua
+++ b/crawl-ref/source/dat/clua/ziggurat.lua
@@ -274,17 +274,19 @@ local function ziggurat_create_loot(c)
loot_depth = you.absdepth() - 1
end
+ local function place_loot(what)
+ free_space_do(function (p)
+ dgn.create_item(p.x, p.y, what, loot_depth)
+ end)
+ end
+
for i = 1, nloot do
if crawl.one_chance_in(depth) then
for j = 1, 4 do
- free_space_do(function (p)
- dgn.create_item(p.x, p.y, "*", loot_depth)
- end)
+ place_loot("*")
end
else
- free_space_do(function (p)
- dgn.create_item(p.x, p.y, "|", loot_depth)
- end)
+ place_loot("|")
end
end
end
@@ -338,5 +340,5 @@ for key, val in pairs(ziggurat_builder_map) do
end
function ziggurat_choose_builder()
- return ziggurat_builders[crawl.random_range(1, #ziggurat_builders)]
+ return util.random_from(ziggurat_builders)
end \ No newline at end of file
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc
index f78a65de55..ed49e16bf9 100644
--- a/crawl-ref/source/dungeon.cc
+++ b/crawl-ref/source/dungeon.cc
@@ -210,12 +210,11 @@ static bool _build_minivaults(int level_number, int force_vault,
bool level_builder = true, bool clobber = false,
bool make_no_exits = false,
const coord_def &where = coord_def() );
-static int _vault_grid( vault_placement &,
- int level_number, const coord_def& where,
- int altar_count,
- FixedVector < object_class_type, 7 > &acq_item_class,
- int vgrid, std::vector<coord_def> &targets,
- int &num_runes, int rune_subst = -1, bool foll = false);
+static void _vault_grid( vault_placement &,
+ int vgrid,
+ const coord_def& where,
+ std::vector<coord_def> &targets,
+ bool recursive = false);
static int _dgn_random_map_for_place(bool wantmini);
static void _dgn_load_colour_grid();
@@ -3937,22 +3936,13 @@ static bool _build_minivaults(int level_number, int force_vault,
bool building_level, bool clobber,
bool make_no_exits, const coord_def &where)
{
- int altar_count = 0;
-
- FixedVector < object_class_type, 7 > acq_item_class;
- acq_item_class[0] = OBJ_WEAPONS;
- acq_item_class[1] = OBJ_ARMOUR;
- acq_item_class[2] = OBJ_WEAPONS;
- acq_item_class[3] = OBJ_JEWELLERY;
- acq_item_class[4] = OBJ_BOOKS;
- acq_item_class[5] = OBJ_STAVES;
- acq_item_class[6] = OBJ_MISCELLANY;
-
if (dgn_check_connectivity && !dgn_zones)
dgn_zones = _dgn_count_disconnected_zones(false);
map_type vgrid;
vault_placement place;
+
+ place.level_number = level_number;
vault_main(vgrid, place, force_vault);
coord_def v1;
@@ -3978,8 +3968,7 @@ static bool _build_minivaults(int level_number, int force_vault,
_register_place(place);
- // These two are throwaways:
- int num_runes = 0;
+ // This is a throwaway.
std::vector<coord_def> &target_connections = place.exits;
// Paint the minivault onto the grid.
@@ -3994,12 +3983,7 @@ static bool _build_minivaults(int level_number, int force_vault,
continue;
const dungeon_feature_type oldgrid = grd(*ri);
- altar_count = _vault_grid( place,
- level_number, *ri,
- altar_count,
- acq_item_class,
- feat, target_connections,
- num_runes );
+ _vault_grid( place, feat, *ri, target_connections );
if (!building_level)
{
link_items();
@@ -4515,26 +4499,16 @@ static bool _build_vaults(int level_number, int force_vault, int rune_subst,
bool generating_level, bool clobber,
bool make_no_exits, const coord_def &where)
{
- int altar_count = 0;
FixedVector < char, 10 > stair_exist;
char stx, sty;
- FixedVector < object_class_type, 7 > acq_item_class;
- // XXX: Hack - passing chars through '...' promotes them to ints,
- // which barfs under gcc in fixvec.h. So don't. -- GDL
- acq_item_class[0] = OBJ_WEAPONS;
- acq_item_class[1] = OBJ_ARMOUR;
- acq_item_class[2] = OBJ_WEAPONS;
- acq_item_class[3] = OBJ_JEWELLERY;
- acq_item_class[4] = OBJ_BOOKS;
- acq_item_class[5] = OBJ_STAVES;
- acq_item_class[6] = OBJ_MISCELLANY;
-
if (dgn_check_connectivity && !dgn_zones)
dgn_zones = _dgn_count_disconnected_zones(false);
map_type vgrid;
vault_placement place;
+
+ place.level_number = level_number;
std::vector<coord_def> &target_connections = place.exits;
if (map_bounds(where))
@@ -4546,8 +4520,6 @@ static bool _build_vaults(int level_number, int force_vault, int rune_subst,
if (gluggy == MAP_NONE || !gluggy)
return (false);
- int num_runes = 0;
-
dgn_region this_vault(place.pos, place.size);
if (!place.size.zero())
{
@@ -4560,12 +4532,8 @@ static bool _build_vaults(int level_number, int force_vault, int rune_subst,
continue;
const dungeon_feature_type oldgrid = grd(*ri);
- altar_count = _vault_grid( place, level_number, *ri, altar_count,
- acq_item_class,
- vgrid[ri->y][ri->x],
- target_connections,
- num_runes,
- rune_subst );
+ _vault_grid( place, vgrid[ri->y][ri->x], *ri,
+ target_connections );
if (!generating_level)
{
// Have to link items each square at a time, or
@@ -4922,10 +4890,7 @@ bool dgn_place_monster(mons_spec &mspec,
if (mg.cls == RANDOM_MONSTER && mspec.place.is_valid())
{
- int lev = monster_level;
-
- if (mspec.place.level_type == LEVEL_DUNGEON)
- lev = mspec.place.absdepth();
+ int lev = mspec.place.absdepth();
if (mlev == -8)
lev = 4 + lev * 2;
@@ -5076,21 +5041,26 @@ dungeon_feature_type map_feature(map_def *map, const coord_def &c, int rawfeat)
: DNGN_FLOOR); // includes everything else
}
+static const object_class_type _acquirement_item_classes[] = {
+ OBJ_WEAPONS,
+ OBJ_ARMOUR,
+ OBJ_WEAPONS,
+ OBJ_JEWELLERY,
+ OBJ_BOOKS,
+ OBJ_STAVES,
+ OBJ_MISCELLANY
+};
+
// Returns altar_count - seems rather odd to me to force such a return
// when I believe the value is only used in the case of the ecumenical
// temple - oh, well... {dlb} (XXX)
-static int _vault_grid( vault_placement &place,
- int level_number,
- const coord_def& where,
- int altar_count,
- FixedVector < object_class_type, 7 > &acq_item_class,
- int vgrid,
- std::vector<coord_def> &targets,
- int &num_runes,
- int rune_subst,
- bool following )
-{
- keyed_mapspec *mapsp = (following ? NULL
+static void _vault_grid( vault_placement &place,
+ int vgrid,
+ const coord_def& where,
+ std::vector<coord_def> &targets,
+ bool recursive )
+{
+ keyed_mapspec *mapsp = (recursive ? NULL
: place.map.mapspec_for_key(vgrid));
if (mapsp)
{
@@ -5102,18 +5072,16 @@ static int _vault_grid( vault_placement &place,
}
else if (f.glyph >= 0)
{
- altar_count = _vault_grid( place, level_number, where,
- altar_count, acq_item_class,
- f.glyph, targets, num_runes,
- rune_subst, true );
+ _vault_grid( place, f.glyph, where, targets, true );
}
else if (f.shop >= 0)
- place_spec_shop(level_number, where, f.shop);
+ place_spec_shop(place.level_number, where, f.shop);
else if (f.trap >= 0)
{
- const trap_type trap
- = (f.trap == TRAP_INDEPTH) ? random_trap_for_place(level_number)
- : static_cast<trap_type>(f.trap);
+ const trap_type trap =
+ (f.trap == TRAP_INDEPTH)
+ ? random_trap_for_place(place.level_number)
+ : static_cast<trap_type>(f.trap);
place_specific_trap(where, trap);
}
@@ -5121,12 +5089,12 @@ static int _vault_grid( vault_placement &place,
grd(where) = DNGN_FLOOR;
mons_list &mons = mapsp->get_monsters();
- _dgn_place_one_monster(place, mons, level_number, where);
+ _dgn_place_one_monster(place, mons, place.level_number, where);
item_list &items = mapsp->get_items();
- dgn_place_multiple_items(items, where, level_number);
+ dgn_place_multiple_items(items, where, place.level_number);
- return (altar_count);
+ return;
}
if (vgrid == 'F' && one_chance_in(100))
@@ -5162,7 +5130,7 @@ static int _vault_grid( vault_placement &place,
(vgrid == 'A') ? DNGN_STONE_ARCH :
(vgrid == 'B') ?
static_cast<dungeon_feature_type>(
- DNGN_ALTAR_FIRST_GOD + altar_count) :// see below
+ DNGN_ALTAR_FIRST_GOD + place.altar_count) :// see below
(vgrid == 'C') ? _pick_an_altar() : // f(x) elsewhere {dlb}
(vgrid == 'F') ? DNGN_GRANITE_STATUE :
(vgrid == 'I') ? DNGN_ORCISH_IDOL :
@@ -5178,7 +5146,7 @@ static int _vault_grid( vault_placement &place,
switch (vgrid)
{
case 'B':
- altar_count++;
+ place.altar_count++;
break;
case '@':
targets.push_back( where );
@@ -5187,7 +5155,7 @@ static int _vault_grid( vault_placement &place,
place_specific_trap(where, TRAP_RANDOM);
break;
case '~':
- place_specific_trap(where, random_trap_for_place(level_number));
+ place_specific_trap(where, random_trap_for_place(place.level_number));
break;
}
@@ -5241,23 +5209,24 @@ static int _vault_grid( vault_placement &place,
which_type = ORB_ZOT;
}
else if (vgrid == '|'
- || (vgrid == 'P' && (!possible_rune || num_runes > 0))
- || (vgrid == 'O' && num_runes > 0))
+ || (vgrid == 'P' && (!possible_rune || place.num_runes > 0))
+ || (vgrid == 'O' && place.num_runes > 0))
{
- which_class = acq_item_class[random2(7)];
+ which_class = RANDOM_ELEMENT(_acquirement_item_classes);
which_type = OBJ_RANDOM;
}
else // for 'P' (1 out of 3 times) {dlb}
{
- if (rune_subst != -1)
+ if (place.rune_subst != -1)
{
- grd(where) = static_cast<dungeon_feature_type>(rune_subst);
+ grd(where) =
+ static_cast<dungeon_feature_type>(place.rune_subst);
break;
}
which_class = OBJ_MISCELLANY;
which_type = MISC_RUNE_OF_ZOT;
- num_runes++;
+ place.num_runes++;
if (you.level_type == LEVEL_PANDEMONIUM)
{
@@ -5278,11 +5247,11 @@ static int _vault_grid( vault_placement &place,
spec = you.where_are_you;
}
- which_depth = level_number;
+ which_depth = place.level_number;
if (vgrid == '|' || vgrid == 'P' || vgrid == 'O' || vgrid == 'Z')
which_depth = MAKE_GOOD_ITEM;
else if (vgrid == '*')
- which_depth = 5 + (level_number * 2);
+ which_depth = 5 + (place.level_number * 2);
item_made = items( 1, which_class, which_type, true,
which_depth, spec );
@@ -5297,7 +5266,7 @@ static int _vault_grid( vault_placement &place,
// defghijk - items
if (vgrid >= 'd' && vgrid <= 'k')
- _dgn_place_item_explicit(vgrid - 'd', where, place, level_number);
+ _dgn_place_item_explicit(vgrid - 'd', where, place, place.level_number);
if (vgrid == 'S' || vgrid == 'H')
{
@@ -5315,11 +5284,11 @@ static int _vault_grid( vault_placement &place,
int monster_level;
mons_spec monster_type_thing(RANDOM_MONSTER);
- monster_level = level_number;
+ monster_level = place.level_number;
if (vgrid == '8')
- monster_level = 4 + (level_number * 2);
+ monster_level = 4 + (place.level_number * 2);
else if (vgrid == '9')
- monster_level = 5 + level_number;
+ monster_level = 5 + place.level_number;
if (monster_level > 30) // very high level monsters more common here
monster_level = 30;
@@ -5329,10 +5298,6 @@ static int _vault_grid( vault_placement &place,
_dgn_place_monster(place, monster_type_thing, monster_level, where);
}
-
- // Again, this seems odd, given that this is just one of many
- // vault types {dlb}
- return (altar_count);
} // end vault_grid()
// Currently only used for Slime: branch end
diff --git a/crawl-ref/source/mapdef.cc b/crawl-ref/source/mapdef.cc
index 3ff9a014c6..e9dbd64b7d 100644
--- a/crawl-ref/source/mapdef.cc
+++ b/crawl-ref/source/mapdef.cc
@@ -362,7 +362,7 @@ void map_lines::init_from(const map_lines &map)
template <typename V>
void map_lines::clear_vector(V &vect)
{
- for (int i = 0, size = vect.size(); i < size; ++i)
+ for (int i = 0, vsize = vect.size(); i < vsize; ++i)
delete vect[i];
vect.clear();
}
@@ -403,7 +403,7 @@ std::string map_lines::add_lua_marker(const std::string &key,
void map_lines::apply_markers(const coord_def &c)
{
- for (int i = 0, size = markers.size(); i < size; ++i)
+ for (int i = 0, vsize = markers.size(); i < vsize; ++i)
{
markers[i]->pos += c;
env.markers.add(markers[i]);
@@ -460,7 +460,7 @@ std::string map_lines::check_block_shuffle(const std::string &s)
const std::vector<std::string> segs = split_string("/", s);
const unsigned seglen = segs[0].length();
- for (int i = 1, size = segs.size(); i < size; ++i)
+ for (int i = 1, vsize = segs.size(); i < vsize; ++i)
{
if (seglen != segs[i].length())
return ("block shuffle segment length mismatch");
@@ -488,7 +488,7 @@ std::string map_lines::parse_glyph_replacements(std::string s,
s = replace_all_of(s, "\t", " ");
std::vector<std::string> segs = split_string(" ", s);
- for (int i = 0, size = segs.size(); i < size; ++i)
+ for (int i = 0, vsize = segs.size(); i < vsize; ++i)
{
const std::string &is = segs[i];
if (is.length() > 2 && is[1] == ':')
@@ -514,7 +514,7 @@ std::string map_lines::parse_weighted_colours(const std::string &cspec,
map_colour_list &colours) const
{
std::vector<std::string> cspeclist = split_string("/", cspec);
- for (int i = 0, size = cspeclist.size(); i < size; ++i)
+ for (int i = 0, vsize = cspeclist.size(); i < vsize; ++i)
{
std::string col = cspeclist[i];
lowercase(col);
@@ -627,13 +627,13 @@ std::string map_lines::add_nsubst(const std::string &s)
return (err);
std::vector<std::string> segs = split_string("/", arg);
- for (int i = 0, size = segs.size(); i < size; ++i)
+ for (int i = 0, vsize = segs.size(); i < vsize; ++i)
{
std::string &ns = segs[i];
if (ns.find('=') == std::string::npos
&& ns.find(':') == std::string::npos)
{
- if (i < size - 1)
+ if (i < vsize - 1)
ns = "1=" + ns;
else
ns = "*=" + ns;
@@ -668,7 +668,7 @@ void map_lines::remove_shuffle(const std::string &raw)
if (err.empty())
{
const shuffle_spec ss(s);
- for (int i = 0, size = transforms.size(); i < size; ++i)
+ for (int i = 0, vsize = transforms.size(); i < vsize; ++i)
{
if (transforms[i]->type() == map_transformer::TT_SHUFFLE)
{
@@ -696,7 +696,7 @@ void map_lines::remove_subst(const std::string &raw)
delete sub;
transforms.pop_back();
- for (int i = 0, size = transforms.size(); i < size; ++i)
+ for (int i = 0, vsize = transforms.size(); i < vsize; ++i)
{
if (transforms[i]->type() == map_transformer::TT_SUBST)
{
@@ -754,6 +754,11 @@ int map_lines::height() const
return lines.size();
}
+coord_def map_lines::size() const
+{
+ return coord_def(width(), height());
+}
+
int map_lines::glyph(int x, int y) const
{
return lines[y][x];
@@ -861,7 +866,8 @@ void map_lines::nsubst(nsubst_spec &spec)
int pcount = 0;
const int psize = positions.size();
- for (int i = 0, size = spec.specs.size(); i < size && pcount < psize; ++i)
+ for (int i = 0, vsize = spec.specs.size();
+ i < vsize && pcount < psize; ++i)
{
const int nsubsts = spec.specs[i].key();
pcount += apply_nsubst(positions, pcount, nsubsts, spec.specs[i]);
@@ -919,7 +925,7 @@ void map_lines::resolve_shuffle(const std::string &shufflage)
if (toshuffle.empty() || shuffled.empty())
return;
- for (int i = 0, size = lines.size(); i < size; ++i)
+ for (int i = 0, vsize = lines.size(); i < vsize; ++i)
{
std::string &s = lines[i];
@@ -936,7 +942,7 @@ void map_lines::resolve_shuffle(const std::string &shufflage)
std::string map_lines::apply_transforms()
{
std::string error;
- for (int i = 0, size = transforms.size(); i < size; ++i)
+ for (int i = 0, vsize = transforms.size(); i < vsize; ++i)
{
error = transforms[i]->apply_transform(*this);
if (!error.empty())
@@ -950,7 +956,7 @@ std::string map_lines::apply_transforms()
void map_lines::normalise(char fillch)
{
- for (int i = 0, size = lines.size(); i < size; ++i)
+ for (int i = 0, vsize = lines.size(); i < vsize; ++i)
{
std::string &s = lines[i];
if (static_cast<int>(s.length()) < map_width)
@@ -1005,7 +1011,7 @@ void map_lines::translate_marker(
void (map_lines::*xform)(map_marker *, int),
int par)
{
- for (int i = 0, size = markers.size(); i < size; ++i)
+ for (int i = 0, vsize = markers.size(); i < vsize; ++i)
(this->*xform)(markers[i], par);
}
@@ -1045,14 +1051,14 @@ void map_lines::rotate_markers(bool clock)
void map_lines::vmirror()
{
- const int size = lines.size();
- const int midpoint = size / 2;
+ const int vsize = lines.size();
+ const int midpoint = vsize / 2;
for (int i = 0; i < midpoint; ++i)
{
std::string temp = lines[i];
- lines[i] = lines[size - 1 - i];
- lines[size - 1 - i] = temp;
+ lines[i] = lines[vsize - 1 - i];
+ lines[vsize - 1 - i] = temp;
}
if (colour_overlay.get())
@@ -1060,7 +1066,7 @@ void map_lines::vmirror()
for (int i = 0; i < midpoint; ++i)
for (int j = 0, wide = width(); j < wide; ++j)
std::swap( (*colour_overlay)(j, i),
- (*colour_overlay)(j, size - 1 - i) );
+ (*colour_overlay)(j, vsize - 1 - i) );
}
vmirror_markers();
@@ -1070,7 +1076,7 @@ void map_lines::vmirror()
void map_lines::hmirror()
{
const int midpoint = map_width / 2;
- for (int i = 0, size = lines.size(); i < size; ++i)
+ for (int i = 0, vsize = lines.size(); i < vsize; ++i)
{
std::string &s = lines[i];
for (int j = 0; j < midpoint; ++j)
@@ -1083,7 +1089,7 @@ void map_lines::hmirror()
if (colour_overlay.get())
{
- for (int i = 0, size = lines.size(); i < size; ++i)
+ for (int i = 0, vsize = lines.size(); i < vsize; ++i)
for (int j = 0; j < midpoint; ++j)
std::swap( (*colour_overlay)(j, i),
(*colour_overlay)(map_width - 1 - j, i) );
@@ -1096,7 +1102,7 @@ void map_lines::hmirror()
std::vector<std::string> map_lines::get_shuffle_strings() const
{
std::vector<std::string> shuffles;
- for (int i = 0, size = transforms.size(); i < size; ++i)
+ for (int i = 0, vsize = transforms.size(); i < vsize; ++i)
if (transforms[i]->type() == map_transformer::TT_SHUFFLE)
shuffles.push_back( transforms[i]->describe() );
return (shuffles);
@@ -1105,7 +1111,7 @@ std::vector<std::string> map_lines::get_shuffle_strings() const
std::vector<std::string> map_lines::get_subst_strings() const
{
std::vector<std::string> substs;
- for (int i = 0, size = transforms.size(); i < size; ++i)
+ for (int i = 0, vsize = transforms.size(); i < vsize; ++i)
if (transforms[i]->type() == map_transformer::TT_SUBST)
substs.push_back( transforms[i]->describe() );
return (substs);
diff --git a/crawl-ref/source/mapdef.h b/crawl-ref/source/mapdef.h
index 8612eaae04..dad2e26af2 100644
--- a/crawl-ref/source/mapdef.h
+++ b/crawl-ref/source/mapdef.h
@@ -257,6 +257,7 @@ public:
int width() const;
int height() const;
+ coord_def size() const;
int glyph(int x, int y) const;
bool is_solid(int gly) const;
diff --git a/crawl-ref/source/maps.cc b/crawl-ref/source/maps.cc
index 31386ff2e3..d08fa2af11 100644
--- a/crawl-ref/source/maps.cc
+++ b/crawl-ref/source/maps.cc
@@ -161,43 +161,38 @@ static bool resolve_map(map_def &map, const map_def &original)
// Determines if the region specified by (x, y, x + width - 1, y + height - 1)
// is a bad place to build a vault.
-static bool bad_map_place(const map_def &map,
- int sx, int sy, int width, int height,
- bool check_place, bool clobber)
+static bool bad_map_place(const map_def &map, const coord_def &c,
+ const coord_def &size)
{
- if (!check_place || clobber)
- return (false);
-
const std::vector<std::string> &lines = map.map.get_lines();
- for (int y = sy; y < sy + height; ++y)
+ for (rectangle_iterator r(c, c + size - 1); r; ++r)
{
- for (int x = sx; x < sx + width; ++x)
- {
- if (lines[y - sy][x - sx] == ' ')
- continue;
+ const coord_def &p(*r);
+ const coord_def dp = p - c;
+ if (lines[dp.y][dp.x] == ' ')
+ continue;
- if (dgn_Map_Mask[x][y])
- return (true);
+ if (dgn_Map_Mask[p.x][p.y])
+ return (true);
- if (igrd[x][y] != NON_ITEM || mgrd[x][y] != NON_MONSTER)
- return (true);
+ if (igrd(p) != NON_ITEM || mgrd(p) != NON_MONSTER)
+ return (true);
- const dungeon_feature_type grid = grd[x][y];
+ const dungeon_feature_type grid = grd(p);
- if (!grid_is_opaque(grid)
- && grid != DNGN_FLOOR
- && grid != DNGN_SHALLOW_WATER
- && grid != DNGN_CLOSED_DOOR
- && grid != DNGN_OPEN_DOOR
- && grid != DNGN_SECRET_DOOR)
- {
+ if (!grid_is_opaque(grid)
+ && grid != DNGN_FLOOR
+ && grid != DNGN_SHALLOW_WATER
+ && grid != DNGN_CLOSED_DOOR
+ && grid != DNGN_OPEN_DOOR
+ && grid != DNGN_SECRET_DOOR)
+ {
#ifdef DEBUG_DIAGNOSTICS
- mprf(MSGCH_DIAGNOSTICS,
- "Rejecting place because of %s at (%d,%d)",
- dungeon_feature_name(grid), x, y);
+ mprf(MSGCH_DIAGNOSTICS,
+ "Rejecting place because of %s at (%d,%d)",
+ dungeon_feature_name(grid), p.x, p.y);
#endif
- return (true);
- }
+ return (true);
}
}
@@ -223,35 +218,35 @@ static bool apply_vault_grid(map_def &def, map_type map,
{
const map_lines &ml = def.map;
const int orient = def.orient;
- const int width = ml.width();
- const int height = ml.height();
+
+ const coord_def size(ml.size());
coord_def start(0, 0);
if (orient == MAP_SOUTH || orient == MAP_SOUTHEAST
- || orient == MAP_SOUTHWEST)
+ || orient == MAP_SOUTHWEST)
{
- start.y = GYM - height;
+ start.y = GYM - size.y;
}
if (orient == MAP_EAST || orient == MAP_NORTHEAST
- || orient == MAP_SOUTHEAST)
+ || orient == MAP_SOUTHEAST)
{
- start.x = GXM - width;
+ start.x = GXM - size.x;
}
// Handle maps aligned along cardinals that are smaller than
// the corresponding map dimension.
if ((orient == MAP_NORTH || orient == MAP_SOUTH
- || orient == MAP_ENCOMPASS)
- && width < GXM)
+ || orient == MAP_ENCOMPASS)
+ && size.x < GXM)
{
- start.x = (GXM - width) / 2;
+ start.x = (GXM - size.x) / 2;
}
if ((orient == MAP_EAST || orient == MAP_WEST
- || orient == MAP_ENCOMPASS)
- && height < GYM)
+ || orient == MAP_ENCOMPASS)
+ && size.y < GYM)
{
- start.y = (GYM - height) / 2;
+ start.y = (GYM - size.y) / 2;
}
// Floating maps can go anywhere, ask the map_def to suggest a place.
@@ -259,19 +254,18 @@ static bool apply_vault_grid(map_def &def, map_type map,
{
if (map_bounds(place.pos))
{
- start = place.pos - coord_def(width, height) / 2;
- fit_region_into_map_bounds(start, coord_def(width, height));
+ start = place.pos - size / 2;
+ fit_region_into_map_bounds(start, size);
}
else
start = def.float_place();
}
- if (bad_map_place(def, start.x, start.y, width, height, check_place,
- clobber))
+ if (check_place && !clobber && bad_map_place(def, start, size))
{
#ifdef DEBUG_DIAGNOSTICS
mprf(MSGCH_DIAGNOSTICS, "Bad vault place: (%d,%d) dim (%d,%d)",
- start.x, start.y, width, height);
+ start.x, start.y, size.x, size.y);
#endif
return (false);
}
@@ -279,17 +273,17 @@ static bool apply_vault_grid(map_def &def, map_type map,
const std::vector<std::string> &lines = ml.get_lines();
#ifdef DEBUG_DIAGNOSTICS
mprf(MSGCH_DIAGNOSTICS, "Applying %s at (%d,%d), dimensions (%d,%d)",
- def.name.c_str(), start.x, start.y, width, height);
+ def.name.c_str(), start.x, start.y, size.x, size.y);
#endif
- for (int y = start.y; y < start.y + height; ++y)
+ for (int y = start.y; y < start.y + size.y; ++y)
{
const std::string &s = lines[y - start.y];
strncpy(&map[y][start.x], s.c_str(), s.length());
}
place.pos = start;
- place.size = coord_def(width, height);
+ place.size = size;
return (true);
}
diff --git a/crawl-ref/source/maps.h b/crawl-ref/source/maps.h
index 20dc1709c1..677956a25e 100644
--- a/crawl-ref/source/maps.h
+++ b/crawl-ref/source/maps.h
@@ -26,9 +26,15 @@ struct vault_placement
map_def map;
std::vector<coord_def> exits;
+ int level_number, altar_count, num_runes;
+
+ // If we're not placing runes, this is the substitute feature.
+ int rune_subst;
+
vault_placement()
: pos(-1, -1), size(0, 0), orient(0), map(),
- exits()
+ exits(), level_number(0), altar_count(0), num_runes(0),
+ rune_subst(-1)
{
}
};