New visibility check functions
authorMartin Read <martin@blackswordsonics.com>
Tue, 18 Feb 2014 22:42:46 +0000 (22:42 +0000)
committerMartin Read <martin@blackswordsonics.com>
Tue, 18 Feb 2014 22:42:46 +0000 (22:42 +0000)
* fov.cc,fov.hh: Added tile_visible() and occupant_visible() functions which
  directly inspect the visibility of a given Coord.

fov.cc
fov.hh

diff --git a/fov.cc b/fov.cc
index dfc8aad..d542265 100644 (file)
--- a/fov.cc
+++ b/fov.cc
@@ -428,5 +428,17 @@ void compute_fov(void)
     resolve_radiance(&player_fov);
 }
 
+bool tile_visible(Coord c)
+{
+    Offset delta = c.delta(u.pos);
+    return (delta.len_cheb() <= MAX_FOV_RADIUS) ? player_fov.affected[MAX_FOV_RADIUS + delta.y][MAX_FOV_RADIUS + delta.x] & (Visflag_central | Visflag_partial) : false;
+}
+
+bool occupant_visible(Coord c)
+{
+    Offset delta = c.delta(u.pos);
+    return (delta.len_cheb() <= MAX_FOV_RADIUS) ? player_fov.affected[MAX_FOV_RADIUS + delta.y][MAX_FOV_RADIUS + delta.x] & Visflag_central : false;
+}
+
 /* fov.c */
 // vim:cindent
diff --git a/fov.hh b/fov.hh
index 8c344e8..15f40ad 100644 (file)
--- a/fov.hh
+++ b/fov.hh
@@ -78,6 +78,8 @@ extern void clear_radiance(Radiance *rad);
 extern void compute_radiance(Radiance *rad);
 extern void resolve_radiance(Radiance *rad);
 extern void compute_fov(void);
+extern bool tile_visible(Coord c);
+extern bool occupant_visible(Coord c);
 extern Radiance player_fov;
 
 #endif