[Freeciv-Dev] PATCH: is_border_pos macro (PR#1006)
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
This teeny-tiny patch introduces the desired topology expression
IS_BORDER_POS(x, y). This macro returns TRUE iff (x, y) is on the
"border" of the map; that is, if any of its 8 neighbors are not normal
(proper). It is not truly needed for any operations (yet), but is of
use in optimizing adjcancy iterators.
To preserve locality, I stuck the macro definition right in the middle
of the other is_*** topological functions. It can be moved up above or
below them as desired.
jason Index: common/map.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.h,v
retrieving revision 1.96
diff -u -r1.96 map.h
--- common/map.h 2001/10/09 16:26:46 1.96
+++ common/map.h 2001/10/12 13:03:19
@@ -232,6 +232,11 @@
int check_coords(int *x, int *y);
int is_real_tile(int x, int y);
int is_normal_map_pos(int x, int y);
+/* A "border position" is any one that has adjacent positions
+ that are not normal/proper. */
+#define IS_BORDER_POS(x, y) \
+ ((y) == 0 || (x) == 0 || \
+ (y) == map.ysize-1 || (x) == map.xsize-1)
int normalize_map_pos(int *x, int *y);
void nearest_real_pos(int *x, int *y);
@@ -404,10 +409,7 @@
int MACRO_center_y = (center_y); \
assert(0 <= MACRO_center_y && MACRO_center_y < map.ysize \
&& 0 <= MACRO_center_x && MACRO_center_x < map.xsize); \
- MACRO_border = (MACRO_center_y == 0 \
- || MACRO_center_x == 0 \
- || MACRO_center_y == map.ysize-1 \
- || MACRO_center_x == map.xsize-1); \
+ MACRO_border = IS_BORDER_POS(MACRO_center_x, MACRO_center_y); \
for (dir_itr = 0; dir_itr < 8; dir_itr++) { \
DIRSTEP(x_itr, y_itr, dir_itr); \
x_itr += MACRO_center_x; \
- [Freeciv-Dev] PATCH: is_border_pos macro (PR#1006),
jdorje <=
|
|