Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2004:
[Freeciv-Dev] (PR#9427) rewrite circle_iterate
Home

[Freeciv-Dev] (PR#9427) rewrite circle_iterate

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#9427) rewrite circle_iterate
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 19 Jul 2004 10:32:14 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=9427 >

This patch rewrites circle_iterate to:

- Be hex-friendly by using map_vector_to_sq_distance.
- Only evaluate its arguments once.
- Respect the style guide.

Of course the first is the main goal (see PR#7481).

jason

Index: common/map.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.h,v
retrieving revision 1.197
diff -u -r1.197 map.h
--- common/map.h        19 Jul 2004 17:13:38 -0000      1.197
+++ common/map.h        19 Jul 2004 17:28:04 -0000
@@ -482,12 +482,13 @@
  * radius.  Positions returned will have adjusted (x, y); unreal
  * positions will be automatically discarded. 
  */
-#define circle_iterate(center_x, center_y, sq_radius, x_itr, y_itr)           \
-{                                                                             \
-  int _cr_radius = (int)sqrt((double)(sq_radius));                            \
-  square_dxy_iterate(center_x, center_y, _cr_radius,                          \
-                    x_itr, y_itr, _dx, _dy) {                                \
-    if (_dy * _dy + _dx * _dx <= (sq_radius)) {
+#define circle_iterate(center_x, center_y, sq_radius, x_itr, y_itr)         \
+{                                                                           \
+  int _sq_radius = (sq_radius);                                                
    \
+  int _cr_radius = (int)sqrt((double)_sq_radius);                          \
+  square_dxy_iterate(center_x, center_y, _cr_radius,                        \
+                    x_itr, y_itr, _dx, _dy) {                              \
+    if (map_vector_to_sq_distance(_dx, _dy) <= _sq_radius) {
 
 #define circle_iterate_end                                                    \
     }                                                                         \

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#9427) rewrite circle_iterate, Jason Short <=