From 47fefb83158f64bbc7a5d02be1f32078eee25826 Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Sat, 14 Nov 2009 22:43:24 +0100 Subject: Merge monster_grid into show_def. --- crawl-ref/source/show.cc | 34 ++++++++++++++++++++++++++++++---- crawl-ref/source/show.h | 2 +- crawl-ref/source/view.cc | 38 -------------------------------------- 3 files changed, 31 insertions(+), 43 deletions(-) (limited to 'crawl-ref') 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() diff --git a/crawl-ref/source/show.h b/crawl-ref/source/show.h index f35c44c790..a7b31033b7 100644 --- a/crawl-ref/source/show.h +++ b/crawl-ref/source/show.h @@ -73,6 +73,7 @@ class show_def void _update_feat_at(const coord_def &gp, const coord_def &ep); void _update_item_at(const coord_def &gp, const coord_def &ep); void _update_cloud(int cloudno); + void _update_monster(const monsters *monster); void _set_backup(const coord_def &e); public: @@ -80,7 +81,6 @@ public: show_type get_backup(const coord_def &ep) const { return backup(ep); } void init(); - bool update_monster(const monsters *monster); void update_at(const coord_def &gp, const coord_def &ep); }; diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index 5596723c49..562d1d8498 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -145,43 +145,6 @@ void monster_grid_updates() } } -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); - ASSERT(!monster_at(monster->pos())); - mgrd(monster->pos()) = s; - } -} - -void monster_grid() -{ - for (monster_iterator mi(&you.get_los()); mi; ++mi) - { - _check_monster_pos(*mi); - env.show.update_monster(*mi); - -#ifdef USE_TILE - if (mi->visible_to(&you)) - tile_place_monster(mi->pos().x, mi->pos().y, mi->mindex(), true); -#endif - } -} - void update_monsters_in_view() { unsigned int num_hostile = 0; @@ -894,7 +857,6 @@ void viewwindow(bool do_updates) env.show.init(); - monster_grid(); if (do_updates && !crawl_state.arena) monster_grid_updates(); -- cgit v1.2.3-54-g00ecf