diff options
author | Robert Vollmert <rvollmert@gmx.net> | 2009-12-02 11:53:47 +0100 |
---|---|---|
committer | Robert Vollmert <rvollmert@gmx.net> | 2009-12-02 11:53:47 +0100 |
commit | 22511077551803bfcffc7631e37a44768eff9de6 (patch) | |
tree | 1d535eb6dc9d04247ecb002c054db0d63853d6f5 /crawl-ref | |
parent | 42ffc507b45717e34d5513929390f40a6972c5b7 (diff) | |
download | crawl-ref-22511077551803bfcffc7631e37a44768eff9de6.tar.gz crawl-ref-22511077551803bfcffc7631e37a44768eff9de6.zip |
Don't always call deferred_exclude_update.
This was now causing general slowness.
Diffstat (limited to 'crawl-ref')
-rw-r--r-- | crawl-ref/source/view.cc | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index edade212b9..8862e4ee34 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -660,12 +660,19 @@ static void _debug_pane_bounds() #endif } +enum update_flags +{ + UF_AFFECT_EXCLUDES = (1 << 0), + UF_ADDED_EXCLUDE = (1 << 1) +}; + // 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) +static int player_view_update_at(const coord_def &gc) { const coord_def ep = grid2show(gc); maybe_remove_autoexclusion(gc); + int ret = 0; // Set excludes in a radius of 1 around harmful clouds genereated // by neither monsters nor the player. @@ -683,7 +690,10 @@ static bool player_view_update_at(const coord_def &gc) { // Optionally add exclude, deferring updates. if (!cell_is_solid(*ai) && !is_exclude_root(*ai)) + { set_exclude(*ai, 0, false, false, true); + ret |= UF_ADDED_EXCLUDE; + } } } } @@ -693,9 +703,10 @@ static bool player_view_update_at(const coord_def &gc) tutorial_observe_cell(gc); if (!player_in_mappable_area()) - return (false); + return (ret); - bool need_excl_update = is_terrain_changed(gc) || !is_terrain_seen(gc); + if (is_terrain_changed(gc) || !is_terrain_seen(gc)) + ret |= UF_AFFECT_EXCLUDES; set_terrain_seen(gc); set_map_knowledge_obj(gc, to_knowledge(env.show(ep), emphasise(gc))); @@ -716,19 +727,26 @@ static bool player_view_update_at(const coord_def &gc) set_map_knowledge_obj(gc, to_knowledge(env.show.get_backup(ep), emphasise(gc))); - return (need_excl_update); + return (ret); } static void player_view_update() { std::vector<coord_def> update_excludes; + bool need_update = false; for (radius_iterator ri(&you.get_los()); ri; ++ri) - if (player_view_update_at(*ri)) + { + int flags = player_view_update_at(*ri); + if (flags & UF_AFFECT_EXCLUDES) update_excludes.push_back(*ri); + if (flags & UF_ADDED_EXCLUDE) + need_update = true; + } // Update exclusion LOS for possibly affected excludes. update_exclusion_los(update_excludes); // Catch up on deferred updates for cloud excludes. - deferred_exclude_update(); + if (need_update) + deferred_exclude_update(); } #ifdef USE_TILE |