Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2005:
[Freeciv-Dev] (PR#12363) gui_rect_iterate doesn't work for unaligned til
Home

[Freeciv-Dev] (PR#12363) gui_rect_iterate doesn't work for unaligned til

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12363) gui_rect_iterate doesn't work for unaligned tilesets
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 26 Feb 2005 02:10:03 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12363 >

The new gui_rect_iterate requires that classic tilesets be a multiple of 
2 in dimension, and iso/hex/iso-hex tilesets be a multiple of 4 (in both 
directions).

This means engels doesn't work anymore.

It could be fixed, either by using floating-point match in 
gui_rect_iterate or by doing division more carefully (which 
unfortunately means a lot of duplicated writing).

This quick-and-dirty patch does the latter.  Is this worthwhile?

-jason

Index: client/mapview_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.h,v
retrieving revision 1.98
diff -u -r1.98 mapview_common.h
--- client/mapview_common.h     25 Feb 2005 17:31:49 -0000      1.98
+++ client/mapview_common.h     26 Feb 2005 10:09:17 -0000
@@ -100,13 +100,13 @@
     _height = -_height;                                                        
    \
   }                                                                        \
   if (_width > 0 && _height > 0) {                                         \
-    const int _ratio = (is_isometric ? 2 : 1);                             \
-    const int _W = NORMAL_TILE_WIDTH / (_ratio * 2);                       \
-    const int _H = NORMAL_TILE_HEIGHT / (_ratio * 2);                      \
-    const int GRI_x0 = DIVIDE(_gui_x0, _W) - 1;                                
    \
-    const int GRI_y0 = DIVIDE(_gui_y0, _H) - 1;                                
    \
-    const int GRI_x1 = DIVIDE(_gui_x0 + _width + _W - 1, _W) + _ratio;     \
-    const int GRI_y1 = DIVIDE(_gui_y0 + _height + _H - 1, _H) + _ratio;        
    \
+    const int _ratio = (is_isometric ? 2 : 1), _r = _ratio * 2;                
\
+    const int _Wr = NORMAL_TILE_WIDTH;                                 \
+    const int _Hr = NORMAL_TILE_HEIGHT;                                        
\
+    const int GRI_x0 = DIVIDE(_gui_x0 * _r, _Wr) - 1;                  \
+    const int GRI_y0 = DIVIDE(_gui_y0 * _r, _Hr) - 1;                  \
+    const int GRI_x1 = DIVIDE((_gui_x0 + _width) * _r + _Wr - 1, _Wr) + 
_ratio; \
+    const int GRI_y1 = DIVIDE((_gui_y0 + _height) * _r + _Hr - 1, _Hr) + 
_ratio; \
     const int _count = (GRI_x1 - GRI_x0) * (GRI_y1 - GRI_y0);              \
     int GRI_itr, GRI_x_itr, GRI_y_itr, GRI_sum, GRI_diff;                  \
                                                                            \
@@ -197,8 +197,8 @@
          }                                                                 \
        }                                                                   \
       }                                                                        
    \
-      gui_x = GRI_x_itr * _W - NORMAL_TILE_WIDTH / 2;                      \
-      gui_y = GRI_y_itr * _H - NORMAL_TILE_HEIGHT / 2;
+      gui_x = GRI_x_itr * _Wr / _r - NORMAL_TILE_WIDTH / 2;            \
+      gui_y = GRI_y_itr * _Hr / _r - NORMAL_TILE_HEIGHT / 2;
 
 #define gui_rect_iterate_end                                               \
     }                                                                      \

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