From f436e7d24f238b1a0c08e17ece91b441b437bdc5 Mon Sep 17 00:00:00 2001 From: Matthew Cline Date: Fri, 13 Nov 2009 01:42:25 -0800 Subject: seen_replace_feat(): replace one feat with another Replacement for replace_area_wrapper, and a lua accessor for the function. Returns true if the player saw the feature being changed. --- crawl-ref/source/dungeon.cc | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'crawl-ref/source/dungeon.cc') diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc index 6eab3cad24..22d4c9735d 100644 --- a/crawl-ref/source/dungeon.cc +++ b/crawl-ref/source/dungeon.cc @@ -5226,11 +5226,26 @@ static void _vault_grid( vault_placement &place, // Currently only used for Slime: branch end // where it will turn the stone walls into clear rock walls // once the royal jelly has been killed. -void replace_area_wrapper(dungeon_feature_type old_feat, - dungeon_feature_type new_feat) +bool seen_replace_feat(dungeon_feature_type old_feat, + dungeon_feature_type new_feat) { ASSERT(old_feat != new_feat); - _replace_area(0, 0, GXM-1, GYM-1, old_feat, new_feat, 0, false); + + coord_def p1(0, 0); + coord_def p2(GXM - 1, GYM - 1); + + bool seen = false; + for (rectangle_iterator ri(p1, p2); ri; ++ri) + { + if (grd(*ri) == old_feat) + { + grd(*ri) = new_feat; + if (you.see_cell(*ri)) + seen = true; + } + } + + return (seen); } static void _replace_area( const coord_def& p1, const coord_def& p2, @@ -5254,6 +5269,7 @@ static void _replace_area( const coord_def& p1, const coord_def& p2, } } + // With apologies to Metallica. bool unforbidden(const coord_def &c, unsigned mask) { -- cgit v1.2.3-54-g00ecf