Author: cazfi
Date: Thu Nov 20 22:11:23 2014
New Revision: 27090

URL: http://svn.gna.org/viewcvs/freeciv?rev=27090&view=rev
Log:
Replaced magic number darkness_style with textual definition in tilesets.

See patch #5434

Modified:
    trunk/client/tilespec.c
    trunk/client/tilespec.h
    trunk/data/amplio.tilespec
    trunk/data/amplio2.tilespec
    trunk/data/cimpletoon.tilespec
    trunk/data/hex2t.tilespec
    trunk/data/hexemplio.tilespec
    trunk/data/isophex.tilespec
    trunk/data/isotrident.tilespec
    trunk/data/toonhex.tilespec
    trunk/data/trident.tilespec
    trunk/doc/README.graphics

Modified: trunk/client/tilespec.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/tilespec.c?rev=27090&r1=27089&r2=27090&view=diff
==============================================================================
--- trunk/client/tilespec.c     (original)
+++ trunk/client/tilespec.c     Thu Nov 20 22:11:23 2014
@@ -383,27 +383,6 @@
   struct drawing_data *drawing[MAX_NUM_ITEMS];
 };
 
-/* Darkness style.  Don't reorder this enum since tilesets depend on it. */
-enum darkness_style {
-  /* No darkness sprites are drawn. */
-  DARKNESS_NONE = 0,
-
-  /* 1 sprite that is split into 4 parts and treated as a darkness4.  Only
-   * works in iso-view. */
-  DARKNESS_ISORECT = 1,
-
-  /* 4 sprites, one per direction.  More than one sprite per tile may be
-   * drawn. */
-  DARKNESS_CARD_SINGLE = 2,
-
-  /* 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,
-
-  /* Corner darkness & fog.  3^4 = 81 sprites. */
-  DARKNESS_CORNER = 4
-};
-
 struct specfile {
   struct sprite *big_sprite;
   char *file_name;
@@ -1521,7 +1500,6 @@
   enum direction8 dir;
   const int spl = strlen(TILE_SECTION_PREFIX);
   struct tileset *t = NULL;
-  int ei2;
   const char *extraname;
   const char *tstr;
 
@@ -1665,23 +1643,24 @@
 
   t->fogstyle = fog_style_by_name(tstr, fc_strcasecmp);
   if (!fog_style_is_valid(t->fogstyle)) {
-    log_error("Tileset \"%s\": unknown fogstyle \"%s\"", t->name, tstr);
+    log_error("Tileset \"%s\": unknown fog_style \"%s\"", t->name, tstr);
     goto ON_ERROR;
   }
 
-  /* FIXME: use specenum to load this. */
-  if (!secfile_lookup_int(file, &ei2,
-                             "tilespec.darkness_style")) {
-    log_error("Tileset \"%s\" invalid darkness_style: %s", t->name, 
secfile_error());
+  tstr = secfile_lookup_str(file, "tilespec.darkness_style");
+  if (tstr == NULL) {
+    log_error("Tileset \"%s\": no darkness_style", t->name);
     goto ON_ERROR;
   }
 
-  t->darkness_style = ei2;
-
-  if (t->darkness_style < DARKNESS_NONE
-      || t->darkness_style > DARKNESS_CORNER
-      || (t->darkness_style == DARKNESS_ISORECT
-          && (t->type == TS_OVERHEAD || t->hex_width > 0 || t->hex_height > 
0))) {
+  t->darkness_style = darkness_style_by_name(tstr, fc_strcasecmp);
+  if (!darkness_style_is_valid(t->darkness_style)) {
+    log_error("Tileset \"%s\": unknown darkness_style \"%s\"", t->name, tstr);
+    goto ON_ERROR;
+  }
+
+  if (t->darkness_style == DARKNESS_ISORECT
+      && (t->type == TS_OVERHEAD || t->hex_width > 0 || t->hex_height > 0)) {
     log_error("Invalid darkness style set in tileset \"%s\".", t->name);
     goto ON_ERROR;
   }

Modified: trunk/client/tilespec.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/tilespec.h?rev=27090&r1=27089&r2=27090&view=diff
==============================================================================
--- trunk/client/tilespec.h     (original)
+++ trunk/client/tilespec.h     Thu Nov 20 22:11:23 2014
@@ -61,6 +61,27 @@
 /* No fog, or fog derived from darkness style. */
 #define SPECENUM_VALUE2 FOG_DARKNESS
 #define SPECENUM_VALUE2NAME "Darkness"
+#include "specenum_gen.h"
+
+#define SPECENUM_NAME darkness_style
+/* No darkness sprites are drawn. */
+#define SPECENUM_VALUE0 DARKNESS_NONE
+#define SPECENUM_VALUE0NAME "None"
+/* 1 sprite that is split into 4 parts and treated as a darkness4.  Only
+ * works in iso-view. */
+#define SPECENUM_VALUE1 DARKNESS_ISORECT
+#define SPECENUM_VALUE1NAME "IsoRect"
+/* 4 sprites, one per direction.  More than one sprite per tile may be
+ * drawn. */
+#define SPECENUM_VALUE2 DARKNESS_CARD_SINGLE
+#define SPECENUM_VALUE2NAME "CardinalSingle"
+/* 15=2^4-1 sprites.  A single sprite is drawn, chosen based on whether
+ * there's darkness in _each_ of the cardinal directions. */
+#define SPECENUM_VALUE3 DARKNESS_CARD_FULL
+#define SPECENUM_VALUE3NAME "CardinalFull"
+/* Corner darkness & fog.  3^4 = 81 sprites. */
+#define SPECENUM_VALUE4 DARKNESS_CORNER
+#define SPECENUM_VALUE4NAME "Corner"
 #include "specenum_gen.h"
 
 /* An edge is the border between two tiles.  This structure represents one

Modified: trunk/data/amplio.tilespec
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/amplio.tilespec?rev=27090&r1=27089&r2=27090&view=diff
==============================================================================
--- trunk/data/amplio.tilespec  (original)
+++ trunk/data/amplio.tilespec  Thu Nov 20 22:11:23 2014
@@ -23,7 +23,7 @@
 
 ; Blended fog
 fog_style      = "Darkness"
-darkness_style = 4
+darkness_style = "Corner"
 ; Which terrain layer darkness is drawn top of (0-2)
 darkness_layer = 0
 

Modified: trunk/data/amplio2.tilespec
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/amplio2.tilespec?rev=27090&r1=27089&r2=27090&view=diff
==============================================================================
--- trunk/data/amplio2.tilespec (original)
+++ trunk/data/amplio2.tilespec Thu Nov 20 22:11:23 2014
@@ -23,7 +23,7 @@
 
 ; Blended fog
 fog_style      = "Darkness"
-darkness_style = 4
+darkness_style = "Corner"
 ; Which terrain layer darkness is drawn top of (0-2)
 darkness_layer = 0
 

Modified: trunk/data/cimpletoon.tilespec
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/cimpletoon.tilespec?rev=27090&r1=27089&r2=27090&view=diff
==============================================================================
--- trunk/data/cimpletoon.tilespec      (original)
+++ trunk/data/cimpletoon.tilespec      Thu Nov 20 22:11:23 2014
@@ -23,7 +23,7 @@
 
 ; Blended fog
 fog_style      = "Darkness"
-darkness_style = 4
+darkness_style = "Corner"
 ; Which terrain layer darkness is drawn top of (0-2)
 darkness_layer = 0
  

Modified: trunk/data/hex2t.tilespec
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/hex2t.tilespec?rev=27090&r1=27089&r2=27090&view=diff
==============================================================================
--- trunk/data/hex2t.tilespec   (original)
+++ trunk/data/hex2t.tilespec   Thu Nov 20 22:11:23 2014
@@ -25,8 +25,8 @@
 ; Use old iso style
 fog_style      = "Auto"
 
-; Was darkness style 1 (single-sprite)
-darkness_style = 2
+; Was darkness style "IsoRect" (single-sprite)
+darkness_style = "CardinalSingle"
 ; Which terrain layer darkness is drawn top of (0-2)
 darkness_layer = 0
 

Modified: trunk/data/hexemplio.tilespec
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/hexemplio.tilespec?rev=27090&r1=27089&r2=27090&view=diff
==============================================================================
--- trunk/data/hexemplio.tilespec       (original)
+++ trunk/data/hexemplio.tilespec       Thu Nov 20 22:11:23 2014
@@ -27,8 +27,8 @@
 ; Use old iso style
 fog_style      = "Auto"
 
-; Was darkness style 1 (single-sprite)
-darkness_style = 2
+; Was darkness style "IsoRect" (single-sprite)
+darkness_style = "CardinalSingle"
 
 ; Which terrain layer darkness is drawn top of (0-2)
 darkness_layer = 0

Modified: trunk/data/isophex.tilespec
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/isophex.tilespec?rev=27090&r1=27089&r2=27090&view=diff
==============================================================================
--- trunk/data/isophex.tilespec (original)
+++ trunk/data/isophex.tilespec Thu Nov 20 22:11:23 2014
@@ -25,8 +25,8 @@
 ; Use old iso style
 fog_style      = "Auto"
 
-; Was darkness style 1 (single-sprite)
-darkness_style = 2
+; Was darkness style "IsoRect" (single-sprite)
+darkness_style = "CardinalSingle"
 ; Which terrain layer darkness is drawn top of (0-2)
 darkness_layer = 0
  

Modified: trunk/data/isotrident.tilespec
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/isotrident.tilespec?rev=27090&r1=27089&r2=27090&view=diff
==============================================================================
--- trunk/data/isotrident.tilespec      (original)
+++ trunk/data/isotrident.tilespec      Thu Nov 20 22:11:23 2014
@@ -24,8 +24,8 @@
 ; Was old iso style
 fog_style      = "Darkness"
 
-; Was darkness style 1 (single-sprite)
-darkness_style = 4
+; Was darkness style "IsoRect" (single-sprite)
+darkness_style = "Corner"
 ; Which terrain layer darkness is drawn top of (0-2)
 darkness_layer = 0
  

Modified: trunk/data/toonhex.tilespec
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/toonhex.tilespec?rev=27090&r1=27089&r2=27090&view=diff
==============================================================================
--- trunk/data/toonhex.tilespec (original)
+++ trunk/data/toonhex.tilespec Thu Nov 20 22:11:23 2014
@@ -28,8 +28,8 @@
 ; Use old iso style
 fog_style      = "Auto"
 
-; Was darkness style 1 (single-sprite)
-darkness_style = 2
+; Was darkness style "IsoRect" (single-sprite)
+darkness_style = "CardinalSingle"
 
 ; Which terrain layer darkness is drawn top of (0-2)
 darkness_layer = 0

Modified: trunk/data/trident.tilespec
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/trident.tilespec?rev=27090&r1=27089&r2=27090&view=diff
==============================================================================
--- trunk/data/trident.tilespec (original)
+++ trunk/data/trident.tilespec Thu Nov 20 22:11:23 2014
@@ -24,8 +24,8 @@
 ; Was old iso style
 fog_style      = "Darkness"
 
-; Was darkness style 3 (15 sprites)
-darkness_style = 4
+; Was darkness style "CardinalFull" (15 sprites)
+darkness_style = "Corner"
 ; Which terrain layer darkness is drawn top of (0-2)
 darkness_layer = 0
  

Modified: trunk/doc/README.graphics
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/doc/README.graphics?rev=27090&r1=27089&r2=27090&view=diff
==============================================================================
--- trunk/doc/README.graphics   (original)
+++ trunk/doc/README.graphics   Thu Nov 20 22:11:23 2014
@@ -104,17 +104,20 @@
                                        tx.fog sprite is used for this.
                           "Darkness" : No fog, or fog from darkness_style = 4.
   darkness_style        : Specifies how "encroaching darkness" is drawn.
-                          0 : No darkness.
-                          1 : A single sprite can be split into 4 parts, each
-                              containing the darkness for that particular
-                              cardinal direction. (Iso-view only.)
-                          2 : Four different sprites exist, each holding the
-                              darkness for a particular direction. Any or all
-                              of the sprites may be drawn.
-                          3 : The sprite is chosen based on the vector sum of
-                              the darkness in all 4 cardinal directions. 15
-                              different sprites are needed.
-                          4 : Corner darkness & fog, 81 sprites needed.
+                          "None"           : No darkness.
+                          "IsoRect"        : A single sprite can be split into 
4
+                                             parts, each containing the 
darkness
+                                             for that particular cardinal 
direction.
+                                             (Iso-view only.)
+                          "CardinalSingle" : Four different sprites exist, each
+                                             holding the darkness for a 
particular
+                                             direction. Any or all of the 
sprites
+                                             may be drawn.
+                          "CardinalFull"   : The sprite is chosen based on the 
vector
+                                             sum of the darkness in all 4 
cardinal
+                                             directions. 15 different sprites 
are
+                                             needed.
+                          "Corner"         : Corner darkness & fog, 81 sprites 
needed.
   unit_flag_offset_x   : Gives an offset from the tile origin at which to
   unit_flag_offset_y     draw flags behind units or cities. With isometric
   city_flag_offset_x     tilesets this should be non-zero so that the flag


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to