summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorMatthew Cline <zelgadis@sourceforge.net>2009-11-13 01:42:25 -0800
committerMatthew Cline <zelgadis@sourceforge.net>2009-11-13 01:44:02 -0800
commitf436e7d24f238b1a0c08e17ece91b441b437bdc5 (patch)
tree786d235d44d8ce79e807cc9481fe597db62bfbf2 /crawl-ref/source
parent63d0387082757a0681b4a4528199bf4865e2409d (diff)
downloadcrawl-ref-f436e7d24f238b1a0c08e17ece91b441b437bdc5.tar.gz
crawl-ref-f436e7d24f238b1a0c08e17ece91b441b437bdc5.zip
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.
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/dungeon.cc22
-rw-r--r--crawl-ref/source/dungeon.h4
-rw-r--r--crawl-ref/source/l_dgngrd.cc11
3 files changed, 32 insertions, 5 deletions
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)
{
diff --git a/crawl-ref/source/dungeon.h b/crawl-ref/source/dungeon.h
index c9c236cb9b..793fccc2c8 100644
--- a/crawl-ref/source/dungeon.h
+++ b/crawl-ref/source/dungeon.h
@@ -354,8 +354,8 @@ void level_welcome_messages();
bool place_specific_trap(const coord_def& where, trap_type spec_type);
void place_spec_shop(int level_number, const coord_def& where,
int force_s_type, bool representative = false);
-void replace_area_wrapper(dungeon_feature_type old_feat,
- dungeon_feature_type new_feat);
+bool seen_replace_feat(dungeon_feature_type replace,
+ dungeon_feature_type feature);
bool unforbidden(const coord_def &c, unsigned mask);
coord_def dgn_find_nearby_stair(dungeon_feature_type stair_to_find,
coord_def base_pos, bool find_closest);
diff --git a/crawl-ref/source/l_dgngrd.cc b/crawl-ref/source/l_dgngrd.cc
index 4f2b62dbfe..90657819cd 100644
--- a/crawl-ref/source/l_dgngrd.cc
+++ b/crawl-ref/source/l_dgngrd.cc
@@ -11,6 +11,7 @@
#include "coord.h"
#include "directn.h"
+#include "dungeon.h"
#include "env.h"
#include "religion.h"
#include "terrain.h"
@@ -255,6 +256,15 @@ LUAFN(_dgn_is_opaque)
return (1);
}
+LUAFN(dgn_seen_replace_feat)
+{
+ dungeon_feature_type f1 = _get_lua_feature(ls, 1);
+ dungeon_feature_type f2 = _get_lua_feature(ls, 2);
+
+ lua_pushboolean(ls, seen_replace_feat(f1, f2));
+ return (1);
+}
+
const struct luaL_reg dgn_grid_dlib[] =
{
{ "feature_number", dgn_feature_number },
@@ -263,6 +273,7 @@ const struct luaL_reg dgn_grid_dlib[] =
{ "feature_desc_at", dgn_feature_desc_at },
{ "set_feature_desc_short", dgn_set_feature_desc_short },
{ "set_feature_desc_long", dgn_set_feature_desc_long },
+{ "seen_replace_feat", dgn_seen_replace_feat },
{ "grid", dgn_grid },
{ "is_opaque", _dgn_is_opaque },