From 9734b6dd43839c3f38c330369c935d92ad403222 Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Wed, 25 Nov 2009 16:32:56 +0100 Subject: Don't use is_travelsafe_square for dungeon generation. This hopefully fixes recent disconnected level problems. --- crawl-ref/source/dungeon.cc | 23 +++++++++-------------- crawl-ref/source/dungeon.h | 3 +++ crawl-ref/source/l_dgn.cc | 2 +- crawl-ref/source/travel.cc | 7 ++----- crawl-ref/source/travel.h | 3 +-- 5 files changed, 16 insertions(+), 22 deletions(-) diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc index 2ae80fe55f..06e4a8c87b 100644 --- a/crawl-ref/source/dungeon.cc +++ b/crawl-ref/source/dungeon.cc @@ -538,9 +538,11 @@ static void _dgn_register_vault(const map_def &map) } } -static bool _is_passable_ignore_vault(const coord_def &c) +bool dgn_square_travel_ok(const coord_def &c) { - return (is_travelsafe_square(c, false, true) || grd(c) == DNGN_SECRET_DOOR); + const dungeon_feature_type feat = grd(c); + return (feat_is_traversable(feat) || feat_is_trap(feat) + || feat == DNGN_SECRET_DOOR); } bool dgn_square_is_passable(const coord_def &c) @@ -551,7 +553,7 @@ bool dgn_square_is_passable(const coord_def &c) // default) because vaults may choose to create isolated regions, // or otherwise cause connectivity issues even if the map terrain // is travel-passable. - return (!(dgn_Map_Mask(c) & MMT_OPAQUE) && (_is_passable_ignore_vault(c))); + return (!(dgn_Map_Mask(c) & MMT_OPAQUE) && (dgn_square_travel_ok(c))); } static inline void _dgn_point_record_stub(const coord_def &) { } @@ -1444,7 +1446,7 @@ static bool _add_feat_if_missing(bool (*iswanted)(const coord_def &), for (int x = 0; x < GXM; ++x) { // [ds] Use dgn_square_is_passable instead of - // _is_passable_ignore_vault here, for we'll otherwise + // dgn_square_travel_ok here, for we'll otherwise // fail on floorless isolated pocket in vaults (like the // altar surrounded by deep water), and trigger the assert // downstairs. @@ -7848,13 +7850,6 @@ struct nearest_point } }; -inline static bool _dgn_square_travel_ok(const coord_def &c) -{ - const dungeon_feature_type feat = grd(c); - return (feat_is_traversable(feat) || feat_is_trap(feat) - || feat == DNGN_SECRET_DOOR); -} - // Fill travel_point_distance out from all stone stairs on the level. static coord_def _dgn_find_closest_to_stone_stairs(coord_def base_pos) { @@ -7865,7 +7860,7 @@ static coord_def _dgn_find_closest_to_stone_stairs(coord_def base_pos) for (int x = 0; x < GXM; ++x) { if (!travel_point_distance[x][y] && feat_is_stone_stair(grd[x][y])) - _dgn_fill_zone(coord_def(x, y), 1, np, _dgn_square_travel_ok); + _dgn_fill_zone(coord_def(x, y), 1, np, dgn_square_travel_ok); } return (np.nearest); @@ -8291,13 +8286,13 @@ static bool _fixup_interlevel_connectivity() coord_def gc(x,y); if (!map_bounds(x, y) || travel_point_distance[x][y] - || !_is_passable_ignore_vault(gc)) + || !dgn_square_travel_ok(gc)) { continue; } _dgn_fill_zone(gc, ++nzones, _dgn_point_record_stub, - _is_passable_ignore_vault, NULL); + dgn_square_travel_ok, NULL); } int max_region = 0; diff --git a/crawl-ref/source/dungeon.h b/crawl-ref/source/dungeon.h index c84695dd74..e7dbfd4ebe 100644 --- a/crawl-ref/source/dungeon.h +++ b/crawl-ref/source/dungeon.h @@ -431,4 +431,7 @@ inline int count_neighbours(const coord_def& p, dungeon_feature_type feat) void remember_vault_placement(std::string key, vault_placement &place); std::string dump_vault_maps(); + +bool dgn_square_travel_ok(const coord_def &c); + #endif diff --git a/crawl-ref/source/l_dgn.cc b/crawl-ref/source/l_dgn.cc index 60eb597cab..a1b42e30cd 100644 --- a/crawl-ref/source/l_dgn.cc +++ b/crawl-ref/source/l_dgn.cc @@ -1293,7 +1293,7 @@ static int dgn_place_cloud(lua_State *ls) static int _dgn_is_passable(lua_State *ls) { COORDS(c, 1, 2); - lua_pushboolean(ls, is_travelsafe_square(c, false, true)); + lua_pushboolean(ls, dgn_square_travel_ok(c)); return (1); } diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc index 7797d1dff3..0c756a7d9c 100644 --- a/crawl-ref/source/travel.cc +++ b/crawl-ref/source/travel.cc @@ -332,14 +332,11 @@ static bool _is_reseedable(const coord_def& c) // Returns true if the square at (x,y) is okay to travel over. If ignore_hostile // is true, returns true even for dungeon features the character can normally // not cross safely (deep water, lava, traps). -bool is_travelsafe_square(const coord_def& c, bool ignore_hostile, - bool ignore_terrain_knowledge) +bool is_travelsafe_square(const coord_def& c, bool ignore_hostile) { - if (!ignore_terrain_knowledge && !is_terrain_known(c)) + if (!is_terrain_known(c)) return (false); - // [dshaligram] At this point we're guaranteed to know the terrain (see - // check ^^^). const dungeon_feature_type grid = env.map_knowledge(c).feat(); // Also make note of what's displayed on the level map for diff --git a/crawl-ref/source/travel.h b/crawl-ref/source/travel.h index 98b0e0ac7b..38f4cdc614 100644 --- a/crawl-ref/source/travel.h +++ b/crawl-ref/source/travel.h @@ -71,8 +71,7 @@ bool is_unknown_stair(const coord_def &p); void find_travel_pos(const coord_def& youpos, char *move_x, char *move_y, std::vector* coords = NULL); -bool is_travelsafe_square(const coord_def& c, bool ignore_hostile = false, - bool ignore_terrain_knowledge = false); +bool is_travelsafe_square(const coord_def& c, bool ignore_hostile = false); /* *********************************************************************** * Initiates explore - the character runs around the level to map it. Note -- cgit v1.2.3-54-g00ecf