From ecca91a48b581c7181b8342fc499dff08ad1bd59 Mon Sep 17 00:00:00 2001 From: Stefan O'Rear Date: Mon, 2 Nov 2009 02:25:50 -0800 Subject: Magic mapping scrolls ignore sealed areas --- crawl-ref/source/view.cc | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'crawl-ref/source/view.cc') diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index 245aaee4e0..8d1062dc1b 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -13,6 +13,7 @@ #include #include #include +#include #ifdef TARGET_OS_DOS #include @@ -2918,6 +2919,46 @@ static const FixedArray& _tile_difficulties(bool random) return cache; } +static std::auto_ptr > _tile_detectability() +{ + std::auto_ptr > map(new FixedArray); + + std::vector flood_from; + + for (int x = X_BOUND_1; x <= X_BOUND_2; ++x) + for (int y = Y_BOUND_1; y <= Y_BOUND_2; ++y) + { + (*map)(coord_def(x,y)) = false; + + if (feat_is_stair(grd[x][y])) + { + flood_from.push_back(coord_def(x, y)); + } + } + + flood_from.push_back(you.pos()); + + while (!flood_from.empty()) + { + coord_def p = flood_from.back(); + flood_from.pop_back(); + + if ((*map)(p)) + continue; + + (*map)(p) = true; + + if (grd(p) < DNGN_MINSEE) + continue; + + for (int dy = -1; dy <= 1; ++dy) + for (int dx = -1; dx <= 1; ++dx) + flood_from.push_back(p + coord_def(dx,dy)); + } + + return map; +} + // Returns true if it succeeded. bool magic_mapping(int map_radius, int proportion, bool suppress_msg, bool force, bool deterministic, bool circular, @@ -2957,6 +2998,11 @@ bool magic_mapping(int map_radius, int proportion, bool suppress_msg, const FixedArray& difficulty = _tile_difficulties(!deterministic); + std::auto_ptr > detectable; + + if (!deterministic) + detectable = _tile_detectability(); + for (radius_iterator ri(pos, map_radius, !circular, false); ri; ++ri) { if (!wizard_map) @@ -2980,6 +3026,9 @@ bool magic_mapping(int map_radius, int proportion, bool suppress_msg, if (!wizard_map && (is_terrain_seen(*ri) || is_terrain_mapped(*ri))) continue; + if (!wizard_map && !deterministic && !((*detectable)(*ri))) + continue; + const dungeon_feature_type feat = grd(*ri); bool open = true; -- cgit v1.2.3-54-g00ecf