summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/actor-los.cc
diff options
context:
space:
mode:
authorNeil Moore <neil@s-z.org>2013-07-28 12:16:33 -0400
committerNeil Moore <neil@s-z.org>2013-07-28 12:16:33 -0400
commitf61e71f529e8ec9710ddd2fe4b89d64ca5481858 (patch)
tree694055f3b723a3c04336f7f212f8539fa23c125e /crawl-ref/source/actor-los.cc
parentcc0fb03b9eee93cd3fbfb7b9ea40c8b1bfa7a872 (diff)
downloadcrawl-ref-f61e71f529e8ec9710ddd2fe4b89d64ca5481858.tar.gz
crawl-ref-f61e71f529e8ec9710ddd2fe4b89d64ca5481858.zip
Don't crash when returning to an level with scrying active (#7387)
The player position is (0,0) in this case, while vlos still uses the location from the last level. This caused tile_draw_map_cell (called from level load) to refer to locations far outside the show area. Rather than forcing you.pos() and vlos to be in sync at this point during level load (which could e.g. reveal the upper left corner of the map), we take the easy way out and prevent a player at (0,0) from seeing anything (outside arena of course).
Diffstat (limited to 'crawl-ref/source/actor-los.cc')
-rw-r--r--crawl-ref/source/actor-los.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/crawl-ref/source/actor-los.cc b/crawl-ref/source/actor-los.cc
index d8dfe30435..d00b34df57 100644
--- a/crawl-ref/source/actor-los.cc
+++ b/crawl-ref/source/actor-los.cc
@@ -24,9 +24,11 @@ bool actor::see_cell(const coord_def &p) const
bool player::see_cell(const coord_def &p) const
{
if (!map_bounds(p))
- return false;
+ return false; // Players can't see (-1,-1) but maybe can see (0,0).
if (crawl_state.game_is_arena() && is_player())
return true;
+ if (!in_bounds(pos()))
+ return false; // A non-arena player at (0,0) can't see anything.
if (xray_vision)
return ((pos() - p).abs() <= dist_range(current_vision));
return actor::see_cell(p);