Complete.Org: Mailing Lists: Archives: freeciv-dev: March 1999:
[Freeciv-Dev] Patch: Granary Size
Home

[Freeciv-Dev] Patch: Granary Size

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxxx
Subject: [Freeciv-Dev] Patch: Granary Size
From: Tony Stuckey <stuckey@xxxxxxxxxxxxxxxxx>
Date: Tue, 23 Mar 1999 12:56:53 -0600

        Civ1 and Civ2 have a granary size that is different than freeciv
currently implements.  (citysize+1)*10, rather than citysize*10.  This
patch brings freeciv into conformance.


Index: ai/aicity.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aicity.c,v
retrieving revision 1.39
diff -u -r1.39 aicity.c
--- aicity.c    1999/02/10 18:26:25     1.39
+++ aicity.c    1999/03/23 18:35:25
@@ -338,7 +338,7 @@
                buycost >= 200) ; /* wait for more vans */
       else if (bestchoice.type && unit_flag(bestchoice.choice, F_SETTLERS) &&
           !city_got_effect(pcity, B_GRANARY) && (pcity->size < 2 ||
-          pcity->food_stock < (pcity->size - 1) * game.foodbox)) ;
+          pcity->food_stock < pcity->size * game.foodbox)) ;
       else if (bestchoice.type && bestchoice.type < 3 && /* not a defender */
         buycost > unit_types[bestchoice.choice].build_cost * 2) { /* too 
expensive */
         if (unit_flag(bestchoice.choice, F_CARAVAN) &&
Index: ai/aihand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aihand.c,v
retrieving revision 1.31
diff -u -r1.31 aihand.c
--- aihand.c    1999/02/10 18:26:26     1.31
+++ aihand.c    1999/03/23 18:35:25
@@ -271,7 +271,7 @@
       n = (((pcity->size + 1)>>1) - pcity->ppl_happy[4]) * 20;
       if (n > pcity->ppl_content[1] * 20) n += (n - pcity->ppl_content[1] * 
20);
       m = ((((city_got_effect(pcity, B_GRANARY) ? 3 : 2) *
-            pcity->size * game.foodbox)>>1) -
+            (pcity->size+1) * game.foodbox)>>1) -
            pcity->food_stock) * food_weighting(pcity->size);
 /*printf("Checking HHJJ for %s, m = %d\n", pcity->name, m);*/
       tot = 0;
Index: client/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/citydlg.c,v
retrieving revision 1.34
diff -u -r1.34 citydlg.c
--- citydlg.c   1999/03/18 14:14:56     1.34
+++ citydlg.c   1999/03/23 18:35:25
@@ -980,7 +980,7 @@
   struct city *pcity=pdialog->pcity;
   
   sprintf(buf, "Granary: %3d/%-3d", pcity->food_stock,
-         game.foodbox*pcity->size);
+         game.foodbox*(pcity->size+1));
 
   xaw_set_label(pdialog->storage_label, buf);
 }
Index: client/cityrep.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/cityrep.c,v
retrieving revision 1.5
diff -u -r1.5 cityrep.c
--- cityrep.c   1999/03/03 14:12:13     1.5
+++ cityrep.c   1999/03/23 18:35:25
@@ -143,7 +143,7 @@
   static char buf[32];
   sprintf(buf,"%d/%d",
          pcity->food_stock,
-         pcity->size * game.foodbox);
+         (pcity->size+1) * game.foodbox);
   return buf;
 }
 
Index: server/cityturn.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/cityturn.c,v
retrieving revision 1.51
diff -u -r1.51 cityturn.c
--- cityturn.c  1999/02/27 18:54:23     1.51
+++ cityturn.c  1999/03/23 18:35:26
@@ -769,7 +769,7 @@
                       pcity->name);
     }
     /* Granary can only hold so much */
-    pcity->food_stock = (pcity->size * game.foodbox *
+    pcity->food_stock = ((pcity->size+1) * game.foodbox *
                         (100 - game.aqueductloss/(1+has_granary))) / 100;
     return;
   }
@@ -786,14 +786,14 @@
                       pcity->name);
     }
     /* Granary can only hold so much */
-    pcity->food_stock = (pcity->size * game.foodbox *
+    pcity->food_stock = ((pcity->size+1) * game.foodbox *
                         (100 - game.aqueductloss/(1+has_granary))) / 100; 
     return;
   }
 
   pcity->size++;
   if (has_granary)
-    pcity->food_stock = (pcity->size * game.foodbox) / 2;
+    pcity->food_stock = ((pcity->size+1) * game.foodbox) / 2;
   else
     pcity->food_stock = 0;
 
@@ -831,13 +831,13 @@
 **************************************************************************/
 void city_reduce_size(struct city *pcity)
 {
-  pcity->size--;
   notify_player_ex(city_owner(pcity), pcity->x, pcity->y, E_CITY_FAMINE,
                   "Game: Famine feared in %s", pcity->name);
   if (city_got_effect(pcity, B_GRANARY))
     pcity->food_stock=(pcity->size*game.foodbox)/2;
   else
     pcity->food_stock=0;
+  pcity->size--;
 
   city_auto_remove_worker(pcity);
 }
@@ -848,7 +848,7 @@
 void city_populate(struct city *pcity)
 {
   pcity->food_stock+=pcity->food_surplus;
-  if(pcity->food_stock >= pcity->size*game.foodbox) 
+  if(pcity->food_stock >= (pcity->size+1)*game.foodbox) 
     city_increase_size(pcity);
   else if(pcity->food_stock<0) {
     unit_list_iterate(pcity->units_supported, punit) {
@@ -860,7 +860,7 @@
        gamelog(GAMELOG_UNITFS, "%s lose Settlers (famine)",
                get_race_name_plural(game.players[pcity->owner].race));
        if (city_got_effect(pcity, B_GRANARY))
-         pcity->food_stock=(pcity->size*game.foodbox)/2;
+         pcity->food_stock=((pcity->size+1)*game.foodbox)/2;
        else
          pcity->food_stock=0;
        return;
@@ -1244,7 +1244,7 @@
   if (city_refresh(pcity) && 
       get_government(pcity->owner)>=G_REPUBLIC &&
       pcity->food_surplus>0 && pcity->size>4) {
-    pcity->food_stock=pcity->size*game.foodbox+1; 
+    pcity->food_stock=(pcity->size+1)*game.foodbox+1; 
   }
 
   if (!city_got_effect(pcity,B_GRANARY) && !pcity->is_building_unit &&
-- 
Anthony J. Stuckey                              stuckey@xxxxxxxxxxxxxxxxx
"When I was young, the sky was filled with stars.
 I watched them burn out one by one."  -Warren Zevon

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] Patch: Granary Size, Tony Stuckey <=