Author: cazfi
Date: Wed May 21 18:38:22 2014
New Revision: 24914

URL: http://svn.gna.org/viewcvs/freeciv?rev=24914&view=rev
Log:
Turn former boolean effect "Visible_Wall" to integer. Value indicates which set 
of city sprites should be used.
There can be up to 7 sets of walled cities graphics, in addition to the 
unwalled version, for each city style.

See patch #4393

Modified:
    trunk/client/packhand.c
    trunk/client/tilespec.c
    trunk/client/tilespec.h
    trunk/common/city.c
    trunk/common/city.h
    trunk/common/packets.def
    trunk/doc/README.effects
    trunk/fc_version
    trunk/server/citytools.c

Modified: trunk/client/packhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/packhand.c?rev=24914&r1=24913&r2=24914&view=diff
==============================================================================
--- trunk/client/packhand.c     (original)
+++ trunk/client/packhand.c     Wed May 21 18:38:22 2014
@@ -780,6 +780,9 @@
   }
 
   pcity->client.walls = packet->walls;
+  if (pcity->client.walls > NUM_WALL_TYPES) {
+    pcity->client.walls = NUM_WALL_TYPES;
+  }
   pcity->style = packet->style;
   pcity->client.city_image = packet->city_image;
 

Modified: trunk/client/tilespec.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/tilespec.c?rev=24914&r1=24913&r2=24914&view=diff
==============================================================================
--- trunk/client/tilespec.c     (original)
+++ trunk/client/tilespec.c     Wed May 21 18:38:22 2014
@@ -296,7 +296,8 @@
       *tile_tradenum[NUM_TILES_DIGITS];
     struct city_sprite
       *tile,
-      *wall,
+      *single_wall,
+      *wall[NUM_WALL_TYPES],
       *occupied;
     struct sprite_vector worked_tile_overlay;
     struct sprite_vector unworked_tile_overlay;
@@ -5075,17 +5076,47 @@
       /* For iso-view the city.wall graphics include the full city, whereas
        * for non-iso view they are an overlay on top of the base city
        * graphic. */
-      if (t->type == TS_OVERVIEW || !pcity->client.walls) {
+      if (t->type == TS_OVERVIEW || pcity->client.walls <= 0) {
        ADD_SPRITE_FULL(get_city_sprite(t->sprites.city.tile, pcity));
       }
-      if (t->type == TS_ISOMETRIC && pcity->client.walls) {
-       ADD_SPRITE_FULL(get_city_sprite(t->sprites.city.wall, pcity));
+      if (t->type == TS_ISOMETRIC && pcity->client.walls > 0) {
+        struct city_sprite *cspr = t->sprites.city.wall[pcity->client.walls - 
1];
+        struct sprite *spr = NULL;
+
+        if (cspr != NULL) {
+          spr = get_city_sprite(cspr, pcity);
+        }
+        if (spr == NULL) {
+          cspr = t->sprites.city.single_wall;
+          if (cspr != NULL) {
+            spr = get_city_sprite(cspr, pcity);
+          }
+        }
+
+        if (spr != NULL) {
+          ADD_SPRITE_FULL(spr);
+        }
       }
       if (!options.draw_full_citybar && pcity->client.occupied) {
        ADD_SPRITE_FULL(get_city_sprite(t->sprites.city.occupied, pcity));
       }
-      if (t->type == TS_OVERVIEW && pcity->client.walls) {
-       ADD_SPRITE_FULL(get_city_sprite(t->sprites.city.wall, pcity));
+      if (t->type == TS_OVERVIEW && pcity->client.walls > 0) {
+        struct city_sprite *cspr = t->sprites.city.wall[pcity->client.walls - 
1];
+        struct sprite *spr = NULL;
+
+        if (cspr != NULL) {
+          spr = get_city_sprite(cspr, pcity);
+        }
+        if (spr == NULL) {
+          cspr = t->sprites.city.single_wall;
+          if (cspr != NULL) {
+            spr = get_city_sprite(cspr, pcity);
+          }
+        }
+
+        if (spr != NULL) {
+          ADD_SPRITE_FULL(spr);
+        }
       }
       if (pcity->client.unhappy) {
        ADD_SPRITE_FULL(t->sprites.city.disorder);
@@ -5312,23 +5343,35 @@
 void tileset_setup_city_tiles(struct tileset *t, int style)
 {
   if (style == game.control.styles_count - 1) {
+    int i;
 
     /* Free old sprites */
     free_city_sprite(t->sprites.city.tile);
-    free_city_sprite(t->sprites.city.wall);
+
+    for (i = 0; i < NUM_WALL_TYPES; i++) {
+      free_city_sprite(t->sprites.city.wall[i]);
+      t->sprites.city.wall[i] = NULL;
+    }
+    free_city_sprite(t->sprites.city.single_wall);
+    t->sprites.city.single_wall = NULL;
+
     free_city_sprite(t->sprites.city.occupied);
 
     t->sprites.city.tile = load_city_sprite(t, "city");
-    t->sprites.city.wall = load_city_sprite(t, "wall");
+
+    for (i = 0; i < NUM_WALL_TYPES; i++) {
+      char buffer[256];
+
+      fc_snprintf(buffer, sizeof(buffer), "bldg_%d", i);
+      t->sprites.city.wall[i] = load_city_sprite(t, buffer);
+    }
+    t->sprites.city.single_wall = load_city_sprite(t, "wall");
+
     t->sprites.city.occupied = load_city_sprite(t, "occupied");
 
     for (style = 0; style < game.control.styles_count; style++) {
       if (t->sprites.city.tile->styles[style].land_num_thresholds == 0) {
         tileset_error(LOG_FATAL, _("City style \"%s\": no city graphics."),
-                      city_style_rule_name(style));
-      }
-      if (t->sprites.city.wall->styles[style].land_num_thresholds == 0) {
-        tileset_error(LOG_FATAL, _("City style \"%s\": no wall graphics."),
                       city_style_rule_name(style));
       }
       if (t->sprites.city.occupied->styles[style].land_num_thresholds == 0) {
@@ -5428,14 +5471,22 @@
 ***********************************************************************/
 void tileset_free_tiles(struct tileset *t)
 {
+  int i;
+
   log_debug("tileset_free_tiles()");
 
   unload_all_sprites(t);
 
   free_city_sprite(t->sprites.city.tile);
   t->sprites.city.tile = NULL;
-  free_city_sprite(t->sprites.city.wall);
-  t->sprites.city.wall = NULL;
+
+  for (i = 0; i < NUM_WALL_TYPES; i++) {
+    free_city_sprite(t->sprites.city.wall[i]);
+    t->sprites.city.wall[i] = NULL;
+  }
+  free_city_sprite(t->sprites.city.single_wall);
+  t->sprites.city.single_wall = NULL;
+
   free_city_sprite(t->sprites.city.occupied);
   t->sprites.city.occupied = NULL;
 
@@ -5862,9 +5913,16 @@
 ****************************************************************************/
 void tileset_init(struct tileset *t)
 {
+  int i;
+
   /* We currently have no city sprites loaded. */
   t->sprites.city.tile     = NULL;
-  t->sprites.city.wall     = NULL;
+
+  for (i = 0; i < NUM_WALL_TYPES; i++) {
+    t->sprites.city.wall[i] = NULL;
+  }
+  t->sprites.city.single_wall = NULL;
+
   t->sprites.city.occupied = NULL;
 
   t->sprites.background.color = NULL;

Modified: trunk/client/tilespec.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/tilespec.h?rev=24914&r1=24913&r2=24914&view=diff
==============================================================================
--- trunk/client/tilespec.h     (original)
+++ trunk/client/tilespec.h     Wed May 21 18:38:22 2014
@@ -264,6 +264,8 @@
     *road,
     *military_base;
 };
+
+#define NUM_WALL_TYPES 7
 
 struct sprite *get_spaceship_sprite(const struct tileset *t,
                                    enum spaceship_part part);

Modified: trunk/common/city.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/city.c?rev=24914&r1=24913&r2=24914&view=diff
==============================================================================
--- trunk/common/city.c (original)
+++ trunk/common/city.c Wed May 21 18:38:22 2014
@@ -1445,14 +1445,6 @@
 }
 
 /**************************************************************************
- Whether a city should have visible walls
-**************************************************************************/
-bool city_got_citywalls(const struct city *pcity)
-{
-  return (get_city_bonus(pcity, EFT_VISIBLE_WALLS) > 0);
-}
-
-/**************************************************************************
  This can be City Walls, Coastal defense... depending on attacker type.
  If attacker type is not given, just any defense effect will do.
 **************************************************************************/

Modified: trunk/common/city.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/city.h?rev=24914&r1=24913&r2=24914&view=diff
==============================================================================
--- trunk/common/city.h (original)
+++ trunk/common/city.h Wed May 21 18:38:22 2014
@@ -415,7 +415,7 @@
     struct {
       /* Only used at the client (the server is omniscient; ./client/). */
       bool occupied;
-      bool walls;
+      int  walls;
       bool happy;
       bool unhappy;
       int  city_image;
@@ -559,7 +559,6 @@
                       const struct impr_type *pimprove);
 bool is_capital(const struct city *pcity);
 bool is_gov_center(const struct city *pcity);
-bool city_got_citywalls(const struct city *pcity);
 bool city_got_defense_effect(const struct city *pcity,
                              const struct unit_type *attacker);
 

Modified: trunk/common/packets.def
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/packets.def?rev=24914&r1=24913&r2=24914&view=diff
==============================================================================
--- trunk/common/packets.def    (original)
+++ trunk/common/packets.def    Wed May 21 18:38:22 2014
@@ -617,7 +617,7 @@
   BOOL did_buy, did_sell, was_happy;
 
   BOOL diplomat_investigate;
-  BOOL walls;
+  UINT8 walls;
   SINT8 city_image;
 
   WORKLIST worklist;
@@ -635,8 +635,8 @@
   UINT8 size;
   UINT8 style;
 
-  BOOL occupied;
-  BOOL walls;
+  BOOL  occupied;
+  UINT8 walls;
 
   BOOL happy;
   BOOL unhappy;

Modified: trunk/doc/README.effects
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/doc/README.effects?rev=24914&r1=24913&r2=24914&view=diff
==============================================================================
--- trunk/doc/README.effects    (original)
+++ trunk/doc/README.effects    Wed May 21 18:38:22 2014
@@ -385,7 +385,8 @@
     for units upgraded in certain city.
 
 Visible_Wall
-    Positive amount only instructs clients to use wall graphics for city.
+    Instruct client to show specific buildings version of the city graphics.
+    Zero or below are considered normal city graphics.
 
 Tech_Cost_Factor
     Factor for research costs.

Modified: trunk/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=24914&r1=24913&r2=24914&view=diff
==============================================================================
--- trunk/fc_version    (original)
+++ trunk/fc_version    Wed May 21 18:38:22 2014
@@ -52,7 +52,7 @@
 #   - Avoid adding a new mandatory capability to the development branch for
 #     as long as possible.  We want to maintain network compatibility with
 #     the stable branch for as long as possible.
-NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-2.6-2014.May.18"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-2.6-2014.May.21"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: trunk/server/citytools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/citytools.c?rev=24914&r1=24913&r2=24914&view=diff
==============================================================================
--- trunk/server/citytools.c    (original)
+++ trunk/server/citytools.c    Wed May 21 18:38:22 2014
@@ -1797,6 +1797,16 @@
 }
 
 /**************************************************************************
+ Which wall gfx city should display?
+**************************************************************************/
+static int city_got_citywalls(const struct city *pcity)
+{
+  int walls = get_city_bonus(pcity, EFT_VISIBLE_WALLS);
+
+  return walls > 0 ? walls : 0;
+}
+
+/**************************************************************************
   Suppress sending cities during game_load() and end_phase()
 **************************************************************************/
 bool send_city_suppression(bool now)


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

Reply via email to