From 6c8f5db8d31b45c96730062c6db82b2aad8a5def Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Fri, 13 Nov 2009 11:50:27 +0100 Subject: Extract player updates from main draw loop. --- crawl-ref/source/view.cc | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index 689014045b..9b0bf121f8 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -701,8 +701,11 @@ static void _debug_pane_bounds() #endif } -static bool player_view_updates(const coord_def &gc, const coord_def &ep) +// Do various updates when the player sees a cell. Returns whether +// exclusion LOS might have been affected. +static bool player_view_update_at(const coord_def &gc) { + const coord_def ep = grid2show(gc); maybe_remove_autoexclusion(gc); // Set excludes in a radius of 1 around harmful clouds genereated @@ -763,6 +766,15 @@ static bool player_view_updates(const coord_def &gc, const coord_def &ep) return (need_excl_update); } +static void player_view_update() +{ + std::vector update_excludes; + for (radius_iterator ri(you.pos(), LOS_RADIUS); ri; ++ri) + if (player_view_update_at(*ri)) + update_excludes.push_back(*ri); + update_exclusion_los(update_excludes); +} + #ifndef USE_TILE #define DRAW(kind) draw_##kind(&buffy[bufcount], gc, ep); #define DRAWFN(kind) \ @@ -869,8 +881,6 @@ DRAWFN(los_backup) //--------------------------------------------------------------- // -// viewwindow -- now unified and rolled into a single pass -// // Draws the main window using the character set returned // by get_symbol(). // @@ -905,6 +915,8 @@ void viewwindow(bool do_updates) if (do_updates && !crawl_state.arena) monster_grid_updates(); + player_view_update(); // XXX: also conditional on do_updates? + #ifdef USE_TILE tile_draw_rays(true); tiles.clear_overlays(); @@ -916,31 +928,26 @@ void viewwindow(bool do_updates) if (flash_colour == BLACK) flash_colour = _viewmap_flash_colour(); - std::vector update_excludes; const coord_def &tl = crawl_view.viewp; const coord_def br = tl + crawl_view.viewsz - coord_def(1,1); int bufcount = 0; - for (rectangle_iterator ri(tl, br); ri; - ++ri, bufcount += 2) + for (rectangle_iterator ri(tl, br); ri; ++ri, bufcount += 2) { // in grid coords const coord_def gc = view2grid(*ri); const coord_def ep = view2show(grid2view(gc)); - if (you.see_cell(gc) && player_view_updates(gc, ep)) - update_excludes.push_back(gc); - // Order is important here. if (!map_bounds(gc)) DRAW(unseen); else if (!crawl_view.in_grid_los(gc)) DRAW(outside_los); - else if (gc == you.pos() && !crawl_state.arena - && !crawl_state.arena_suspended) + else if (gc == you.pos() && + !crawl_state.arena && !crawl_state.arena_suspended) { DRAW(player); } - else if (you.see_cell(gc)) + else if (observe_cell(gc)) DRAW(los); else DRAW(los_backup); @@ -964,8 +971,6 @@ void viewwindow(bool do_updates) } } - update_exclusion_los(update_excludes); - // Leaving it this way because short flashes can occur in long ones, // and this simply works without requiring a stack. you.flash_colour = BLACK; -- cgit v1.2.3-54-g00ecf