summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/terrain.cc
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-05 01:57:22 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-05 01:57:22 +0000
commit0e94dff22d8b71060ef1de50aa53c9374de3284e (patch)
tree650d693d3f65b0f3eabcf11eedfd4b2cce3af047 /crawl-ref/source/terrain.cc
parent3a8f8e48fcbd6808379705b4749b76ab7518e3c9 (diff)
downloadcrawl-ref-0e94dff22d8b71060ef1de50aa53c9374de3284e.tar.gz
crawl-ref-0e94dff22d8b71060ef1de50aa53c9374de3284e.zip
Changed dungeon_terrain_changed() so that it removes bloodstains when
appropriate, and so it unsubmerges monsters if they can't stay submerged in the new terrain. Also, changed the Water card to use dungeon_terrain_changed() in order to simplify the code a bit, to clean up bloodstains, and to fire off DET_FEAT_CHANGE dungeon events. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5479 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/terrain.cc')
-rw-r--r--crawl-ref/source/terrain.cc47
1 files changed, 45 insertions, 2 deletions
diff --git a/crawl-ref/source/terrain.cc b/crawl-ref/source/terrain.cc
index ec4cc04a53..c1cb3097cf 100644
--- a/crawl-ref/source/terrain.cc
+++ b/crawl-ref/source/terrain.cc
@@ -32,6 +32,7 @@
#include "spells3.h"
#include "stuff.h"
#include "transfor.h"
+#include "traps.h"
#include "view.h"
bool grid_is_wall(dungeon_feature_type grid)
@@ -429,13 +430,45 @@ static void _dgn_check_terrain_monsters(const coord_def &pos)
if (mindex != NON_MONSTER)
{
monsters *mons = &menv[mindex];
+
+ if (mons->has_ench(ENCH_SUBMERGED)
+ && !monster_can_submerge(mons, grd(pos))
+ && pos != you.pos())
+ {
+ mons->del_ench(ENCH_SUBMERGED);
+ }
+
if (grid_is_solid(grd(pos)))
monster_teleport(mons, true, false);
else
mons_check_pool(mons, KILL_MISC, -1);
}
- set_terrain_changed(pos.x, pos.y);
+}
+
+static void _dgn_check_terrain_blood(const coord_def &pos,
+ dungeon_feature_type old_feat,
+ dungeon_feature_type new_feat)
+{
+ if (env.map(pos).property != FPROP_BLOODY)
+ return;
+
+ if (new_feat == DNGN_UNSEEN)
+ {
+ // Caller has already changed the grid, and old_feat is actually
+ // the new feat.
+ if (old_feat != DNGN_FLOOR && !grid_is_solid(old_feat))
+ env.map(pos).property = FPROP_NONE;
+ }
+ else
+ {
+ if (grid_is_solid(old_feat) != grid_is_solid(new_feat)
+ || grid_is_water(new_feat) || grid_destroys_items(new_feat)
+ || is_critical_feature(new_feat))
+ {
+ env.map(pos).property = FPROP_NONE;
+ }
+ }
}
void dungeon_terrain_changed(const coord_def &pos,
@@ -444,6 +477,11 @@ void dungeon_terrain_changed(const coord_def &pos,
bool preserve_features,
bool preserve_items)
{
+ if (grd(pos) == nfeat)
+ return;
+
+ _dgn_check_terrain_blood(pos, grd(pos), nfeat);
+
if (nfeat != DNGN_UNSEEN)
{
if (preserve_features)
@@ -454,9 +492,13 @@ void dungeon_terrain_changed(const coord_def &pos,
env.grid_colours(pos) = BLACK;
if (is_notable_terrain(nfeat) && see_grid(pos))
seen_notable_thing(nfeat, pos.x, pos.y);
+
+ destroy_trap(pos);
}
_dgn_check_terrain_items(pos, preserve_items);
+ _dgn_check_terrain_monsters(pos);
+
if (affect_player && pos == you.pos())
{
if (!grid_is_solid(grd(pos)))
@@ -467,7 +509,8 @@ void dungeon_terrain_changed(const coord_def &pos,
else
you_teleport_now(true, false);
}
- _dgn_check_terrain_monsters(pos);
+
+ set_terrain_changed(pos.x, pos.y);
}
// returns true if we manage to scramble free.