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

This patch 'fixes' the drawing problems for amplio with deep ocean.

These problems were several.  First, as the comment says in
amplio.tilespec, drawing it like this is a hack.  We basically overlay
coast on top of the actual ocean drawing, so that in the bottom layer
ocean and deep-ocean are drawn (with an appropriate border tile) and in
the next layer up coast and deep-ocean are drawn (with an appropriate
border tile).

Two bugs kept this from working.  The first is that there is no way to
have 2 layers use the same match style for the same terrain, because the
layer number isn't a part of the sprite name.  This patch fixes that by
adding the layer number (only for these boolean-matched corner cells
though).

The second is that the layers were being reversed!  The coast has to be
drawn on *top* of the deep-ocean graphics or we always get ocean
overwriting the pretty coastlines.  To work around this (and it too is
UGLY) I added a new terrain parameter, is_reversed.  If this is set then
the 2 (or however many) layers are simply drawn in reverse order for
that terrain.

This patch has to be used with Daniel's terrain2.png (attached earlier
in the patch).  Even so there are still problems.  Because the ocean
encroaches onto the deep-ocean tiles (since ocean is only matched
against coastline, NOT against deep ocean), narrow areas of deep ocean
(often seen along the poles) look VERY bad.

Also, as a final comment, I think that ocean isn't deep enough on
average.  With a trireme in an average map you can go pretty much anywhere.

-jason

Index: data/amplio/terrain2.spec
===================================================================
--- data/amplio/terrain2.spec	(revision 12631)
+++ data/amplio/terrain2.spec	(working copy)
@@ -144,76 +144,113 @@
 tiles = { "row", "column","tag"
 
 ; ocean cell sprites.  See doc/README.graphics
- 0, 0,  "t.ocean_cell_u000"
- 0, 2,  "t.ocean_cell_u100"
- 0, 4,  "t.ocean_cell_u010"
- 0, 6,  "t.ocean_cell_u110"
- 0, 8,  "t.ocean_cell_u001"
- 0, 10, "t.ocean_cell_u101"
- 0, 12, "t.ocean_cell_u011"
- 0, 14, "t.ocean_cell_u111"
+ 0, 0,  "t.l0.ocean_cell_u000"
+ 0, 2,  "t.l0.ocean_cell_u100"
+ 0, 4,  "t.l0.ocean_cell_u010"
+ 0, 6,  "t.l0.ocean_cell_u110"
+ 0, 8,  "t.l0.ocean_cell_u001"
+ 0, 10, "t.l0.ocean_cell_u101"
+ 0, 12, "t.l0.ocean_cell_u011"
+ 0, 14, "t.l0.ocean_cell_u111"
  
- 1, 0,  "t.ocean_cell_d000"
- 1, 2,  "t.ocean_cell_d100"
- 1, 4,  "t.ocean_cell_d010"
- 1, 6,  "t.ocean_cell_d110"
- 1, 8,  "t.ocean_cell_d001"
- 1, 10, "t.ocean_cell_d101"
- 1, 12, "t.ocean_cell_d011"
- 1, 14, "t.ocean_cell_d111"
+ 1, 0,  "t.l0.ocean_cell_d000"
+ 1, 2,  "t.l0.ocean_cell_d100"
+ 1, 4,  "t.l0.ocean_cell_d010"
+ 1, 6,  "t.l0.ocean_cell_d110"
+ 1, 8,  "t.l0.ocean_cell_d001"
+ 1, 10, "t.l0.ocean_cell_d101"
+ 1, 12, "t.l0.ocean_cell_d011"
+ 1, 14, "t.l0.ocean_cell_d111"
 
- 2, 0,  "t.ocean_cell_l000"
- 2, 2,  "t.ocean_cell_l100"
- 2, 4,  "t.ocean_cell_l010"
- 2, 6,  "t.ocean_cell_l110"
- 2, 8,  "t.ocean_cell_l001"
- 2, 10, "t.ocean_cell_l101"
- 2, 12, "t.ocean_cell_l011"
- 2, 14, "t.ocean_cell_l111"
+ 2, 0,  "t.l0.ocean_cell_l000"
+ 2, 2,  "t.l0.ocean_cell_l100"
+ 2, 4,  "t.l0.ocean_cell_l010"
+ 2, 6,  "t.l0.ocean_cell_l110"
+ 2, 8,  "t.l0.ocean_cell_l001"
+ 2, 10, "t.l0.ocean_cell_l101"
+ 2, 12, "t.l0.ocean_cell_l011"
+ 2, 14, "t.l0.ocean_cell_l111"
 
- 2, 1,  "t.ocean_cell_r000"
- 2, 3,  "t.ocean_cell_r100"
- 2, 5,  "t.ocean_cell_r010"
- 2, 7,  "t.ocean_cell_r110"
- 2, 9,  "t.ocean_cell_r001"
- 2, 11, "t.ocean_cell_r101"
- 2, 13, "t.ocean_cell_r011"
- 2, 15, "t.ocean_cell_r111"
+ 2, 1,  "t.l0.ocean_cell_r000"
+ 2, 3,  "t.l0.ocean_cell_r100"
+ 2, 5,  "t.l0.ocean_cell_r010"
+ 2, 7,  "t.l0.ocean_cell_r110"
+ 2, 9,  "t.l0.ocean_cell_r001"
+ 2, 11, "t.l0.ocean_cell_r101"
+ 2, 13, "t.l0.ocean_cell_r011"
+ 2, 15, "t.l0.ocean_cell_r111"
 
+; deep ocean coasts.
+ 0, 1,  "t.l0.deep_cell_u000"
+ 6, 2,  "t.l0.deep_cell_u100"
+ 6, 4,  "t.l0.deep_cell_u010"
+ 6, 6,  "t.l0.deep_cell_u110"
+ 6, 8,  "t.l0.deep_cell_u001"
+ 6, 10, "t.l0.deep_cell_u101"
+ 6, 12, "t.l0.deep_cell_u011"
+ 6, 14, "t.l0.deep_cell_u111"
+ 
+ 0, 1,  "t.l0.deep_cell_d000"
+ 7, 2,  "t.l0.deep_cell_d100"
+ 7, 4,  "t.l0.deep_cell_d010"
+ 7, 6,  "t.l0.deep_cell_d110"
+ 7, 8,  "t.l0.deep_cell_d001"
+ 7, 10, "t.l0.deep_cell_d101"
+ 7, 12, "t.l0.deep_cell_d011"
+ 7, 14, "t.l0.deep_cell_d111"
+
+ 0, 1,  "t.l0.deep_cell_l000"
+ 8, 2,  "t.l0.deep_cell_l100"
+ 8, 4,  "t.l0.deep_cell_l010"
+ 8, 6,  "t.l0.deep_cell_l110"
+ 8, 8,  "t.l0.deep_cell_l001"
+ 8, 10, "t.l0.deep_cell_l101"
+ 8, 12, "t.l0.deep_cell_l011"
+ 8, 14, "t.l0.deep_cell_l111"
+
+ 0, 1,  "t.l0.deep_cell_r000"
+ 8, 3,  "t.l0.deep_cell_r100"
+ 8, 5,  "t.l0.deep_cell_r010"
+ 8, 7,  "t.l0.deep_cell_r110"
+ 8, 9,  "t.l0.deep_cell_r001"
+ 8, 11, "t.l0.deep_cell_r101"
+ 8, 13, "t.l0.deep_cell_r011"
+ 8, 15, "t.l0.deep_cell_r111"
+
 ; Deep Ocean sprites.
- 3, 0,  "t.deep_cell_u000"
- 3, 2,  "t.deep_cell_u100"
- 3, 4,  "t.deep_cell_u010"
- 3, 6,  "t.deep_cell_u110"
- 3, 8,  "t.deep_cell_u001"
- 3, 10, "t.deep_cell_u101"
- 3, 12, "t.deep_cell_u011"
- 3, 14, "t.deep_cell_u111"
+ 3, 0,  "t.l1.deep_cell_u000"
+ 3, 2,  "t.l1.deep_cell_u100"
+ 3, 4,  "t.l1.deep_cell_u010"
+ 3, 6,  "t.l1.deep_cell_u110"
+ 3, 8,  "t.l1.deep_cell_u001"
+ 3, 10, "t.l1.deep_cell_u101"
+ 3, 12, "t.l1.deep_cell_u011"
+ 3, 14, "t.l1.deep_cell_u111"
  
- 4, 0,  "t.deep_cell_d000"
- 4, 2,  "t.deep_cell_d100"
- 4, 4,  "t.deep_cell_d010"
- 4, 6,  "t.deep_cell_d110"
- 4, 8,  "t.deep_cell_d001"
- 4, 10, "t.deep_cell_d101"
- 4, 12, "t.deep_cell_d011"
- 4, 14, "t.deep_cell_d111"
+ 4, 0,  "t.l1.deep_cell_d000"
+ 4, 2,  "t.l1.deep_cell_d100"
+ 4, 4,  "t.l1.deep_cell_d010"
+ 4, 6,  "t.l1.deep_cell_d110"
+ 4, 8,  "t.l1.deep_cell_d001"
+ 4, 10, "t.l1.deep_cell_d101"
+ 4, 12, "t.l1.deep_cell_d011"
+ 4, 14, "t.l1.deep_cell_d111"
 
- 5, 0,  "t.deep_cell_l000"
- 5, 2,  "t.deep_cell_l100"
- 5, 4,  "t.deep_cell_l010"
- 5, 6,  "t.deep_cell_l110"
- 5, 8,  "t.deep_cell_l001"
- 5, 10, "t.deep_cell_l101"
- 5, 12, "t.deep_cell_l011"
- 5, 14, "t.deep_cell_l111"
+ 5, 0,  "t.l1.deep_cell_l000"
+ 5, 2,  "t.l1.deep_cell_l100"
+ 5, 4,  "t.l1.deep_cell_l010"
+ 5, 6,  "t.l1.deep_cell_l110"
+ 5, 8,  "t.l1.deep_cell_l001"
+ 5, 10, "t.l1.deep_cell_l101"
+ 5, 12, "t.l1.deep_cell_l011"
+ 5, 14, "t.l1.deep_cell_l111"
 
- 5, 1,  "t.deep_cell_r000"
- 5, 3,  "t.deep_cell_r100"
- 5, 5,  "t.deep_cell_r010"
- 5, 7,  "t.deep_cell_r110"
- 5, 9,  "t.deep_cell_r001"
- 5, 11, "t.deep_cell_r101"
- 5, 13, "t.deep_cell_r011"
- 5, 15, "t.deep_cell_r111"
+ 5, 1,  "t.l1.deep_cell_r000"
+ 5, 3,  "t.l1.deep_cell_r100"
+ 5, 5,  "t.l1.deep_cell_r010"
+ 5, 7,  "t.l1.deep_cell_r110"
+ 5, 9,  "t.l1.deep_cell_r001"
+ 5, 11, "t.l1.deep_cell_r101"
+ 5, 13, "t.l1.deep_cell_r011"
+ 5, 15, "t.l1.deep_cell_r111"
 }
Index: data/amplio/terrain2.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: data/amplio.tilespec
===================================================================
--- data/amplio.tilespec	(revision 12631)
+++ data/amplio.tilespec	(working copy)
@@ -167,6 +167,7 @@
 ; - There is no coast drawn beteen Deep Ocean and land tiles
 [terrain_deep]
 is_blended = 0
+is_reversed = 1
 num_layers = 2
 layer0_match_style = "bool"
 layer0_match_type  = "ocean"
Index: data/default/terrain.ruleset
===================================================================
--- data/default/terrain.ruleset	(revision 12631)
+++ data/default/terrain.ruleset	(working copy)
@@ -216,6 +216,45 @@
  work with.\
 ")
 
+[terrain_deep_ocean]
+name                 = _("Deep Ocean")
+graphic              = "deep"
+graphic_alt	     = "ocean"
+identifier	     = " "
+movement_cost        = 1
+defense_bonus        = 0
+food                 = 1
+shield               = 0
+trade                = 2
+resources            = "Fish", "Whales"
+road_trade_incr      = 0
+road_time            = 0
+irrigation_result    = "no"
+irrigation_food_incr = 0
+irrigation_time      = 0
+mining_result        = "no"
+mining_shield_incr   = 0
+mining_time          = 0
+transform_result     = "Ocean"
+transform_time       = 36
+rail_time            = 3
+airbase_time         = 3
+fortress_time        = 3
+clean_pollution_time = 3
+clean_fallout_time   = 3
+warmer_wetter_result = "no"
+warmer_drier_result  = "no"
+cooler_wetter_result = "no"
+cooler_drier_result  = "no"
+native_to            = "Sea", "Air", "Missile", "Helicopter"
+flags                = "Oceanic", "NoPollution", "UnsafeCoast", "NoCities"
+property_ocean_depth = 80
+helptext	     = _("\
+Oceans cover much of the world, and only sea units can travel on them.\
+\n\n\
+Ocean squares can never be polluted or subjected to fallout.\
+")
+
 [terrain_desert]
 name                 = _("Desert")
 graphic              = "desert"
@@ -453,7 +492,7 @@
 name                 = _("Ocean")
 graphic              = "ocean"
 graphic_alt	     = "-"
-identifier	     = " "
+identifier	     = "_"
 movement_cost        = 1
 defense_bonus        = 0
 food                 = 1
@@ -481,7 +520,7 @@
 cooler_drier_result  = "no"
 native_to            = "Sea", "Air", "Missile", "Helicopter"
 flags                = "Oceanic", "NoPollution", "UnsafeCoast", "NoCities"
-property_ocean_depth = 10
+property_ocean_depth = 30
 helptext	     = _("\
 Oceans cover much of the world, and only sea units (Triremes and\
  other boats) can travel on them.\
Index: client/tilespec.c
===================================================================
--- client/tilespec.c	(revision 12631)
+++ client/tilespec.c	(working copy)
@@ -106,6 +106,7 @@
   } layer[MAX_NUM_LAYERS];
 
   bool is_blended;
+  bool is_reversed;
   struct sprite *blend[4]; /* indexed by a direction4 */
 
   struct sprite *mine;
@@ -1444,6 +1445,9 @@
     terr->name = mystrdup(terrains[i] + strlen("terrain_"));
     terr->is_blended = secfile_lookup_bool(file, "%s.is_blended",
 					    terrains[i]);
+    terr->is_reversed = secfile_lookup_bool_default(file, FALSE,
+						    "%s.is_reversed",
+						    terrains[i]);
     terr->num_layers = secfile_lookup_int(file, "%s.num_layers",
 					  terrains[i]);
     terr->num_layers = CLIP(1, terr->num_layers, MAX_NUM_LAYERS);
@@ -2668,7 +2672,8 @@
 	      assert(0); /* Impossible. */
 	      break;
 	    case MATCH_BOOLEAN:
-	      my_snprintf(buffer1, sizeof(buffer1), "t.%s_cell_%c%d%d%d",
+	      my_snprintf(buffer1, sizeof(buffer1), "t.l%d.%s_cell_%c%d%d%d",
+			  l,
 			  draw->name, dirs[dir],
 			  (value >> 0) & 1,
 			  (value >> 1) & 1,
@@ -3539,7 +3544,7 @@
 ****************************************************************************/
 static int fill_terrain_sprite_array(struct tileset *t,
 				     struct drawn_sprite *sprs,
-				     int layer,
+				     int layer_num,
 				     const struct tile *ptile,
 				     struct terrain **tterrain_near)
 {
@@ -3547,7 +3552,7 @@
   struct sprite *sprite;
   struct terrain *pterrain = ptile->terrain;
   struct terrain_drawing_data *draw = t->sprites.terrain[pterrain->index];
-  const int l = layer;
+  const int l = (draw->is_reversed ? (draw->num_layers - layer_num - 1) : layer_num);
   int i, tileno;
   struct tile *adjc_tile;
 
@@ -3559,7 +3564,7 @@
   /* FIXME: this should avoid calling load_sprite since it's slow and
    * increases the refcount without limit. */
   if (ptile->spec_sprite && (sprite = load_sprite(t, ptile->spec_sprite))) {
-    if (layer == 0) {
+    if (l == 0) {
       ADD_SPRITE_SIMPLE(sprite);
       return 1;
     } else {
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to