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

This patch adds a third terrain layer, and makes the blending layer
configurable.

-jason

Index: data/trident.tilespec
===================================================================
--- data/trident.tilespec	(revision 12674)
+++ data/trident.tilespec	(working copy)
@@ -2,7 +2,7 @@
 [tilespec]
 
 ; Format and options of this tilespec file:
-options = "+tilespec4.2007.Feb.18"
+options = "+tilespec4.2007.Feb.20"
 
 ; A simple name for the tileset specified by this file:
 name = "Trident"
@@ -39,6 +39,9 @@
 unit_offset_x = 0
 unit_offset_y = 0
 
+; The layer in which blending is used (see terrains below)
+blend_layer = -1
+
 ; offset the citybar text by this amount (from the city tile origin)
 citybar_offset_y = 27
 
Index: data/isophex.tilespec
===================================================================
--- data/isophex.tilespec	(revision 12674)
+++ data/isophex.tilespec	(working copy)
@@ -2,7 +2,7 @@
 [tilespec]
 
 ; Format and options of this tilespec file:
-options = "+tilespec4.2007.Feb.18"
+options = "+tilespec4.2007.Feb.20"
 
 ; A simple name for the tileset specified by this file:
 name = "isophex"
@@ -36,6 +36,9 @@
 unit_offset_x = 21
 unit_offset_y = 13
 
+; The layer in which blending is used (see terrains below)
+blend_layer = 0
+
 ; offset the citybar text by this amount (from the city tile origin)
 citybar_offset_y = 20
 
Index: data/amplio.tilespec
===================================================================
--- data/amplio.tilespec	(revision 12674)
+++ data/amplio.tilespec	(working copy)
@@ -2,7 +2,7 @@
 [tilespec]
 
 ; Format and options of this tilespec file:
-options = "+tilespec4.2007.Feb.18"
+options = "+tilespec4.2007.Feb.20"
 
 ; A simple name for the tileset specified by this file:
 name = "amplio"
@@ -40,6 +40,9 @@
 unit_offset_x = 19
 unit_offset_y = 18
 
+; The layer in which blending is used (see terrains below)
+blend_layer = 0
+
 ;Enable citybar
 is_full_citybar = 1
 ; offset the citybar text by this amount (from the city tile origin)
Index: data/isotrident.tilespec
===================================================================
--- data/isotrident.tilespec	(revision 12674)
+++ data/isotrident.tilespec	(working copy)
@@ -2,7 +2,7 @@
 [tilespec]
 
 ; Format and options of this tilespec file:
-options = "+tilespec4.2007.Feb.18"
+options = "+tilespec4.2007.Feb.20"
 
 ; A simple name for the tileset specified by this file:
 name = "MacroIsoTrident"
@@ -39,6 +39,9 @@
 unit_offset_x = 21
 unit_offset_y = 13
 
+; The layer in which blending is used (see terrains below)
+blend_layer = 0
+
 ; offset the citybar text by this amount (from the city tile origin)
 citybar_offset_y = 20
 
Index: data/hex2t.tilespec
===================================================================
--- data/hex2t.tilespec	(revision 12674)
+++ data/hex2t.tilespec	(working copy)
@@ -2,7 +2,7 @@
 [tilespec]
 
 ; Format and options of this tilespec file:
-options = "+tilespec4.2007.Feb.18"
+options = "+tilespec4.2007.Feb.20"
 
 ; A simple name for the tileset specified by this file:
 
@@ -43,6 +43,9 @@
 unit_offset_x = 4
 unit_offset_y = 57
 
+; The layer in which blending is used (see terrains below)
+blend_layer = 0
+
 ; offset the citybar text by this amount (from the city tile origin)
 
 citybar_offset_y = 48
Index: client/tilespec.c
===================================================================
--- client/tilespec.c	(revision 12674)
+++ client/tilespec.c	(working copy)
@@ -84,7 +84,7 @@
   CELL_SINGLE, CELL_RECT
 };
 
-#define MAX_NUM_LAYERS 2
+#define MAX_NUM_LAYERS 3
 
 struct terrain_drawing_data {
   char *name;
@@ -372,6 +372,8 @@
   int city_flag_offset_x, city_flag_offset_y;
   int unit_offset_x, unit_offset_y;
 
+  int blend_layer;
+
   int citybar_offset_y;
 
 #define NUM_CORNER_DIRS 4
@@ -407,7 +409,7 @@
 
 struct tileset *tileset;
 
-#define TILESPEC_CAPSTR "+tilespec4.2007.Feb.18 duplicates_ok"
+#define TILESPEC_CAPSTR "+tilespec4.2007.Feb.20 duplicates_ok"
 /*
  * Tilespec capabilities acceptable to this program:
  *
@@ -785,11 +787,9 @@
       if (draw->mine_tag) {
 	free(draw->mine_tag);
       }
-      if (draw->is_blended && t->is_isometric) {
-	for (i = 0; i < 4; i++) {
-	  if (draw->blend[i]) {
-	    free_sprite(draw->blend[i]);
-	  }
+      for (i = 0; i < 4; i++) {
+	if (draw->blend[i]) {
+	  free_sprite(draw->blend[i]);
 	}
       }
       for (i = 0; i < draw->num_layers; i++) {
@@ -1379,6 +1379,8 @@
   t->unit_offset_x = secfile_lookup_int(file, "tilespec.unit_offset_x");
   t->unit_offset_y = secfile_lookup_int(file, "tilespec.unit_offset_y");
 
+  t->blend_layer = secfile_lookup_int(file, "tilespec.blend_layer");
+
   t->citybar_offset_y
     = secfile_lookup_int(file, "tilespec.citybar_offset_y");
 
@@ -1400,7 +1402,8 @@
 
   /* Terrain layer info. */
   for (i = 0; i < MAX_NUM_LAYERS; i++) {
-    char *style = secfile_lookup_str(file, "layer%d.match_style", i);
+    char *style = secfile_lookup_str_default(file, "none",
+					     "layer%d.match_style", i);
     int j;
 
     if (mystrcasecmp(style, "full") == 0) {
@@ -2762,25 +2765,26 @@
     }
   }
 
-  if (draw->is_blended && t->is_isometric) {
+  if (t->blend_layer >= 0 && t->blend_layer < MAX_NUM_LAYERS) {
     /* Set up blending sprites. This only works in iso-view! */
     const int W = t->normal_tile_width, H = t->normal_tile_height;
     const int offsets[4][2] = {
       {W / 2, 0}, {0, H / 2}, {W / 2, H / 2}, {0, 0}
     };
     enum direction4 dir;
+    const int l = t->blend_layer;
 
-    if (draw->layer[0].base.size < 1) {
-      my_snprintf(buffer1, sizeof(buffer1), "t.l0.%s1", draw->name);
-      sprite_vector_reserve(&draw->layer[0].base, 1);
-      draw->layer[0].base.p[0]
+    if (draw->layer[l].base.size < 1) {
+      my_snprintf(buffer1, sizeof(buffer1), "t.l%d.%s1", l, draw->name);
+      sprite_vector_reserve(&draw->layer[l].base, 1);
+      draw->layer[l].base.p[0]
 	= lookup_sprite_tag_alt(t, buffer1, "", TRUE, "tile_type",
 				pterrain->name);
     }
 
     for (dir = 0; dir < 4; dir++) {
-      assert(sprite_vector_size(&draw->layer[0].base) > 0);
-      draw->blend[dir] = crop_sprite(draw->layer[0].base.p[0],
+      assert(sprite_vector_size(&draw->layer[l].base) > 0);
+      draw->blend[dir] = crop_sprite(draw->layer[l].base.p[0],
 				     offsets[dir][0], offsets[dir][1],
 				     W / 2, H / 2,
 				     t->sprites.dither_tile, 0, 0);
@@ -3459,33 +3463,31 @@
 {
   struct drawn_sprite *saved_sprs = sprs;
   struct terrain *pterrain = tile_get_terrain(ptile);
+  enum direction4 dir;
+  const int W = t->normal_tile_width, H = t->normal_tile_height;
+  const int offsets[4][2] = {
+    {W/2, 0}, {0, H / 2}, {W / 2, H / 2}, {0, 0}
+  };
 
-  if (t->is_isometric && t->sprites.terrain[pterrain->index]->is_blended) {
-    enum direction4 dir;
-    const int W = t->normal_tile_width, H = t->normal_tile_height;
-    const int offsets[4][2] = {
-      {W/2, 0}, {0, H / 2}, {W / 2, H / 2}, {0, 0}
-    };
+  /*
+   * 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 < 4; dir++) {
+    struct tile *tile1 = mapstep(ptile, DIR4_TO_DIR8[dir]);
+    struct terrain *other = tterrain_near[DIR4_TO_DIR8[dir]];
 
-    /*
-     * 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 < 4; dir++) {
-      struct tile *tile1 = mapstep(ptile, DIR4_TO_DIR8[dir]);
-      struct terrain *other = tterrain_near[DIR4_TO_DIR8[dir]];
+    if (!tile1
+	|| client_tile_get_known(tile1) == TILE_UNKNOWN
+	|| other == pterrain
+	|| !(t->sprites.terrain[pterrain->index]->is_blended
+	     || t->sprites.terrain[other->index]->is_blended)) {
+      continue;
+    }
 
-      if (!tile1
-	  || client_tile_get_known(tile1) == TILE_UNKNOWN
-	  || other == pterrain
-	  || !t->sprites.terrain[other->index]->is_blended) {
-	continue;
-      }
-
-      ADD_SPRITE(t->sprites.terrain[other->index]->blend[dir], TRUE,
-		 offsets[dir][0], offsets[dir][1]);
-    }
+    ADD_SPRITE(t->sprites.terrain[other->index]->blend[dir], TRUE,
+	       offsets[dir][0], offsets[dir][1]);
   }
 
   return sprs - saved_sprs;
@@ -3578,10 +3580,7 @@
     }
   }
 
-  if (l >= draw->num_layers) {
-    return 0;
-  }
-
+  if (l < draw->num_layers) {
   if (draw->layer[l].match_style == MATCH_NONE) {
     int count = sprite_vector_size(&draw->layer[l].base);
 
@@ -3684,9 +3683,10 @@
     }
 #undef MATCH
   }
+  }
 
   /* Add blending on top of the first layer. */
-  if (l == 0 && draw->is_blended) {
+  if (l == t->blend_layer) {
     sprs += fill_blending_sprite_array(t, sprs, ptile, tterrain_near);
   }
 
@@ -4008,12 +4008,15 @@
 
   case LAYER_TERRAIN1:
   case LAYER_TERRAIN2:
+  case LAYER_TERRAIN3:
     /* Terrain and specials.  These are drawn in multiple layers so that
      * upper layers will cover layers underneath. */
     if (ptile && !solid_bg && client_tile_get_known(ptile) != TILE_UNKNOWN) {
-      assert(MAX_NUM_LAYERS == 2);
-      sprs += fill_terrain_sprite_array(t, sprs,
-					(layer == LAYER_TERRAIN1) ? 0 : 1,
+      int l = (layer == LAYER_TERRAIN1)
+	? 0 : ((layer == LAYER_TERRAIN2) ? 1 : 2);
+
+      assert(MAX_NUM_LAYERS == 3);
+      sprs += fill_terrain_sprite_array(t, sprs, l,
 					ptile, tterrain_near);
     }
     break;
Index: client/tilespec.h
===================================================================
--- client/tilespec.h	(revision 12674)
+++ client/tilespec.h	(working copy)
@@ -69,6 +69,7 @@
   LAYER_BACKGROUND,
   LAYER_TERRAIN1,
   LAYER_TERRAIN2,
+  LAYER_TERRAIN3,
   LAYER_WATER,
   LAYER_ROADS,
   LAYER_SPECIAL1,
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to