From 7b6bfa7d8c9922a6a690fe31db02d678bb60298b Mon Sep 17 00:00:00 2001 From: dolorous Date: Mon, 26 Jan 2009 20:19:40 +0000 Subject: Fix bounds checks for monsters' moving off the map to use map_bounds(). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8793 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/stuff.cc | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'crawl-ref/source/stuff.cc') diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc index 0d6368fb83..d724ca5730 100644 --- a/crawl-ref/source/stuff.cc +++ b/crawl-ref/source/stuff.cc @@ -1243,11 +1243,30 @@ bool player_can_hear(const coord_def& p) return (!silenced(p) && !silenced(you.pos())); } +bool in_bounds_x(int x) +{ + return (x > X_BOUND_1 && x < X_BOUND_2); +} + +bool in_bounds_y(int y) +{ + return (y > Y_BOUND_1 && y < Y_BOUND_2); +} + // Returns true if inside the area the player can move and dig (ie exclusive). bool in_bounds(int x, int y) { - return (x > X_BOUND_1 && x < X_BOUND_2 - && y > Y_BOUND_1 && y < Y_BOUND_2); + return (in_bounds_x(x) && in_bounds_y(y)); +} + +bool map_bounds_x(int x) +{ + return (x >= X_BOUND_1 && x <= X_BOUND_2); +} + +bool map_bounds_y(int y) +{ + return (y >= Y_BOUND_1 && y <= Y_BOUND_2); } // Returns true if inside the area the player can map (ie inclusive). @@ -1255,8 +1274,7 @@ bool in_bounds(int x, int y) // ring of rock to frame the level. bool map_bounds(int x, int y) { - return (x >= X_BOUND_1 && x <= X_BOUND_2 - && y >= Y_BOUND_1 && y <= Y_BOUND_2); + return (map_bounds_x(x) && map_bounds_y(y)); } coord_def random_in_bounds() -- cgit v1.2.3-54-g00ecf