summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/areas.cc
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2010-07-04 01:16:56 +0200
committerAdam Borowski <kilobyte@angband.pl>2010-07-04 01:16:56 +0200
commitc1e58e2dc97180a8e799b4af8c00667f59c20022 (patch)
treec8374a5892f0cf7b3867cac59af0ac356c039e7b /crawl-ref/source/areas.cc
parenta0390096b8ae4c7c8dfde9a4f3ee96097ec8b24c (diff)
downloadcrawl-ref-c1e58e2dc97180a8e799b4af8c00667f59c20022.tar.gz
crawl-ref-c1e58e2dc97180a8e799b4af8c00667f59c20022.zip
Don't recalculate the agrid when it's known there are no areas.
Diffstat (limited to 'crawl-ref/source/areas.cc')
-rw-r--r--crawl-ref/source/areas.cc22
1 files changed, 20 insertions, 2 deletions
diff --git a/crawl-ref/source/areas.cc b/crawl-ref/source/areas.cc
index 57b0df3dae..e7a3641ca8 100644
--- a/crawl-ref/source/areas.cc
+++ b/crawl-ref/source/areas.cc
@@ -41,6 +41,7 @@ typedef FixedArray<unsigned long, GXM, GYM> propgrid_t;
static propgrid_t _agrid;
static bool _agrid_valid = false;
+static bool no_areas = false;
static void _set_agrid_flag(const coord_def& p, areaprop_flag f)
{
@@ -52,9 +53,11 @@ static bool _check_agrid_flag(const coord_def& p, areaprop_flag f)
return (_agrid(p) & f);
}
-void invalidate_agrid()
+void invalidate_agrid(bool recheck_new)
{
_agrid_valid = false;
+ if (recheck_new)
+ no_areas = false;
}
void areas_actor_moved(const actor* act, const coord_def& oldpos)
@@ -63,28 +66,43 @@ void areas_actor_moved(const actor* act, const coord_def& oldpos)
(you.entering_level
|| act->halo_radius2() > -1 || act->silence_radius2() > -1))
{
- invalidate_agrid();
+ // Not necessarily new, but certainly potentially interesting.
+ invalidate_agrid(true);
}
}
static void _update_agrid()
{
+ if (no_areas)
+ {
+ _agrid_valid = true;
+ return;
+ }
+
_agrid.init(0);
+ no_areas = true;
+
for (actor_iterator ai; ai; ++ai)
{
int r;
if ((r = ai->silence_radius2()) >= 0)
+ {
for (radius_iterator ri(ai->pos(), r, C_CIRCLE); ri; ++ri)
_set_agrid_flag(*ri, APROP_SILENCE);
+ no_areas = false;
+ }
if ((r = ai->halo_radius2()) >= 0)
+ {
for (radius_iterator ri(ai->pos(), r, C_CIRCLE, ai->get_los());
ri; ++ri)
{
_set_agrid_flag(*ri, APROP_HALO);
}
+ no_areas = false;
+ }
}
// TODO: update sanctuary here.