Re: [Freeciv-Dev] (PR#37977) [Bug] City walls drawn if city has any defense building

2007-03-17 Thread Marko Lindqvist

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

On 3/15/07, Marko Lindqvist [EMAIL PROTECTED] wrote:
 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.

 Trunk version committed. While doing some more testing with S2_1
version I found that walls for some enemy cities are not immediately
drawn when loading saved game and Great Wall is providing
Visible_Walls effect to that enemy.


 - ML



___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] (PR#37977) [Bug] City walls drawn if city has any defense building

2007-03-17 Thread Marko Lindqvist

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.

  New S2_1 version with fixed capability handling.


 - ML

diff -Nurd -X.diff_ignore freeciv/ai/aicity.c freeciv/ai/aicity.c
--- freeciv/ai/aicity.c	2007-03-17 05:21:32.0 +0200
+++ freeciv/ai/aicity.c	2007-03-17 20:28:33.0 +0200
@@ -647,6 +647,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.0 +0200
+++ freeciv/client/gui-sdl/mapview.c	2007-03-17 20:28:33.0 +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.0 +0200
+++ freeciv/client/packhand.c	2007-03-17 21:15:19.0 +0200
@@ -560,6 +560,16 @@
 agents_city_changed(pcity);
   }
 
+  if (has_capability(CitywallFix, aconnection.capability)) {
+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(CitywallFix, aconnection.capability)) {
+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.0 +0200
+++ freeciv/client/tilespec.c	2007-03-17 20:28:33.0 +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.0 +0200
+++ freeciv/common/city.c	2007-03-17 20:28:33.0 +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.0 +0200
+++ freeciv/common/city.h	2007-03-17 20:28:33.0 +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 

Re: [Freeciv-Dev] (PR#37977) [Bug] City walls drawn if city has any defense building

2007-03-15 Thread Marko Lindqvist

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.0 +0200
+++ freeciv/ai/aicity.c	2007-03-15 13:14:31.0 +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.0 +0200
+++ freeciv/client/gui-sdl/mapview.c	2007-03-15 13:14:31.0 +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.0 +0200
+++ freeciv/client/packhand.c	2007-03-15 13:14:31.0 +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.0 +0200
+++ freeciv/client/tilespec.c	2007-03-15 13:14:31.0 +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.0 +0200
+++ freeciv/common/city.c	2007-03-15 13:14:31.0 +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.0 +0200
+++ freeciv/common/city.h	2007-03-15 13:14:31.0 +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 

[Freeciv-Dev] (PR#37977) [Bug] City walls drawn if city has any defense building

2007-03-11 Thread Marko Lindqvist

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

 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.
 Even with distributed rulesets this is an problem, since also Coastal
defense, SAM battery and SDI defense provide Defend_Bonus


 - ML



___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] (PR#37977) [Bug] City walls drawn if city has any defense building

2007-03-11 Thread Marko Lindqvist

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

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.

 This version is for trunk and applies on top of #37980 and #37983.


 - ML



___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev