Complete.Org: Mailing Lists: Archives: freeciv-dev: June 2004:
[Freeciv-Dev] (PR#8897) extend tileset match_style
Home

[Freeciv-Dev] (PR#8897) extend tileset match_style

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#8897) extend tileset match_style
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 2 Jun 2004 20:10:05 -0700
Reply-to: rt@xxxxxxxxxxx

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

Currently if a terrain specifies a nonzero match_type, Freeciv assumes 
that this tileset is to be boolean matched (see doc/README.graphics for 
an explanation).  If the match_type is 0 or unset, no matching is done.

However I want to introduce a third type of matching, full matching. 
See PR#8622.  This patch is a step toward that by adding a match_style 
enumeration (currently either NONE or BOOLEAN) and some corresponding 
fields to the tileset.

jason

Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.172
diff -u -r1.172 tilespec.c
--- client/tilespec.c   1 Jun 2004 19:10:31 -0000       1.172
+++ client/tilespec.c   3 Jun 2004 03:03:18 -0000
@@ -795,6 +795,8 @@
     terr->num_layers = CLIP(1, terr->num_layers, MAX_NUM_LAYERS);
 
     for (l = 0; l < terr->num_layers; l++) {
+      char *match_style;
+
       terr->layer[l].is_tall
        = secfile_lookup_bool_default(file, FALSE, "%s.layer%d_is_tall",
                                      terrains[i], l);
@@ -804,9 +806,21 @@
       terr->layer[l].offset_y
        = secfile_lookup_int_default(file, 0, "%s.layer%d_offset_y",
                                     terrains[i], l);
-      terr->layer[l].match_type
-       = secfile_lookup_int_default(file, 0, "%s.layer%d_match_type",
-                                    terrains[i], l);
+      match_style = secfile_lookup_str_default(file, "none",
+                                              "%s.layer%d_match_style",
+                                              terrains[i], l);
+      if (mystrcasecmp(match_style, "bool") == 0) {
+       terr->layer[l].match_style = MATCH_BOOLEAN;
+      } else {
+       terr->layer[l].match_style = MATCH_NONE;
+      }
+
+      if (terr->layer[l].match_style == MATCH_BOOLEAN) {
+       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);
@@ -1331,7 +1345,7 @@
 
   /* Set up each layer of the drawing. */
   for (l = 0; l < draw->num_layers; l++) {
-    if (draw->layer[l].match_type == 0) {
+    if (draw->layer[l].match_style == MATCH_NONE) {
       /* Load single sprite for this terrain. */
       my_snprintf(buffer1, sizeof(buffer1), "t.%s1", draw->name);
       draw->layer[l].base = lookup_sprite_tag_alt(buffer1, "", TRUE,
@@ -2019,7 +2033,7 @@
   }
 
   for (l = 0; l < draw->num_layers; l++) {
-    if (draw->layer[l].match_type == 0) {
+    if (draw->layer[l].match_style == MATCH_NONE) {
       ADD_SPRITE_SIMPLE(draw->layer[l].base);
     } else {
       int match_type = draw->layer[l].match_type;
Index: client/tilespec.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.h,v
retrieving revision 1.68
diff -u -r1.68 tilespec.h
--- client/tilespec.h   1 Jun 2004 19:10:32 -0000       1.68
+++ client/tilespec.h   3 Jun 2004 03:03:18 -0000
@@ -104,6 +104,10 @@
   DIR4_NORTH = 0, DIR4_SOUTH, DIR4_EAST, DIR4_WEST
 };
 
+enum match_style {
+  MATCH_NONE, MATCH_BOOLEAN
+};
+
 enum cell_type {
   CELL_SINGLE, CELL_RECT
 };
@@ -118,7 +122,10 @@
   struct {
     bool is_tall;
     int offset_x, offset_y;
+
+    enum match_style match_style;
     int match_type;
+
     enum cell_type cell_type;
 
     struct Sprite *base;
Index: data/isotrident.tilespec
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/isotrident.tilespec,v
retrieving revision 1.16
diff -u -r1.16 isotrident.tilespec
--- data/isotrident.tilespec    1 Apr 2004 23:11:23 -0000       1.16
+++ data/isotrident.tilespec    3 Jun 2004 03:03:18 -0000
@@ -102,6 +102,7 @@
 [terrain_ocean]
 is_blended = 1
 num_layers = 1
+layer0_match_style = "bool"
 layer0_match_type = 6
 layer0_cell_type = "rect"
 
Index: data/trident.tilespec
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/trident.tilespec,v
retrieving revision 1.21
diff -u -r1.21 trident.tilespec
--- data/trident.tilespec       1 Apr 2004 23:11:23 -0000       1.21
+++ data/trident.tilespec       3 Jun 2004 03:03:18 -0000
@@ -65,58 +65,69 @@
 [terrain_arctic]
 is_blended = 0
 num_layers = 1
+layer0_match_style = "bool"
 layer0_match_type = 1
 mine_sprite = "tx.oil_mine"
 
 [terrain_desert]
 is_blended = 0
 num_layers = 1
+layer0_match_style = "bool"
 layer0_match_type = 2
 mine_sprite = "tx.oil_mine"
 
 [terrain_forest]
 is_blended = 0
 num_layers = 1
+layer0_match_style = "bool"
 layer0_match_type = 3
 
 [terrain_grassland]
 is_blended = 0
 num_layers = 1
+layer0_match_style = "bool"
 layer0_match_type = 3
 
 [terrain_hills]
 is_blended = 0
 num_layers = 1
+layer0_match_style = "bool"
 layer0_match_type = 4
 mine_sprite = "tx.mine"
 
 [terrain_jungle]
 is_blended = 0
 num_layers = 1
+layer0_match_style = "bool"
 layer0_match_type = 5
 
 [terrain_mountains]
 is_blended = 0
 num_layers = 1
+layer0_match_style = "bool"
 layer0_match_type = 6
 mine_sprite = "tx.mine"
 
 [terrain_ocean]
 is_blended = 0
 num_layers = 1
+layer0_match_style = "bool"
 layer0_match_type = 7
 
 [terrain_plains]
 is_blended = 0
 num_layers = 1
+layer0_match_style = "bool"
 layer0_match_type = 8
 
 [terrain_swamp]
 is_blended = 0
 num_layers = 1
+layer0_match_style = "bool"
 layer0_match_type = 9
 
 [terrain_tundra]
 is_blended = 0
 num_layers = 1
+layer0_match_style = "bool"
 layer0_match_type = 10

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#8897) extend tileset match_style, Jason Short <=