Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2001:
[Freeciv-Dev] another tilespec fix (PR#1131)
Home

[Freeciv-Dev] another tilespec fix (PR#1131)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Cc: bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] another tilespec fix (PR#1131)
From: jdorje@xxxxxxxxxxxxxxxxxxxxx
Date: Thu, 13 Dec 2001 03:43:09 -0800 (PST)

It looks like the tilespec cleanup I did a while back was a bit buggy. Notice the "unknown" dither along the north pole in the following screenshots:

ftp://ftp.freeciv.org/freeciv/incoming/tilespec-pre-flat.jpg
ftp://ftp.freeciv.org/freeciv/incoming/tilespec-pre-iso.jpg

I think most people would agree this isn't good, and I'm pretty sure it's not what we had before (although I could be wrong on this one).

The attached patch fixes this, so that there is no "unknown" dither along the poles:

ftp://ftp.freeciv.org/freeciv/incoming/tilespec-post-flat.jpg
ftp://ftp.freeciv.org/freeciv/incoming/tilespec-post-iso.jpg

I've also added some comments clarifying this, as well as "fixed" the SAFE_MAPSTEP macro so that it doesn't use nearest_real_map_pos (but instead just discards the step and remains at the current position if an unreal position is reached, which is basically the same thing).

jason
? diff
? old
? other_patches
? topology
? data/nation/old
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.58
diff -u -r1.58 tilespec.c
--- client/tilespec.c   2001/12/08 15:15:50     1.58
+++ client/tilespec.c   2001/12/13 11:22:00
@@ -1128,21 +1128,31 @@
     tspecial |= S_RIVER;
   }
 
+  /* Find specials.  Any unreal tile will be given no specials. */
   for (dir = 0; dir < 8; dir++) {
-    ttype_near[dir] = T_UNKNOWN;
     tspecial_near[dir] = S_NO_SPECIAL;
-  } 
-
+  }
   adjc_dir_iterate(x, y, x1, y1, dir) {
-    ttype_near[dir] = map_get_terrain(x1, y1);
     tspecial_near[dir] = map_get_special(x1, y1);
+  } adjc_dir_iterate_end;
+
+  /*
+   * Find terrain types.  Any unreal tile will be given the
+   * same terrain type as we have.
+   */
+  for (dir = 0; dir < 8; dir++) {
+    int x1, y1;
+
+    /* nearest_real_pos is used to make the poles seamless */
+    SAFE_MAPSTEP(x1, y1, x, y, dir);
+    ttype_near[dir] = map_get_terrain(x1, y1);
 
     /* hacking away the river here... */
     if (ttype_near[dir] == T_RIVER) {
       ttype_near[dir] = T_GRASSLAND;
       tspecial_near[dir] |= S_RIVER;
     }
-  } adjc_dir_iterate_end;
+  }
   
   if (draw_terrain) {
     if (ttype != T_OCEAN) /* painted via coasts. */
@@ -1289,16 +1299,18 @@
     }
   }
 
-  for (dir = 0; dir < 4; dir++) {
-    dither[dir] = get_dither(ttype, T_UNKNOWN);
-  }
-  adjc_dir_iterate(x, y, x1, y1, dir8) {
-    if (!DIR_IS_CARDINAL(dir8) || !tile_get_known(x1, y1)) {
+  /*
+   * We want to mark unknown tiles so that an unreal tile will be
+   * given the same marking as our current tile - that way we won't
+   * get the "unknown" dither along the edge of the map.
+   */
+  for (dir = 0; dir < 8; dir++) {
+    int x1, y1;
+    if (!DIR_IS_CARDINAL(dir))
       continue;
-    }
-
-    dither[dir8_to_dir4(dir8)] = get_dither(ttype, ttype_near[dir8]);
-  } adjc_dir_iterate_end;
+    SAFE_MAPSTEP(x1, y1, x, y, dir);
+    dither[dir8_to_dir4(dir)] = get_dither(ttype, tile_get_known(x1, y1) ? 
map_get_terrain(x1, y1) : T_UNKNOWN);
+  }
 
   return sprs - save_sprs;
 }
@@ -1369,6 +1381,19 @@
     }
   }
 
+  /* Find specials.  Any unreal tile will be given no specials. */
+  tspecial=map_get_special(abs_x0, abs_y0);
+  for (dir = 0; dir < 8; dir++) {
+    tspecial_near[dir] = S_NO_SPECIAL;
+  }
+  adjc_dir_iterate(abs_x0, abs_y0, x, y, dir) {
+    tspecial_near[dir] = map_get_special(x, y);
+  } adjc_dir_iterate_end;
+
+  /*
+   * Find terrain types.  Any unreal tile will be given the
+   * same terrain type as we have.
+   */
   ttype=map_get_terrain(abs_x0, abs_y0);
   for (dir = 0; dir < 8; dir++) {
     int x, y;
@@ -1378,15 +1403,6 @@
     ttype_near[dir] = map_get_terrain(x, y);
   }
 
-  /* make sure that S_NO_SPECIAL is set past poles */
-  tspecial=map_get_special(abs_x0, abs_y0);
-  for (dir = 0; dir < 8; dir++) {
-    tspecial_near[dir] = S_NO_SPECIAL;
-  }
-  adjc_dir_iterate(abs_x0, abs_y0, x, y, dir) {
-    tspecial_near[dir] = map_get_special(x, y);
-  } adjc_dir_iterate_end;
-
   if(map.is_earth &&
      abs_x0>=34 && abs_x0<=36 && abs_y0>=den_y && abs_y0<=den_y+1) {
     mysprite = sprites.tx.denmark[abs_y0-den_y][abs_x0-34];
@@ -1566,15 +1582,20 @@
   if(!citymode) {
     /* 
      * We're looking to find the INDEX_NSEW for the directions that
-     * are unknown
+     * are unknown.  We want to mark unknown tiles so that an unreal
+     * tile will be given the same marking as our current tile -
+     * that way we won't get the "unknown" dither along the edge
+     * of the map.
      */
     int known[4];
     memset(known, 0, sizeof(known));
-    adjc_dir_iterate(abs_x0, abs_y0, x, y, dir8) {
-      if (!DIR_IS_CARDINAL(dir8))
-       continue;
-      known[dir8_to_dir4(dir8)] = (tile_get_known(x, y) != TILE_UNKNOWN);
-    } adjc_dir_iterate_end;
+    for (dir = 0; dir < 8; dir++) {
+      int x1, y1;
+      if (!DIR_IS_CARDINAL(dir))
+        continue;
+      SAFE_MAPSTEP(x1, y1, abs_x0, abs_y0, dir);
+      known[dir8_to_dir4(dir)] = (tile_get_known(x1, y1) != TILE_UNKNOWN);
+    }
 
     tileno =
        INDEX_NSEW(!known[DIR4_NORTH], !known[DIR4_SOUTH],
Index: common/map.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.h,v
retrieving revision 1.107
diff -u -r1.107 map.h
--- common/map.h        2001/12/09 09:16:23     1.107
+++ common/map.h        2001/12/13 11:22:01
@@ -233,10 +233,16 @@
  * SAFE_MAPSTEP.
  */
 #define SAFE_MAPSTEP(dest_x, dest_y, src_x, src_y, dir)        \
-(    DIRSTEP(dest_x, dest_y, dir),                     \
-     (dest_x) += (src_x),                              \
-     (dest_y) += (src_y),                              \
-     nearest_real_pos(&(dest_x), &(dest_y)))
+   do {                                                 \
+     DIRSTEP(dest_x, dest_y, dir);                     \
+     (dest_x) += (src_x);                              \
+     (dest_y) += (src_y);                              \
+     if (!normalize_map_pos(&(dest_x), &(dest_y))) {    \
+       (dest_x) = (src_x);                              \
+       (dest_y) = (src_y);                              \
+       CHECK_MAP_POS((dest_x), (dest_y));               \
+     }                                                  \
+   } while(0)
 
 /*
  * Returns the next direction clock-wise

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] another tilespec fix (PR#1131), jdorje <=