Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2005:
[Freeciv-Dev] (PR#12596) remove game.aqueduct_size
Home

[Freeciv-Dev] (PR#12596) remove game.aqueduct_size

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12596) remove game.aqueduct_size
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 22 Mar 2005 17:45:07 -0800
Reply-to: bugs@xxxxxxxxxxx

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

This patch removes game.aqueduct_size, and replaces it with an effect.

I think it fixes a bug in the AI code.  The checks for SIZE_ADJ and 
SIZE_UNLIMIT both discount the possibility that there is already a 
SIZE_ADJ/SIZE_UNLIMIT effect present.  This isn't a problem in the 
default ruleset because there is just one SIZE_ADJ and one SIZE_UNLIMIT 
effect (and the latter requires the former).

-jason

? data/diff
Index: ai/aicity.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aicity.c,v
retrieving revision 1.205
diff -u -r1.205 aicity.c
--- ai/aicity.c 18 Mar 2005 11:26:23 -0000      1.205
+++ ai/aicity.c 23 Mar 2005 01:44:43 -0000
@@ -435,16 +435,24 @@
          }
          break;
        case EFT_SIZE_UNLIMIT:
-         amount = 20; /* really big city */
+         /* Note we look up the SIZE_UNLIMIT again right below.  This could
+          * be avoided... */
+         if (get_city_bonus(pcity, EFT_SIZE_UNLIMIT) == 0) {
+           amount = 20; /* really big city */
+         }
          /* there not being a break here is deliberate, mind you */
-       case EFT_SIZE_ADJ: 
-         if (!city_can_grow_to(pcity, pcity->size + 1)) {
-           v += pcity->surplus[O_FOOD] * ai->food_priority * amount;
-           if (pcity->size == game.aqueduct_size) {
-             v += 30 * pcity->surplus[O_FOOD];
+       case EFT_SIZE_ADJ:
+         if (get_city_bonus(pcity, EFT_SIZE_UNLIMIT) == 0) {
+           const int aqueduct_size = get_city_bonus(pcity, EFT_SIZE_ADJ);
+
+           if (!city_can_grow_to(pcity, pcity->size + 1)) {
+             v += pcity->surplus[O_FOOD] * ai->food_priority * amount;
+             if (pcity->size == aqueduct_size) {
+               v += 30 * pcity->surplus[O_FOOD];
+             }
            }
+           v += c * amount * 4 / aqueduct_size;
          }
-         v += c * amount * 4 / game.aqueduct_size;
          break;
        case EFT_SS_STRUCTURAL:
        case EFT_SS_COMPONENT:
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.479
diff -u -r1.479 packhand.c
--- client/packhand.c   18 Mar 2005 11:26:24 -0000      1.479
+++ client/packhand.c   23 Mar 2005 01:44:44 -0000
@@ -2081,7 +2081,6 @@
 
   ruleset_cache_init();
 
-  game.aqueduct_size = packet->aqueduct_size;
   game.add_to_size_limit = packet->add_to_size_limit;
   game.notradesize = packet->notradesize;
   game.fulltradesize = packet->fulltradesize;
Index: common/capstr.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/capstr.c,v
retrieving revision 1.222
diff -u -r1.222 capstr.c
--- common/capstr.c     23 Feb 2005 03:34:05 -0000      1.222
+++ common/capstr.c     23 Mar 2005 01:44:44 -0000
@@ -82,7 +82,7 @@
  *     as long as possible.  We want to maintain network compatibility with
  *     the stable branch for as long as possible.
  */
-#define CAPABILITY "+Freeciv.Devel.2004.Feb.22"
+#define CAPABILITY "+Freeciv.Devel.2004.Mar.22"
 
 void init_our_capability(void)
 {
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.319
diff -u -r1.319 city.c
--- common/city.c       15 Mar 2005 16:08:24 -0000      1.319
+++ common/city.c       23 Mar 2005 01:44:44 -0000
@@ -1435,14 +1435,8 @@
 ****************************************************************************/
 bool city_can_grow_to(const struct city *pcity, int pop_size)
 {
-  if (get_city_bonus(pcity, EFT_SIZE_UNLIMIT) > 0) {
-    return TRUE;
-  } else {
-    int max_size;
-                                                                               
-    max_size = game.aqueduct_size + get_city_bonus(pcity, EFT_SIZE_ADJ);
-    return (pop_size <= max_size);
-  }
+  return (get_city_bonus(pcity, EFT_SIZE_UNLIMIT) > 0
+         || pop_size <= get_city_bonus(pcity, EFT_SIZE_ADJ));
 }
 
 /**************************************************************************
Index: common/game.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.h,v
retrieving revision 1.178
diff -u -r1.178 game.h
--- common/game.h       21 Mar 2005 13:05:21 -0000      1.178
+++ common/game.h       23 Mar 2005 01:44:44 -0000
@@ -137,7 +137,6 @@
   int razechance;
   bool scorelog;
   int seed;
-  int aqueduct_size;
   int add_to_size_limit;
   bool savepalace;
   bool natural_city_names;
Index: common/packets.def
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.def,v
retrieving revision 1.97
diff -u -r1.97 packets.def
--- common/packets.def  5 Mar 2005 00:06:25 -0000       1.97
+++ common/packets.def  23 Mar 2005 01:44:44 -0000
@@ -1206,7 +1206,6 @@
   info for its own "control" packet, done separately.)
 *********************************************************/
 PACKET_RULESET_CONTROL=106;sc,lsend
-  UINT8 aqueduct_size;
   UINT8 add_to_size_limit;
   UINT8 notradesize, fulltradesize;
   UINT8 num_unit_types;
Index: data/civ1/buildings.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ1/buildings.ruleset,v
retrieving revision 1.43
diff -u -r1.43 buildings.ruleset
--- data/civ1/buildings.ruleset 21 Dec 2004 03:36:19 -0000      1.43
+++ data/civ1/buildings.ruleset 23 Mar 2005 01:44:45 -0000
@@ -1453,5 +1453,4 @@
 
 ; Special values:
 
-aqueduct_size=10;
 default="Capitalization"
Index: data/civ1/effects.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ1/effects.ruleset,v
retrieving revision 1.2
diff -u -r1.2 effects.ruleset
--- data/civ1/effects.ruleset   1 Mar 2005 22:40:28 -0000       1.2
+++ data/civ1/effects.ruleset   23 Mar 2005 01:44:45 -0000
@@ -16,6 +16,11 @@
 ; /* <-- avoid gettext warnings
 ; */ <-- avoid gettext warnings
 
+; Base max city size of 10
+[effect_aqueduct_size]
+name    = "Size_Adj"
+value   = 10
+
 [effect_aqueduct]
 name   = "Size_Unlimit"
 value  = 1
Index: data/civ2/buildings.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ2/buildings.ruleset,v
retrieving revision 1.46
diff -u -r1.46 buildings.ruleset
--- data/civ2/buildings.ruleset 21 Dec 2004 03:36:19 -0000      1.46
+++ data/civ2/buildings.ruleset 23 Mar 2005 01:44:45 -0000
@@ -1884,5 +1884,4 @@
 
 ; Special values:
 
-aqueduct_size=8;
 default="Capitalization"
Index: data/civ2/effects.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ2/effects.ruleset,v
retrieving revision 1.2
diff -u -r1.2 effects.ruleset
--- data/civ2/effects.ruleset   1 Mar 2005 22:40:28 -0000       1.2
+++ data/civ2/effects.ruleset   23 Mar 2005 01:44:45 -0000
@@ -40,6 +40,11 @@
       "Building", "Airport", "City"
     }
 
+; Base max city size of 8
+[effect_aqueduct_size]
+name    = "Size_Adj"
+value   = 8
+
 [effect_aqueduct]
 name   = "Size_Adj"
 value  = 4
Index: data/default/buildings.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/default/buildings.ruleset,v
retrieving revision 1.66
diff -u -r1.66 buildings.ruleset
--- data/default/buildings.ruleset      22 Mar 2005 03:42:30 -0000      1.66
+++ data/default/buildings.ruleset      23 Mar 2005 01:44:45 -0000
@@ -1601,5 +1601,4 @@
 
 ; Special values:
 
-aqueduct_size=8
 default="Coinage"
Index: data/default/effects.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/default/effects.ruleset,v
retrieving revision 1.2
diff -u -r1.2 effects.ruleset
--- data/default/effects.ruleset        1 Mar 2005 22:40:28 -0000       1.2
+++ data/default/effects.ruleset        23 Mar 2005 01:44:45 -0000
@@ -40,6 +40,11 @@
       "Building", "Airport", "City"
     }
 
+; Base max city size of 8
+[effect_aqueduct_size]
+name    = "Size_Adj"
+value   = 8
+
 [effect_aqueduct]
 name   = "Size_Adj"
 value  = 4
Index: data/history/buildings.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/history/buildings.ruleset,v
retrieving revision 1.19
diff -u -r1.19 buildings.ruleset
--- data/history/buildings.ruleset      1 Mar 2005 22:40:28 -0000       1.19
+++ data/history/buildings.ruleset      23 Mar 2005 01:44:46 -0000
@@ -1924,5 +1924,4 @@
 
 ; Special values:
 
-aqueduct_size=8
 default="Coinage"
Index: data/history/effects.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/history/effects.ruleset,v
retrieving revision 1.2
diff -u -r1.2 effects.ruleset
--- data/history/effects.ruleset        1 Mar 2005 22:40:28 -0000       1.2
+++ data/history/effects.ruleset        23 Mar 2005 01:44:46 -0000
@@ -40,6 +40,11 @@
       "Building", "Airport", "City"
     }
 
+; Base max city size of 8
+[effect_aqueduct_size]
+name    = "Size_Adj"
+value   = 8
+
 [effect_aqueduct]
 name   = "Size_Adj"
 value  = 4
Index: server/ruleset.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v
retrieving revision 1.234
diff -u -r1.234 ruleset.c
--- server/ruleset.c    21 Mar 2005 13:05:21 -0000      1.234
+++ server/ruleset.c    23 Mar 2005 01:44:46 -0000
@@ -1263,8 +1263,6 @@
     }
   } impr_type_iterate_end;
 
-  game.aqueduct_size = secfile_lookup_int(file, "b_special.aqueduct_size");
-
   item = secfile_lookup_str(file, "b_special.default");
   if (*item != '\0') {
     game.default_building = find_improvement_by_name(item);
@@ -1727,7 +1725,6 @@
   struct packet_ruleset_control packet;
   int i;
 
-  packet.aqueduct_size = game.aqueduct_size;
   packet.add_to_size_limit = game.add_to_size_limit;
   packet.notradesize = game.notradesize;
   packet.fulltradesize = game.fulltradesize;

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12596) remove game.aqueduct_size, Jason Short <=