Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2001:
[Freeciv-Dev] Re: patches
Home

[Freeciv-Dev] Re: patches

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: rf13@xxxxxxxxxxxxxxxxxxxxxx
Cc: freeciv development list <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: patches
From: Jason Dorje Short <jshort@xxxxxxxxxxxxx>
Date: Sun, 09 Sep 2001 14:59:50 -0400
Reply-to: jdorje@xxxxxxxxxxxxxxxxxxxxx

Raimar Falke wrote:
> 
> On Tue, Aug 28, 2001 at 10:52:16AM +0200, Raimar Falke wrote:
> >  - cartesian_adjacent_iterate (move normalize_map_pos out of switch
> >    statement)
> 
> Comments?

Looks fine to me.  But how about this one instead?

jason
Index: common/map.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.h,v
retrieving revision 1.88
diff -u -r1.88 map.h
--- common/map.h        2001/09/06 18:19:09     1.88
+++ common/map.h        2001/09/09 18:55:52
@@ -456,43 +456,13 @@
 extern const int CAR_DIR_DX[4];
 extern const int CAR_DIR_DY[4];
 
-#define cartesian_adjacent_iterate(x, y, IAC_x, IAC_y) \
-{                                                      \
-  int IAC_i;                                           \
-  int IAC_x, IAC_y;                                    \
-  for (IAC_i = 0; IAC_i < 4; IAC_i++) {                \
-    switch (IAC_i) {                                   \
-    case 0:                                            \
-      IAC_x = x + 1;                                   \
-      IAC_y = y;                                       \
-      if (!normalize_map_pos(&IAC_x, &IAC_y))          \
-       continue;                                      \
-      break;                                           \
-    case 1:                                            \
-      IAC_x = x;                                       \
-      IAC_y = y + 1;                                   \
-      if (!normalize_map_pos(&IAC_x, &IAC_y))          \
-       continue;                                      \
-      break;                                           \
-    case 2:                                            \
-      IAC_x = x - 1;                                   \
-      IAC_y = y;                                       \
-      if (!normalize_map_pos(&IAC_x, &IAC_y))          \
-       continue;                                      \
-      break;                                           \
-    case 3:                                            \
-      IAC_x = x;                                       \
-      IAC_y = y - 1;                                   \
-      if (!normalize_map_pos(&IAC_x, &IAC_y))          \
-       continue;                                      \
-      break;                                           \
-    default:                                           \
-      abort();                                         \
-    }
+#define cartesian_adjacent_iterate(center_x, center_y, itr_x, itr_y)          \
+  adjc_dir_iterate(center_x, center_y, itr_x, itr_y, _itr_dir) {              \
+    if (!DIR_IS_CARDINAL(_itr_dir)) continue;
 
-#define cartesian_adjacent_iterate_end                 \
-  }                                                    \
-}
+
+#define cartesian_adjacent_iterate_end                                        \
+  } adjc_dir_iterate_end
 
 
 /*

[Prev in Thread] Current Thread [Next in Thread]