summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/dungeon.h
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-27 19:42:23 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-27 19:42:23 +0000
commit9b41135da821d07d54c7a6ee75ed6dcbd19e9322 (patch)
treeb5151b3dd9d18dbfb50646ee91155382b22a2c59 /crawl-ref/source/dungeon.h
parent6a2be1555b3d27614a7a5d3a8fd973cebc0865c8 (diff)
downloadcrawl-ref-9b41135da821d07d54c7a6ee75ed6dcbd19e9322.tar.gz
crawl-ref-9b41135da821d07d54c7a6ee75ed6dcbd19e9322.zip
Added glyphs_connected and friends for maps to test connectedness of points
after map transforms are applied. Fixed conflicts in bison grammar. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1669 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/dungeon.h')
-rw-r--r--crawl-ref/source/dungeon.h128
1 files changed, 120 insertions, 8 deletions
diff --git a/crawl-ref/source/dungeon.h b/crawl-ref/source/dungeon.h
index f46106a3ed..04f013b655 100644
--- a/crawl-ref/source/dungeon.h
+++ b/crawl-ref/source/dungeon.h
@@ -16,6 +16,9 @@
#include "FixVec.h"
#include "externs.h"
+#include "misc.h"
+#include "travel.h"
+#include "stuff.h"
const int MAKE_GOOD_ITEM = 351;
@@ -89,18 +92,127 @@ struct dgn_region
};
void builder(int level_number, int level_type);
-
void define_zombie(int mid, int ztype, int cs, int power);
-
bool is_wall(int feature);
+bool place_specific_trap(int spec_x, int spec_y, trap_type spec_type);
+void place_spec_shop(int level_number, int shop_x, int shop_y,
+ int force_s_type, bool representative = false);
+bool unforbidden(const coord_def &c, const dgn_region_list &forbidden);
+
-bool place_specific_trap(unsigned char spec_x, unsigned char spec_y,
- trap_type spec_type);
+//////////////////////////////////////////////////////////////////////////
+template <typename fgrd, typename bound_check>
+class flood_find : public travel_pathfind
+{
+public:
+ flood_find(const fgrd &f, const bound_check &bc);
-void place_spec_shop(int level_number, unsigned char shop_x,
- unsigned char shop_y, unsigned char force_s_type,
- bool representative = false );
+ void add_feat(int feat);
+ void add_point(const coord_def &pos);
+ coord_def find_first_from(const coord_def &c, const dgn_region_list &vlts);
+ bool points_connected_from(const coord_def &start);
-bool unforbidden(const coord_def &c, const dgn_region_list &forbidden);
+ bool did_leave_vault() const { return left_vault; }
+
+protected:
+ bool path_flood(const coord_def &c, const coord_def &dc);
+protected:
+ bool point_hunt;
+ bool needed_features[NUM_FEATURES];
+ std::vector<coord_def> needed_points;
+ bool left_vault;
+ dgn_region_list vaults;
+
+ const fgrd &fgrid;
+ const bound_check &bcheck;
+};
+
+template <typename fgrd, typename bound_check>
+flood_find<fgrd, bound_check>::flood_find(const fgrd &f, const bound_check &bc)
+ : travel_pathfind(), point_hunt(false), needed_features(),
+ needed_points(), left_vault(true), vaults(),
+ fgrid(f), bcheck(bc)
+{
+ memset(needed_features, false, sizeof needed_features);
+}
+
+template <typename fgrd, typename bound_check>
+void flood_find<fgrd, bound_check>::add_feat(int feat)
+{
+ if (feat >= 0 && feat < NUM_FEATURES)
+ needed_features[feat] = true;
+}
+
+template <typename fgrd, typename bound_check>
+coord_def
+flood_find<fgrd, bound_check>::find_first_from(
+ const coord_def &c,
+ const dgn_region_list &vlts)
+{
+ set_floodseed(c);
+ vaults = vlts;
+ return pathfind(RMODE_EXPLORE);
+}
+
+template <typename fgrd, typename bound_check>
+void flood_find<fgrd, bound_check>::add_point(const coord_def &c)
+{
+ needed_points.push_back(c);
+}
+
+template <typename fgrd, typename bound_check>
+bool flood_find<fgrd, bound_check>::points_connected_from(
+ const coord_def &sp)
+{
+ if (needed_points.empty())
+ return (true);
+ set_floodseed(sp);
+ pathfind(RMODE_EXPLORE);
+ return (needed_points.empty());
+}
+
+template <typename fgrd, typename bound_check>
+bool flood_find<fgrd, bound_check>::path_flood(
+ const coord_def &c,
+ const coord_def &dc)
+{
+ if (!bcheck(dc))
+ return (false);
+
+ if (!needed_points.empty())
+ {
+ std::vector<coord_def>::iterator i =
+ std::find(needed_points.begin(), needed_points.end(), dc);
+ if (i != needed_points.end())
+ {
+ needed_points.erase(i);
+ if (needed_points.empty())
+ return (true);
+ }
+ }
+
+ const dungeon_feature_type grid = fgrid(dc);
+ if (needed_features[ grid ])
+ {
+ unexplored_place = dc;
+ unexplored_dist = traveled_distance;
+ return (true);
+ }
+
+ if (!is_traversable(grid)
+ && grid != DNGN_SECRET_DOOR
+ && !grid_is_trap(grid))
+ {
+ return (false);
+ }
+
+ if (!left_vault && unforbidden(dc, vaults))
+ left_vault = true;
+
+ good_square(dc);
+
+ return (false);
+}
+//////////////////////////////////////////////////////////////////////////
#endif