[Freeciv-Dev] Re: (PR#8627) best overview for iso-maps
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] Re: (PR#8627) best overview for iso-maps |
From: |
"Marcelo Burda" <mburda@xxxxxxxxx> |
Date: |
Thu, 13 May 2004 00:33:51 -0700 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=8627 >
Le jeu 13/05/2004 à 04:41, Jason Short a écrit :
> <URL: http://rt.freeciv.org/Ticket/Display.html?id=8627 >
>
Hi
Am thinkung to extend overview struct to avoid globals vars. no more
OVERVIEW_TILE_WIDTH but overview.TILE_WIDTH,
see last code. (there is incomplete work about new fonctionalities in
selected topologies)
> Why do you turn OVERVIEW_TILE_WIDTH and OVERVIEW_TILE_HEIGHT into
> constant values? You shouldn't do this. They should be adjusted based
> on the height of the map.
There are not constant but based on OVERVIEW_TILE_SIZE, this single var
is scaled to size ov view. this is important because in some part of
code i need to use the base OVERVIEW_TILE_SIZE to calculate
over_positions and not the OVERVIEW_TILE_WIDTH. this last and ..._HEIGHT
are only used to paint.
code as
*overview_x = overview.TILE_SIZE * ovr_x;
*overview_y = overview.TILE_SIZE * ovr_y;
need a test for TF_ISO if i use OVERVIEW_TILE_WIDTH as you propose
>
> I suggest something like:
>
> climap.h:
>
> /* Number of tile units in a covering natural tile. */
> #define NATURAL_TILE_WIDTH (topo_has_flag(TF_ISO) ? 2 : 1)
> #define NATURAL_TILE_HEIGHT 1
>
> tilespec.h:
>
> int overview_tile_width, overview_tile_height;
> #define OVERVIEW_TILE_WIDTH (overview_tile_width * NATURAL_TILE_WIDTH)
> #define OVERVIEW_TILE_HEIGHT (overview_tile_height * \
> NATURAL_TILE_HEIGHT);
>
> packhand.c (or mapview_common.c):
>
> overview_tile_width = 120 / NATURAL_WIDTH;
> overview_tile_height = OVERVIEW_TILE_WIDTH;
no good if NATURAL_WIDTH are more than 120
>
> There are other ways to do it. But:
>
> 1. The overview tile size should be scaled to keep the overview width
> around 120.
>
> 2. The TF_ISO check should only be done in one place when calculating
> overview tile width.
>
> jason
there inlude 2 files. the overview_tuning51.diff. where i am make near
zero changes(finished for me) and a new one where i am experimenting
with news ideas.
Probably the best is get finished and aply this patch and open a new
thicket with the new one!
--
. / . ' , . (*) ' ` ' ` .
| , | ` , . , ' Marcelo Julián Burda .
/ ' \ ` \@_ ' . ' ` '
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff -ruN -Xdiff_ignore freeciv/client/climap.h freeciv_/client/climap.h
--- freeciv/client/climap.h 2003-04-23 19:08:50.000000000 +0200
+++ freeciv_/client/climap.h 2004-05-12 17:28:41.000000000 +0200
@@ -24,4 +24,8 @@
enum direction8 gui_to_map_dir(enum direction8 gui_dir);
enum direction8 map_to_gui_dir(enum direction8 map_dir);
+#define OVERVIEW_TILE_WIDTH \
+ ((topo_has_flag(TF_ISO) ? 2 : 1) * OVERVIEW_TILE_SIZE)
+#define OVERVIEW_TILE_HEIGHT OVERVIEW_TILE_SIZE
+
#endif
diff -ruN -Xdiff_ignore freeciv/client/mapview_common.c
freeciv_/client/mapview_common.c
--- freeciv/client/mapview_common.c 2004-05-12 17:18:11.000000000 +0200
+++ freeciv_/client/mapview_common.c 2004-05-12 17:24:30.000000000 +0200
@@ -1995,8 +1995,8 @@
{
struct canvas *src = overview.store;
- int x = overview.map_x0 * OVERVIEW_TILE_WIDTH;
- int y = overview.map_y0 * OVERVIEW_TILE_HEIGHT;
+ int x = overview.map_x0 * OVERVIEW_TILE_SIZE;
+ int y = overview.map_y0 * OVERVIEW_TILE_SIZE;
int ix = overview.width - x;
int iy = overview.height - y;
@@ -2049,23 +2049,24 @@
**************************************************************************/
static void center_tile_overviewcanvas(int map_x, int map_y)
{
- /* The overview coordinates are equivalent to native coordinates. */
- map_to_native_pos(&map_x, &map_y, map_x, map_y);
+ /* The overview coordinates are equivalent to natural coordinates. */
+ do_in_natural_pos(ntl_x, ntl_y, map_x, map_y) {
- /* NOTE: this embeds the map wrapping in the overview code. This is
- * basically necessary for the overview to be efficiently
- * updated. */
- if (topo_has_flag(TF_WRAPX)) {
- overview.map_x0 = FC_WRAP(map_x - map.xsize / 2, map.xsize);
- } else {
- overview.map_x0 = 0;
- }
- if (topo_has_flag(TF_WRAPY)) {
- overview.map_y0 = FC_WRAP(map_y - map.ysize / 2, map.ysize);
- } else {
- overview.map_y0 = 0;
- }
- redraw_overview();
+ /* NOTE: this embeds the map wrapping in the overview code. This is
+ * basically necessary for the overview to be efficiently
+ * updated. */
+ if (topo_has_flag(TF_WRAPX)) {
+ overview.map_x0 = FC_WRAP(ntl_x - NATURAL_WIDTH / 2, NATURAL_WIDTH);
+ } else {
+ overview.map_x0 = 0;
+ }
+ if (topo_has_flag(TF_WRAPY)) {
+ overview.map_y0 = FC_WRAP(ntl_y - NATURAL_HEIGHT / 2, NATURAL_HEIGHT);
+ } else {
+ overview.map_y0 = 0;
+ }
+ redraw_overview();
+ } do_in_natural_pos_end;
}
/**************************************************************************
@@ -2074,23 +2075,26 @@
void map_to_overview_pos(int *overview_x, int *overview_y,
int map_x, int map_y)
{
- int gui_x, gui_y;
-
/* The map position may not be normal, for instance when the mapview
* origin is not a normal position.
*
* NOTE: this embeds the map wrapping in the overview code. */
- map_to_native_pos(&gui_x, &gui_y, map_x, map_y);
- gui_x -= overview.map_x0;
- gui_y -= overview.map_y0;
- if (topo_has_flag(TF_WRAPX)) {
- gui_x = FC_WRAP(gui_x, map.xsize);
- }
- if (topo_has_flag(TF_WRAPY)) {
- gui_y = FC_WRAP(gui_y, map.ysize);
- }
- *overview_x = OVERVIEW_TILE_WIDTH * gui_x;
- *overview_y = OVERVIEW_TILE_HEIGHT * gui_y;
+ do_in_natural_pos(ntl_x, ntl_y, map_x, map_y) {
+ int ovr_x = ntl_x - overview.map_x0,
+ ovr_y = ntl_y - overview.map_y0;
+ const int natural_width = NATURAL_WIDTH; /* optimizing speed*/
+
+ if (topo_has_flag(TF_WRAPX)) {
+ ovr_x = FC_WRAP(ovr_x, natural_width);
+ } else {
+ if( topo_has_flag(TF_ISO)) { ovr_x--; }; /* clip half tile */
+ }
+ if (topo_has_flag(TF_WRAPY)) {
+ ovr_y = FC_WRAP(ovr_y, NATURAL_HEIGHT);
+ }
+ *overview_x = OVERVIEW_TILE_SIZE * ovr_x;
+ *overview_y = OVERVIEW_TILE_SIZE * ovr_y;
+ } do_in_natural_pos_end;
}
/**************************************************************************
@@ -2099,10 +2103,16 @@
void overview_to_map_pos(int *map_x, int *map_y,
int overview_x, int overview_y)
{
- int nat_x = overview_x / OVERVIEW_TILE_WIDTH + overview.map_x0;
- int nat_y = overview_y / OVERVIEW_TILE_HEIGHT + overview.map_y0;
+ int ntl_x = overview_x / OVERVIEW_TILE_SIZE + overview.map_x0,
+ ntl_y = overview_y / OVERVIEW_TILE_SIZE + overview.map_y0;
+
+ /* clip half tile left and right */
+ if(topo_has_flag(TF_ISO) && !topo_has_flag(TF_WRAPX)) {
+ ntl_x++;
+ }
- native_to_map_pos(map_x, map_y, nat_x, nat_y);
+ natural_to_map_pos(map_x, map_y, ntl_x, ntl_y);
+
if (!normalize_map_pos(map_x, map_y)) {
/* All positions on the overview should be valid. */
assert(FALSE);
@@ -2116,52 +2126,56 @@
static void get_mapview_corners(int x[4], int y[4])
{
int map_x0, map_y0;
-
+ const int TILE_WIDTH = OVERVIEW_TILE_WIDTH,
+ TILE_HEIGHT = OVERVIEW_TILE_HEIGHT;
canvas_to_map_pos(&map_x0, &map_y0, 0, 0);
map_to_overview_pos(&x[0], &y[0], map_x0, map_y0);
/* Note: these calculations operate on overview coordinates as if they
* are native. */
+ /* TILE_WIDTH is there to correct it to natural, but corners can are off
+ by 1 */
+
if (is_isometric && !topo_has_flag(TF_ISO)) {
/* We start with the west corner. */
/* North */
- x[1] = x[0] + OVERVIEW_TILE_WIDTH * mapview_canvas.tile_width;
- y[1] = y[0] - OVERVIEW_TILE_HEIGHT * mapview_canvas.tile_width;
+ x[1] = x[0] + TILE_WIDTH * mapview_canvas.tile_width;
+ y[1] = y[0] - TILE_HEIGHT * mapview_canvas.tile_width;
/* East */
- x[2] = x[1] + OVERVIEW_TILE_WIDTH * mapview_canvas.tile_height;
- y[2] = y[1] + OVERVIEW_TILE_HEIGHT * mapview_canvas.tile_height;
+ x[2] = x[1] + TILE_WIDTH * mapview_canvas.tile_height;
+ y[2] = y[1] + TILE_HEIGHT * mapview_canvas.tile_height;
/* South */
- x[3] = x[0] + OVERVIEW_TILE_WIDTH * mapview_canvas.tile_height;
- y[3] = y[0] + OVERVIEW_TILE_HEIGHT * mapview_canvas.tile_height;
+ x[3] = x[0] + TILE_WIDTH * mapview_canvas.tile_height;
+ y[3] = y[0] + TILE_HEIGHT * mapview_canvas.tile_height;
} else if (!is_isometric && topo_has_flag(TF_ISO)) {
/* We start with the west corner. Note the X scale is smaller. */
/* North */
- x[1] = x[0] + OVERVIEW_TILE_WIDTH * mapview_canvas.tile_width / 2;
- y[1] = y[0] + OVERVIEW_TILE_HEIGHT * mapview_canvas.tile_width;
+ x[1] = x[0] + TILE_WIDTH * mapview_canvas.tile_width / 2;
+ y[1] = y[0] + TILE_HEIGHT * mapview_canvas.tile_width;
/* East */
- x[2] = x[1] - OVERVIEW_TILE_WIDTH * mapview_canvas.tile_height / 2;
- y[2] = y[1] + OVERVIEW_TILE_HEIGHT * mapview_canvas.tile_height;
+ x[2] = x[1] - TILE_WIDTH * mapview_canvas.tile_height / 2;
+ y[2] = y[1] + TILE_HEIGHT * mapview_canvas.tile_height;
/* South */
- x[3] = x[2] - OVERVIEW_TILE_WIDTH * mapview_canvas.tile_width / 2;
- y[3] = y[2] - OVERVIEW_TILE_HEIGHT * mapview_canvas.tile_width;
+ x[3] = x[2] - TILE_WIDTH * mapview_canvas.tile_width / 2;
+ y[3] = y[2] - TILE_HEIGHT * mapview_canvas.tile_width;
} else {
/* We start with the northwest corner. */
int screen_width = mapview_canvas.tile_width;
int screen_height = mapview_canvas.tile_height * (is_isometric ? 2 : 1);
/* Northeast */
- x[1] = x[0] + OVERVIEW_TILE_WIDTH * screen_width - 1;
+ x[1] = x[0] + TILE_WIDTH * screen_width - 1;
y[1] = y[0];
/* Southeast */
x[2] = x[1];
- y[2] = y[0] + OVERVIEW_TILE_HEIGHT * screen_height - 1;
+ y[2] = y[0] + TILE_HEIGHT * screen_height - 1;
/* Southwest */
x[3] = x[0];
@@ -2188,18 +2202,36 @@
**************************************************************************/
void overview_update_tile(int map_x, int map_y)
{
- int base_x, base_y;
-
- /* Base overview positions are just like native positions, but scaled to
+ /* Base overview positions are just like natural positions, but scaled to
* the overview tile dimensions. */
- map_to_native_pos(&base_x, &base_y, map_x, map_y);
- base_x *= OVERVIEW_TILE_WIDTH;
- base_y *= OVERVIEW_TILE_HEIGHT;
-
- canvas_put_rectangle(overview.store,
- overview_tile_color(map_x, map_y), base_x, base_y,
- OVERVIEW_TILE_WIDTH, OVERVIEW_TILE_HEIGHT);
- dirty_overview();
+ do_in_natural_pos(ntl_x, ntl_y, map_x, map_y) {
+ int overview_y =ntl_y * OVERVIEW_TILE_SIZE,
+ overview_x =ntl_x * OVERVIEW_TILE_SIZE;
+ const int TILE_WIDTH = OVERVIEW_TILE_WIDTH,
+ TILE_HEIGHT = OVERVIEW_TILE_HEIGHT;
+
+ if (topo_has_flag(TF_ISO)) {
+ if(topo_has_flag(TF_WRAPX)) {
+ if(overview_x > overview.width - TILE_WIDTH) {
+ /* Oops! we need update half tile at 0 */
+ canvas_put_rectangle(overview.store,
+ overview_tile_color(map_x, map_y),
+ overview_x - overview.width, overview_y,
+ TILE_WIDTH , TILE_HEIGHT);
+ }
+ } else {
+ /* clip half tile */
+ overview_x -= OVERVIEW_TILE_SIZE;
+ }
+ }
+
+ canvas_put_rectangle(overview.store,
+ overview_tile_color(map_x, map_y),
+ overview_x, overview_y,
+ TILE_WIDTH, TILE_HEIGHT);
+
+ dirty_overview();
+ } do_in_natural_pos_end;
}
/**************************************************************************
@@ -2207,8 +2239,20 @@
**************************************************************************/
void set_overview_dimensions(int width, int height)
{
- overview.width = OVERVIEW_TILE_WIDTH * width;
+ int shift = 0; /* used to calculate shift in iso view */
+ /* Set the scale of the overview map. Note, since only the width is
+ * used to calculate the overview scale you can end up with a really
+ * tall or short overview if your map is unusually sized. */
+
+ OVERVIEW_TILE_SIZE = (120 / width) + 1;
+ if(topo_has_flag(TF_ISO)) {
+ OVERVIEW_TILE_SIZE = MAX(120 / width, 1);
+ /* clip half tile left and right*/
+ shift = (!topo_has_flag(TF_WRAPX) ? -OVERVIEW_TILE_SIZE : 0);
+ }
+
overview.height = OVERVIEW_TILE_HEIGHT * height;
+ overview.width = OVERVIEW_TILE_WIDTH * width + shift;
if (overview.store) {
canvas_free(overview.store);
diff -ruN -Xdiff_ignore freeciv/client/packhand.c freeciv_/client/packhand.c
--- freeciv/client/packhand.c 2004-05-11 18:42:50.000000000 +0200
+++ freeciv_/client/packhand.c 2004-05-12 17:24:30.000000000 +0200
@@ -1303,19 +1303,17 @@
****************************************************************************/
void handle_map_info(int xsize, int ysize, int topology_id)
{
+ map.size = 0; /* use server sended sizes */
+ map.ratio = 100;
+ map.topology_id = topology_id;
+ map_init_topology();
+
map.xsize = xsize;
map.ysize = ysize;
- map.topology_id = topology_id;
map_allocate();
init_client_goto();
- /* Set the scale of the overview map. Note, since only the width is
- * used to calculate the overview scale you can end up with a really
- * tall or short overview if your map is unusually sized. */
- OVERVIEW_TILE_WIDTH = (120 / map.xsize) + 1;
- OVERVIEW_TILE_HEIGHT = OVERVIEW_TILE_WIDTH;
-
set_overview_dimensions(map.xsize, map.ysize);
}
diff -ruN -Xdiff_ignore freeciv/client/tilespec.c freeciv_/client/tilespec.c
--- freeciv/client/tilespec.c 2004-05-08 17:21:05.000000000 +0200
+++ freeciv_/client/tilespec.c 2004-05-12 17:24:30.000000000 +0200
@@ -72,8 +72,7 @@
int SMALL_TILE_WIDTH;
int SMALL_TILE_HEIGHT;
-int OVERVIEW_TILE_WIDTH = 2;
-int OVERVIEW_TILE_HEIGHT = 2;
+int OVERVIEW_TILE_SIZE = 2;
bool is_isometric;
int hex_width, hex_height;
diff -ruN -Xdiff_ignore freeciv/client/tilespec.h freeciv_/client/tilespec.h
--- freeciv/client/tilespec.h 2004-04-30 00:49:10.000000000 +0200
+++ freeciv_/client/tilespec.h 2004-05-12 17:24:30.000000000 +0200
@@ -278,8 +278,7 @@
extern int SMALL_TILE_WIDTH;
extern int SMALL_TILE_HEIGHT;
-extern int OVERVIEW_TILE_WIDTH;
-extern int OVERVIEW_TILE_HEIGHT;
+extern int OVERVIEW_TILE_SIZE;
extern bool is_isometric;
extern int hex_width, hex_height;
diff -ruN -Xdiff_ignore freeciv/common/map.c freeciv_/common/map.c
--- freeciv/common/map.c 2004-04-27 18:28:09.000000000 +0200
+++ freeciv_/common/map.c 2004-05-12 17:24:20.000000000 +0200
@@ -176,9 +176,11 @@
***************************************************************/
void map_init(void)
{
- map.topology_id = MAP_DEFAULT_TOPO;
- map.xsize = MAP_DEFAULT_WIDTH;
- map.ysize = MAP_DEFAULT_HEIGHT;
+ map.topology_id = MAP_DEFAULT_TOPO;
+ map.size = MAP_DEFAULT_SIZE;
+ map.ratio = MAP_DEFAULT_RATIO;
+ map.xsize = 0; /* to be set by map_init_topology() */
+ map.ysize = 0;
map.seed = MAP_DEFAULT_SEED;
map.riches = MAP_DEFAULT_RICHES;
map.huts = MAP_DEFAULT_HUTS;
@@ -199,6 +201,127 @@
map.have_specials = FALSE;
map.have_rivers_overlay = FALSE;
map.have_huts = FALSE;
+ map_init_topology(); /* correct xsize/ysize values if needed */
+}
+static int mcd(int A, int B) {
+ if ((A % 2) == 0 && (B % 2) == 0) {
+ return 2 * mcd( A / 2, B / 2);
+ }
+ if ((A % 3) == 0 && (B % 3) == 0) {
+ return 3 * mcd( A / 3, B / 3);
+ }
+ if ((A % 5) == 0 && (B % 5) == 0) {
+ return 5 * mcd( A / 5, B / 5);
+ }
+ if ((A % 7) == 0 && (B % 7) == 0) {
+ return 7 * mcd( A / 7, B / 7);
+ }
+ return 1;
+}
+
+/*
+ * This is the core of calculate size of the maps
+ * final value are calculate to get defined ratios size in natural
+ * coordinated
+ * xsize and ysize are even numbers
+ * if iso-map ysize%4 == 0 to avoid any type of problems in
+ * extended topologies and iso-maps
+ */
+static void setmapratio(double base_size, int Xratio, int Yratio)
+{
+ const int MCD = mcd(Xratio, Yratio);
+ /* if map.xsize and map.ysize are set from server do nothing*/
+ if (base_size == 0)
+ return;
+ /*
+ * Simplify the prime common divisor in ratios
+ * ratios as 9:9 8:8 7:7 are converted to 1:1
+ */
+ Xratio /= MCD;
+ Yratio /= MCD;
+
+ /*
+ Correct exesives ratios
+ */
+ if( Xratio / Yratio >= 3) {
+ Xratio = 3;
+ Yratio = 1 ;
+ /* server mesage: the ratios was raised to 31*/
+ }
+ if( Yratio / Xratio >= 3) {
+ Xratio = 1;
+ Yratio = 3 ;
+ /* server mesage: the ratios was raised to 13*/
+ }
+
+ /* set corrected ratio in map.ratio if these values are set by user */
+ if( map.ratio != 100 ) {
+ map.ratio = Xratio + 10 * Yratio;
+ if(MCD != 1) {
+ /* server mesage: the user defined ratios was corrected to */
+ }
+ }
+
+ /* in TF_ISO we need double map.ysize/map.ysize factor */
+ int iso = topo_has_flag(TF_ISO)? 2 : 1;
+ /* get a integer for the internal i_size var,this alow to make easly even
numbers */
+ int i_size = floor(0.49 + sqrt(250.0 * base_size / (Xratio * Yratio * iso)));
+ /* verify for map.xsize and map.ysize estimated minimum value*/
+ /* this is make there to avoid a too complex code, but it is not exact */
+ int i_size_min = MIN(1, MAP_MIN_LINEAR_SIZE / MIN(Xratio, Yratio * iso) / 2);
+ if (i_size < i_size_min) { i_size = i_size_min; };
+
+ /* set map.[xy]size as even numbers (and ysize %4 == 0 for TF_ISO)*/
+ map.xsize = 2 * Xratio * i_size;
+ map.ysize = iso * 2 * Yratio * i_size;
+
+ /* Verify up limit for map coordinates and correct it if needed */
+ if (MAX(MAP_WIDTH, MAP_HEIGHT) >= MAP_MAX_LINEAR_SIZE) { /* make a more
litle map if possible */
+ assert(base_size > 0.1);
+ setmapratio(base_size - 0.1, Xratio, Yratio);
+ return;
+ }
+}
+
+/* auto-ratios can't change map.ratio */
+static void auto_ratio(int ratio)
+{
+ assert(ratio >= 11 && ratio < 100);
+ setmapratio(map.size, ratio / 10,(ratio % 10));
+}
+
+static void user_ratio(void)
+{
+ assert(map.ratio >= 11 && map.ratio <= 100);
+ if (map.ratio != 100)
+ setmapratio(map.size, map.ratio / 10,
+ (map.ratio % 10));
+}
+
+#define INIT_TOPOLOGIE_CASE(TOPO,DEFAULTRATIO) \
+ case TOPO: \
+ if( map.ratio == 100){ \
+ auto_ratio(DEFAULTRATIO); \
+ } else { user_ratio(); } \
+ break;
+
+/***************************************************************************
+ map_init_topology() need to be called after changes on
+ map.topology_id, map.size and map.ratio was donned.
+ this calculate map.xsize and map.ysize
+
+ in client or when loading savegames map.size can be set to zero to
+ alow code to set direcly xsize and ysize
+ [mburda]
+*************************************************************************/
+void map_init_topology( void)
+{
+ switch (map.topology_id & (TF_WRAPX |TF_WRAPY)) {
+ INIT_TOPOLOGIE_CASE(0, AUTO_RATIO_FLAT);
+ INIT_TOPOLOGIE_CASE((TF_WRAPX |TF_WRAPY), AUTO_RATIO_TORUS);
+ INIT_TOPOLOGIE_CASE(TF_WRAPY, AUTO_RATIO_URANUS);
+ INIT_TOPOLOGIE_CASE(TF_WRAPX, AUTO_RATIO_CLASSIC);
+ };
}
/***************************************************************
diff -ruN -Xdiff_ignore freeciv/common/map.h freeciv_/common/map.h
--- freeciv/common/map.h 2004-05-11 18:42:50.000000000 +0200
+++ freeciv_/common/map.h 2004-05-12 17:26:02.000000000 +0200
@@ -117,6 +117,7 @@
struct civ_map {
int topology_id;
+ int size, ratio; /* used to calculate [xy]size */
int xsize, ysize; /* native dimensions */
int seed;
int riches;
@@ -154,6 +155,8 @@
#define topo_has_flag(flag) ((CURRENT_TOPOLOGY & (flag)) != 0)
+void map_init_topology(void );
+
bool map_is_empty(void);
void map_init(void);
void map_allocate(void);
@@ -207,9 +210,22 @@
*(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) \
+ ? (*(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) \
+ ? (*(pnat_y) = (map_x) + (map_y) - map.xsize, \
+ *(pnat_x) = 2 * (map_x) - *(pnat_y)) \
+ : (*(pnat_x) = (map_x), *(pnat_y) = (map_y)))
+
+
/* Provide a block to convert from map to native coordinates. This allows
* you to use a native version of the map position within the block. Note
- * that any changes to the native position won't affect the map position. */
+ * that native position are declare as const. */
#define do_in_native_pos(nat_x, nat_y, map_x, map_y) \
{ \
int _nat_x, _nat_y; \
@@ -221,6 +237,27 @@
} \
}
+/* Provide a block to convert from map to natural coordinates. This allows
+ * you to use a natural version of the map position within the block.
+ * natural version vars are const and can't be changed inside the block */
+
+#define do_in_natural_pos(ntl_x, ntl_y, map_x, map_y) \
+{ \
+ int _ntl_x, _ntl_y; \
+ map_to_natural_pos(&_ntl_x, &_ntl_y, map_x, map_y); \
+ { \
+ const int ntl_x = _ntl_x, ntl_y = _ntl_y;
+
+#define do_in_natural_pos_end \
+ } \
+}
+
+#define NATIVE_WIDTH map.xsize
+#define NATIVE_HEIGHT map.ysize
+
+#define NATURAL_WIDTH (topo_has_flag(TF_ISO) ? 2 * map.xsize : map.xsize)
+#define NATURAL_HEIGHT map.ysize
+
static inline int map_pos_to_index(int map_x, int map_y);
/* index_to_map_pos(int *, int *, int) inverts map_pos_to_index */
@@ -233,6 +270,14 @@
( (dest_x) = DIR_DX[(dir)], \
(dest_y) = DIR_DY[(dir)])
+#define MAP_WIDTH \
+ (topo_has_flag(TF_ISO) \
+ ? (map.xsize + map.ysize / 2) \
+ : map.xsize)
+#define MAP_HEIGHT \
+ (topo_has_flag(TF_ISO) \
+ ? (map.xsize + map.ysize / 2) \
+ : map.ysize)
/*
* Returns true if the step yields a new valid map position. If yes
* (dest_x, dest_y) is set to the new map position.
@@ -597,13 +642,44 @@
#define MAP_MIN_HUTS 0
#define MAP_MAX_HUTS 500
-#define MAP_DEFAULT_WIDTH 80
-#define MAP_MIN_WIDTH 40
-#define MAP_MAX_WIDTH 200
-
-#define MAP_DEFAULT_HEIGHT 50
-#define MAP_MIN_HEIGHT 25
-#define MAP_MAX_HEIGHT 100
+/* size of the map in thusand of tiles */
+#define MAP_DEFAULT_SIZE 4
+#define MAP_MIN_SIZE 1
+#define MAP_MAX_SIZE 26
+
+/*
+ * This define the max linear size in map or native coordinates
+ * this must be liter than 255, this value is reserved for net usage
+ */
+#define MAP_MAX_LINEAR_SIZE 254
+#define MAP_MIN_LINEAR_SIZE 8
+
+/*
+ * This value determine the x:y ration of the map in NATURAL coordinated
+ * This ratio need to be corrected for NATIVE coordinated in
+ * iso-map by a factor sqrt(2) as (x / sqrt(2)) : (y * sqrt (2))
+ * the spetial values 100 is the AUTO RATIO (this is the prefered value)
+ */
+#define MAP_DEFAULT_RATIO 100
+#define MAP_MIN_RATIO 11
+#define MAP_MAX_RATIO 100
+
+/*
+ * The auto ratios for knowns topologies
+ * best if (but not needed)
+ * get RATIO factor = Xratio*Yratio as litle as posible
+ * this is best for litles map sizes
+ * get DEFAULT RATIO <= 2:1 or 1:2
+ */
+#define AUTO_RATIO_FLAT 11
+#define AUTO_RATIO_CLASSIC 85
+#define AUTO_RATIO_URANUS 47
+#define AUTO_RATIO_TORUS 11
+
+#define MAP_MIN_WIDTH MAP_MIN_LINEAR_SIZE
+#define MAP_MAX_WIDTH MAP_MAX_LINEAR_SIZE
+#define MAP_MIN_HEIGHT MAP_MIN_LINEAR_SIZE
+#define MAP_MAX_HEIGHT MAP_MAX_LINEAR_SIZE
#define MAP_ORIGINAL_TOPO TF_WRAPX
#define MAP_DEFAULT_TOPO TF_WRAPX
diff -ruN -Xdiff_ignore freeciv/server/savegame.c freeciv_/server/savegame.c
--- freeciv/server/savegame.c 2004-04-27 18:28:18.000000000 +0200
+++ freeciv_/server/savegame.c 2004-05-12 17:24:20.000000000 +0200
@@ -323,8 +323,11 @@
***************************************************************/
static void map_tiles_load(struct section_file *file)
{
+ map.size = 0; /* use xize/ysize from load */
+ map.ratio= 100;
map.topology_id = secfile_lookup_int_default(file, MAP_ORIGINAL_TOPO,
"map.topology_id");
+ map_init_topology(); /* this call never change [xy]size */
/* In some cases we read these before, but not always, and
* its safe to read them again:
diff -ruN -Xdiff_ignore freeciv/server/stdinhand.c freeciv_/server/stdinhand.c
--- freeciv/server/stdinhand.c 2004-05-12 17:18:15.000000000 +0200
+++ freeciv_/server/stdinhand.c 2004-05-12 17:24:20.000000000 +0200
@@ -254,28 +254,42 @@
/* These should be grouped by sclass */
/* Map size parameters: adjustable if we don't yet have a map */
- GEN_INT("xsize", map.xsize, SSET_MAP_SIZE, SSET_GEOLOGY, SSET_TO_CLIENT,
- N_("Map width in squares"), "", NULL,
- MAP_MIN_WIDTH, MAP_MAX_WIDTH, MAP_DEFAULT_WIDTH)
-
- GEN_INT("ysize", map.ysize, SSET_MAP_SIZE, SSET_GEOLOGY, SSET_TO_CLIENT,
- N_("Map height in squares"), "", NULL,
- MAP_MIN_HEIGHT, MAP_MAX_HEIGHT, MAP_DEFAULT_HEIGHT)
-
+ GEN_INT("size", map.size, SSET_MAP_SIZE, SSET_GEOLOGY, SSET_TO_CLIENT,
+ N_("Map size in 1,000 tiles units"),
+ N_("This value is used to determine xsize and ysize\n"
+ " size = 4 is a litle map of 4,000 tiles (default)\n"
+ " size = 20 is a Huge map of 20,000 tiles \n"
+ "The maximal size is limited by topology and ratio\n"
+ "See the topologie help. the real size auto reised\n"
+ "to these maximals"), NULL,
+ MAP_MIN_SIZE,MAP_MAX_SIZE , MAP_DEFAULT_SIZE)
+
+ GEN_INT("ratio", map.ratio, SSET_MAP_SIZE, SSET_GEOLOGY, SSET_TO_CLIENT,
+ N_("Map ratio, keep it default value of 100 (auto)\n"),
+ N_("This value is used to determine xsize and ysize \n"
+ " 100 is the default ratio determined by the topology_id\n"
+ "Otherwise first digit is the x factor \n"
+ "and second digit the y factor of the x:y ratio \n"
+ " 11 is 1:1 ratio, 85 is a 8:5 ratio. \n"
+ "Extreme ratio (more than 3/1) are auto raised to these limit \n"
+ "Change it at your own risk, bad ratios limit size of map!"
+ ), NULL,
+ MAP_MIN_RATIO, MAP_MAX_RATIO , MAP_DEFAULT_RATIO)
GEN_INT("topology", map.topology_id, SSET_MAP_SIZE, SSET_GEOLOGY,
SSET_TO_CLIENT,
N_("The map topology index"),
N_("Two-dimensional maps can wrap at the north-south or \n"
"east-west edges, and use a cartesian or isometric \n"
"rectangular grid. See the manual for further explanation.\n"
- " 0 Flat Earth (unwrapped)\n"
- " 1 Earth (wraps E-W)\n"
- " 2 Uranus (wraps N-S)\n"
- " 3 Donut World (wraps N-S, E-W)\n"
- " 4 Flat Earth (isometric)\n"
- " 5 Earth (isometric)\n"
- " 6 Uranus (isometric)\n"
- " 7 Donut World (isometric)"
+ " 0 Flat Earth (unwrapped) [64]\n"
+ " 1 Earth (wraps E-W) [40]\n"
+ " 2 Uranus (wraps N-S) [36]\n"
+ " 3 Donut World (wraps N-S, E-W)[64]\n"
+ " 4 Flat Earth (isometric) [14]\n"
+ " 5 Earth (isometric) [26]\n"
+ " 6 Uranus (isometric) [11]\n"
+ " 7 Donut World (isometric) [14]\n"
+ " [] the maximal size are calculated for auto ratio"
), NULL,
MAP_MIN_TOPO, MAP_MAX_TOPO, MAP_DEFAULT_TOPO)
@@ -3572,6 +3586,7 @@
}
if (!check && do_update) {
+ map_init_topology(); /* update map.[xy]size from last changes */
/*
* send any modified game parameters to the clients -- if sent
* before RUN_GAME_STATE, triggers a popdown_races_dialog() call
diff -ruN -Xdiff_ignore freeciv/client/climap.h freeciv_/client/climap.h
--- freeciv/client/climap.h 2003-04-23 19:08:50.000000000 +0200
+++ freeciv_/client/climap.h 2004-05-12 19:08:58.000000000 +0200
@@ -24,4 +24,10 @@
enum direction8 gui_to_map_dir(enum direction8 gui_dir);
enum direction8 map_to_gui_dir(enum direction8 map_dir);
+struct overview_pos {
+ int x, y;
+};
+
+
+
#endif
diff -ruN -Xdiff_ignore freeciv/client/gui-gtk-2.0/mapctrl.c
freeciv_/client/gui-gtk-2.0/mapctrl.c
--- freeciv/client/gui-gtk-2.0/mapctrl.c 2004-04-27 18:28:08.000000000
+0200
+++ freeciv_/client/gui-gtk-2.0/mapctrl.c 2004-05-12 18:17:18.000000000
+0200
@@ -293,8 +293,8 @@
} else {
gdk_window_get_pointer(overview_canvas->window, &x, &y, 0);
if (x >= 0 && y >= 0
- && x < OVERVIEW_TILE_WIDTH * map.xsize
- && y < OVERVIEW_TILE_WIDTH * map.ysize) {
+ && x < overview.TILE_WIDTH * map.xsize
+ && y < overview.TILE_HEIGHT * map.ysize) {
overview_update_line(x, y);
}
}
diff -ruN -Xdiff_ignore freeciv/client/mapview_common.c
freeciv_/client/mapview_common.c
--- freeciv/client/mapview_common.c 2004-05-12 17:18:11.000000000 +0200
+++ freeciv_/client/mapview_common.c 2004-05-13 11:23:32.000000000 +0200
@@ -1995,8 +1995,8 @@
{
struct canvas *src = overview.store;
- int x = overview.map_x0 * OVERVIEW_TILE_WIDTH;
- int y = overview.map_y0 * OVERVIEW_TILE_HEIGHT;
+ int x = overview.map_x0 * overview.TILE_SIZE;
+ int y = overview.map_y0 * overview.TILE_SIZE;
int ix = overview.width - x;
int iy = overview.height - y;
@@ -2049,23 +2049,24 @@
**************************************************************************/
static void center_tile_overviewcanvas(int map_x, int map_y)
{
- /* The overview coordinates are equivalent to native coordinates. */
- map_to_native_pos(&map_x, &map_y, map_x, map_y);
+ /* The overview coordinates are equivalent to natural coordinates. */
+ do_in_natural_pos(ntl_x, ntl_y, map_x, map_y) {
- /* NOTE: this embeds the map wrapping in the overview code. This is
- * basically necessary for the overview to be efficiently
- * updated. */
- if (topo_has_flag(TF_WRAPX)) {
- overview.map_x0 = FC_WRAP(map_x - map.xsize / 2, map.xsize);
- } else {
- overview.map_x0 = 0;
- }
- if (topo_has_flag(TF_WRAPY)) {
- overview.map_y0 = FC_WRAP(map_y - map.ysize / 2, map.ysize);
- } else {
- overview.map_y0 = 0;
- }
- redraw_overview();
+ /* NOTE: this embeds the map wrapping in the overview code. This is
+ * basically necessary for the overview to be efficiently
+ * updated. */
+ if (topo_has_flag(TF_WRAPX)) {
+ overview.map_x0 = FC_WRAP(ntl_x - NATURAL_WIDTH / 2, NATURAL_WIDTH);
+ } else {
+ overview.map_x0 = 0;
+ }
+ if (topo_has_flag(TF_WRAPY)) {
+ overview.map_y0 = FC_WRAP(ntl_y - NATURAL_HEIGHT / 2, NATURAL_HEIGHT);
+ } else {
+ overview.map_y0 = 0;
+ }
+ redraw_overview();
+ } do_in_natural_pos_end;
}
/**************************************************************************
@@ -2074,23 +2075,37 @@
void map_to_overview_pos(int *overview_x, int *overview_y,
int map_x, int map_y)
{
- int gui_x, gui_y;
-
/* The map position may not be normal, for instance when the mapview
* origin is not a normal position.
*
* NOTE: this embeds the map wrapping in the overview code. */
- map_to_native_pos(&gui_x, &gui_y, map_x, map_y);
- gui_x -= overview.map_x0;
- gui_y -= overview.map_y0;
- if (topo_has_flag(TF_WRAPX)) {
- gui_x = FC_WRAP(gui_x, map.xsize);
- }
- if (topo_has_flag(TF_WRAPY)) {
- gui_y = FC_WRAP(gui_y, map.ysize);
- }
- *overview_x = OVERVIEW_TILE_WIDTH * gui_x;
- *overview_y = OVERVIEW_TILE_HEIGHT * gui_y;
+ do_in_natural_pos(ntl_x, ntl_y, map_x, map_y) {
+ if(topo_has_flag(TF_ISO) == overview.is_isometric) {
+ int ovr_x = ntl_x - overview.map_x0,
+ ovr_y = ntl_y - overview.map_y0;
+ const int natural_width = NATURAL_WIDTH; /* optimizing speed*/
+
+ if (topo_has_flag(TF_WRAPX)) {
+ ovr_x = FC_WRAP(ovr_x, natural_width);
+ } else {
+ if( topo_has_flag(TF_ISO)) { ovr_x--; }; /* clip half tile */
+ }
+ if (topo_has_flag(TF_WRAPY)) {
+ ovr_y = FC_WRAP(ovr_y, NATURAL_HEIGHT);
+ }
+ *overview_x = overview.TILE_SIZE * ovr_x;
+ *overview_y = overview.TILE_SIZE * ovr_y;
+ return;
+ }
+
+ /* this is only alowed for selected topologies */
+ /* TORUS */
+ assert( topo_has_flag(TF_WRAPX) && topo_has_flag(TF_WRAPY));
+
+ if ( overview.is_isometric ) { /* topo is not iso */
+ } else { /* topo is iso but ovoerview is not */
+ }
+ } do_in_natural_pos_end;
}
/**************************************************************************
@@ -2099,10 +2114,16 @@
void overview_to_map_pos(int *map_x, int *map_y,
int overview_x, int overview_y)
{
- int nat_x = overview_x / OVERVIEW_TILE_WIDTH + overview.map_x0;
- int nat_y = overview_y / OVERVIEW_TILE_HEIGHT + overview.map_y0;
+ int ntl_x = overview_x / overview.TILE_SIZE + overview.map_x0,
+ ntl_y = overview_y / overview.TILE_SIZE + overview.map_y0;
- native_to_map_pos(map_x, map_y, nat_x, nat_y);
+ /* clip half tile left and right */
+ if(topo_has_flag(TF_ISO) && !topo_has_flag(TF_WRAPX)) {
+ ntl_x++;
+ }
+
+ natural_to_map_pos(map_x, map_y, ntl_x, ntl_y);
+
if (!normalize_map_pos(map_x, map_y)) {
/* All positions on the overview should be valid. */
assert(FALSE);
@@ -2116,52 +2137,54 @@
static void get_mapview_corners(int x[4], int y[4])
{
int map_x0, map_y0;
-
canvas_to_map_pos(&map_x0, &map_y0, 0, 0);
map_to_overview_pos(&x[0], &y[0], map_x0, map_y0);
/* Note: these calculations operate on overview coordinates as if they
* are native. */
+ /* TILE_WIDTH is there to correct it to natural, but corners can are off
+ by 1 */
+
if (is_isometric && !topo_has_flag(TF_ISO)) {
/* We start with the west corner. */
/* North */
- x[1] = x[0] + OVERVIEW_TILE_WIDTH * mapview_canvas.tile_width;
- y[1] = y[0] - OVERVIEW_TILE_HEIGHT * mapview_canvas.tile_width;
+ x[1] = x[0] + overview.TILE_WIDTH * mapview_canvas.tile_width;
+ y[1] = y[0] - overview.TILE_HEIGHT * mapview_canvas.tile_width;
/* East */
- x[2] = x[1] + OVERVIEW_TILE_WIDTH * mapview_canvas.tile_height;
- y[2] = y[1] + OVERVIEW_TILE_HEIGHT * mapview_canvas.tile_height;
+ x[2] = x[1] + overview.TILE_WIDTH * mapview_canvas.tile_height;
+ y[2] = y[1] + overview.TILE_HEIGHT * mapview_canvas.tile_height;
/* South */
- x[3] = x[0] + OVERVIEW_TILE_WIDTH * mapview_canvas.tile_height;
- y[3] = y[0] + OVERVIEW_TILE_HEIGHT * mapview_canvas.tile_height;
+ 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)) {
/* We start with the west corner. Note the X scale is smaller. */
/* North */
- x[1] = x[0] + OVERVIEW_TILE_WIDTH * mapview_canvas.tile_width / 2;
- y[1] = y[0] + OVERVIEW_TILE_HEIGHT * mapview_canvas.tile_width;
+ x[1] = x[0] + overview.TILE_WIDTH * mapview_canvas.tile_width / 2;
+ y[1] = y[0] + overview.TILE_HEIGHT * mapview_canvas.tile_width;
/* East */
- x[2] = x[1] - OVERVIEW_TILE_WIDTH * mapview_canvas.tile_height / 2;
- y[2] = y[1] + OVERVIEW_TILE_HEIGHT * mapview_canvas.tile_height;
+ x[2] = x[1] - overview.TILE_WIDTH * mapview_canvas.tile_height / 2;
+ y[2] = y[1] + overview.TILE_HEIGHT * mapview_canvas.tile_height;
/* South */
- x[3] = x[2] - OVERVIEW_TILE_WIDTH * mapview_canvas.tile_width / 2;
- y[3] = y[2] - OVERVIEW_TILE_HEIGHT * mapview_canvas.tile_width;
+ x[3] = x[2] - overview.TILE_WIDTH * mapview_canvas.tile_width / 2;
+ y[3] = y[2] - overview.TILE_HEIGHT * mapview_canvas.tile_width;
} else {
/* We start with the northwest corner. */
int screen_width = mapview_canvas.tile_width;
int screen_height = mapview_canvas.tile_height * (is_isometric ? 2 : 1);
/* Northeast */
- x[1] = x[0] + OVERVIEW_TILE_WIDTH * screen_width - 1;
+ x[1] = x[0] + overview.TILE_WIDTH * screen_width - 1;
y[1] = y[0];
/* Southeast */
x[2] = x[1];
- y[2] = y[0] + OVERVIEW_TILE_HEIGHT * screen_height - 1;
+ y[2] = y[0] + overview.TILE_HEIGHT * screen_height - 1;
/* Southwest */
x[3] = x[0];
@@ -2188,18 +2211,34 @@
**************************************************************************/
void overview_update_tile(int map_x, int map_y)
{
- int base_x, base_y;
-
- /* Base overview positions are just like native positions, but scaled to
+ /* Base overview positions are just like natural positions, but scaled to
* the overview tile dimensions. */
- map_to_native_pos(&base_x, &base_y, map_x, map_y);
- base_x *= OVERVIEW_TILE_WIDTH;
- base_y *= OVERVIEW_TILE_HEIGHT;
-
- canvas_put_rectangle(overview.store,
- overview_tile_color(map_x, map_y), base_x, base_y,
- OVERVIEW_TILE_WIDTH, OVERVIEW_TILE_HEIGHT);
- dirty_overview();
+ do_in_natural_pos(ntl_x, ntl_y, map_x, map_y) {
+ int overview_y =ntl_y * overview.TILE_SIZE,
+ overview_x =ntl_x * overview.TILE_SIZE;
+
+ if (topo_has_flag(TF_ISO)) {
+ if(topo_has_flag(TF_WRAPX)) {
+ if(overview_x > overview.width - overview.TILE_WIDTH) {
+ /* Oops! we need update half tile at 0 */
+ canvas_put_rectangle(overview.store,
+ overview_tile_color(map_x, map_y),
+ overview_x - overview.width, overview_y,
+ overview.TILE_WIDTH , overview.TILE_HEIGHT);
+ }
+ } else {
+ /* clip half tile */
+ overview_x -= overview.TILE_SIZE;
+ }
+ }
+
+ canvas_put_rectangle(overview.store,
+ overview_tile_color(map_x, map_y),
+ overview_x, overview_y,
+ overview.TILE_WIDTH, overview.TILE_HEIGHT);
+
+ dirty_overview();
+ } do_in_natural_pos_end;
}
/**************************************************************************
@@ -2207,9 +2246,61 @@
**************************************************************************/
void set_overview_dimensions(int width, int height)
{
- overview.width = OVERVIEW_TILE_WIDTH * width;
- overview.height = OVERVIEW_TILE_HEIGHT * height;
+ int shift = 0; /* used to calculate shift in iso view */
+ /* Set the scale of the overview map. Note, since only the width is
+ * used to calculate the overview scale you can end up with a really
+ * tall or short overview if your map is unusually sized. */
+
+ overview.is_isometric = topo_has_flag(TF_ISO);
+
+ /* for selected topologies we can choice to set
+ overview.is_isometric equal to main windows is_isometric */
+ /* FIX ME: include the code needed to alow this
+
+ if(topo_has_flag(TF_WRAPX) && topo_has_flag(TF_WRAPY)) {
+ overview.is_isometric= is_isometric;
+ }
+
+ only closed topologies as torus or quincutial can use it with out black areas
+ on overview, for others topos we can still using the old thechnics
+ a torus overview as (no TF_ISO)
+ ABCD
+ EDGH
+ IJKL
+ MNOP
+ is viewved in iso overview as
+ E_B_
+ _D_C
+ J_G_
+ _K_H
+ O_L_
+ _P_I
+ D_M_
+ _A_N
+ the overview change from 1:1 ratio to 1:2
+ but the main ratio and the overview as some indexing system
+ */
+ if( overview.is_isometric == topo_has_flag(TF_ISO) ) {
+ if(overview.is_isometric) {
+ overview.TILE_SIZE = MAX(120 / width, 1);
+ overview.TILE_WIDTH = overview.TILE_SIZE * 2;
+ overview.TILE_HEIGHT = overview.TILE_SIZE;
+ /* clip half tile left and right*/
+ shift = (!topo_has_flag(TF_WRAPX) ? -overview.TILE_SIZE : 0);
+ } else if (!overview.is_isometric) {
+ overview.TILE_SIZE = (120 / width) + 1;
+ overview.TILE_WIDTH = overview.TILE_SIZE;
+ overview.TILE_HEIGHT = overview.TILE_SIZE;
+ }
+ overview.height = overview.TILE_HEIGHT * height;
+ overview.width = overview.TILE_WIDTH * width + shift;
+ } else { /* if overview.is_isometric != topo_has_flag(TF_ISO) */
+ if (overview.is_isometric) {
+ assert( 0 );
+ } else { assert( 0); };
+ }
+ /* create store */
if (overview.store) {
canvas_free(overview.store);
}
diff -ruN -Xdiff_ignore freeciv/client/mapview_common.h
freeciv_/client/mapview_common.h
--- freeciv/client/mapview_common.h 2004-05-12 17:18:11.000000000 +0200
+++ freeciv_/client/mapview_common.h 2004-05-12 18:13:32.000000000 +0200
@@ -37,6 +37,8 @@
int map_x0, map_y0;
int width, height; /* Size in pixels. */
struct canvas *store;
+ bool is_isometric;
+ int TILE_SIZE, TILE_WIDTH, TILE_HEIGHT;
};
extern struct mapview_canvas mapview_canvas;
diff -ruN -Xdiff_ignore freeciv/client/packhand.c freeciv_/client/packhand.c
--- freeciv/client/packhand.c 2004-05-11 18:42:50.000000000 +0200
+++ freeciv_/client/packhand.c 2004-05-13 11:32:30.000000000 +0200
@@ -1310,12 +1310,6 @@
map_allocate();
init_client_goto();
- /* Set the scale of the overview map. Note, since only the width is
- * used to calculate the overview scale you can end up with a really
- * tall or short overview if your map is unusually sized. */
- OVERVIEW_TILE_WIDTH = (120 / map.xsize) + 1;
- OVERVIEW_TILE_HEIGHT = OVERVIEW_TILE_WIDTH;
-
set_overview_dimensions(map.xsize, map.ysize);
}
diff -ruN -Xdiff_ignore freeciv/client/tilespec.c freeciv_/client/tilespec.c
--- freeciv/client/tilespec.c 2004-05-08 17:21:05.000000000 +0200
+++ freeciv_/client/tilespec.c 2004-05-12 18:07:21.000000000 +0200
@@ -72,9 +72,6 @@
int SMALL_TILE_WIDTH;
int SMALL_TILE_HEIGHT;
-int OVERVIEW_TILE_WIDTH = 2;
-int OVERVIEW_TILE_HEIGHT = 2;
-
bool is_isometric;
int hex_width, hex_height;
diff -ruN -Xdiff_ignore freeciv/client/tilespec.h freeciv_/client/tilespec.h
--- freeciv/client/tilespec.h 2004-04-30 00:49:10.000000000 +0200
+++ freeciv_/client/tilespec.h 2004-05-12 18:06:20.000000000 +0200
@@ -278,9 +278,6 @@
extern int SMALL_TILE_WIDTH;
extern int SMALL_TILE_HEIGHT;
-extern int OVERVIEW_TILE_WIDTH;
-extern int OVERVIEW_TILE_HEIGHT;
-
extern bool is_isometric;
extern int hex_width, hex_height;
diff -ruN -Xdiff_ignore freeciv/common/map.h freeciv_/common/map.h
--- freeciv/common/map.h 2004-05-11 18:42:50.000000000 +0200
+++ freeciv_/common/map.h 2004-05-13 11:32:30.000000000 +0200
@@ -207,9 +207,22 @@
*(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) \
+ ? (*(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) \
+ ? (*(pnat_y) = (map_x) + (map_y) - map.xsize, \
+ *(pnat_x) = 2 * (map_x) - *(pnat_y)) \
+ : (*(pnat_x) = (map_x), *(pnat_y) = (map_y)))
+
+
/* Provide a block to convert from map to native coordinates. This allows
* you to use a native version of the map position within the block. Note
- * that any changes to the native position won't affect the map position. */
+ * that native position are declare as const. */
#define do_in_native_pos(nat_x, nat_y, map_x, map_y) \
{ \
int _nat_x, _nat_y; \
@@ -221,6 +234,27 @@
} \
}
+/* Provide a block to convert from map to natural coordinates. This allows
+ * you to use a natural version of the map position within the block.
+ * natural version vars are const and can't be changed inside the block */
+
+#define do_in_natural_pos(ntl_x, ntl_y, map_x, map_y) \
+{ \
+ int _ntl_x, _ntl_y; \
+ map_to_natural_pos(&_ntl_x, &_ntl_y, map_x, map_y); \
+ { \
+ const int ntl_x = _ntl_x, ntl_y = _ntl_y;
+
+#define do_in_natural_pos_end \
+ } \
+}
+
+#define NATIVE_WIDTH map.xsize
+#define NATIVE_HEIGHT map.ysize
+
+#define NATURAL_WIDTH (topo_has_flag(TF_ISO) ? 2 * map.xsize : map.xsize)
+#define NATURAL_HEIGHT map.ysize
+
static inline int map_pos_to_index(int map_x, int map_y);
/* index_to_map_pos(int *, int *, int) inverts map_pos_to_index */
- [Freeciv-Dev] Re: (PR#8627) best overview for iso-maps, (continued)
- [Freeciv-Dev] Re: (PR#8627) best overview for iso-maps, Marcelo Burda, 2004/05/09
- [Freeciv-Dev] Re: (PR#8627) best overview for iso-maps, Jason Short, 2004/05/09
- [Freeciv-Dev] Re: (PR#8627) best overview for iso-maps, Marcelo Burda, 2004/05/09
- [Freeciv-Dev] Re: (PR#8627) best overview for iso-maps, Jason Short, 2004/05/09
- [Freeciv-Dev] Re: (PR#8627) best overview for iso-maps, Marcelo Burda, 2004/05/09
- [Freeciv-Dev] Re: (PR#8627) best overview for iso-maps, Marcelo Burda, 2004/05/09
- [Freeciv-Dev] Re: (PR#8627) best overview for iso-maps, Jason Short, 2004/05/10
- [Freeciv-Dev] Re: (PR#8627) best overview for iso-maps, Marcelo Burda, 2004/05/12
- [Freeciv-Dev] Re: (PR#8627) best overview for iso-maps, Jason Short, 2004/05/12
- [Freeciv-Dev] Re: (PR#8627) best overview for iso-maps, Jason Short, 2004/05/12
- [Freeciv-Dev] Re: (PR#8627) best overview for iso-maps,
Marcelo Burda <=
- [Freeciv-Dev] (PR#8627) best overview for iso-maps, Marcelo Burda, 2004/05/15
- [Freeciv-Dev] (PR#8627) best overview for iso-maps, Jason Short, 2004/05/19
- [Freeciv-Dev] Re: (PR#8627) best overview for iso-maps, Marcelo Burda, 2004/05/20
- [Freeciv-Dev] Re: (PR#8627) best overview for iso-maps, Jason Short, 2004/05/20
- [Freeciv-Dev] Re: (PR#8627) best overview for iso-maps, Marcelo Burda, 2004/05/20
- [Freeciv-Dev] Re: (PR#8627) best overview for iso-maps, Jason Short, 2004/05/20
- [Freeciv-Dev] Re: (PR#8627) best overview for iso-maps, Marcelo Burda, 2004/05/21
- [Freeciv-Dev] (PR#8627) best overview for iso-maps, Marcelo Burda, 2004/05/12
|
|