From 94548b833021c90537d5d8814d78cd0eba5ce12b Mon Sep 17 00:00:00 2001 From: Martin Read Date: Tue, 18 Feb 2014 22:48:19 +0000 Subject: [PATCH] Added bounds check function to Level * map.hh: Level now has a bounds checking function in_bounds which verifies the acceptability of a Coord. --- map.hh | 6 ++++++ 1 file changed, 6 insertions(+) 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; -- 2.11.0