Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2004:
[Freeciv-Dev] (PR#8487) RFC: hex tilesets
Home

[Freeciv-Dev] (PR#8487) RFC: hex tilesets

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#8487) RFC: hex tilesets
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 24 Apr 2004 10:44:36 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=8487 >

> [jdorje - Sat Apr 24 17:42:34 2004]:
> 
> Here's an updated hex-tileset patch.

Oops.  Here's the correct patch.

jason

Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.106
diff -u -r1.106 mapview_common.c
--- client/mapview_common.c     24 Apr 2004 17:20:17 -0000      1.106
+++ client/mapview_common.c     24 Apr 2004 17:43:36 -0000
@@ -758,6 +758,7 @@
                                int *end_x, int *end_y)
 {
   const int W = NORMAL_TILE_WIDTH, H = NORMAL_TILE_HEIGHT;
+  const int HW = hex_width, HH = hex_height;
   const int overlap = (width > 1) ? 1 : 0;
 
   assert(inset >= 0);
@@ -801,37 +802,52 @@
     switch (dir) {
     case DIR8_NORTH:
       /* Top right. */
-      *start_x = W / 2;
-      *end_x = W - inset;
-      *start_y = inset + width;
-      *end_y = H / 2 + width;
+      *start_x = (W + HW) / 2;
+      *end_x = W - HW / 2 - inset;
+      *start_y = HH / 2 + inset + width;
+      *end_y = (H - HH) / 2 + width;
       return (draw & D_M_R) == D_M_R;
     case DIR8_SOUTH:
       /* Bottom left. */
-      *start_x = inset;
-      *end_x = W / 2;
-      *start_y = H / 2 - overlap;
-      *end_y = H - inset - overlap;
+      *start_x = (W - HW) / 2;
+      *end_x = HW / 2 + inset;
+      *start_y = H - HH / 2 - inset - overlap;
+      *end_y = (H + HH) / 2 - overlap;
       return (draw & D_B_L) == D_B_L && (inset + overlap) > 0;
     case DIR8_EAST:
       /* Bottom right. */
-      *start_x = W - inset;
-      *end_x = W / 2;
-      *start_y = H / 2 - overlap;
-      *end_y = H - inset - overlap;
+      *start_x = W - HW / 2 - inset;
+      *end_x = (W + HW) / 2;
+      *start_y = (H + HH) / 2 - overlap;
+      *end_y = H - HH / 2 - inset - overlap;
       return (draw & D_B_R) == D_B_R && (inset + overlap) > 0;
     case DIR8_WEST:
       /* Top left. */
-      *start_x = inset;
-      *end_x = W / 2;
-      *start_y = H / 2 + width;
-      *end_y = inset + width;
+      *start_x = HW / 2 + inset;
+      *end_x = (W - HW) / 2;
+      *start_y = (H - HH) / 2 + width;
+      *end_y = HH / 2 + inset + width;
       return (draw & D_M_L) == D_M_L;
     case DIR8_NORTHEAST:
+      *start_x = *end_x = W - HW / 2 - inset - overlap;
+      *start_y = (draw & D_M_R) ? ((H - HH) / 2) : H / 2;
+      *end_y = (draw & D_B_R) ? ((H + HH) / 2) : H / 2;
+      return HH > 0 && (draw & D_MB_R) == D_MB_R;
     case DIR8_SOUTHEAST:
+      *start_x = (draw & D_B_R) ? ((W + HW) / 2) : W / 2;
+      *end_x = (draw & D_B_L) ? ((W - HW) / 2) : W / 2;
+      *start_y = *end_y = H - HH / 2 - inset - overlap;
+      return HW > 0 && (draw & D_B_LR) == D_B_LR;
     case DIR8_SOUTHWEST:
+      *start_x = *end_x = HW / 2 + inset + width;
+      *start_y = (draw & D_B_L) ? ((H + HH) / 2) : H / 2;
+      *end_y = (draw & D_M_L) ? ((H - HH) / 2) : H / 2;
+      return HH > 0 && (draw & D_MB_L) == D_MB_L;
     case DIR8_NORTHWEST:
-      return FALSE;
+      *start_x = (draw & D_M_L) ? ((W - HW) / 2) : W / 2;
+      *end_x = (draw & D_M_R) ? ((W + HW) / 2) : W / 2;
+      *start_y = *end_y = HH / 2 + inset + width;
+      return HW > 0 && (draw & D_M_LR) == D_M_LR;
     }
   } else {
     switch (dir) {
@@ -953,7 +969,7 @@
      * we use this hack. */
     adjc_dir_iterate(map_x, map_y, adjc_x, adjc_y, dir) {
       if ((dir == DIR8_WEST || dir == DIR8_NORTHWEST
-          || dir == DIR8_NORTH || dir == DIR8_NORTHEAST)
+          || dir == DIR8_NORTH || dir == DIR8_SOUTHWEST)
          && get_tile_boundaries(dir, 0, BORDER_WIDTH, draw,
                                  &start_x, &start_y, &end_x, &end_y)
          && tile_get_known(adjc_x, adjc_y)
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.161
diff -u -r1.161 tilespec.c
--- client/tilespec.c   24 Apr 2004 07:46:52 -0000      1.161
+++ client/tilespec.c   24 Apr 2004 17:43:36 -0000
@@ -76,6 +76,7 @@
 int OVERVIEW_TILE_HEIGHT = 2;
 
 bool is_isometric;
+int hex_width, hex_height;
 
 char *city_names_font;
 char *city_productions_font_name;
@@ -635,10 +636,10 @@
   struct section_file the_file, *file = &the_file;
   char *fname, *c;
   int i;
-  int num_spec_files, num_terrains;
+  int num_spec_files, num_terrains, hex_side;
   char **spec_filenames, **terrains;
   char *file_capstr;
-  bool duplicates_ok;
+  bool duplicates_ok, is_hex;
 
   fname = tilespec_fullname(tileset_name);
   freelog(LOG_VERBOSE, "tilespec file is %s", fname);
@@ -659,6 +660,20 @@
   (void) section_file_lookup(file, "tilespec.name"); /* currently unused */
 
   is_isometric = secfile_lookup_bool_default(file, FALSE, 
"tilespec.is_isometric");
+
+  /* Read hex-tileset information. */
+  is_hex = secfile_lookup_bool_default(file, FALSE, "tilespec.is_hex");
+  hex_side = secfile_lookup_int_default(file, 0, "tilespec.hex_side");
+  hex_width = hex_height = 0;
+  if (is_hex) {
+    if (is_isometric) {
+      hex_height = hex_side;
+    } else {
+      hex_width = hex_side;
+    }
+    is_isometric = TRUE; /* Hex tilesets are drawn the same as isometric. */
+  }
+
   if (is_isometric && !isometric_view_supported()) {
     freelog(LOG_ERROR, _("Client does not support isometric tilesets."
            " Using default tileset instead."));
Index: client/tilespec.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.h,v
retrieving revision 1.62
diff -u -r1.62 tilespec.h
--- client/tilespec.h   22 Apr 2004 21:07:32 -0000      1.62
+++ client/tilespec.h   24 Apr 2004 17:43:36 -0000
@@ -284,6 +284,7 @@
 extern int OVERVIEW_TILE_HEIGHT;
 
 extern bool is_isometric;
+extern int hex_width, hex_height;
 
 /* name of font to use to draw city names on main map */
 

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