From: Martin Read Date: Tue, 18 Feb 2014 22:48:19 +0000 (+0000) Subject: Added bounds check function to Level X-Git-Tag: stretchy-levels~8 X-Git-Url: http://git.blackswordsonics.com/?a=commitdiff_plain;h=94548b833021c90537d5d8814d78cd0eba5ce12b;p=victrix-abyssi Added bounds check function to Level * map.hh: Level now has a bounds checking function in_bounds which verifies the acceptability of a Coord. --- diff --git a/map.hh b/map.hh index 28dfaee..6942c9c 100644 --- a/map.hh +++ b/map.hh @@ -217,6 +217,12 @@ public: } } Coord random_point(int margin) const; + bool in_bounds(Coord c) const + { + c += origin_off; + return !((c.y < 0) || (c.x < 0) || (c.y >= (chunks_high << CHUNK_SHIFT)) || + (c.x >= (chunks_wide << CHUNK_SHIFT))); + } }; extern Level lvl;