summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/view.cc
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-11-09 22:18:58 +0100
committerRobert Vollmert <rvollmert@gmx.net>2009-11-09 23:21:40 +0100
commitdfda276192319251804dd53a266e2549fd99a710 (patch)
tree305cfbf25a538a232510be1c64137faa94e25a94 /crawl-ref/source/view.cc
parentd28e78dbe5232913c7e620d15347cb2394c550e2 (diff)
downloadcrawl-ref-dfda276192319251804dd53a266e2549fd99a710.tar.gz
crawl-ref-dfda276192319251804dd53a266e2549fd99a710.zip
Split up monster_grid into update and non-update part.
Diffstat (limited to 'crawl-ref/source/view.cc')
-rw-r--r--crawl-ref/source/view.cc73
1 files changed, 46 insertions, 27 deletions
diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc
index a97911d0ba..8968ea16fc 100644
--- a/crawl-ref/source/view.cc
+++ b/crawl-ref/source/view.cc
@@ -381,47 +381,24 @@ void force_monster_shout(monsters* monster)
}
#endif
-void monster_grid(bool do_updates)
+void monster_grid_updates()
{
- do_updates = do_updates && !crawl_state.arena;
-
for (int s = 0; s < MAX_MONSTERS; ++s)
{
monsters *monster = &menv[s];
if (monster->alive() && mons_near(monster))
{
- if (do_updates && (monster->asleep()
- || mons_is_wandering(monster))
+ if ((monster->asleep() || mons_is_wandering(monster))
&& check_awaken(monster))
{
behaviour_event(monster, ME_ALERT, MHITYOU, you.pos(), false);
handle_monster_shouts(monster);
}
- // [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);
- ASSERT(!monster_at(monster->pos()));
- mgrd(monster->pos()) = s;
- }
-
- if (!env.show.update_monster(monster))
+ if (!monster->visible_to(&you))
continue;
-#ifdef USE_TILE
- tile_place_monster(monster->pos().x, monster->pos().y, s, true);
-#endif
-
good_god_follower_attitude_change(monster);
beogh_follower_convert(monster);
slime_convert(monster);
@@ -430,6 +407,46 @@ void monster_grid(bool do_updates)
}
}
+static void _check_monster_pos(const monsters* monster, int s)
+{
+ ASSERT(mgrd(monster->pos()) == s);
+
+ // [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);
+ ASSERT(!monster_at(monster->pos()));
+ mgrd(monster->pos()) = s;
+ }
+}
+
+void monster_grid()
+{
+ for (int s = 0; s < MAX_MONSTERS; ++s)
+ {
+ monsters *monster = &menv[s];
+
+ if (monster->alive() && mons_near(monster))
+ {
+ _check_monster_pos(monster, s);
+ env.show.update_monster(monster);
+
+#ifdef USE_TILE
+ if (monster->visible_to(&you))
+ tile_place_monster(monster->pos().x, monster->pos().y, s, true);
+#endif
+ }
+ }
+}
+
void update_monsters_in_view()
{
unsigned int num_hostile = 0;
@@ -1262,7 +1279,9 @@ void viewwindow(bool draw_it, bool do_updates)
env.show.init();
- monster_grid(do_updates);
+ monster_grid();
+ if (do_updates && !crawl_state.arena)
+ monster_grid_updates();
#ifdef USE_TILE
tile_draw_rays(true);