diff options
author | Bardur Arantsson <bardur@scientician.net> | 2015-03-07 17:39:39 +0100 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2015-03-07 17:39:39 +0100 |
commit | 9d339661c8646f2ddb598a8490b34a45f928edb8 (patch) | |
tree | a0763368abb55ad53bd91a46605076a221ea1459 /src | |
parent | ee2234b03fdc201045261d13b4c9101befbe074d (diff) |
Change in_bounds* and panel_contains macros to functions in util.cc
Diffstat (limited to 'src')
-rw-r--r-- | src/defines.h | 27 | ||||
-rw-r--r-- | src/util.cc | 25 | ||||
-rw-r--r-- | src/util.hpp | 3 |
3 files changed, 28 insertions, 27 deletions
diff --git a/src/defines.h b/src/defines.h index 3d87df47..c5ec3a20 100644 --- a/src/defines.h +++ b/src/defines.h @@ -3385,33 +3385,6 @@ - - -/* - * Determines if a map location is fully inside the outer walls - */ -#define in_bounds(Y,X) \ - (((Y) > 0) && ((X) > 0) && ((Y) < cur_hgt-1) && ((X) < cur_wid-1)) - -/* - * Determines if a map location is on or inside the outer walls - */ -#define in_bounds2(Y,X) \ - (((Y) >= 0) && ((X) >= 0) && ((Y) < cur_hgt) && ((X) < cur_wid)) - - -/* - * Determines if a map location is currently "on screen" -RAK- - * Note that "panel_contains(Y,X)" always implies "in_bounds2(Y,X)". - */ -#define panel_contains(Y,X) \ - (((Y) >= panel_row_min) && ((Y) <= panel_row_max) && \ - ((X) >= panel_col_min) && ((X) <= panel_col_max)) - - - - - /*** Color constants ***/ diff --git a/src/util.cc b/src/util.cc index c35eab78..fc1d6aa8 100644 --- a/src/util.cc +++ b/src/util.cc @@ -3717,3 +3717,28 @@ int get_keymap_mode() return KEYMAP_MODE_ORIG; } } + +/** + * Determines if a map location is fully inside the outer walls + */ +bool in_bounds(int y, int x) +{ + return (y > 0) && (x > 0) && (y < cur_hgt-1) && (x < cur_wid-1); +} + +/** + * Determines if a map location is on or inside the outer walls + */ +bool in_bounds2(int y, int x) +{ + return (y >= 0) && (x >= 0) && (y < cur_hgt) && (x < cur_wid); +} + +/** + * Determines if a map location is currently "on screen" -RAK- + * Note that "panel_contains(Y,X)" always implies "in_bounds2(Y,X)". + */ +bool panel_contains(int y, int x) +{ + return (y >= panel_row_min) && (y <= panel_row_max) && (x >= panel_col_min) && (x <= panel_col_max); +} diff --git a/src/util.hpp b/src/util.hpp index e9a93be8..8b389927 100644 --- a/src/util.hpp +++ b/src/util.hpp @@ -70,3 +70,6 @@ extern void repeat_push(int what); extern bool_ repeat_pull(int *what); extern void repeat_check(void); extern void get_count(int number, int max); +extern bool in_bounds(int y, int x); +extern bool in_bounds2(int y, int x); +extern bool panel_contains(int y, int x); |