summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/dungeon.cc131
-rw-r--r--crawl-ref/source/dungeon.h35
-rw-r--r--crawl-ref/source/makeitem.cc2
-rw-r--r--crawl-ref/source/makeitem.h1
-rw-r--r--crawl-ref/source/mapdef.cc5
-rw-r--r--crawl-ref/source/mapdef.h1
-rw-r--r--crawl-ref/source/maps.cc38
-rw-r--r--crawl-ref/source/maps.h27
-rw-r--r--crawl-ref/source/newgame.cc1
-rw-r--r--crawl-ref/source/traps.cc1
-rw-r--r--crawl-ref/source/util/levcomp.lpp1
11 files changed, 112 insertions, 131 deletions
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc
index 2e5322e791..9e580b2e0c 100644
--- a/crawl-ref/source/dungeon.cc
+++ b/crawl-ref/source/dungeon.cc
@@ -211,7 +211,6 @@ static bool _build_minivaults(int level_number, int force_vault,
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);
@@ -3941,11 +3940,10 @@ static bool _build_minivaults(int level_number, int force_vault,
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);
+ vault_main(place, force_vault);
coord_def v1;
@@ -3970,37 +3968,13 @@ static bool _build_minivaults(int level_number, int force_vault,
_register_place(place);
- // This is a throwaway.
- std::vector<coord_def> &target_connections = place.exits;
-
- // Paint the minivault onto the grid.
- for (rectangle_iterator ri(v1, v1 + place.size - 1); ri; ++ri)
- {
- const coord_def vdelta = *ri - v1;
-
- // FIXME: why the y and x swap?
- const int feat = vgrid[vdelta.y][vdelta.x];
-
- if (feat == ' ')
- continue;
-
- const dungeon_feature_type oldgrid = grd(*ri);
- _vault_grid( place, feat, *ri, target_connections );
- if (!Generating_Level)
- {
- link_items();
- const dungeon_feature_type newgrid = grd(*ri);
- grd(*ri) = oldgrid;
- dungeon_terrain_changed(*ri, newgrid, true, true);
- env.markers.remove_markers_at(*ri, MAT_ANY);
- }
- env.map(*ri).property |= FPROP_VAULT;
- }
-
- place.map.map.apply_overlays(v1);
+ place.apply_grid();
if (!make_no_exits)
{
+ // This is a throwaway.
+ std::vector<coord_def> &target_connections = place.exits;
+
if (target_connections.empty() && place.map.has_tag("mini_float"))
_pick_float_exits(place, target_connections);
@@ -4501,52 +4475,22 @@ static bool _build_vaults(int level_number, int force_vault, int rune_subst,
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))
place.pos = where;
- const int gluggy = vault_main(vgrid, place, force_vault,
+ const int gluggy = vault_main(place, force_vault,
check_collisions);
if (gluggy == MAP_NONE || !gluggy)
return (false);
- dgn_region this_vault(place.pos, place.size);
- if (!place.size.zero())
- {
- // NOTE: assumes *no* previous item (I think) or monster (definitely)
- // placement.
- for ( rectangle_iterator ri(place.pos, place.pos + place.size - 1);
- ri; ++ri )
- {
- if (vgrid[ri->y][ri->x] == ' ')
- continue;
-
- const dungeon_feature_type oldgrid = grd(*ri);
- _vault_grid( place, vgrid[ri->y][ri->x], *ri,
- target_connections );
- if (!Generating_Level)
- {
- // Have to link items each square at a time, or
- // dungeon_terrain_changed could blow up.
- link_items();
- const dungeon_feature_type newgrid = grd(*ri);
- grd(*ri) = oldgrid;
- dungeon_terrain_changed(*ri, newgrid, true, true);
- env.markers.remove_markers_at(*ri, MAT_ANY);
- }
- env.map(*ri).property |= FPROP_VAULT;
- }
- }
-
- place.map.map.apply_overlays(place.pos);
+ place.apply_grid();
_register_place(place);
+ std::vector<coord_def> &target_connections = place.exits;
if (target_connections.empty() && gluggy != MAP_ENCOMPASS)
_pick_float_exits(place, target_connections);
@@ -5053,7 +4997,6 @@ static const object_class_type _acquirement_item_classes[] = {
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
@@ -5068,7 +5011,7 @@ static void _vault_grid( vault_placement &place,
}
else if (f.glyph >= 0)
{
- _vault_grid( place, f.glyph, where, targets, true );
+ _vault_grid( place, f.glyph, where, true );
}
else if (f.shop >= 0)
place_spec_shop(place.level_number, where, f.shop);
@@ -5145,7 +5088,7 @@ static void _vault_grid( vault_placement &place,
place.altar_count++;
break;
case '@':
- targets.push_back( where );
+ place.exits.push_back( where );
break;
case '^':
place_specific_trap(where, TRAP_RANDOM);
@@ -5160,7 +5103,7 @@ static void _vault_grid( vault_placement &place,
|| where.x == place.pos.x + place.size.x - 1
|| where.y == place.pos.y + place.size.y - 1))
{
- targets.push_back( where );
+ place.exits.push_back( where );
}
// Then, handle grids that place "stuff" {dlb}:
@@ -6623,8 +6566,7 @@ static void _labyrinth_place_exit(const coord_def &end)
static void _init_minivault_placement(int vault, vault_placement &place)
{
- map_type vgrid;
- vault_main(vgrid, place, vault);
+ vault_main(place, vault);
}
// Checks whether a given grid has at least one neighbour surrounded
@@ -8407,3 +8349,52 @@ static bool _fixup_interlevel_connectivity()
return (true);
}
+
+//////////////////////////////////////////////////////////////////////////
+// vault_placement
+
+void vault_placement::reset()
+{
+ altar_count = 0;
+}
+
+void vault_placement::apply_grid()
+{
+ if (!size.zero())
+ {
+ // NOTE: assumes *no* previous item (I think) or monster (definitely)
+ // placement.
+ for ( rectangle_iterator ri(pos, pos + size - 1); ri; ++ri )
+ {
+ const coord_def &rp(*ri);
+ const coord_def dp = rp - pos;
+
+ const int feat = map.map.glyph(dp);
+
+ if (feat == ' ')
+ continue;
+
+ const dungeon_feature_type oldgrid = grd(*ri);
+ _vault_grid( *this, feat, *ri );
+ if (!Generating_Level)
+ {
+ // Have to link items each square at a time, or
+ // dungeon_terrain_changed could blow up.
+ link_items();
+ const dungeon_feature_type newgrid = grd(*ri);
+ grd(*ri) = oldgrid;
+ dungeon_terrain_changed(*ri, newgrid, true, true);
+ env.markers.remove_markers_at(*ri, MAT_ANY);
+ }
+ env.map(*ri).property |= FPROP_VAULT;
+ }
+
+ map.map.apply_overlays(pos);
+ }
+}
+
+void vault_placement::draw_at(const coord_def &c)
+{
+ pos = c;
+ apply_grid();
+}
diff --git a/crawl-ref/source/dungeon.h b/crawl-ref/source/dungeon.h
index 7ea0f06b6f..3fa64ac7f3 100644
--- a/crawl-ref/source/dungeon.h
+++ b/crawl-ref/source/dungeon.h
@@ -16,6 +16,8 @@
#include "terrain.h"
#include "travel.h"
#include "stuff.h"
+#include "mapdef.h"
+
#include <vector>
#include <set>
#include <algorithm>
@@ -46,13 +48,10 @@ const int MAKE_GOOD_ITEM = 351;
// Should be the larger of GXM/GYM
#define MAP_SIDE ( (GXM) > (GYM) ? (GXM) : (GYM) )
-// This may sometimes be used as map_type[x][y] (for minivaults) and as
-// map_type[y][x] for large-scale vaults. Keep an eye out for the associated
-// brain-damage. [dshaligram]
-typedef char map_type[MAP_SIDE + 1][MAP_SIDE + 1];
typedef FixedArray<unsigned short, GXM, GYM> map_mask;
extern map_mask dgn_Map_Mask;
+extern bool Generating_Level;
extern std::string dgn_Layout_Type;
extern std::set<std::string> Level_Unique_Maps;
@@ -141,6 +140,34 @@ class dgn_region
bool overlaps(const map_mask &dgn_map_mask) const;
};
+struct vault_placement
+{
+public:
+ coord_def pos;
+ coord_def size;
+
+ int orient;
+ 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;
+
+public:
+ vault_placement()
+ : pos(-1, -1), size(0, 0), orient(0), map(),
+ exits(), level_number(0), altar_count(0), num_runes(0),
+ rune_subst(-1)
+ {
+ }
+
+ void reset();
+ void apply_grid();
+ void draw_at(const coord_def &c);
+};
+
//////////////////////////////////////////////////////////////////////////
template <typename fgrd, typename bound_check>
class flood_find : public travel_pathfind
diff --git a/crawl-ref/source/makeitem.cc b/crawl-ref/source/makeitem.cc
index bf05dbe144..d70d8e4955 100644
--- a/crawl-ref/source/makeitem.cc
+++ b/crawl-ref/source/makeitem.cc
@@ -16,6 +16,7 @@
#include "decks.h"
#include "describe.h"
+#include "dungeon.h"
#include "food.h"
#include "it_use2.h"
#include "itemname.h"
@@ -27,6 +28,7 @@
#include "randart.h"
#include "spl-book.h"
#include "stuff.h"
+#include "travel.h"
#include "view.h"
void item_set_appearance(item_def &item);
diff --git a/crawl-ref/source/makeitem.h b/crawl-ref/source/makeitem.h
index 5409f008dc..26797f7bb3 100644
--- a/crawl-ref/source/makeitem.h
+++ b/crawl-ref/source/makeitem.h
@@ -9,7 +9,6 @@
#ifndef MAKEITEM_H
#define MAKEITEM_H
-#include "dungeon.h"
#include "itemprop.h"
enum item_make_species_type
diff --git a/crawl-ref/source/mapdef.cc b/crawl-ref/source/mapdef.cc
index e9dbd64b7d..48fc6fd2d8 100644
--- a/crawl-ref/source/mapdef.cc
+++ b/crawl-ref/source/mapdef.cc
@@ -764,6 +764,11 @@ int map_lines::glyph(int x, int y) const
return lines[y][x];
}
+int map_lines::glyph(const coord_def &c) const
+{
+ return glyph(c.x, c.y);
+}
+
bool map_lines::is_solid(int gly) const
{
return (gly == 'x' || gly == 'c' || gly == 'b' || gly == 'v');
diff --git a/crawl-ref/source/mapdef.h b/crawl-ref/source/mapdef.h
index dad2e26af2..585ed6a542 100644
--- a/crawl-ref/source/mapdef.h
+++ b/crawl-ref/source/mapdef.h
@@ -260,6 +260,7 @@ public:
coord_def size() const;
int glyph(int x, int y) const;
+ int glyph(const coord_def &) const;
bool is_solid(int gly) const;
bool solid_borders(map_section_type border);
diff --git a/crawl-ref/source/maps.cc b/crawl-ref/source/maps.cc
index c0b3120456..7e4de773e2 100644
--- a/crawl-ref/source/maps.cc
+++ b/crawl-ref/source/maps.cc
@@ -30,12 +30,11 @@
#include "stuff.h"
#include "terrain.h"
-static int write_vault(map_def &mdef, map_type mt,
+static int write_vault(map_def &mdef,
vault_placement &,
bool check_place);
static int apply_vault_definition(
map_def &def,
- map_type map,
vault_placement &,
bool check_place);
@@ -57,8 +56,7 @@ static map_vector vdefs;
// Make sure that vault_n, where n is a number, is a vault which can be put
// anywhere, while other vault names are for specific level ranges, etc.
-int vault_main( map_type vgrid,
- vault_placement &place,
+int vault_main( vault_placement &place,
int which_vault,
bool check_place)
{
@@ -71,23 +69,13 @@ int vault_main( map_type vgrid,
mapgen_report_map_try(vdefs[which_vault]);
#endif
- // First, fill in entirely with walls and null-terminate {dlb}:
- for (int vx = 0; vx < MAP_SIDE; vx++)
- {
- for (int vy = 0; vy < MAP_SIDE; vy++)
- vgrid[vx][vy] = 'x';
-
- vgrid[MAP_SIDE][vx] = 0;
- vgrid[vx][MAP_SIDE] = 0;
- }
-
// 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.
- return (write_vault( vdefs[which_vault], vgrid, place, check_place ));
+ return (write_vault( vdefs[which_vault], place, check_place ));
}
-static int write_vault(map_def &mdef, map_type map,
+static int write_vault(map_def &mdef,
vault_placement &place,
bool check_place)
{
@@ -107,7 +95,7 @@ static int write_vault(map_def &mdef, map_type map,
if (!resolve_map(place.map, mdef))
continue;
- place.orient = apply_vault_definition(place.map, map,
+ place.orient = apply_vault_definition(place.map,
place, check_place);
if (place.orient != MAP_NONE)
@@ -210,7 +198,7 @@ void fit_region_into_map_bounds(coord_def &pos, const coord_def &size)
pos.y = Y_BOUND_2 - size.y + 1;
}
-static bool apply_vault_grid(map_def &def, map_type map,
+static bool apply_vault_grid(map_def &def,
vault_placement &place,
bool check_place)
{
@@ -268,17 +256,6 @@ static bool apply_vault_grid(map_def &def, map_type map,
return (false);
}
- 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, size.x, size.y);
-#endif
-
- 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 = size;
@@ -288,11 +265,10 @@ static bool apply_vault_grid(map_def &def, map_type map,
static int apply_vault_definition(
map_def &def,
- map_type map,
vault_placement &place,
bool check_place)
{
- if (!apply_vault_grid(def, map, place, check_place))
+ if (!apply_vault_grid(def, place, check_place))
return (MAP_NONE);
int orient = def.orient;
diff --git a/crawl-ref/source/maps.h b/crawl-ref/source/maps.h
index b729c3b36c..01b6af9fb4 100644
--- a/crawl-ref/source/maps.h
+++ b/crawl-ref/source/maps.h
@@ -12,35 +12,12 @@
#include "FixVec.h"
#include "dungeon.h"
-#include "mapdef.h"
#include <vector>
class map_def;
-struct vault_placement
-{
- coord_def pos;
- coord_def size;
-
- int orient;
- 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(), level_number(0), altar_count(0), num_runes(0),
- rune_subst(-1)
- {
- }
-};
-
-int vault_main(map_type vgrid,
- vault_placement &vp,
+
+int vault_main(vault_placement &vp,
int vault_force,
bool check_place = false);
diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc
index a477165ac6..6f2dbccc15 100644
--- a/crawl-ref/source/newgame.cc
+++ b/crawl-ref/source/newgame.cc
@@ -34,6 +34,7 @@
#include "cio.h"
#include "command.h"
#include "describe.h"
+#include "dungeon.h"
#include "files.h"
#include "fight.h"
#include "food.h"
diff --git a/crawl-ref/source/traps.cc b/crawl-ref/source/traps.cc
index 89f35f7a6c..7963073cf2 100644
--- a/crawl-ref/source/traps.cc
+++ b/crawl-ref/source/traps.cc
@@ -36,6 +36,7 @@
#include "spells3.h"
#include "spl-mis.h"
#include "spl-util.h"
+#include "stuff.h"
#include "terrain.h"
#include "transfor.h"
#include "tutorial.h"
diff --git a/crawl-ref/source/util/levcomp.lpp b/crawl-ref/source/util/levcomp.lpp
index 41d3b60b0f..41342277b7 100644
--- a/crawl-ref/source/util/levcomp.lpp
+++ b/crawl-ref/source/util/levcomp.lpp
@@ -11,6 +11,7 @@
#include "AppHdr.h"
#include "mapdef.h"
#include "levcomp.tab.h"
+#include "stuff.h"
static bool alloced = false;