Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2005:
[Freeciv-Dev] (PR#12109) corner fog graphics
Home

[Freeciv-Dev] (PR#12109) corner fog graphics

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12109) corner fog graphics
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 5 Feb 2005 15:43:25 -0800
Reply-to: bugs@xxxxxxxxxxx

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

> [jdorje - Sat Feb 05 23:41:03 2005]:
> 
> Here's a new patch.  I think this is ready for inclusion.


? blend.png
? fog
? fog.c
? fog.png
? foo
? terrain1.png
? data/isotrident/fog.png
? data/trident/fog.png
? po/en.po
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.230
diff -u -r1.230 tilespec.c
--- client/tilespec.c   5 Feb 2005 19:26:38 -0000       1.230
+++ client/tilespec.c   5 Feb 2005 23:37:50 -0000
@@ -118,7 +118,10 @@
 
   /* 15=2^4-1 sprites.  A single sprite is drawn, chosen based on whether
    * there's darkness in _each_ of the cardinal directions. */
-  DARKNESS_CARD_FULL = 3
+  DARKNESS_CARD_FULL = 3,
+
+  /* Corner darkness & fog.  3^4 = 81 sprites. */
+  DARKNESS_CORNER = 4
 } darkness_style;
 
 struct specfile;
@@ -872,7 +875,7 @@
                                 "tilespec.fogstyle");
   darkness_style = secfile_lookup_int(file, "tilespec.darkness_style");
   if (darkness_style < DARKNESS_NONE
-      || darkness_style > DARKNESS_CARD_FULL
+      || darkness_style > DARKNESS_CORNER
       || (darkness_style == DARKNESS_ISORECT
          && (!is_isometric || hex_width > 0 || hex_height > 0))) {
     freelog(LOG_FATAL, _("Invalid darkness style set in tileset."));
@@ -1512,6 +1515,26 @@
       SET_SPRITE(tx.darkness[i], buffer);
     }
     break;
+  case DARKNESS_CORNER:
+    sprites.tx.fullfog = fc_realloc(sprites.tx.fullfog,
+                                   81 * sizeof(*sprites.tx.fullfog));
+    for (i = 0; i < 81; i++) {
+      /* Unknown, fog, known. */
+      char ids[] = {'u', 'f', 'k'};
+      char buf[512] = "t.fog";
+      int values[4], j, k = i;
+
+      for (j = 0; j < 4; j++) {
+       values[j] = k % 3;
+       k /= 3;
+
+       cat_snprintf(buf, sizeof(buf), "_%c", ids[values[j]]);
+      }
+      assert(k == 0);
+
+      sprites.tx.fullfog[i] = load_sprite(buf);
+    }
+    break;
   }
 
   for(i=0; i<4; i++) {
@@ -2474,6 +2497,57 @@
 }
 
 /****************************************************************************
+  Add sprites for fog (and some forms of darkness).
+****************************************************************************/
+static int fill_fog_sprite_array(struct drawn_sprite *sprs,
+                                const struct tile *ptile,
+                                const struct tile_edge *pedge,
+                                const struct tile_corner *pcorner)
+{
+  struct drawn_sprite *saved_sprs = sprs;
+
+  if (fogstyle == FOG_SPRITE && draw_fog_of_war
+      && ptile && tile_get_known(ptile) == TILE_KNOWN_FOGGED) {
+    /* With FOG_AUTO, fog is done this way. */
+    ADD_SPRITE_SIMPLE(sprites.tx.fog);
+  }
+
+  if (darkness_style == DARKNESS_CORNER && pcorner && draw_fog_of_war) {
+    int i, tileno = 0;
+
+    for (i = 3; i >= 0; i--) {
+      const int unknown = 0, fogged = 1, known = 2;
+      int value = -1;
+
+      if (!pcorner->tile[i]) {
+       value = known;
+      } else {
+       switch (tile_get_known(pcorner->tile[i])) {
+       case TILE_KNOWN:
+         value = known;
+         break;
+       case TILE_KNOWN_FOGGED:
+         value = fogged;
+         break;
+       case TILE_UNKNOWN:
+         value = unknown;
+         break;
+       }
+      }
+      assert(value >= 0 && value < 3);
+
+      tileno = tileno * 3 + value;
+    }
+
+    if (sprites.tx.fullfog[tileno]) {
+      ADD_SPRITE_SIMPLE(sprites.tx.fullfog[tileno]);
+    }
+  }
+
+  return sprs - saved_sprs;
+}
+
+/****************************************************************************
   Add sprites for the base terrain to the sprite list.  This doesn't
   include specials or rivers.
 ****************************************************************************/
@@ -2650,6 +2724,9 @@
        ADD_SPRITE_SIMPLE(sprites.tx.darkness[tileno]);
       }
       break;
+    case DARKNESS_CORNER:
+      /* Handled separately. */
+      break;
     }
 #undef UNKNOWN
   }
@@ -2836,11 +2913,7 @@
     break;
 
   case LAYER_FOG:
-    if (fogstyle == FOG_SPRITE && draw_fog_of_war
-       && ptile && tile_get_known(ptile) == TILE_KNOWN_FOGGED) {
-      /* With FOG_SPRITE, fog is done this way. */
-      ADD_SPRITE_SIMPLE(sprites.tx.fog);
-    }
+    sprs += fill_fog_sprite_array(sprs, ptile, pedge, pcorner);
     break;
 
   case LAYER_CITY2:
Index: client/tilespec.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.h,v
retrieving revision 1.100
diff -u -r1.100 tilespec.h
--- client/tilespec.h   5 Feb 2005 19:26:38 -0000       1.100
+++ client/tilespec.h   5 Feb 2005 23:37:50 -0000
@@ -309,6 +309,7 @@
       *airbase,
       *fallout,
       *fog,
+      **fullfog,
       *spec_river[MAX_INDEX_CARDINAL],
       *darkness[MAX_INDEX_CARDINAL],         /* first unused */
       *river_outlet[4];                /* indexed by enum direction4 */
Index: data/isotrident.tilespec
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/isotrident.tilespec,v
retrieving revision 1.26
diff -u -r1.26 isotrident.tilespec
--- data/isotrident.tilespec    3 Feb 2005 19:28:41 -0000       1.26
+++ data/isotrident.tilespec    5 Feb 2005 23:37:50 -0000
@@ -22,10 +22,10 @@
 roadstyle = 0
 
 ; Use fogstyle  (old iso style)
-fogstyle = 0
+fogstyle = 2
 
 ; Use darkness style 1 (single-sprite)
-darkness_style = 1
+darkness_style = 4
  
 ; offset the flags by this amount when drawing units
 flag_offset_x = 17
@@ -62,6 +62,7 @@
   "misc/space.spec",
 ;  "misc/techs.spec",
   "misc/treaty.spec",
+  "isotrident/fog.spec",
   "isotrident/nuke.spec",
   "isotrident/cities.spec",
   "isotrident/morecities.spec"
Index: data/trident.tilespec
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/trident.tilespec,v
retrieving revision 1.28
diff -u -r1.28 trident.tilespec
--- data/trident.tilespec       25 Dec 2004 19:50:29 -0000      1.28
+++ data/trident.tilespec       5 Feb 2005 23:37:50 -0000
@@ -22,10 +22,10 @@
 roadstyle = 1
 
 ; Use fogstyle 0 (old iso style)
-fogstyle = 0
+fogstyle = 2
 
 ; Use darkness style 3 (15 sprites)
-darkness_style = 3
+darkness_style = 4
  
 ; offset the flags by this amount when drawing units
 flag_offset_x = 0
@@ -56,6 +56,7 @@
   "misc/space.spec",
 ;  "misc/techs.spec",
   "misc/treaty.spec",
+  "trident/fog.spec",
   "trident/cities.spec",
   "trident/explosions.spec"
 
Index: data/isotrident/Makefile.am
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/isotrident/Makefile.am,v
retrieving revision 1.6
diff -u -r1.6 Makefile.am
--- data/isotrident/Makefile.am 3 Feb 2005 19:28:41 -0000       1.6
+++ data/isotrident/Makefile.am 5 Feb 2005 23:37:50 -0000
@@ -6,6 +6,8 @@
 pkgdata_DATA =          \
        cities.png      \
        cities.spec     \
+       fog.png         \
+       fog.spec        \
        morecities.png  \
        morecities.spec \
        nuke.spec       \
Index: data/isotrident/fog.spec
===================================================================
RCS file: data/isotrident/fog.spec
diff -N data/isotrident/fog.spec
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ data/isotrident/fog.spec    5 Feb 2005 23:37:50 -0000
@@ -0,0 +1,101 @@
+[spec]
+
+options = "+spec3"
+
+artists = "unknown"
+
+[file]
+gfx = "isotrident/fog"
+
+[grid_main]
+
+x_top_left = 0
+y_top_left = 0
+dx = 64
+dy = 32
+is_pixel_border = 0
+
+tiles = { "row", "column", "tag"
+
+  0, 0, "t.fog_u_u_u_u"
+  0, 1, "t.fog_f_u_u_u"
+  0, 2, "t.fog_k_u_u_u"
+  0, 3, "t.fog_u_u_u_f"
+  0, 4, "t.fog_f_u_u_f"
+  0, 5, "t.fog_k_u_u_f"
+  0, 6, "t.fog_u_u_u_k"
+  0, 7, "t.fog_f_u_u_k"
+  0, 8, "t.fog_k_u_u_k"
+  1, 0, "t.fog_u_f_u_u"
+  1, 1, "t.fog_f_f_u_u"
+  1, 2, "t.fog_k_f_u_u"
+  1, 3, "t.fog_u_f_u_f"
+  1, 4, "t.fog_f_f_u_f"
+  1, 5, "t.fog_k_f_u_f"
+  1, 6, "t.fog_u_f_u_k"
+  1, 7, "t.fog_f_f_u_k"
+  1, 8, "t.fog_k_f_u_k"
+  2, 0, "t.fog_u_k_u_u"
+  2, 1, "t.fog_f_k_u_u"
+  2, 2, "t.fog_k_k_u_u"
+  2, 3, "t.fog_u_k_u_f"
+  2, 4, "t.fog_f_k_u_f"
+  2, 5, "t.fog_k_k_u_f"
+  2, 6, "t.fog_u_k_u_k"
+  2, 7, "t.fog_f_k_u_k"
+  2, 8, "t.fog_k_k_u_k"
+  3, 0, "t.fog_u_u_f_u"
+  3, 1, "t.fog_f_u_f_u"
+  3, 2, "t.fog_k_u_f_u"
+  3, 3, "t.fog_u_u_f_f"
+  3, 4, "t.fog_f_u_f_f"
+  3, 5, "t.fog_k_u_f_f"
+  3, 6, "t.fog_u_u_f_k"
+  3, 7, "t.fog_f_u_f_k"
+  3, 8, "t.fog_k_u_f_k"
+  4, 0, "t.fog_u_f_f_u"
+  4, 1, "t.fog_f_f_f_u"
+  4, 2, "t.fog_k_f_f_u"
+  4, 3, "t.fog_u_f_f_f"
+  4, 4, "t.fog_f_f_f_f"
+  4, 5, "t.fog_k_f_f_f"
+  4, 6, "t.fog_u_f_f_k"
+  4, 7, "t.fog_f_f_f_k"
+  4, 8, "t.fog_k_f_f_k"
+  5, 0, "t.fog_u_k_f_u"
+  5, 1, "t.fog_f_k_f_u"
+  5, 2, "t.fog_k_k_f_u"
+  5, 3, "t.fog_u_k_f_f"
+  5, 4, "t.fog_f_k_f_f"
+  5, 5, "t.fog_k_k_f_f"
+  5, 6, "t.fog_u_k_f_k"
+  5, 7, "t.fog_f_k_f_k"
+  5, 8, "t.fog_k_k_f_k"
+  6, 0, "t.fog_u_u_k_u"
+  6, 1, "t.fog_f_u_k_u"
+  6, 2, "t.fog_k_u_k_u"
+  6, 3, "t.fog_u_u_k_f"
+  6, 4, "t.fog_f_u_k_f"
+  6, 5, "t.fog_k_u_k_f"
+  6, 6, "t.fog_u_u_k_k"
+  6, 7, "t.fog_f_u_k_k"
+  6, 8, "t.fog_k_u_k_k"
+  7, 0, "t.fog_u_f_k_u"
+  7, 1, "t.fog_f_f_k_u"
+  7, 2, "t.fog_k_f_k_u"
+  7, 3, "t.fog_u_f_k_f"
+  7, 4, "t.fog_f_f_k_f"
+  7, 5, "t.fog_k_f_k_f"
+  7, 6, "t.fog_u_f_k_k"
+  7, 7, "t.fog_f_f_k_k"
+  7, 8, "t.fog_k_f_k_k"
+  8, 0, "t.fog_u_k_k_u"
+  8, 1, "t.fog_f_k_k_u"
+  8, 2, "t.fog_k_k_k_u"
+  8, 3, "t.fog_u_k_k_f"
+  8, 4, "t.fog_f_k_k_f"
+  8, 5, "t.fog_k_k_k_f"
+  8, 6, "t.fog_u_k_k_k"
+  8, 7, "t.fog_f_k_k_k"
+  8, 8, "t.fog_k_k_k_k"
+}
Index: data/trident/Makefile.am
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/trident/Makefile.am,v
retrieving revision 1.8
diff -u -r1.8 Makefile.am
--- data/trident/Makefile.am    27 Feb 2004 00:14:01 -0000      1.8
+++ data/trident/Makefile.am    5 Feb 2005 23:37:50 -0000
@@ -9,6 +9,8 @@
        cities.spec     \
        explosions.png  \
        explosions.spec \
+       fog.png         \
+       fog.spec        \
        roads.png       \
        roads.spec      \
        tiles.png       \
Index: data/trident/fog.spec
===================================================================
RCS file: data/trident/fog.spec
diff -N data/trident/fog.spec
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ data/trident/fog.spec       5 Feb 2005 23:37:50 -0000
@@ -0,0 +1,101 @@
+[spec]
+
+options = "+spec3"
+
+artists = "unknown"
+
+[file]
+gfx = "trident/fog"
+
+[grid_main]
+
+x_top_left = 0
+y_top_left = 0
+dx = 30
+dy = 30
+is_pixel_border = 0
+
+tiles = { "row", "column", "tag"
+
+  0, 0, "t.fog_u_u_u_u"
+  0, 1, "t.fog_f_u_u_u"
+  0, 2, "t.fog_k_u_u_u"
+  0, 3, "t.fog_u_u_u_f"
+  0, 4, "t.fog_f_u_u_f"
+  0, 5, "t.fog_k_u_u_f"
+  0, 6, "t.fog_u_u_u_k"
+  0, 7, "t.fog_f_u_u_k"
+  0, 8, "t.fog_k_u_u_k"
+  1, 0, "t.fog_u_f_u_u"
+  1, 1, "t.fog_f_f_u_u"
+  1, 2, "t.fog_k_f_u_u"
+  1, 3, "t.fog_u_f_u_f"
+  1, 4, "t.fog_f_f_u_f"
+  1, 5, "t.fog_k_f_u_f"
+  1, 6, "t.fog_u_f_u_k"
+  1, 7, "t.fog_f_f_u_k"
+  1, 8, "t.fog_k_f_u_k"
+  2, 0, "t.fog_u_k_u_u"
+  2, 1, "t.fog_f_k_u_u"
+  2, 2, "t.fog_k_k_u_u"
+  2, 3, "t.fog_u_k_u_f"
+  2, 4, "t.fog_f_k_u_f"
+  2, 5, "t.fog_k_k_u_f"
+  2, 6, "t.fog_u_k_u_k"
+  2, 7, "t.fog_f_k_u_k"
+  2, 8, "t.fog_k_k_u_k"
+  3, 0, "t.fog_u_u_f_u"
+  3, 1, "t.fog_f_u_f_u"
+  3, 2, "t.fog_k_u_f_u"
+  3, 3, "t.fog_u_u_f_f"
+  3, 4, "t.fog_f_u_f_f"
+  3, 5, "t.fog_k_u_f_f"
+  3, 6, "t.fog_u_u_f_k"
+  3, 7, "t.fog_f_u_f_k"
+  3, 8, "t.fog_k_u_f_k"
+  4, 0, "t.fog_u_f_f_u"
+  4, 1, "t.fog_f_f_f_u"
+  4, 2, "t.fog_k_f_f_u"
+  4, 3, "t.fog_u_f_f_f"
+  4, 4, "t.fog_f_f_f_f"
+  4, 5, "t.fog_k_f_f_f"
+  4, 6, "t.fog_u_f_f_k"
+  4, 7, "t.fog_f_f_f_k"
+  4, 8, "t.fog_k_f_f_k"
+  5, 0, "t.fog_u_k_f_u"
+  5, 1, "t.fog_f_k_f_u"
+  5, 2, "t.fog_k_k_f_u"
+  5, 3, "t.fog_u_k_f_f"
+  5, 4, "t.fog_f_k_f_f"
+  5, 5, "t.fog_k_k_f_f"
+  5, 6, "t.fog_u_k_f_k"
+  5, 7, "t.fog_f_k_f_k"
+  5, 8, "t.fog_k_k_f_k"
+  6, 0, "t.fog_u_u_k_u"
+  6, 1, "t.fog_f_u_k_u"
+  6, 2, "t.fog_k_u_k_u"
+  6, 3, "t.fog_u_u_k_f"
+  6, 4, "t.fog_f_u_k_f"
+  6, 5, "t.fog_k_u_k_f"
+  6, 6, "t.fog_u_u_k_k"
+  6, 7, "t.fog_f_u_k_k"
+  6, 8, "t.fog_k_u_k_k"
+  7, 0, "t.fog_u_f_k_u"
+  7, 1, "t.fog_f_f_k_u"
+  7, 2, "t.fog_k_f_k_u"
+  7, 3, "t.fog_u_f_k_f"
+  7, 4, "t.fog_f_f_k_f"
+  7, 5, "t.fog_k_f_k_f"
+  7, 6, "t.fog_u_f_k_k"
+  7, 7, "t.fog_f_f_k_k"
+  7, 8, "t.fog_k_f_k_k"
+  8, 0, "t.fog_u_k_k_u"
+  8, 1, "t.fog_f_k_k_u"
+  8, 2, "t.fog_k_k_k_u"
+  8, 3, "t.fog_u_k_k_f"
+  8, 4, "t.fog_f_k_k_f"
+  8, 5, "t.fog_k_k_k_f"
+  8, 6, "t.fog_u_k_k_k"
+  8, 7, "t.fog_f_k_k_k"
+  8, 8, "t.fog_k_k_k_k"
+}

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