diff options
author | Robert Vollmert <rvollmert@gmx.net> | 2010-07-05 21:46:34 +0200 |
---|---|---|
committer | Robert Vollmert <rvollmert@gmx.net> | 2010-07-05 21:46:34 +0200 |
commit | 46bb005ece25b6dc17a2fa46bd2573687334e5af (patch) | |
tree | 01ba649c85d4957ec9c5bef1553047bea5b67898 /crawl-ref/source/losglobal.cc | |
parent | 1a55a16a990d2db67e253e8531d372eed9f34324 (diff) | |
download | crawl-ref-46bb005ece25b6dc17a2fa46bd2573687334e5af.tar.gz crawl-ref-46bb005ece25b6dc17a2fa46bd2573687334e5af.zip |
Invalidate LOS entirely at start of manage_clouds for busy maps.
Keep a count of how many LOS-affecting clouds change last turn,
and invalidate LOS at the start of manage_clouds if there were
more than 10 for now.
Additionally, keep track of whether LOS has been completely
invalidated, and skip all LOS invalidations as long as this
is the case.
This should be a safe change in terms of functionality, and
speed things up quite a bit provided that the cloud management
code doesn't cause LOS computations. (Forest fires currently
check player LOS for messaging, and gloom dissipation checks
halos, so if these are around, improvements may be limited.)
Diffstat (limited to 'crawl-ref/source/losglobal.cc')
-rw-r--r-- | crawl-ref/source/losglobal.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/crawl-ref/source/losglobal.cc b/crawl-ref/source/losglobal.cc index ed68e60d6d..1a779c6faf 100644 --- a/crawl-ref/source/losglobal.cc +++ b/crawl-ref/source/losglobal.cc @@ -29,6 +29,8 @@ static losfield_t* _lookup_globallos(const coord_def& p, const coord_def& q) return (&globallos[p.x][p.y][ diff.x + o_half_x][ diff.y + o_half_y]); } +static bool _los_completely_invalid; + static void _save_los(los_def* los, los_type l) { const coord_def o = los->get_center(); @@ -45,11 +47,14 @@ static void _save_los(los_def* los, los_type l) else *flags &= ~l; } + _los_completely_invalid = false; } // Opacity at p has changed. void invalidate_los_around(const coord_def& p) { + if (_los_completely_invalid) + return; const coord_def tl = p - coord_def(LOS_MAX_RANGE, LOS_MAX_RANGE); const coord_def br = p + coord_def(0, LOS_MAX_RANGE); // We're wiping out a little more than required here. @@ -60,8 +65,11 @@ void invalidate_los_around(const coord_def& p) void invalidate_los() { + if (_los_completely_invalid) + return; for (rectangle_iterator ri(0); ri; ++ri) memset(globallos[ri->x][ri->y], LOS_FLAG_INVALID, sizeof(halflos_t)); + _los_completely_invalid = true; } static void _update_globallos_at(const coord_def& p) |