Re: [Freeciv-Dev] (PR#39811) BUG: oddball iterators

2007-10-30 Thread William Allen Simpson

http://bugs.freeciv.org/Ticket/Display.html?id=39811 >

It would have been more helpful to have a report that it was the very
first savegame that differed, because the generation differed!  Wasted an
awful lot of time testing 2.1 to completion for each iterator individually,
when I'd already tested them in trunk.  Worried about minor differences in
generation (in this case, merely the startpos)?  Oh well, fixed that, too.

Anyway, even though it was not intended for 2.1, with so much 2.1 testing,
it was committed there, too.

Committed trunk revision 13906.
Committed S2_2 revision 13907.
Committed S2_1 revision 13908, for posterity:


Index: server/generator/utilities.h
===
--- server/generator/utilities.h(revision 13907)
+++ server/generator/utilities.h(working copy)
@@ -33,44 +33,45 @@
 }
 
 /***
- iterate axe iterate on selected axe ( x if Xaxe is TRUE) over a intervale
- of -dist to dist arround the tile indexed by index0
- this iterator create 2 vars:
- index : the map index of the iterate pointed tile
- i : the position in the intervale of iteration (from -dist to dist)
- index0, dist, Xaxe are side effect safe.
+ iterate on selected axe (x if is_X_axis is TRUE) over a interval of -dist
+ to dist around the center_tile
+ _index : the position in the interval of iteration (from -dist to dist)
+ _tile : the tile pointer
  ***/
-#define iterate_axe(iter_tile, i, center_tile, dist, Xaxe) \
-  {\
-const int ___dist = (dist);
\
-const struct tile *_center_tile = (center_tile);   \
-const bool ___Xaxe = (Xaxe);   \
-int i, ___x, ___y; \
-struct tile *iter_tile;\
+#define axis_iterate(center_tile, _tile, _index, dist, is_X_axis)  \
+{  \
+  int _tile##_x, _tile##_y;\
+  struct tile *_tile;  \
+  const struct tile *_tile##_center = (center_tile);   \
+  const bool _index##_axis = (is_X_axis);  \
+  const int _index##_d = (dist);   \
+  int _index = -(_index##_d);  \
\
-for (i = -___dist; i <= ___dist; i++) {\
-  ___x = _center_tile->nat_x + (___Xaxe ? i : 0);  \
-  ___y = _center_tile->nat_y + (___Xaxe ? 0 : i);  \
-  iter_tile = native_pos_to_tile(___x, ___y);  \
-  if (!iter_tile) {
\
-   continue;   \
-  }
+  for (; _index <= _index##_d; _index++) { \
+_tile##_x = _tile##_center->nat_x + (_index##_axis ? _index : 0);  \
+_tile##_y = _tile##_center->nat_y + (_index##_axis ? 0 : _index);  \
+_tile = native_pos_to_tile(_tile##_x, _tile##_y);  \
+if (NULL != _tile) {
 
-#define iterate_axe_end \
-} \
+#define axis_iterate_end   \
+}  \
+  }\
 } 
-#define whole_map_iterate_filtered(ptile, pdata, pfilter)   \
-{  \
-  bool (*_filter)(const struct tile *ptile, const void *data) = (pfilter);  \
-  const void *_data = (pdata); \
-   \
-  whole_map_iterate(ptile) {\
-if (_filter && !(_filter)(ptile, _data)) { \
-  continue; \
-}
 
-#define whole_map_iterate_filtered_end \
-  } whole_map_iterate_end  \
+/***
+ pdata or pfilter can be NULL!
+***/
+#define whole_map_iterate_filtered(_tile, pdata, pfilter)  \
+{  \
+  bool (*_tile##_filter)(const struct tile *vtile,

Re: [Freeciv-Dev] (PR#39811) BUG: oddball iterators

2007-10-29 Thread William Allen Simpson

http://bugs.freeciv.org/Ticket/Display.html?id=39811 >

Come to think of it, I hadn't been applying these iterator patches
against 2.1.  They were trunk-only (nee 2.2).  It's kinda nice to
hear that they apply cleanly, but wasn't my expectation.  They were
written for 2.2.

When I was testing 2.1 six months ago, I was never able to replicate
two 2.1 games.  I did manage to get some of the random variables
saved in 2.1, although more is done in 2.2/trunk.

I'll try adding these patches to 2.1 one at a time, and see which one
changes the output  I didn't expect that any output would change!

Still, you haven't reported an actual bug.



___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] (PR#39811) BUG: oddball iterators

2007-10-29 Thread William Allen Simpson

http://bugs.freeciv.org/Ticket/Display.html?id=39811 >

Marko Lindqvist wrote:
>  There seems to be some regression. Autogames differ.
> 
A regression is the return of a previously reported and fixed bug.
What bug are you reporting has returned?



___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] (PR#39811) BUG: oddball iterators

2007-10-29 Thread Marko Lindqvist

http://bugs.freeciv.org/Ticket/Display.html?id=39811 >

 Since TRUNK and S2_2 AI is very much broken, I tested this with S2_1
(patch applied cleanly except one line change in unitlist.h)

 There seems to be some regression. Autogames differ.


 - ML



___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev