summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/show.cc
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-11-14 22:43:24 +0100
committerRobert Vollmert <rvollmert@gmx.net>2009-11-14 22:43:24 +0100
commit47fefb83158f64bbc7a5d02be1f32078eee25826 (patch)
tree0c963cd70b929ad6d25f32d833b144227d22eebc /crawl-ref/source/show.cc
parenta90ac74e64cc1e7a143dca06f8c8288afbf952af (diff)
downloadcrawl-ref-47fefb83158f64bbc7a5d02be1f32078eee25826.tar.gz
crawl-ref-47fefb83158f64bbc7a5d02be1f32078eee25826.zip
Merge monster_grid into show_def.
Diffstat (limited to 'crawl-ref/source/show.cc')
-rw-r--r--crawl-ref/source/show.cc34
1 files changed, 30 insertions, 4 deletions
diff --git a/crawl-ref/source/show.cc b/crawl-ref/source/show.cc
index ca595e2ff8..a6886f17ca 100644
--- a/crawl-ref/source/show.cc
+++ b/crawl-ref/source/show.cc
@@ -132,8 +132,32 @@ void show_def::_update_cloud(int cloudno)
#endif
}
-bool show_def::update_monster(const monsters* mons)
+static void _check_monster_pos(const monsters* monster)
{
+ int s = monster->mindex();
+ ASSERT(mgrd(monster->pos()) == s);
+
+ // [rob] The following in case asserts aren't enabled.
+ // [enne] - It's possible that mgrd and monster->x/y are out of
+ // sync because they are updated separately. If we can see this
+ // monster, then make sure that the mgrd is set correctly.
+ if (mgrd(monster->pos()) != s)
+ {
+ // If this mprf triggers for you, please note any special
+ // circumstances so we can track down where this is coming
+ // from.
+ mprf(MSGCH_ERROR, "monster %s (%d) at (%d, %d) was "
+ "improperly placed. Updating mgrd.",
+ monster->name(DESC_PLAIN, true).c_str(), s,
+ monster->pos().x, monster->pos().y);
+ mgrd(monster->pos()) = s;
+ }
+}
+
+void show_def::_update_monster(const monsters* mons)
+{
+ _check_monster_pos(mons);
+
const coord_def e = grid2show(mons->pos());
if (!mons->visible_to(&you))
@@ -171,7 +195,7 @@ bool show_def::update_monster(const monsters* mons)
grid(e).colour = ripple_table[base_colour & 0x0f];
}
- return (false);
+ return;
}
// Mimics are always left on map.
@@ -182,7 +206,9 @@ bool show_def::update_monster(const monsters* mons)
grid(e).mons = mons->type;
grid(e).colour = get_mons_colour(mons);
- return (true);
+#ifdef USE_TILE
+ tile_place_monster(mons->pos().x, mons->pos().y, mons->mindex(), true);
+#endif
}
void show_def::update_at(const coord_def &gp, const coord_def &ep)
@@ -204,7 +230,7 @@ void show_def::update_at(const coord_def &gp, const coord_def &ep)
const monsters *mons = monster_at(gp);
if (mons && mons->alive())
- update_monster(mons);
+ _update_monster(mons);
}
void show_def::init()