Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2004:
[Freeciv-Dev] (PR#8412) full layered drawing system
Home

[Freeciv-Dev] (PR#8412) full layered drawing system

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#8412) full layered drawing system
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 28 Mar 2004 11:04:18 -0800
Reply-to: rt@xxxxxxxxxxx

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

Currently it's impossible to specify a match_type for both layers of a 
terrain.

This patch changes that.  Now each layer has its drawing method 
specified independently.  Rather than

   is_blended = 1
   is_layered = 1
   match_type = 5

you have

   is_blended = 1
   num_layers = 2
   layer0_match_type = 0
   layer1_match_type = 5

And of course each layer can have its own cell_type as well. 
Surprisingly the drawing code doesn't become any more complicated since 
the logic is now simpler and a loop can be used.  Also it's now possible 
to have more than 2 layers, although I can't think why you'd want to do 
this.

Separating the layer drawing logic is necessary for more advanced 
drawing systems.  For instance in the civ3 drawing system mountains are 
drawn as a matched single-cell mountain sprite (matched with other 
mountains and hills) on top of a matched rectangular-cell grassland 
sprite (matched against all other terrains).

Trident, isotrident, and trident_shields are all updated.  Note that 
none of them actually use matching for both layers.

jason

? Womoks
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.153
diff -u -r1.153 tilespec.c
--- client/tilespec.c   28 Mar 2004 18:33:29 -0000      1.153
+++ client/tilespec.c   28 Mar 2004 19:02:33 -0000
@@ -693,37 +693,40 @@
   for (i = 0; i < num_terrains; i++) {
     struct terrain_drawing_data *terr = fc_malloc(sizeof(*terr));
     char *cell_type;
+    int l;
 
     memset(terr, 0, sizeof(*terr));
     terr->name = mystrdup(terrains[i] + strlen("terrain_"));
     terr->is_blended = secfile_lookup_bool(file, "%s.is_blended",
                                            terrains[i]);
-    terr->is_layered = secfile_lookup_bool(file, "%s.is_layered",
-                                          terrains[i]);
-    terr->match_type = secfile_lookup_int(file, "%s.match_type",
+    terr->num_layers = secfile_lookup_int(file, "%s.num_layers",
                                          terrains[i]);
-    cell_type = secfile_lookup_str_default(file, "single", "%s.cell_type",
-                                          terrains[i]);
-    if (strcasecmp(cell_type, "single") == 0) {
-      terr->cell_type = CELL_SINGLE;
-    } else if (strcasecmp(cell_type, "rect") == 0) {
-      terr->cell_type = CELL_RECT;
-    } else {
-      freelog(LOG_ERROR, "Unknown cell type %s for %s.",
-             cell_type, terrains[i]);
-      terr->cell_type = CELL_SINGLE;
+    terr->num_layers = MAX(1, terr->num_layers);
+
+    for (l = 0; l < terr->num_layers; l++) {
+      terr->layer[l].match_type
+       = secfile_lookup_int_default(file, 0, "%s.layer%d_match_type",
+                                    terrains[i], l);
+      cell_type
+       = secfile_lookup_str_default(file, "single", "%s.layer%d_cell_type",
+                                    terrains[i], l);
+      if (strcasecmp(cell_type, "single") == 0) {
+       terr->layer[l].cell_type = CELL_SINGLE;
+      } else if (strcasecmp(cell_type, "rect") == 0) {
+       terr->layer[l].cell_type = CELL_RECT;
+      } else {
+       freelog(LOG_ERROR, "Unknown cell type %s for %s.",
+               cell_type, terrains[i]);
+       terr->layer[l].cell_type = CELL_SINGLE;
+      }
     }
+
     terr->mine_tag = secfile_lookup_str_default(file, NULL, "%s.mine_sprite",
                                                terrains[i]);
     if (terr->mine_tag) {
       terr->mine_tag = mystrdup(terr->mine_tag);
     }
 
-    if (terr->is_layered && terr->match_type == 0) {
-      freelog(LOG_FATAL, "%s is layered but has no matching type set.",
-             terr->name);
-    }
-
     if (!hash_insert(terrain_hash, terr->name, terr)) {
       die("warning: duplicate terrain entry %s.", terrains[i]);
     }
@@ -1181,7 +1184,7 @@
   struct tile_type *tt = get_tile_type(terrain);
   struct terrain_drawing_data *draw;
   char buffer1[MAX_LEN_NAME+20];
-  int i;
+  int i, l;
   
   if(tt->terrain_name[0] == '\0') {
     return;
@@ -1197,49 +1200,47 @@
     }
   }
 
-  /* Currently ocean terrains have special handling.  Although a match type
-   * may be specified it is ignored.  This is a hack. */
-  if (draw->match_type == 0 || draw->is_layered) {
-    /* Load single sprite for this terrain. */
-    my_snprintf(buffer1, sizeof(buffer1), "t.%s1", draw->name);
-    draw->base = lookup_sprite_tag_alt(buffer1, "", TRUE, "tile_type",
-                                      tt->terrain_name);
-  }
-
-  if (draw->match_type != 0) {
-    int j;
-
-    switch (draw->cell_type) {
-    case CELL_SINGLE:
-      /* Load 16 cardinally-matched sprites. */
-      for (i = 0; i < NUM_DIRECTION_NSEW; i++) {
-       my_snprintf(buffer1, sizeof(buffer1),
-                   "t.%s_%s", draw->name, nsew_str(i));
-       draw->match[i] = lookup_sprite_tag_alt(buffer1, "", TRUE,
-                                              "tile_type",
-                                              tt->terrain_name);
-      }
-      break;
-    case CELL_RECT:
-      for (i = 0; i < 4; i++) {
-       for (j = 0; j < 8; j++) {
-         char *dir2 = "udlr";
-
-         my_snprintf(buffer1, sizeof(buffer1), "t.%s_cell_%c%d",
-                     draw->name, dir2[i], j);
-         draw->cells[j][i] = lookup_sprite_tag_alt(buffer1, "", TRUE,
-                                                   "tile_type",
-                                                   tt->terrain_name);
-       }
-      }
+  /* Set up each layer of the drawing. */
+  for (l = 0; l < draw->num_layers; l++) {
+    if (draw->layer[l].match_type == 0) {
+      /* Load single sprite for this terrain. */
       my_snprintf(buffer1, sizeof(buffer1), "t.%s1", draw->name);
-      draw->base = lookup_sprite_tag_alt(buffer1, "", FALSE, "tile_type",
-                                        tt->terrain_name);
-      break;
-    }
+      draw->layer[l].base = lookup_sprite_tag_alt(buffer1, "", TRUE,
+                                                 "tile_type",
+                                                 tt->terrain_name);
+    } else {
+      int j;
 
-    if (!draw->base) {
-      draw->base = draw->match[0];
+      switch (draw->layer[l].cell_type) {
+      case CELL_SINGLE:
+       /* Load 16 cardinally-matched sprites. */
+       for (i = 0; i < NUM_DIRECTION_NSEW; i++) {
+         my_snprintf(buffer1, sizeof(buffer1),
+                     "t.%s_%s", draw->name, nsew_str(i));
+         draw->layer[l].match[i] = lookup_sprite_tag_alt(buffer1, "", TRUE,
+                                                         "tile_type",
+                                                         tt->terrain_name);
+       }
+       draw->layer[l].base = draw->layer[l].match[0];
+       break;
+      case CELL_RECT:
+       for (i = 0; i < 4; i++) {
+         for (j = 0; j < 8; j++) {
+           char *dir2 = "udlr";
+
+           my_snprintf(buffer1, sizeof(buffer1), "t.%s_cell_%c%d",
+                       draw->name, dir2[i], j);
+           draw->layer[l].cells[j][i]
+             = lookup_sprite_tag_alt(buffer1, "", TRUE, "tile_type",
+                                     tt->terrain_name);
+         }
+       }
+       my_snprintf(buffer1, sizeof(buffer1), "t.%s1", draw->name);
+       draw->layer[l].base
+         = lookup_sprite_tag_alt(buffer1, "", FALSE, "tile_type",
+                                 tt->terrain_name);
+       break;
+      }
     }
   }
 
@@ -1252,7 +1253,7 @@
     enum direction4 dir;
 
     for (dir = 0; dir < 4; dir++) {
-      draw->blend[dir] = crop_sprite(draw->base,
+      draw->blend[dir] = crop_sprite(draw->layer[0].base,
                                     offsets[dir][0], offsets[dir][1],
                                     W / 2, H / 2,
                                     sprites.dither_tile, 0, 0);
@@ -1953,71 +1954,72 @@
   struct Sprite *sprite;
   struct tile *ptile = map_get_tile(map_x, map_y);
   enum tile_terrain_type ttype = ptile->terrain;
+  struct terrain_drawing_data *draw = sprites.terrain[ttype];
+  int l;
 
   if (!draw_terrain) {
     return 0;
   }
 
+  /* Skip the normal drawing process. */
   if (ptile->spec_sprite && (sprite = load_sprite(ptile->spec_sprite))) {
-    /* Skip dithering. */
     ADD_SPRITE_SIMPLE(sprite);
     return 1;
   }
 
-  if (sprites.terrain[ttype]->match_type == 0
-      || sprites.terrain[ttype]->is_layered) {
-    ADD_SPRITE_SIMPLE(sprites.terrain[ttype]->base);
-  }
-
-  if (sprites.terrain[ttype]->is_layered) {
-    sprs += fill_blending_sprite_array(sprs, map_x, map_y, ttype_near);
-  }
-
-  if (sprites.terrain[ttype]->match_type != 0) {
-    int match_type = sprites.terrain[ttype]->match_type;
-
-#define MATCH(dir) ((sprites.terrain[ttype_near[(dir)]]->match_type) \
-                   == match_type)
-    if (sprites.terrain[ttype]->cell_type == CELL_SINGLE) {
-      int tileno;
-
-      tileno = INDEX_NSEW(MATCH(DIR8_NORTH), MATCH(DIR8_SOUTH),
-                         MATCH(DIR8_EAST), MATCH(DIR8_WEST));
-
-      ADD_SPRITE_SIMPLE(sprites.terrain[ttype]->match[tileno]);
-    } else if (sprites.terrain[ttype]->cell_type == CELL_RECT) {
-      /* Divide the tile up into four rectangular cells.  Now each of these
-       * cells covers one corner, and each is adjacent to 3 different
-       * tiles.  For each cell we pixk a sprite based upon the adjacent
-       * terrains at each of those tiles.  Thus we have 8 different sprites
-       * for each of the 4 cells (32 sprites total). */
-      const int W = NORMAL_TILE_WIDTH, H = NORMAL_TILE_HEIGHT;
-      const enum direction8 dirs[4] = {
-       DIR8_NORTHWEST, DIR8_SOUTHEAST, DIR8_SOUTHWEST, DIR8_NORTHEAST
-      };
-      const int iso_offsets[4][2] = {
-       {W / 4, 0},
-       {W / 4, H / 2},
-       {0, H / 4},
-       {W / 2, H / 4},
-      };
-      const int noniso_offsets[4][2] = {
-       {0, 0}, {W / 2, H / 2}, {0, H / 2}, {W / 2, 0}
-      };
-      int i;
-
-      /* put coasts */
-      for (i = 0; i < 4; i++) {
-       int array_index = ((!MATCH(dir_ccw(dirs[i])) ? 1 : 0)
-                          + (!MATCH(dirs[i]) ? 2 : 0)
-                          + (!MATCH(dir_cw(dirs[i])) ? 4 : 0));
-       int x = (is_isometric ? iso_offsets[i][0] : noniso_offsets[i][0]);
-       int y = (is_isometric ? iso_offsets[i][1] : noniso_offsets[i][1]);
+  for (l = 0; l < draw->num_layers; l++) {
+    if (draw->layer[l].match_type == 0) {
+      ADD_SPRITE_SIMPLE(draw->layer[l].base);
+    } else {
+      int match_type = draw->layer[l].match_type;
+
+#define MATCH(dir)                                               \
+      ((sprites.terrain[ttype_near[(dir)]]->layer[l].match_type) \
+       == match_type)
+
+      if (draw->layer[l].cell_type == CELL_SINGLE) {
+       int tileno;
+
+       tileno = INDEX_NSEW(MATCH(DIR8_NORTH), MATCH(DIR8_SOUTH),
+                           MATCH(DIR8_EAST), MATCH(DIR8_WEST));
+
+       ADD_SPRITE_SIMPLE(draw->layer[l].match[tileno]);
+      } else if (draw->layer[l].cell_type == CELL_RECT) {
+       /* Divide the tile up into four rectangular cells.  Now each of these
+        * cells covers one corner, and each is adjacent to 3 different
+        * tiles.  For each cell we pixk a sprite based upon the adjacent
+        * terrains at each of those tiles.  Thus we have 8 different sprites
+        * for each of the 4 cells (32 sprites total). */
+       const int W = NORMAL_TILE_WIDTH, H = NORMAL_TILE_HEIGHT;
+       const enum direction8 dirs[4] = {
+         DIR8_NORTHWEST, DIR8_SOUTHEAST, DIR8_SOUTHWEST, DIR8_NORTHEAST
+       };
+       const int iso_offsets[4][2] = {
+         {W / 4, 0}, {W / 4, H / 2}, {0, H / 4}, {W / 2, H / 4},
+       };
+       const int noniso_offsets[4][2] = {
+         {0, 0}, {W / 2, H / 2}, {0, H / 2}, {W / 2, 0}
+       };
+       int i;
+
+       /* put coasts */
+       for (i = 0; i < 4; i++) {
+         int array_index = ((!MATCH(dir_ccw(dirs[i])) ? 1 : 0)
+                            + (!MATCH(dirs[i]) ? 2 : 0)
+                            + (!MATCH(dir_cw(dirs[i])) ? 4 : 0));
+         int x = (is_isometric ? iso_offsets[i][0] : noniso_offsets[i][0]);
+         int y = (is_isometric ? iso_offsets[i][1] : noniso_offsets[i][1]);
 
-       ADD_SPRITE(sprites.terrain[ttype]->cells[array_index][i], x, y);
+         ADD_SPRITE(draw->layer[l].cells[array_index][i], x, y);
+       }
       }
-    }
 #undef MATCH
+    }
+
+    /* Add blending on top of the first layer. */
+    if (l == 0 && draw->is_blended) {
+      sprs += fill_blending_sprite_array(sprs, map_x, map_y, ttype_near);
+    }
   }
 
   /* Extra "capes" added on in non-iso view. */
@@ -2037,10 +2039,6 @@
     if (tileno != 0) {
       ADD_SPRITE_SIMPLE(sprites.tx.coast_cape[tileno]);
     }
-  }
-
-  if (!sprites.terrain[ttype]->is_layered) {
-    sprs += fill_blending_sprite_array(sprs, map_x, map_y, ttype_near);
   }
 
   return sprs - saved_sprs;
Index: client/tilespec.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.h,v
retrieving revision 1.57
diff -u -r1.57 tilespec.h
--- client/tilespec.h   24 Mar 2004 06:18:18 -0000      1.57
+++ client/tilespec.h   28 Mar 2004 19:02:33 -0000
@@ -102,15 +102,19 @@
   char *name;
   char *mine_tag;
 
-  bool is_blended;
-  bool is_layered;
-  int match_type;
-  enum cell_type cell_type;
+  int num_layers; /* Can only be 1 or 2. */
+  struct {
+    int match_type;
+    enum cell_type cell_type;
+
+    struct Sprite *base;
+    struct Sprite *match[NUM_DIRECTION_NSEW];
+    struct Sprite *cells[8][4]; /* 4 = up down left right */
+  } layer[2];
 
-  struct Sprite *base;
-  struct Sprite *match[NUM_DIRECTION_NSEW];
-  struct Sprite *cells[8][4]; /* 4 = up down left right */
+  bool is_blended;
   struct Sprite *blend[4]; /* indexed by a direction4 */
+
   struct Sprite *special[2];
   struct Sprite *mine;
 };
Index: data/isotrident.tilespec
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/isotrident.tilespec,v
retrieving revision 1.14
diff -u -r1.14 isotrident.tilespec
--- data/isotrident.tilespec    28 Mar 2004 18:33:29 -0000      1.14
+++ data/isotrident.tilespec    28 Mar 2004 19:02:34 -0000
@@ -63,71 +63,53 @@
 
 [terrain_arctic]
 is_blended = 1
-is_layered = 0
-match_type = 0
+num_layers = 1
 mine_sprite = "tx.oil_mine"
 
 [terrain_desert]
 is_blended = 1
-is_layered = 0
-match_type = 0
+num_layers = 1
 mine_sprite = "tx.oil_mine"
 
 [terrain_forest]
 is_blended = 1
-is_layered = 1
-match_type = 1
+num_layers = 2
+layer1_match_type = 1
 
 [terrain_grassland]
 is_blended = 1
-is_layered = 0
-match_type = 0
+num_layers = 1
 
 [terrain_hills]
 is_blended = 1
-is_layered = 1
-match_type = 2
+num_layers = 2
+layer1_match_type = 2
 mine_sprite = "tx.mine"
 
 [terrain_jungle]
 is_blended = 1
-is_layered = 0
-match_type = 0
+num_layers = 1
 
 [terrain_mountains]
 is_blended = 1
-is_layered = 1
-match_type = 3
+num_layers = 2
+layer1_match_type = 3
 mine_sprite = "tx.mine"
 
-; ocean has special handling
 [terrain_ocean]
 is_blended = 1
-is_layered = 0
-match_type = 6
-cell_type = "rect"
+num_layers = 1
+layer0_match_type = 6
+layer0_cell_type = "rect"
 
 [terrain_plains]
 is_blended = 1
-is_layered = 0
-match_type = 0
+num_layers = 1
 
 [terrain_swamp]
 is_blended = 1
-is_layered = 0
-match_type = 0
+num_layers = 1
 
 [terrain_tundra]
 is_blended = 1
-is_layered = 0
-match_type = 0
-
-[terrain_unknown]
-is_blended = 1
-is_layered = 0
-match_type = 0
-
-[terrain_t_river]
-is_blended = 1
-is_layered = 1
-match_type = 5
+num_layers = 1
Index: data/trident.tilespec
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/trident.tilespec,v
retrieving revision 1.19
diff -u -r1.19 trident.tilespec
--- data/trident.tilespec       24 Mar 2004 06:18:19 -0000      1.19
+++ data/trident.tilespec       28 Mar 2004 19:02:34 -0000
@@ -61,70 +61,59 @@
 
 [terrain_arctic]
 is_blended = 0
-is_layered = 0
-match_type = 1
+num_layers = 1
+layer0_match_type = 1
 mine_sprite = "tx.oil_mine"
 
 [terrain_desert]
 is_blended = 0
-is_layered = 0
-match_type = 2
+num_layers = 1
+layer0_match_type = 2
 mine_sprite = "tx.oil_mine"
 
 [terrain_forest]
 is_blended = 0
-is_layered = 0
-match_type = 3
+num_layers = 1
+layer0_match_type = 3
 
 [terrain_grassland]
 is_blended = 0
-is_layered = 0
-match_type = 3
+num_layers = 1
+layer0_match_type = 3
 
 [terrain_hills]
 is_blended = 0
-is_layered = 0
-match_type = 4
+num_layers = 1
+layer0_match_type = 4
 mine_sprite = "tx.mine"
 
 [terrain_jungle]
 is_blended = 0
-is_layered = 0
-match_type = 5
+num_layers = 1
+layer0_match_type = 5
 
 [terrain_mountains]
 is_blended = 0
-is_layered = 0
-match_type = 6
+num_layers = 1
+layer0_match_type = 6
 mine_sprite = "tx.mine"
 
-; ocean has special handling
 [terrain_ocean]
 is_blended = 0
-is_layered = 0
-match_type = 7
+num_layers = 1
+layer0_match_type = 7
 
 [terrain_plains]
 is_blended = 0
-is_layered = 0
-match_type = 8
+num_layers = 1
+layer0_match_type = 8
 
 [terrain_swamp]
 is_blended = 0
-is_layered = 0
-match_type = 9
+num_layers = 1
+layer0_match_type = 9
 
 [terrain_tundra]
 is_blended = 0
-is_layered = 0
-match_type = 10
-
-[terrain_unknown]
-is_blended = 0
-is_layered = 0
-match_type = 0
-
-[terrain_t_river]
-is_blended = 0
-is_layered = 0
-match_type = 7
+num_layers = 1
+layer0_match_type = 10
Index: data/trident_shields.tilespec
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/trident_shields.tilespec,v
retrieving revision 1.9
diff -u -r1.9 trident_shields.tilespec
--- data/trident_shields.tilespec       27 Feb 2004 21:24:30 -0000      1.9
+++ data/trident_shields.tilespec       28 Mar 2004 19:02:34 -0000
@@ -64,70 +64,59 @@
 
 [terrain_arctic]
 is_blended = 0
-is_layered = 0
-match_type = 1
+num_layers = 1
+layer0_match_type = 1
 mine_sprite = "tx.oil_mine"
 
 [terrain_desert]
 is_blended = 0
-is_layered = 0
-match_type = 2
+num_layers = 1
+layer0_match_type = 2
 mine_sprite = "tx.oil_mine"
 
 [terrain_forest]
 is_blended = 0
-is_layered = 0
-match_type = 3
+num_layers = 1
+layer0_match_type = 3
 
 [terrain_grassland]
 is_blended = 0
-is_layered = 0
-match_type = 3
+num_layers = 1
+layer0_match_type = 3
 
 [terrain_hills]
 is_blended = 0
-is_layered = 0
-match_type = 4
+num_layers = 1
+layer0_match_type = 4
 mine_sprite = "tx.mine"
 
 [terrain_jungle]
 is_blended = 0
-is_layered = 0
-match_type = 5
+num_layers = 1
+layer0_match_type = 5
 
 [terrain_mountains]
 is_blended = 0
-is_layered = 0
-match_type = 6
+num_layers = 1
+layer0_match_type = 6
 mine_sprite = "tx.mine"
 
-; ocean has special handling
 [terrain_ocean]
 is_blended = 0
-is_layered = 0
-match_type = 7
+num_layers = 1
+layer0_match_type = 7
 
 [terrain_plains]
 is_blended = 0
-is_layered = 0
-match_type = 8
+num_layers = 1
+layer0_match_type = 8
 
 [terrain_swamp]
 is_blended = 0
-is_layered = 0
-match_type = 9
+num_layers = 1
+layer0_match_type = 9
 
 [terrain_tundra]
 is_blended = 0
-is_layered = 0
-match_type = 10
-
-[terrain_unknown]
-is_blended = 0
-is_layered = 0
-match_type = 11
-
-[terrain_t_river]
-is_blended = 0
-is_layered = 0
-match_type = 7
+num_layers = 1
+layer0_match_type = 10
Index: doc/README.graphics
===================================================================
RCS file: /home/freeciv/CVS/freeciv/doc/README.graphics,v
retrieving revision 1.9
diff -u -r1.9 README.graphics
--- doc/README.graphics 27 Feb 2004 18:31:39 -0000      1.9
+++ doc/README.graphics 28 Mar 2004 19:02:34 -0000
@@ -120,20 +120,21 @@
   is_blended            : If set, this terrain will be blended with adjacent
                           terrains.  Blending is done civ2-style with a
                           dither mask.  Only iso-view currently supports
-                          blending.  Only the base graphic will be dithered.
+                          blending.  Only the base graphic will be blended.
+                          Blending is drawn on top of the first layer (see
+                          below).
                           The blending mask has sprite t.dither_tile.
-  is_layered            : If set, this terrain will be drawn layered.  The
-                          base sprite will be drawn underneath (possibly
-                          blended) with a matched sprite on top.  This option
-                          only makes sense if a match_type is set.  Only
-                          iso-view currently supports layering.
-  match_type            : If 0, no terrain matching will be done and the base
-                          sprite will be drawn for the terrain.  If non-zero,
-                          then terrain matching will be done.  A matched
-                          sprite will be chosen that matches all cardinally
-                          adjacent tiles whose terrain has the same
+  num_layers            : The number of layers in the terrain.  This value
+                          must be either 1 or 2.  Each layer is drawn
+                          separately.  The layerN options below control the
+                          drawing of each layer (N should be either 0 or 1).
+  layerN_match_type     : If 0 or unset, no terrain matching will be done and
+                          the base sprite will be drawn for the terrain.  If
+                          non-zero, then terrain matching will be done.  A
+                          matched sprite will be chosen that matches all
+                          cardinally adjacent tiles whose terrain has the same
                           match_type.
-  cell_type             : With traditional tilesets each tile is drawn using
+  layerN_cell_type      : With traditional tilesets each tile is drawn using
                           one sprite.  Which sprite to use may be specified
                           using a match_type, and there may be multiple layers
                           (each having one sprite).  This method corresponds
@@ -174,8 +175,8 @@
   ; t.grassland is needed; it will be drawn blended.
   [terrain_grassland]
   is_blended = 1
-  is_layered = 0
-  match_type = 0
+  num_layers = 1
+  layer0_match_type = 0
 
   ; This specifies a civ1-like mountain tile.  16 sprites
   ; t.mountains_n0s0e0w0 ... t.mountains_n1s1e1w1 are needed.  One of them
@@ -183,8 +184,8 @@
   ; has this match_type, adjacent mountains will match.
   [terrain_mountains]
   is_blended = 0
-  is_layered = 0
-  match_type = 7
+  num_layers = 1
+  layer0_match_type = 7
 
   ; This specifies a civ2-like hills tile.  A base sprite t.hills will be
   ; needed, plus 16 matching sprites.  The base sprite will be drawn,
@@ -193,11 +194,17 @@
   ; sprite).
   [terrain_hills]
   is_blended = 1
-  is_layered = 1
-  match_type = 8
-
-The exception to the above rule is the ocean terrain.  Although it should
-have an entry in the tilespec file it is drawn according to hard-coded rules.
+  num_layers = 2
+  layer0_match_type = 0
+  layer1_match_type = 8
+
+  ; This specifies a civ2-like ocean tile.  Ocean is drawn via a cell-based
+  ; system as explained above.
+  [terrain_ocean]
+  is_blended = 1
+  num_layers = 1
+  layer0_match_type = 6
+  layer0_cell_type = "rect"
 
 ----------------------------------------------------------------------
 Individual spec files:

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#8412) full layered drawing system, Jason Short <=