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

On 3/12/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote:
>
>  First step toward fixing #37977. Server decides if wall gfx should be
> drawn and sends that information to client.
>  This does change how Great Wall effects appear. Previously client
> knew that even fogged cities get walls when player builds Great Wall
> and lose walls when it gets obsolete. Now player knowledge about
> fogged cities is not updated.

 S2_1 version with proper capability checking. I'm not going to commit
this in this form. Both this and final #37977 require capability
change. In order to minimize capstring pollution I'm going to merge
S2_1 versions of these two (to #37977).


 - ML

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-14 04:13: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-14 04:27:32.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-14 04:13: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.h freeciv/common/city.h
--- freeciv/common/city.h	2007-03-13 17:43:47.000000000 +0200
+++ freeciv/common/city.h	2007-03-14 04:13: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/packets.def freeciv/common/packets.def
--- freeciv/common/packets.def	2007-03-05 19:14:29.000000000 +0200
+++ freeciv/common/packets.def	2007-03-14 04:19:44.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/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-14 04:13:31.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-14 04:13:31.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-14 04:13:31.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-05 19:14:36.000000000 +0200
+++ freeciv/version.in	2007-03-14 04:14:35.000000000 +0200
@@ -24,4 +24,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