Complete.Org: Mailing Lists: Archives: freeciv-dev: December 1998:
[Freeciv-Dev] Patch: City growth and granary optimizing.
Home

[Freeciv-Dev] Patch: City growth and granary optimizing.

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxxx
Subject: [Freeciv-Dev] Patch: City growth and granary optimizing.
From: Tony & <stuckey@xxxxxxxxxxxxxxxxx>
Date: Wed, 9 Dec 1998 18:12:36 -0600

        When building a granary in a city, it is useful to postpone city
growth until the granary is complete so that you can save large amounts of
your foodbox.  This patch is intended to warn players when this type of
situation exists.
        Try it out, and as always, complain if it does something bad.
Suggestions of better parent functions to locate this in are also
accepted.  If it is too chatty, let me know that, too.


Index: client/messagedlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/messagedlg.c,v
retrieving revision 1.8
diff -u -r1.8 messagedlg.c
--- messagedlg.c        1998/11/14 00:49:53     1.8
+++ messagedlg.c        1998/12/09 23:52:43
@@ -74,6 +74,7 @@
   "Diplomat Actions - Own   ",          /* E_MY_DIPLOMAT */
   "Unit Attack Failed       ",          /* E_UNIT_LOST_ATT */
   "Unit Attack Succeeded    ",          /* E_UNIT_WIN_ATT */
+  "Suggest Growth Throttling",          /* E_CITY_GRAN_THROTTLE */
 };
 
 
Index: common/events.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/events.h,v
retrieving revision 1.5
diff -u -r1.5 events.h
--- events.h    1998/11/12 07:57:19     1.5
+++ events.h    1998/12/09 23:52:45
@@ -35,6 +35,7 @@
   E_MY_DIPLOMAT,
   E_UNIT_LOST_ATT,
   E_UNIT_WIN_ATT,
+  E_CITY_GRAN_THROTTLE,
   E_LAST
 };
 
Index: server/cityturn.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/cityturn.c,v
retrieving revision 1.42
diff -u -r1.42 cityturn.c
--- cityturn.c  1998/11/18 11:10:35     1.42
+++ cityturn.c  1998/12/09 23:52:54
@@ -1168,12 +1168,32 @@
 int update_city_activity(struct player *pplayer, struct city *pcity)
 {
   int got_tech = 0;
+  int turns_growth, turns_granary;
+
   city_check_workers(pplayer, pcity);
   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; 
   }
+
+  if (!city_got_effect(pcity,B_GRANARY) && !pcity->is_building_unit &&
+    (pcity->currently_building == B_GRANARY) && (pcity->food_surplus > 0)) {
+    turns_growth = ((pcity->size * game.foodbox) - pcity->food_stock)
+                     / pcity->food_surplus;
+    turns_granary = (improvement_value(B_GRANARY) - pcity->shield_stock)
+                     / pcity->shield_surplus;
+    /* if growth and granary completion occur simultaneously, granary
+       preserves food.  -AJS */
+    if ((turns_growth < 5) && (turns_granary < 5) &&
+        (turns_growth < turns_granary)) {
+       notify_player_ex(city_owner(pcity), pcity->x, pcity->y,
+                     E_CITY_GRAN_THROTTLE,
+                    "Game: %s suggest throttling growth to use granary (being 
built) more effectively.", pcity->name);
+       }
+    }
+  
 
 /* the AI often has widespread disorder when the Gardens or Oracle
 become obsolete.  This is a quick hack to prevent this.  980805 -- Syela */
-- 
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: City growth and granary optimizing., Tony & <=