summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/stuff.cc
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-26 20:19:40 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-26 20:19:40 +0000
commit7b6bfa7d8c9922a6a690fe31db02d678bb60298b (patch)
treec88a4b788f7e156a53d74a131c75a5ade27bab60 /crawl-ref/source/stuff.cc
parent105d4e75d3ada5b2dfbcd08ab44fff124472a8cf (diff)
downloadcrawl-ref-7b6bfa7d8c9922a6a690fe31db02d678bb60298b.tar.gz
crawl-ref-7b6bfa7d8c9922a6a690fe31db02d678bb60298b.zip
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
Diffstat (limited to 'crawl-ref/source/stuff.cc')
-rw-r--r--crawl-ref/source/stuff.cc26
1 files changed, 22 insertions, 4 deletions
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()