[Freeciv-Dev] Re: (PR#10424) bugs with non-iso hex topologies
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] Re: (PR#10424) bugs with non-iso hex topologies |
From: |
"Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx> |
Date: |
Mon, 4 Oct 2004 10:13:11 -0700 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=10424 >
Jason Short wrote:
> <URL: http://rt.freeciv.org/Ticket/Display.html?id=10424 >
>
> With topologies 8-11 there are some bugs. One such is with the
> overview, which shows the map oriented quite wrongly.
This patch should fix it.
In almost all cases places that check for isometric maps should be
checking for isometric-or-hex maps. All hex maps are "tilted" like an
isometric map is.
However until we have a hex-non-iso tileset it's difficult to do full
testing.
jason
Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.151
diff -u -r1.151 mapview_common.c
--- client/mapview_common.c 1 Oct 2004 17:53:01 -0000 1.151
+++ client/mapview_common.c 4 Oct 2004 17:11:11 -0000
@@ -521,7 +521,7 @@
*xsize = mapview_canvas.width;
*ysize = mapview_canvas.height;
- if (topo_has_flag(TF_ISO) == is_isometric) {
+ if (MAP_IS_ISOMETRIC == is_isometric) {
/* If the map and view line up, it's easy. */
NATIVE_TO_MAP_POS(xmin, ymin, 0, 0);
map_to_gui_pos(xmin, ymin, *xmin, *ymin);
@@ -681,7 +681,7 @@
: 2 * NORMAL_TILE_WIDTH);
const int border_y = (is_isometric ? NORMAL_TILE_HEIGHT / 2
: 2 * NORMAL_TILE_HEIGHT);
- bool same = (is_isometric == topo_has_flag(TF_ISO));
+ bool same = (is_isometric == MAP_IS_ISOMETRIC);
get_mapview_scroll_window(&xmin, &ymin, &xmax, &ymax, &xsize, &ysize);
get_mapview_scroll_pos(&scroll_x, &scroll_y);
@@ -2250,7 +2250,7 @@
if (topo_has_flag(TF_WRAPX)) {
ovr_x = FC_WRAP(ovr_x, NATURAL_WIDTH);
} else {
- if (topo_has_flag(TF_ISO)) {
+ if (MAP_IS_ISOMETRIC) {
/* HACK: For iso-maps that don't wrap in the X direction we clip
* a half-tile off of the left and right of the overview. This
* means some tiles only are halfway shown. However it means we
@@ -2276,7 +2276,7 @@
int ntl_x = overview_x / OVERVIEW_TILE_SIZE + overview.map_x0;
int ntl_y = overview_y / OVERVIEW_TILE_SIZE + overview.map_y0;
- if (topo_has_flag(TF_ISO) && !topo_has_flag(TF_WRAPX)) {
+ if (MAP_IS_ISOMETRIC && !topo_has_flag(TF_WRAPX)) {
/* Clip half tile left and right. See comment in map_to_overview_pos. */
ntl_x++;
}
@@ -2302,7 +2302,7 @@
/* Note: these calculations operate on overview coordinates as if they
* are natural. Corners may be off by one tile, however. */
- if (is_isometric && !topo_has_flag(TF_ISO)) {
+ if (is_isometric && !MAP_IS_ISOMETRIC) {
/* We start with the west corner. */
/* North */
@@ -2316,7 +2316,7 @@
/* South */
x[3] = x[0] + OVERVIEW_TILE_WIDTH * mapview_canvas.tile_height;
y[3] = y[0] + OVERVIEW_TILE_HEIGHT * mapview_canvas.tile_height;
- } else if (!is_isometric && topo_has_flag(TF_ISO)) {
+ } else if (!is_isometric && MAP_IS_ISOMETRIC) {
/* We start with the west corner. Note the X scale is smaller. */
/* North */
@@ -2374,7 +2374,7 @@
int overview_y = ntl_y * OVERVIEW_TILE_SIZE;
int overview_x = ntl_x * OVERVIEW_TILE_SIZE;
- if (topo_has_flag(TF_ISO)) {
+ if (MAP_IS_ISOMETRIC) {
if (topo_has_flag(TF_WRAPX)) {
if (overview_x > overview.width - OVERVIEW_TILE_WIDTH) {
/* This tile is shown half on the left and half on the right
@@ -2412,7 +2412,7 @@
* tall or short overview if your map is unusually sized. */
OVERVIEW_TILE_SIZE = (120 / width) + 1;
- if (topo_has_flag(TF_ISO)) {
+ if (MAP_IS_ISOMETRIC) {
OVERVIEW_TILE_SIZE = MAX(120 / width, 1);
/* Clip half tile left and right. See comment in map_to_overview_pos. */
Index: client/tilespec.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.h,v
retrieving revision 1.89
diff -u -r1.89 tilespec.h
--- client/tilespec.h 29 Sep 2004 02:24:19 -0000 1.89
+++ client/tilespec.h 4 Oct 2004 17:11:11 -0000
@@ -309,8 +309,7 @@
* coordinates are used. For classical maps the width and height are
* equal. The base size may be adjusted to get the correct scale. */
extern int OVERVIEW_TILE_SIZE;
-#define OVERVIEW_TILE_WIDTH \
- ((topo_has_flag(TF_ISO) ? 2 : 1) * OVERVIEW_TILE_SIZE)
+#define OVERVIEW_TILE_WIDTH ((MAP_IS_ISOMETRIC ? 2 : 1) * OVERVIEW_TILE_SIZE)
#define OVERVIEW_TILE_HEIGHT OVERVIEW_TILE_SIZE
extern bool is_isometric;
Index: common/map.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.c,v
retrieving revision 1.199
diff -u -r1.199 map.c
--- common/map.c 1 Oct 2004 17:53:02 -0000 1.199
+++ common/map.c 4 Oct 2004 17:11:12 -0000
@@ -322,8 +322,7 @@
}
/* sanity check for iso topologies*/
- assert(!(topo_has_flag(TF_ISO) || topo_has_flag(TF_HEX))
- || (map.ysize % 2) == 0);
+ assert(!MAP_IS_ISOMETRIC || (map.ysize % 2) == 0);
/* The size and ratio must satisfy the minimum and maximum *linear*
* restrictions on width */
@@ -1825,7 +1824,7 @@
{
do_in_natural_pos(ntl_x, ntl_y, ptile->x, ptile->y) {
/* Iso-natural coordinates are doubled in scale. */
- dist *= topo_has_flag(TF_ISO) ? 2 : 1;
+ dist *= MAP_IS_ISOMETRIC ? 2 : 1;
return ((!topo_has_flag(TF_WRAPX)
&& (ntl_x < dist || ntl_x >= NATURAL_WIDTH - dist))
Index: common/map.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.h,v
retrieving revision 1.219
diff -u -r1.219 map.h
--- common/map.h 1 Oct 2004 17:53:02 -0000 1.219
+++ common/map.h 4 Oct 2004 17:11:12 -0000
@@ -202,6 +202,8 @@
TF_HEX = 8
};
+#define MAP_IS_ISOMETRIC (topo_has_flag(TF_ISO) || topo_has_flag(TF_HEX))
+
#define CURRENT_TOPOLOGY (map.topology_id)
#define topo_has_flag(flag) ((CURRENT_TOPOLOGY & (flag)) != 0)
@@ -257,25 +259,25 @@
/* Obscure math. See explanation in doc/HACKING. */
#define NATIVE_TO_MAP_POS(pmap_x, pmap_y, nat_x, nat_y) \
- ((topo_has_flag(TF_ISO) || topo_has_flag(TF_HEX)) \
+ (MAP_IS_ISOMETRIC \
? (*(pmap_x) = ((nat_y) + ((nat_y) & 1)) / 2 + (nat_x), \
*(pmap_y) = (nat_y) - *(pmap_x) + map.xsize) \
: (*(pmap_x) = (nat_x), *(pmap_y) = (nat_y)))
#define MAP_TO_NATIVE_POS(pnat_x, pnat_y, map_x, map_y) \
- ((topo_has_flag(TF_ISO) || topo_has_flag(TF_HEX)) \
+ (MAP_IS_ISOMETRIC \
? (*(pnat_y) = (map_x) + (map_y) - map.xsize, \
*(pnat_x) = (2 * (map_x) - *(pnat_y) - (*(pnat_y) & 1)) / 2) \
: (*(pnat_x) = (map_x), *(pnat_y) = (map_y)))
#define NATURAL_TO_MAP_POS(pmap_x, pmap_y, nat_x, nat_y) \
- (topo_has_flag(TF_ISO) \
+ (MAP_IS_ISOMETRIC \
? (*(pmap_x) = ((nat_y) + (nat_x)) / 2, \
*(pmap_y) = (nat_y) - *(pmap_x) + map.xsize) \
: (*(pmap_x) = (nat_x), *(pmap_y) = (nat_y)))
#define MAP_TO_NATURAL_POS(pnat_x, pnat_y, map_x, map_y) \
- (topo_has_flag(TF_ISO) \
+ (MAP_IS_ISOMETRIC \
? (*(pnat_y) = (map_x) + (map_y) - map.xsize, \
*(pnat_x) = 2 * (map_x) - *(pnat_y)) \
: (*(pnat_x) = (map_x), *(pnat_y) = (map_y)))
@@ -316,17 +318,13 @@
#define NATIVE_HEIGHT map.ysize
/* Width and height of the map, in natural coordinates. */
-#define NATURAL_WIDTH (topo_has_flag(TF_ISO) ? 2 * map.xsize : map.xsize)
+#define NATURAL_WIDTH (MAP_IS_ISOMETRIC ? 2 * map.xsize : map.xsize)
#define NATURAL_HEIGHT map.ysize
-#define MAP_WIDTH \
- (topo_has_flag(TF_ISO) \
- ? (map.xsize + map.ysize / 2) \
- : map.xsize)
+#define MAP_WIDTH \
+ (MAP_IS_ISOMETRIC ? (map.xsize + map.ysize / 2) : map.xsize)
#define MAP_HEIGHT \
-(topo_has_flag(TF_ISO) \
- ? (map.xsize + map.ysize / 2) \
- : map.ysize)
+ (MAP_IS_ISOMETRIC ? (map.xsize + map.ysize / 2) : map.ysize)
static inline int map_pos_to_index(int map_x, int map_y);
@@ -695,8 +693,7 @@
* the Y direction. Hence (x+1,y) is 1 tile away while (x,y+2) is also
* one tile away. */
int xdist = dist;
- int ydist = ((topo_has_flag(TF_ISO) || topo_has_flag(TF_HEX))
- ? (2 * dist) : dist);
+ int ydist = (MAP_IS_ISOMETRIC ? (2 * dist) : dist);
return (ptile->nat_x < xdist
|| ptile->nat_y < ydist
Index: server/generator/mapgen_topology.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/generator/mapgen_topology.c,v
retrieving revision 1.4
diff -u -r1.4 mapgen_topology.c
--- server/generator/mapgen_topology.c 29 Sep 2004 02:24:24 -0000 1.4
+++ server/generator/mapgen_topology.c 4 Oct 2004 17:11:13 -0000
@@ -178,7 +178,7 @@
/* In iso-maps we need to double the map.ysize factor, since xsize is
* in native coordinates which are compressed 2x in the X direction. */
- const int iso = (topo_has_flag(TF_ISO) || topo_has_flag(TF_HEX)) ? 2 : 1;
+ const int iso = MAP_IS_ISOMETRIC ? 2 : 1;
/* We have:
*
Index: server/generator/utilities.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/generator/utilities.c,v
retrieving revision 1.8
diff -u -r1.8 utilities.c
--- server/generator/utilities.c 1 Oct 2004 17:53:02 -0000 1.8
+++ server/generator/utilities.c 4 Oct 2004 17:11:13 -0000
@@ -167,6 +167,7 @@
do {
whole_map_iterate(ptile) {
int N = 0, D = 0;
+
iterate_axe(tile1, i, ptile, 2, axe) {
D += weight[i + 2];
N += weight[i + 2] * source_map[tile1->index];
@@ -177,16 +178,16 @@
target_map[ptile->index] = N / D;
} whole_map_iterate_end;
- if (topo_has_flag(TF_ISO) || topo_has_flag(TF_HEX)) {
- weight[0] = weight[4] = 0.5;
- weight[1] = weight[3] = 0.7;
- total_weight = 3.4;
- }
+ if (MAP_IS_ISOMETRIC) {
+ weight[0] = weight[4] = 0.5;
+ weight[1] = weight[3] = 0.7;
+ total_weight = 3.4;
+ }
- axe = !axe;
+ axe = !axe;
- source_map = alt_int_map;
- target_map = int_map;
+ source_map = alt_int_map;
+ target_map = int_map;
- } while ( !axe );
+ } while (!axe);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] Re: (PR#10424) bugs with non-iso hex topologies,
Jason Short <=
|
|