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

On 3/12/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote:
>
> On 3/12/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote:
> >
> >  Whether city is drawn with walls or not is decided by calling
> > city_got_citywalls(). That just checks if city has *any*
> > "Defend_Bonus" effect active.
>
>  Attached patch adds "Visible_Wall" effect. City Walls has it in one
> city range and Great Wall in player range.

 S2_1 version. #37980 merged to this patch.


 - ML

diff -Nurd -X.diff_ignore freeciv/ai/aicity.c freeciv/ai/aicity.c
--- freeciv/ai/aicity.c	2007-03-05 19:14:29.000000000 +0200
+++ freeciv/ai/aicity.c	2007-03-15 13:14:31.000000000 +0200
@@ -648,6 +648,9 @@
         case EFT_OUTPUT_INC_TILE_CELEBRATE:
 	case EFT_TRADE_REVENUE_BONUS:
           break;
+          /* This has no effect for AI */
+        case EFT_VISIBLE_WALLS:
+          break;
 	case EFT_LAST:
 	  freelog(LOG_ERROR, "Bad effect type.");
 	  break;
diff -Nurd -X.diff_ignore freeciv/client/gui-sdl/mapview.c freeciv/client/gui-sdl/mapview.c
--- freeciv/client/gui-sdl/mapview.c	2007-03-12 10:28:37.000000000 +0200
+++ freeciv/client/gui-sdl/mapview.c	2007-03-15 13:14:31.000000000 +0200
@@ -775,7 +775,7 @@
 			  
 	    cat_snprintf(buffer, sizeof(buffer), _("\nCity of %s"), pTile->city->name);
             	  
-	    citywall = city_got_citywalls(pTile->city);
+	    citywall = pTile->city->client.walls;
                           
 #if 0                          
 	    if (pplayers_allied(game.player_ptr, pOwner)) {
diff -Nurd -X.diff_ignore freeciv/client/packhand.c freeciv/client/packhand.c
--- freeciv/client/packhand.c	2007-03-05 19:14:36.000000000 +0200
+++ freeciv/client/packhand.c	2007-03-15 13:14:31.000000000 +0200
@@ -560,6 +560,16 @@
     agents_city_changed(pcity);
   }
 
+  if (has_capability(aconnection.capability, "CitywallFix")) {
+    pcity->client.walls = packet->walls;
+  } else {
+    /* Try to guess
+     * Note that we cannot use city_got_citywalls() here, as
+     * server without "CitywallFix" has not sent us VisibleWalls
+     * effect either */
+    pcity->client.walls = city_got_defense_effect(pcity, NULL);
+  }
+
   handle_city_packet_common(pcity, city_is_new, popup,
 			    packet->diplomat_investigate);
 
@@ -776,6 +786,16 @@
     agents_city_changed(pcity);
   }
 
+  if (has_capability(aconnection.capability, "CitywallFix")) {
+    pcity->client.walls = packet->walls;
+  } else {
+    /* Try to guess
+     * Note that we cannot use city_got_citywalls() here, as
+     * server without "CitywallFix" has not sent us VisibleWalls
+     * effect either */
+    pcity->client.walls = city_got_defense_effect(pcity, NULL);
+  }
+
   handle_city_packet_common(pcity, city_is_new, FALSE, FALSE);
 
   /* Update the description if necessary. */
diff -Nurd -X.diff_ignore freeciv/client/tilespec.c freeciv/client/tilespec.c
--- freeciv/client/tilespec.c	2007-03-05 19:14:36.000000000 +0200
+++ freeciv/client/tilespec.c	2007-03-15 13:14:31.000000000 +0200
@@ -4081,16 +4081,16 @@
       /* 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->is_isometric || !city_got_citywalls(pcity)) {
+      if (!t->is_isometric || !pcity->client.walls) {
 	ADD_SPRITE_FULL(get_city_sprite(t->sprites.city.tile, pcity));
       }
-      if (t->is_isometric && city_got_citywalls(pcity)) {
+      if (t->is_isometric && pcity->client.walls) {
 	ADD_SPRITE_FULL(get_city_sprite(t->sprites.city.wall, pcity));
       }
       if (!draw_full_citybar && pcity->client.occupied) {
 	ADD_SPRITE_FULL(get_city_sprite(t->sprites.city.occupied, pcity));
       }
-      if (!t->is_isometric && city_got_citywalls(pcity)) {
+      if (!t->is_isometric && pcity->client.walls) {
 	ADD_SPRITE_FULL(get_city_sprite(t->sprites.city.wall, pcity));
       }
       if (pcity->client.unhappy) {
diff -Nurd -X.diff_ignore freeciv/common/city.c freeciv/common/city.c
--- freeciv/common/city.c	2007-03-13 17:43:47.000000000 +0200
+++ freeciv/common/city.c	2007-03-15 13:14:31.000000000 +0200
@@ -980,7 +980,7 @@
 **************************************************************************/
 bool city_got_citywalls(const struct city *pcity)
 {
-  return (get_city_bonus(pcity, EFT_DEFEND_BONUS) > 0);
+  return (get_city_bonus(pcity, EFT_VISIBLE_WALLS) > 0);
 }
 
 /**************************************************************************
diff -Nurd -X.diff_ignore freeciv/common/city.h freeciv/common/city.h
--- freeciv/common/city.h	2007-03-13 17:43:47.000000000 +0200
+++ freeciv/common/city.h	2007-03-15 13:14:31.000000000 +0200
@@ -262,6 +262,8 @@
     /* The color is an index into the city_colors array in mapview_common */
     bool colored;
     int color_index;
+
+    bool walls;
   } client;
 
   int steal;		      /* diplomats steal once; for spies, gets harder */
diff -Nurd -X.diff_ignore freeciv/common/effects.c freeciv/common/effects.c
--- freeciv/common/effects.c	2007-03-05 19:14:29.000000000 +0200
+++ freeciv/common/effects.c	2007-03-15 13:14:31.000000000 +0200
@@ -18,6 +18,7 @@
 #include <ctype.h>
 #include <string.h>
 
+#include "capability.h"
 #include "fcintl.h"
 #include "log.h"
 #include "mem.h"
@@ -115,7 +116,8 @@
   "Output_Waste",
   "Output_Waste_By_Distance",
   "Output_Penalty_Tile",
-  "Output_Inc_Tile_Celebrate"
+  "Output_Inc_Tile_Celebrate",
+  "Visible_Walls"
 };
 
 static bool initialized = FALSE;
@@ -449,6 +451,7 @@
 void send_ruleset_cache(struct conn_list *dest)
 {
   unsigned id = 0;
+  unsigned id_no_walls = 0;
 
   effect_list_iterate(ruleset_cache.tracker, peffect) {
     struct packet_ruleset_effect effect_packet;
@@ -456,7 +459,16 @@
     effect_packet.effect_type = peffect->type;
     effect_packet.effect_value = peffect->value;
 
-    lsend_packet_ruleset_effect(dest, &effect_packet);
+    if (peffect->type != EFT_VISIBLE_WALLS) {
+      lsend_packet_ruleset_effect(dest, &effect_packet);
+    } else {
+      /* Send EFT_VISIBLE_WALLS only to clients capable of handling it */
+      conn_list_iterate(dest, pconn) {
+        if (has_capability(pconn->capability, "CitywallFix")) {
+          send_packet_ruleset_effect(pconn, &effect_packet);
+        }
+      } conn_list_iterate_end;
+    }
 
     requirement_list_iterate(peffect->reqs, preq) {
       struct packet_ruleset_effect_req packet;
@@ -472,7 +484,18 @@
       packet.survives = survives;
       packet.negated = FALSE;
 
-      lsend_packet_ruleset_effect_req(dest, &packet);
+      conn_list_iterate(dest, pconn) {
+        if (has_capability(pconn->capability, "CitywallFix")) {
+          packet.effect_id = id;
+          send_packet_ruleset_effect_req(pconn, &packet);
+        } else {
+          /* No capability to handle EFT_VISIBLE_WALLS */
+          if (peffect->type != EFT_VISIBLE_WALLS) {
+            packet.effect_id = id_no_walls;
+            send_packet_ruleset_effect_req(pconn, &packet);
+          }
+        }
+      } conn_list_iterate_end;
     } requirement_list_iterate_end;
 
     requirement_list_iterate(peffect->nreqs, preq) {
@@ -489,10 +512,26 @@
       packet.survives = survives;
       packet.negated = FALSE;
 
-      lsend_packet_ruleset_effect_req(dest, &packet);
+      conn_list_iterate(dest, pconn) {
+        if (has_capability(pconn->capability, "CitywallFix")) {
+          packet.effect_id = id;
+          send_packet_ruleset_effect_req(pconn, &packet);
+        } else {
+          /* No capability to handle EFT_VISIBLE_WALLS */
+          if (peffect->type != EFT_VISIBLE_WALLS) {
+            packet.effect_id = id_no_walls;
+            send_packet_ruleset_effect_req(pconn, &packet);
+          }
+        }
+      } conn_list_iterate_end;
     } requirement_list_iterate_end;
 
     id++;
+
+    if (peffect->type != EFT_VISIBLE_WALLS) {
+      id_no_walls++;
+    }
+
   } effect_list_iterate_end;
 }
 
diff -Nurd -X.diff_ignore freeciv/common/effects.h freeciv/common/effects.h
--- freeciv/common/effects.h	2007-03-05 19:14:29.000000000 +0200
+++ freeciv/common/effects.h	2007-03-15 13:14:31.000000000 +0200
@@ -104,6 +104,7 @@
   EFT_OUTPUT_WASTE_BY_DISTANCE,
   EFT_OUTPUT_PENALTY_TILE, /* -1 penalty to tiles producing more than this */
   EFT_OUTPUT_INC_TILE_CELEBRATE,
+  EFT_VISIBLE_WALLS,       /* City should use walls gfx */
   EFT_LAST	/* keep this last */
 };
 
diff -Nurd -X.diff_ignore freeciv/common/packets.def freeciv/common/packets.def
--- freeciv/common/packets.def	2007-03-05 19:14:29.000000000 +0200
+++ freeciv/common/packets.def	2007-03-15 13:14:31.000000000 +0200
@@ -535,6 +535,8 @@
 
   BV_CITY_OPTIONS city_options;
   TURN turn_founded;
+
+  BOOL walls; add-cap(CitywallFix)
 end
 
 PACKET_CITY_SHORT_INFO=22; sc,lsend
@@ -548,6 +550,7 @@
   BOOL unhappy;
   BV_IMPRS improvements;
   BOOL occupied;
+  BOOL walls;
   UINT16 tile_trade;
 end
 
diff -Nurd -X.diff_ignore freeciv/data/civ1/effects.ruleset freeciv/data/civ1/effects.ruleset
--- freeciv/data/civ1/effects.ruleset	2007-03-05 19:13:55.000000000 +0200
+++ freeciv/data/civ1/effects.ruleset	2007-03-15 13:14:40.000000000 +0200
@@ -617,6 +617,14 @@
       "Building", "City Walls", "City"
     }
 
+[effect_city_walls_visible]
+name	= "Visible_Walls"
+value	= 1
+reqs	=
+    { "type", "name", "range"
+      "Building", "City Walls", "City"
+    }
+
 [effect_colosseum]
 name	= "Make_Content"
 value	= 3
@@ -990,6 +998,14 @@
       "UnitClass", "Sea", "Local"
     }
 
+[effect_great_wall_visible]
+name	= "Visible_Walls"
+value	= 1
+reqs	=
+    { "type", "name", "range"
+      "Building", "Great Wall", "Player"
+    }
+
 [effect_hanging_gardens]
 name	= "Make_Happy"
 value	= 1
diff -Nurd -X.diff_ignore freeciv/data/civ2/effects.ruleset freeciv/data/civ2/effects.ruleset
--- freeciv/data/civ2/effects.ruleset	2007-03-05 19:13:55.000000000 +0200
+++ freeciv/data/civ2/effects.ruleset	2007-03-15 13:14:40.000000000 +0200
@@ -998,6 +998,14 @@
       "Building", "City Walls", "City"
     }
 
+[effect_city_walls_visible]
+name	= "Visible_Walls"
+value	= 1
+reqs	=
+    { "type", "name", "range"
+      "Building", "City Walls", "City"
+    }
+
 [effect_coastal_defense]
 name	= "Defend_Bonus"
 value	= 100
@@ -1596,6 +1604,14 @@
       "Building", "Great Wall", "Player"
     }
 
+[effect_great_wall_visible]
+name	= "Visible_Walls"
+value	= 1
+reqs	=
+    { "type", "name", "range"
+      "Building", "Great Wall", "Player"
+    }
+
 [effect_hanging_gardens]
 name	= "Make_Happy"
 value	= 1
diff -Nurd -X.diff_ignore freeciv/data/default/effects.ruleset freeciv/data/default/effects.ruleset
--- freeciv/data/default/effects.ruleset	2007-03-05 19:13:55.000000000 +0200
+++ freeciv/data/default/effects.ruleset	2007-03-15 13:14:40.000000000 +0200
@@ -858,6 +858,14 @@
       "Building", "City Walls", "City"
     }
 
+[effect_city_walls_visible]
+name	= "Visible_Walls"
+value	= 1
+reqs	=
+    { "type", "name", "range"
+      "Building", "City Walls", "City"
+    }
+
 [effect_coastal_defense]
 name	= "Defend_Bonus"
 value	= 100
@@ -1539,6 +1547,14 @@
       "Building", "Great Wall", "Player"
     }
 
+[effect_great_wall_visible]
+name	= "Visible_Walls"
+value	= 1
+reqs	=
+    { "type", "name", "range"
+      "Building", "Great Wall", "Player"
+    }
+
 [effect_hanging_gardens]
 name	= "Make_Happy"
 value	= 1
diff -Nurd -X.diff_ignore freeciv/doc/README.effects freeciv/doc/README.effects
--- freeciv/doc/README.effects	2007-03-05 19:13:43.000000000 +0200
+++ freeciv/doc/README.effects	2007-03-15 13:14:40.000000000 +0200
@@ -289,3 +289,6 @@
 
 Output_Inc_Tile_Celebrate
     Tiles get amount extra output when city working them is celebrating.
+
+Visible_Wall
+    Positive amount only instructs clients to use wall graphics for city.
diff -Nurd -X.diff_ignore freeciv/server/citytools.c freeciv/server/citytools.c
--- freeciv/server/citytools.c	2007-03-05 19:13:46.000000000 +0200
+++ freeciv/server/citytools.c	2007-03-15 13:14:40.000000000 +0200
@@ -1348,6 +1348,7 @@
   packet->size = pdcity->size;
 
   packet->occupied = pdcity->occupied;
+  packet->walls = pdcity->walls;
   packet->happy = pdcity->happy;
   packet->unhappy = pdcity->unhappy;
 
@@ -1640,6 +1641,8 @@
       BV_SET(packet->improvements, i);
     }
   } impr_type_iterate_end;
+
+  packet->walls = city_got_citywalls(pcity);
 }
 
 /**************************************************************************
@@ -1661,6 +1664,7 @@
    * unit list to check the occupied status. */
   bool occupied =
     (unit_list_size(pcity->tile->units) > 0);
+  bool walls = city_got_citywalls(pcity);
   bool happy = city_happy(pcity), unhappy = city_unhappy(pcity);
   bv_imprs improvements;
 
@@ -1676,6 +1680,7 @@
       && strcmp(pdcity->name, pcity->name) == 0
       && pdcity->size == pcity->size
       && pdcity->occupied == occupied
+      && pdcity->walls == walls
       && pdcity->happy == happy
       && pdcity->unhappy == unhappy
       && pdcity->owner == pcity->owner
@@ -1696,6 +1701,7 @@
   sz_strlcpy(pdcity->name, pcity->name);
   pdcity->size = pcity->size;
   pdcity->occupied = occupied;
+  pdcity->walls = walls;
   pdcity->happy = happy;
   pdcity->unhappy = unhappy;
   pdcity->owner = pcity->owner;
diff -Nurd -X.diff_ignore freeciv/server/maphand.h freeciv/server/maphand.h
--- freeciv/server/maphand.h	2007-03-05 19:13:46.000000000 +0200
+++ freeciv/server/maphand.h	2007-03-15 13:14:40.000000000 +0200
@@ -28,6 +28,7 @@
    * pointers in here. */
   int id;
   bool occupied;
+  bool walls;
   bool happy, unhappy;
   char name[MAX_LEN_NAME];
   unsigned short size;
diff -Nurd -X.diff_ignore freeciv/server/savegame.c freeciv/server/savegame.c
--- freeciv/server/savegame.c	2007-03-10 23:18:01.000000000 +0200
+++ freeciv/server/savegame.c	2007-03-15 13:14:40.000000000 +0200
@@ -2623,6 +2623,8 @@
 	pdcity->size = secfile_lookup_int(file, "player%d.dc%d.size", plrno, j);
 	pdcity->occupied = secfile_lookup_bool_default(file, FALSE,
 					"player%d.dc%d.occupied", plrno, j);
+        pdcity->walls = secfile_lookup_bool_default(file, FALSE,
+                                        "player%d.dc%d.walls", plrno, j);
 	pdcity->happy = secfile_lookup_bool_default(file, FALSE,
 					"player%d.dc%d.happy", plrno, j);
 	pdcity->unhappy = secfile_lookup_bool_default(file, FALSE,
@@ -3226,6 +3228,8 @@
 			      "player%d.dc%d.has_walls", plrno, i);
 	  secfile_insert_bool(file, pdcity->occupied,
 			      "player%d.dc%d.occupied", plrno, i);
+          secfile_insert_bool(file, pdcity->walls,
+                              "player%d.dc%d.walls", plrno, i);
 	  secfile_insert_bool(file, pdcity->happy,
 			      "player%d.dc%d.happy", plrno, i);
 	  secfile_insert_bool(file, pdcity->unhappy,
diff -Nurd -X.diff_ignore freeciv/version.in freeciv/version.in
--- freeciv/version.in	2007-03-15 13:12:11.000000000 +0200
+++ freeciv/version.in	2007-03-15 13:15:38.000000000 +0200
@@ -16,6 +16,9 @@
 
 # Freeciv network capstring: see documentation in common/capstr.c
 #
+# For reasons I don't understand, any spaces in this string causes it to
+# be seen completely empty.
+#
 # +2.1c is the base capability string.
 #
 #   - No new manditory capabilities can be added to the release branch; doing
@@ -24,4 +27,4 @@
 #   - Avoid adding a new manditory capbility to the development branch for
 #     as long as possible.  We want to maintain network compatibility with
 #     the stable branch for as long as possible.
-FREECIV_NETWORK_CAPSTRING(["+2.1c"])
+FREECIV_NETWORK_CAPSTRING(["+2.1c, CitywallFix"])
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to