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/util.cc | |
parent | ee2234b03fdc201045261d13b4c9101befbe074d (diff) |
Change in_bounds* and panel_contains macros to functions in util.cc
Diffstat (limited to 'src/util.cc')
-rw-r--r-- | src/util.cc | 25 |
1 files changed, 25 insertions, 0 deletions
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); +} |