Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2005:
[Freeciv-Dev] Re: (PR#13399) Granary Not Working - FreeCiv 2.02 (Fedora
Home

[Freeciv-Dev] Re: (PR#13399) Granary Not Working - FreeCiv 2.02 (Fedora

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jasoltow@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#13399) Granary Not Working - FreeCiv 2.02 (Fedora Core 4)
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 19 Jul 2005 11:12:29 -0700
Reply-to: bugs@xxxxxxxxxxx

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

And finally...this patch should fix the same code bugs for the
development version.  I believe the rulesets for the dev version are
correct (default and history have cumulative but weakened effects).

-jason


Index: server/cityturn.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/cityturn.c,v
retrieving revision 1.323
diff -p -u -r1.323 cityturn.c
--- server/cityturn.c   4 Jul 2005 17:48:38 -0000       1.323
+++ server/cityturn.c   19 Jul 2005 18:08:28 -0000
@@ -460,10 +460,12 @@ static void city_increase_size(struct ci
 {
   struct player *powner = city_owner(pcity);
   bool have_square;
-  int savings_pct = granary_savings(pcity), new_food;
+  int foodloss_pct = 100 - granary_savings(pcity);
   bool rapture_grow = city_rapture_grow(pcity); /* check before size increase! 
*/
 
   if (!city_can_grow_to(pcity, pcity->size + 1)) { /* need improvement */
+    int new_food;
+
     if (get_current_construction_bonus(pcity, EFT_SIZE_ADJ) > 0
         || get_current_construction_bonus(pcity, EFT_SIZE_UNLIMIT) > 0) {
       notify_player_ex(powner, pcity->tile, E_CITY_AQ_BUILDING,
@@ -477,20 +479,21 @@ static void city_increase_size(struct ci
     }
     /* Granary can only hold so much */
     new_food = (city_granary_size(pcity->size)
-               * (100 * 100 - game.info.aqueductloss * (100 - savings_pct))
+               * (100 * 100 - game.info.aqueductloss * foodloss_pct)
                / (100 * 100));
     pcity->food_stock = MIN(pcity->food_stock, new_food);
     return;
   }
 
-  pcity->size++;
-  /* Do not empty food stock if city is growing by celebrating */
-  if (rapture_grow) {
-    new_food = city_granary_size(pcity->size);
-  } else {
-    new_food = city_granary_size(pcity->size) * savings_pct / 100;
+  /* Take away food before increasing the population (which affects foodbox
+   * size).  Don't take away food for rapture growth.  Allow food to
+   * carry over where applicable. */
+  if (!rapture_grow) {
+    pcity->food_stock -= city_granary_size(pcity->size) * foodloss_pct / 100;
   }
-  pcity->food_stock = MIN(pcity->food_stock, new_food);
+
+  /* Increase size *after* growing. */
+  pcity->size++;
 
   /* If there is enough food, and the city is big enough,
    * make new citizens into scientists or taxmen -- Massimo */

[Prev in Thread] Current Thread [Next in Thread]