diff options
author | Robert Vollmert <rvollmert@gmx.net> | 2010-03-04 21:13:25 +0100 |
---|---|---|
committer | Robert Vollmert <rvollmert@gmx.net> | 2010-03-04 21:14:33 +0100 |
commit | 317d40a99d401d8a9446841a05cf6c99eae2b446 (patch) | |
tree | b49929090974bf8f689dc11e88a34ee61f4d0e33 /crawl-ref/source/actor-los.cc | |
parent | 8441ee9fedad2fd7f030709bb2c181b1cde7832e (diff) | |
download | crawl-ref-317d40a99d401d8a9446841a05cf6c99eae2b446.tar.gz crawl-ref-317d40a99d401d8a9446841a05cf6c99eae2b446.zip |
Update monster's LOS if close enough to the player.
Previously we skipped this if the monster couldn't be seen, but
that may mean the monster thinks it can still see the player if say
a door has been closed or the player has read ?fog.
Fixes issue #1007.
Diffstat (limited to 'crawl-ref/source/actor-los.cc')
-rw-r--r-- | crawl-ref/source/actor-los.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/crawl-ref/source/actor-los.cc b/crawl-ref/source/actor-los.cc index 1f5c644c79..9bf564f1b2 100644 --- a/crawl-ref/source/actor-los.cc +++ b/crawl-ref/source/actor-los.cc @@ -1,6 +1,7 @@ #include "AppHdr.h" #include "actor.h" +#include "coord.h" #include "player.h" #include "monster.h" #include "state.h" @@ -18,7 +19,13 @@ bool actor::see_cell(const coord_def &p) const void actor::update_los() { - if (changed_los_center || observable()) + // Optimization to prevent updating every monster's LOS + // every turn. Monsters may have incorrect LOS if opacities + // change without the monster moving (e.g. digging, doors + // opening/closing, smoke appearing/disappearing). + if (changed_los_center + || distance(you.pos(), pos()) <= LOS_MAX_RADIUS_SQ + || observable()) // arena { los.update(); changed_los_center = false; |