summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Cline <zelgadis@sourceforge.net>2009-11-29 01:08:06 -0800
committerMatthew Cline <zelgadis@sourceforge.net>2009-11-29 01:14:47 -0800
commit7f9e84d7674d4a370c1514f40832afaf654736cc (patch)
treef286f068de02f1470c7db26ec80e5e4e72d66dd1
parent83b3d564bcad6422fca7545cb5bc56fd9aa92a1c (diff)
downloadcrawl-ref-7f9e84d7674d4a370c1514f40832afaf654736cc.tar.gz
crawl-ref-7f9e84d7674d4a370c1514f40832afaf654736cc.zip
Reduce dependency on travel.h
Removed inclusion of travel.h from most .h files to reduce the number of .cc files dependant on it. This involved moving the level_pos declaration to externs.h, moving the flood_find template to it's own header file, and moving two typedefs from travel.h to travel_defs.h because typedefs can't be forward declared (argh).
-rw-r--r--crawl-ref/source/abyss.cc1
-rw-r--r--crawl-ref/source/chardump.cc1
-rw-r--r--crawl-ref/source/dbg-maps.cc1
-rw-r--r--crawl-ref/source/dungeon.cc1
-rw-r--r--crawl-ref/source/dungeon.h164
-rw-r--r--crawl-ref/source/externs.h60
-rw-r--r--crawl-ref/source/fight.cc1
-rw-r--r--crawl-ref/source/flood_find.h173
-rw-r--r--crawl-ref/source/items.cc1
-rw-r--r--crawl-ref/source/l_dgn.cc1
-rw-r--r--crawl-ref/source/mapdef.cc1
-rw-r--r--crawl-ref/source/mapdef.h2
-rw-r--r--crawl-ref/source/maps.cc1
-rw-r--r--crawl-ref/source/mon-pick.h2
-rw-r--r--crawl-ref/source/mon-place.cc1
-rw-r--r--crawl-ref/source/mon-stuff.cc1
-rw-r--r--crawl-ref/source/mon-transit.h1
-rw-r--r--crawl-ref/source/overmap.cc1
-rw-r--r--crawl-ref/source/shopping.cc1
-rw-r--r--crawl-ref/source/show.cc1
-rw-r--r--crawl-ref/source/stash.h1
-rw-r--r--crawl-ref/source/terrain.cc1
-rw-r--r--crawl-ref/source/traps.cc1
-rw-r--r--crawl-ref/source/traps.h2
-rw-r--r--crawl-ref/source/travel.h67
-rw-r--r--crawl-ref/source/travel_defs.h15
-rw-r--r--crawl-ref/source/tutorial.cc1
-rw-r--r--crawl-ref/source/wiz-dgn.cc1
-rw-r--r--crawl-ref/source/xom.cc1
29 files changed, 275 insertions, 231 deletions
diff --git a/crawl-ref/source/abyss.cc b/crawl-ref/source/abyss.cc
index 5d5bb9a627..562f93729c 100644
--- a/crawl-ref/source/abyss.cc
+++ b/crawl-ref/source/abyss.cc
@@ -44,6 +44,7 @@
#endif
#include "tiles.h"
#include "traps.h"
+#include "travel.h"
#include "view.h"
#include "xom.h"
diff --git a/crawl-ref/source/chardump.cc b/crawl-ref/source/chardump.cc
index 0a5c163a9b..493fdcbf80 100644
--- a/crawl-ref/source/chardump.cc
+++ b/crawl-ref/source/chardump.cc
@@ -52,6 +52,7 @@
#include "stuff.h"
#include "env.h"
#include "transfor.h"
+#include "travel.h"
#include "view.h"
#include "viewchar.h"
#include "xom.h"
diff --git a/crawl-ref/source/dbg-maps.cc b/crawl-ref/source/dbg-maps.cc
index fe4040406f..b745fcec10 100644
--- a/crawl-ref/source/dbg-maps.cc
+++ b/crawl-ref/source/dbg-maps.cc
@@ -13,6 +13,7 @@
#include "coord.h"
#include "dungeon.h"
#include "env.h"
+#include "flood_find.h"
#include "map_knowledge.h"
#include "initfile.h"
#include "maps.h"
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc
index f165ee457d..5d7d35227d 100644
--- a/crawl-ref/source/dungeon.cc
+++ b/crawl-ref/source/dungeon.cc
@@ -27,6 +27,7 @@
#include "env.h"
#include "enum.h"
#include "map_knowledge.h"
+#include "flood_find.h"
#include "fprop.h"
#include "externs.h"
#include "options.h"
diff --git a/crawl-ref/source/dungeon.h b/crawl-ref/source/dungeon.h
index c2f5e7456f..590a91b897 100644
--- a/crawl-ref/source/dungeon.h
+++ b/crawl-ref/source/dungeon.h
@@ -11,7 +11,6 @@
#include "fixedarray.h"
#include "externs.h"
#include "terrain.h"
-#include "travel.h"
#include "stuff.h"
#include "mapdef.h"
@@ -19,6 +18,8 @@
#include <set>
#include <algorithm>
+class map_mask;
+
#define BUILD_METHOD_KEY "build_method_key"
#define LAYOUT_TYPE_KEY "layout_type_key"
#define LEVEL_VAULTS_KEY "level_vaults_key"
@@ -49,8 +50,6 @@ const int MAKE_GOOD_ITEM = 351;
// Should be the larger of GXM/GYM
#define MAP_SIDE ( (GXM) > (GYM) ? (GXM) : (GYM) )
-typedef FixedArray<unsigned short, GXM, GYM> map_mask;
-
// Map mask constants.
enum map_mask_type
@@ -162,7 +161,6 @@ public:
void draw_at(const coord_def &c);
};
-extern map_mask dgn_Map_Mask;
extern bool Generating_Level;
extern std::string dgn_Layout_Type;
@@ -172,164 +170,6 @@ extern std::set<std::string> Level_Unique_Tags;
extern std::vector<vault_placement> Level_Vaults;
extern std::vector<vault_placement> Temp_Vaults;
-//////////////////////////////////////////////////////////////////////////
-template <typename fgrd, typename bound_check>
-class flood_find : public travel_pathfind
-{
-public:
- flood_find(const fgrd &f, const bound_check &bc);
-
- void add_feat(int feat);
- void add_point(const coord_def &pos);
- coord_def find_first_from(const coord_def &c, const map_mask &vlts);
- bool points_connected_from(const coord_def &start);
- bool any_point_connected_from(const coord_def &start);
- bool has_exit_from(const coord_def &start);
-
- bool did_leave_vault() const { return left_vault; }
-
-protected:
- bool path_flood(const coord_def &c, const coord_def &dc);
-protected:
- bool point_hunt, want_exit;
- bool needed_features[NUM_FEATURES];
- std::vector<coord_def> needed_points;
- bool left_vault;
- const map_mask *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), want_exit(false),
- needed_features(), needed_points(), left_vault(true), vaults(NULL),
- 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 map_mask &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>::any_point_connected_from(
- const coord_def &sp)
-{
- if (needed_points.empty())
- return (true);
- set_floodseed(sp);
- const size_t sz = needed_points.size();
- pathfind(RMODE_EXPLORE);
- return (needed_points.size() < sz);
-}
-
-template <typename fgrd, typename bound_check>
-bool flood_find<fgrd, bound_check>::has_exit_from(
- const coord_def &sp)
-{
- want_exit = true;
- set_floodseed(sp);
- return (pathfind(RMODE_EXPLORE) == coord_def(-1, -1));
-}
-
-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))
- {
- if (want_exit)
- {
- greedy_dist = 100;
- greedy_place = coord_def(-1, -1);
- return (true);
- }
- 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 feat = fgrid(dc);
-
- if (feat == NUM_FEATURES)
- {
- if (want_exit)
- {
- greedy_dist = 100;
- greedy_place = coord_def(-1, -1);
- return (true);
- }
- return (false);
- }
-
- if (needed_features[ feat ])
- {
- unexplored_place = dc;
- unexplored_dist = traveled_distance;
- return (true);
- }
-
- if (!feat_is_traversable(feat)
- && feat != DNGN_SECRET_DOOR
- && !feat_is_trap(feat))
- {
- return (false);
- }
-
- if (!left_vault && vaults && !(*vaults)[dc.x][dc.y])
- left_vault = true;
-
- good_square(dc);
-
- return (false);
-}
-//////////////////////////////////////////////////////////////////////////
-
void init_level_connectivity();
void read_level_connectivity(reader &th);
void write_level_connectivity(writer &th);
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h
index 979e7f81a7..51e2eea241 100644
--- a/crawl-ref/source/externs.h
+++ b/crawl-ref/source/externs.h
@@ -400,6 +400,66 @@ public:
void load(reader&);
};
+// A position on a particular level.
+struct level_pos
+{
+ level_id id;
+ coord_def pos; // The grid coordinates on this level.
+
+ level_pos() : id(), pos()
+ {
+ pos.x = pos.y = -1;
+ }
+
+ level_pos(const level_id &lid, const coord_def &coord)
+ : id(lid), pos(coord)
+ {
+ }
+
+ level_pos(const level_id &lid)
+ : id(lid), pos()
+ {
+ pos.x = pos.y = -1;
+ }
+
+ // Returns the level_pos of where the player is standing.
+ static level_pos current();
+
+ bool operator == ( const level_pos &lp ) const
+ {
+ return id == lp.id && pos == lp.pos;
+ }
+
+ bool operator != ( const level_pos &lp ) const
+ {
+ return id != lp.id || pos != lp.pos;
+ }
+
+ bool operator < ( const level_pos &lp ) const
+ {
+ return (id < lp.id) || (id == lp.id && pos < lp.pos);
+ }
+
+ bool is_valid() const
+ {
+ return id.depth > -1 && pos.x != -1 && pos.y != -1;
+ }
+
+ bool is_on( const level_id _id)
+ {
+ return id == _id;
+ }
+
+ void clear()
+ {
+ id.clear();
+ pos = coord_def(-1, -1);
+ }
+
+ void save(writer&) const;
+ void load(reader&);
+};
+
class monsters;
struct item_def
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index e726c234a8..063fd8c9f8 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -64,6 +64,7 @@
#include "stuff.h"
#include "transfor.h"
#include "traps.h"
+#include "travel.h"
#include "tutorial.h"
#include "view.h"
#include "shout.h"
diff --git a/crawl-ref/source/flood_find.h b/crawl-ref/source/flood_find.h
new file mode 100644
index 0000000000..ad4b6bf310
--- /dev/null
+++ b/crawl-ref/source/flood_find.h
@@ -0,0 +1,173 @@
+/*
+ * File: flood_find.h
+ * Summary: flood_find template
+ */
+
+#ifndef FLOOD_FIND_H
+#define FLOOD_FIND_H
+
+#include "terrain.h"
+#include "travel.h"
+
+// You can't forward declare typedefs, so do this instead.
+class map_mask : public FixedArray<unsigned short, GXM, GYM> {} ;
+
+extern map_mask dgn_Map_Mask;
+
+template <typename fgrd, typename bound_check>
+class flood_find : public travel_pathfind
+{
+public:
+ flood_find(const fgrd &f, const bound_check &bc);
+
+ void add_feat(int feat);
+ void add_point(const coord_def &pos);
+ coord_def find_first_from(const coord_def &c, const map_mask &vlts);
+ bool points_connected_from(const coord_def &start);
+ bool any_point_connected_from(const coord_def &start);
+ bool has_exit_from(const coord_def &start);
+
+ bool did_leave_vault() const { return left_vault; }
+
+protected:
+ bool path_flood(const coord_def &c, const coord_def &dc);
+protected:
+ bool point_hunt, want_exit;
+ bool needed_features[NUM_FEATURES];
+ std::vector<coord_def> needed_points;
+ bool left_vault;
+ const map_mask *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), want_exit(false),
+ needed_features(), needed_points(), left_vault(true), vaults(NULL),
+ 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 map_mask &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>::any_point_connected_from(
+ const coord_def &sp)
+{
+ if (needed_points.empty())
+ return (true);
+ set_floodseed(sp);
+ const size_t sz = needed_points.size();
+ pathfind(RMODE_EXPLORE);
+ return (needed_points.size() < sz);
+}
+
+template <typename fgrd, typename bound_check>
+bool flood_find<fgrd, bound_check>::has_exit_from(
+ const coord_def &sp)
+{
+ want_exit = true;
+ set_floodseed(sp);
+ return (pathfind(RMODE_EXPLORE) == coord_def(-1, -1));
+}
+
+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))
+ {
+ if (want_exit)
+ {
+ greedy_dist = 100;
+ greedy_place = coord_def(-1, -1);
+ return (true);
+ }
+ 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 feat = fgrid(dc);
+
+ if (feat == NUM_FEATURES)
+ {
+ if (want_exit)
+ {
+ greedy_dist = 100;
+ greedy_place = coord_def(-1, -1);
+ return (true);
+ }
+ return (false);
+ }
+
+ if (needed_features[ feat ])
+ {
+ unexplored_place = dc;
+ unexplored_dist = traveled_distance;
+ return (true);
+ }
+
+ if (!feat_is_traversable(feat)
+ && feat != DNGN_SECRET_DOOR
+ && !feat_is_trap(feat))
+ {
+ return (false);
+ }
+
+ if (!left_vault && vaults && !(*vaults)[dc.x][dc.y])
+ left_vault = true;
+
+ good_square(dc);
+
+ return (false);
+}
+
+#endif
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index a76d92ffc3..ad2d189658 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -62,6 +62,7 @@
#include "stash.h"
#include "state.h"
#include "terrain.h"
+#include "travel.h"
#include "tutorial.h"
#include "viewgeom.h"
#include "xom.h"
diff --git a/crawl-ref/source/l_dgn.cc b/crawl-ref/source/l_dgn.cc
index ca0ca1db9b..422270dbc3 100644
--- a/crawl-ref/source/l_dgn.cc
+++ b/crawl-ref/source/l_dgn.cc
@@ -12,6 +12,7 @@
#include "directn.h"
#include "dungeon.h"
#include "env.h"
+#include "flood_find.h"
#include "l_defs.h"
#include "mapmark.h"
#include "maps.h"
diff --git a/crawl-ref/source/mapdef.cc b/crawl-ref/source/mapdef.cc
index e20d29d8d2..2d04e483be 100644
--- a/crawl-ref/source/mapdef.cc
+++ b/crawl-ref/source/mapdef.cc
@@ -21,6 +21,7 @@
#include "describe.h"
#include "directn.h"
#include "dungeon.h"
+#include "exclude.h"
#include "files.h"
#include "initfile.h"
#include "invent.h"
diff --git a/crawl-ref/source/mapdef.h b/crawl-ref/source/mapdef.h
index fb8728d3f6..a04a092307 100644
--- a/crawl-ref/source/mapdef.h
+++ b/crawl-ref/source/mapdef.h
@@ -21,7 +21,7 @@
#include "matrix.h"
#include "fprop.h"
#include "makeitem.h"
-#include "travel.h"
+#include "travel_defs.h"
// [dshaligram] Maps can be mirrored; for every orientation, there must be
// a suitable mirror.
diff --git a/crawl-ref/source/maps.cc b/crawl-ref/source/maps.cc
index 90f1bd0453..1d27c6bddc 100644
--- a/crawl-ref/source/maps.cc
+++ b/crawl-ref/source/maps.cc
@@ -22,6 +22,7 @@
#include "env.h"
#include "enum.h"
#include "files.h"
+#include "flood_find.h"
#include "message.h"
#include "mapdef.h"
#include "mon-util.h"
diff --git a/crawl-ref/source/mon-pick.h b/crawl-ref/source/mon-pick.h
index 9fa7c42b83..ef728babdc 100644
--- a/crawl-ref/source/mon-pick.h
+++ b/crawl-ref/source/mon-pick.h
@@ -8,7 +8,7 @@
#ifndef MONPICK_H
#define MONPICK_H
-#include "travel.h"
+#include "externs.h"
int mons_rarity(int mcls, const level_id &place = level_id::current());
diff --git a/crawl-ref/source/mon-place.cc b/crawl-ref/source/mon-place.cc
index 9ef799590c..bfe28f2f81 100644
--- a/crawl-ref/source/mon-place.cc
+++ b/crawl-ref/source/mon-place.cc
@@ -38,6 +38,7 @@
#include "env.h"
#include "terrain.h"
#include "traps.h"
+#include "travel.h"
#include "view.h"
static std::vector<int> vault_mon_types;
diff --git a/crawl-ref/source/mon-stuff.cc b/crawl-ref/source/mon-stuff.cc
index dce2c5809e..8c6f9c57d9 100644
--- a/crawl-ref/source/mon-stuff.cc
+++ b/crawl-ref/source/mon-stuff.cc
@@ -18,6 +18,7 @@
#include "dgnevent.h"
#include "directn.h"
#include "dlua.h"
+#include "exclude.h"
#include "fprop.h"
#include "files.h"
#include "food.h"
diff --git a/crawl-ref/source/mon-transit.h b/crawl-ref/source/mon-transit.h
index 8075f88a90..7ed57464eb 100644
--- a/crawl-ref/source/mon-transit.h
+++ b/crawl-ref/source/mon-transit.h
@@ -8,7 +8,6 @@
#define MON_TRANSIT_H
#include "monster.h"
-#include "travel.h"
#include <map>
#include <list>
diff --git a/crawl-ref/source/overmap.cc b/crawl-ref/source/overmap.cc
index 975f9db76a..f07dadebf9 100644
--- a/crawl-ref/source/overmap.cc
+++ b/crawl-ref/source/overmap.cc
@@ -35,6 +35,7 @@
#include "stuff.h"
#include "env.h"
#include "terrain.h"
+#include "travel.h"
#include "view.h"
typedef std::map<branch_type, level_id> stair_map_type;
diff --git a/crawl-ref/source/shopping.cc b/crawl-ref/source/shopping.cc
index dd398df098..13175097dc 100644
--- a/crawl-ref/source/shopping.cc
+++ b/crawl-ref/source/shopping.cc
@@ -34,6 +34,7 @@
#include "spl-book.h"
#include "stash.h"
#include "stuff.h"
+#include "travel.h"
#include "env.h"
#define SHOPPING_LIST_COST_KEY "shopping_list_cost_key"
diff --git a/crawl-ref/source/show.cc b/crawl-ref/source/show.cc
index 5722ae80a7..628e41baed 100644
--- a/crawl-ref/source/show.cc
+++ b/crawl-ref/source/show.cc
@@ -8,6 +8,7 @@
#include "cloud.h"
#include "coordit.h"
#include "env.h"
+#include "exclude.h"
#include "fprop.h"
#include "itemprop.h"
#include "mon-stuff.h"
diff --git a/crawl-ref/source/stash.h b/crawl-ref/source/stash.h
index 8ad6e2f0e5..35b9c62030 100644
--- a/crawl-ref/source/stash.h
+++ b/crawl-ref/source/stash.h
@@ -15,7 +15,6 @@
#include <vector>
#include "externs.h"
-#include "travel.h"
#include "player.h"
class input_history;
diff --git a/crawl-ref/source/terrain.cc b/crawl-ref/source/terrain.cc
index ea4649b2b3..20a5fad0d0 100644
--- a/crawl-ref/source/terrain.cc
+++ b/crawl-ref/source/terrain.cc
@@ -35,6 +35,7 @@
#include "spells3.h"
#include "stuff.h"
#include "env.h"
+#include "travel.h"
#include "transfor.h"
#include "traps.h"
#include "view.h"
diff --git a/crawl-ref/source/traps.cc b/crawl-ref/source/traps.cc
index e3d1c0ddc7..d27137443b 100644
--- a/crawl-ref/source/traps.cc
+++ b/crawl-ref/source/traps.cc
@@ -35,6 +35,7 @@
#include "spl-util.h"
#include "state.h"
#include "stuff.h"
+#include "travel.h"
#include "env.h"
#include "areas.h"
#include "terrain.h"
diff --git a/crawl-ref/source/traps.h b/crawl-ref/source/traps.h
index c39b70482c..43285f96d7 100644
--- a/crawl-ref/source/traps.h
+++ b/crawl-ref/source/traps.h
@@ -8,7 +8,7 @@
#define TRAPS_H
#include "enum.h"
-#include "travel.h"
+#include "externs.h"
struct bolt;
class monsters;
diff --git a/crawl-ref/source/travel.h b/crawl-ref/source/travel.h
index 38f4cdc614..6483715a5b 100644
--- a/crawl-ref/source/travel.h
+++ b/crawl-ref/source/travel.h
@@ -10,6 +10,9 @@
#include "exclude.h"
+// For travel_distance_col and travel_distance_grid_t
+#include "travel_defs.h"
+
#include <stdio.h>
#include <string>
#include <vector>
@@ -139,9 +142,6 @@ const int PD_EXCLUDED = -20099;
// This square is within LOS radius of an excluded square
const int PD_EXCLUDED_RADIUS = -20100;
-typedef int travel_distance_col[GYM];
-typedef travel_distance_col travel_distance_grid_t[GXM];
-
/* ***********************************************************************
* Array of points on the map, each value being the distance the character
* would have to travel to get there. Negative distances imply that the point
@@ -174,67 +174,6 @@ enum explore_stop_type
////////////////////////////////////////////////////////////////////////////
// Structs for interlevel travel.
-
-// A position on a particular level.
-struct level_pos
-{
- level_id id;
- coord_def pos; // The grid coordinates on this level.
-
- level_pos() : id(), pos()
- {
- pos.x = pos.y = -1;
- }
-
- level_pos(const level_id &lid, const coord_def &coord)
- : id(lid), pos(coord)
- {
- }
-
- level_pos(const level_id &lid)
- : id(lid), pos()
- {
- pos.x = pos.y = -1;
- }
-
- // Returns the level_pos of where the player is standing.
- static level_pos current();
-
- bool operator == ( const level_pos &lp ) const
- {
- return id == lp.id && pos == lp.pos;
- }
-
- bool operator != ( const level_pos &lp ) const
- {
- return id != lp.id || pos != lp.pos;
- }
-
- bool operator < ( const level_pos &lp ) const
- {
- return (id < lp.id) || (id == lp.id && pos < lp.pos);
- }
-
- bool is_valid() const
- {
- return id.depth > -1 && pos.x != -1 && pos.y != -1;
- }
-
- bool is_on( const level_id _id)
- {
- return id == _id;
- }
-
- void clear()
- {
- id.clear();
- pos = coord_def(-1, -1);
- }
-
- void save(writer&) const;
- void load(reader&);
-};
-
struct travel_target
{
level_pos p;
diff --git a/crawl-ref/source/travel_defs.h b/crawl-ref/source/travel_defs.h
new file mode 100644
index 0000000000..9d95a589e2
--- /dev/null
+++ b/crawl-ref/source/travel_defs.h
@@ -0,0 +1,15 @@
+/*
+ * File: travel_defs.h
+ * Summary: Just because typedefs can't be forward declared. Argh.
+ * Written by: Darshan Shaligram
+ */
+
+#ifndef TRAVEL_DEFS_H
+#define TRAVEL_DEFS_H
+
+#include "defines.h"
+
+typedef int travel_distance_col[GYM];
+typedef travel_distance_col travel_distance_grid_t[GXM];
+
+#endif
diff --git a/crawl-ref/source/tutorial.cc b/crawl-ref/source/tutorial.cc
index 65acaed376..6893f64262 100644
--- a/crawl-ref/source/tutorial.cc
+++ b/crawl-ref/source/tutorial.cc
@@ -56,6 +56,7 @@
#ifdef USE_TILE
#include "tiles.h"
#endif
+#include "travel.h"
#include "view.h"
#include "viewchar.h"
#include "viewgeom.h"
diff --git a/crawl-ref/source/wiz-dgn.cc b/crawl-ref/source/wiz-dgn.cc
index a976c93c12..ea55dc9e56 100644
--- a/crawl-ref/source/wiz-dgn.cc
+++ b/crawl-ref/source/wiz-dgn.cc
@@ -29,6 +29,7 @@
#include "religion.h"
#include "stuff.h"
#include "terrain.h"
+#include "travel.h"
#include "traps.h"
#include "view.h"
#include "wiz-mon.h"
diff --git a/crawl-ref/source/xom.cc b/crawl-ref/source/xom.cc
index 6c3074b621..ba4d299b9e 100644
--- a/crawl-ref/source/xom.cc
+++ b/crawl-ref/source/xom.cc
@@ -58,6 +58,7 @@
#include "terrain.h"
#include "transfor.h"
#include "traps.h"
+#include "travel.h"
#include "view.h"
#include "viewchar.h"
#include "xom.h"