Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2004:
[Freeciv-Dev] (PR#8128) don't do darkness via dithering
Home

[Freeciv-Dev] (PR#8128) don't do darkness via dithering

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#8128) don't do darkness via dithering
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 16 Mar 2004 13:37:28 -0800
Reply-to: rt@xxxxxxxxxxx

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

In iso-view darkness (the encroaching darkness near the edge of the 
known map) is done in the same way as dithering (aka blending).  This is 
a problem because I want to do dithering in a simpler way (see PR#7612) 
which would mean darkness would have to be special-cased in a very ugly 
way (see the PR#7612 patch).

My solution is to split darkness off into its own special case first. 
The tileset specifies tx.darkness which is then split up into the 4 
darkness sprites.  These sprites are then drawn directly rather than 
using the dithering algorithm.

In future it should be possible to use either the non-iso-view or the 
iso-view algorithm to do dithering.  The non-iso-view algorithm is 
better but requires more sprites.

jason

Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.149
diff -u -r1.149 tilespec.c
--- client/tilespec.c   9 Mar 2004 19:10:40 -0000       1.149
+++ client/tilespec.c   16 Mar 2004 21:33:15 -0000
@@ -1055,6 +1055,20 @@
       my_snprintf(buffer, sizeof(buffer), "tx.coast_cape_%s", nsew_str(i));
       SET_SPRITE(tx.coast_cape[i], buffer);
     }
+  } else {
+    /* Isometric: take a single tx.darkness tile and split it into 4. */
+    struct Sprite *darkness = load_sprite("tx.darkness");
+    const int W = NORMAL_TILE_WIDTH, H = NORMAL_TILE_HEIGHT;
+    int offsets[4][2] = {{W / 2, 0}, {0, H / 2}, {W / 2, H / 2}, {0, 0}};
+
+    if (!darkness) {
+      die("Sprite tag darkness missing.");
+    }
+
+    for (i = 0; i < 4; i++) {
+      sprites.tx.darkness[i] = crop_sprite(darkness, offsets[i][0],
+                                          offsets[i][1], W / 2, H / 2);
+    }
   }
 
   for(i=0; i<4; i++) {
@@ -1585,7 +1599,7 @@
 static struct Sprite *get_dither(int ttype, int ttype_other)
 {
   if (ttype_other == T_UNKNOWN)
-    return sprites.black_tile;
+    return NULL;
 
   if (!sprites.terrain[ttype]->is_blended) {
     return NULL;
@@ -2113,6 +2127,19 @@
       else
         other = ttype_near[dir];
       dither[dir] = get_dither(ttype, other);
+    }
+  }
+
+  /* Add darkness sprites. */
+  for (dir = 0; dir < 4; dir++) {
+    int x1, y1;
+    const int W = NORMAL_TILE_WIDTH, H = NORMAL_TILE_HEIGHT;
+    int offsets[4][2] = {{W / 2, 0}, {0, H / 2}, {W / 2, H / 2}, {0, 0}};
+
+    if (MAPSTEP(x1, y1, x, y, DIR4_TO_DIR8[dir])
+       && tile_get_known(x1, y1) == TILE_UNKNOWN) {
+      ADD_SPRITE(sprites.tx.darkness[dir],
+                offsets[dir][0], offsets[dir][1]);
     }
   }
 
Index: data/isotrident/terrain1.spec
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/isotrident/terrain1.spec,v
retrieving revision 1.2
diff -u -r1.2 terrain1.spec
--- data/isotrident/terrain1.spec       17 Feb 2004 04:53:00 -0000      1.2
+++ data/isotrident/terrain1.spec       16 Mar 2004 21:33:16 -0000
@@ -133,6 +133,7 @@
 
 tiles = { "row", "column","tag"
   0, 0, "t.dither_tile"
+  0, 0, "tx.darkness"
   0, 1, "tx.fog"
   0, 2, "t.black_tile"
   0, 3, "t.coast_color"

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