Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2004:
[Freeciv-Dev] (PR#11404) new function citygov_free_upkeep
Home

[Freeciv-Dev] (PR#11404) new function citygov_free_upkeep

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#11404) new function citygov_free_upkeep
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 8 Dec 2004 00:30:40 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=11404 >

This patch merges citygov_free_shields, citygov_free_food, and 
citygov_free_gold into a single function citygov_free_upkeep.  It is 
quite simple.

I considered making this function static.  But citygov_free_happy() is 
used in the AI code so this one probably should be too.

-jason

? client/gui-gtk/citydlg.c.10508
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.275
diff -u -r1.275 city.c
--- common/city.c       8 Dec 2004 07:48:24 -0000       1.275
+++ common/city.c       8 Dec 2004 08:28:45 -0000
@@ -1211,15 +1211,16 @@
 }
 
 /**************************************************************************
-  Return the number of free shields for unit support the city would get
-  under the given government.
+  Return the number of free units of upkeep for unit support the city
+  would get under the given government.
 **************************************************************************/
-int citygov_free_shield(const struct city *pcity, struct government *gov)
+int citygov_free_upkeep(const struct city *pcity,
+                       const struct government *gov, Output_type_id otype)
 {
-  if (gov->free_upkeep[O_SHIELD] == G_CITY_SIZE_FREE) {
+  if (gov->free_upkeep[otype] == G_CITY_SIZE_FREE) {
     return pcity->size;
   } else {
-    return gov->free_upkeep[O_SHIELD];
+    return gov->free_upkeep[otype];
   }
 }
 
@@ -1236,31 +1237,6 @@
 }
 
 /**************************************************************************
-...
-**************************************************************************/
-int citygov_free_food(const struct city *pcity, struct government *gov)
-{
-  if (gov->free_upkeep[O_FOOD] == G_CITY_SIZE_FREE) {
-    return pcity->size;
-  } else {
-    return gov->free_upkeep[O_FOOD];
-  }
-}
-
-/**************************************************************************
-...
-**************************************************************************/
-static int citygov_free_gold(const struct city *pcity, 
-                             struct government *gov)
-{
-  if (gov->free_upkeep[O_GOLD] == G_CITY_SIZE_FREE) {
-    return pcity->size;
-  } else {
-    return gov->free_upkeep[O_GOLD];
-  }
-}
-
-/**************************************************************************
 Evaluate which style should be used to draw a city.
 **************************************************************************/
 int get_city_style(const struct city *pcity)
@@ -2033,9 +2009,9 @@
   struct government *g = get_gov_pcity(pcity);
 
   int free_happy = citygov_free_happy(pcity, g);
-  int free_shield = citygov_free_shield(pcity, g);
-  int free_food = citygov_free_food(pcity, g);
-  int free_gold = citygov_free_gold(pcity, g);
+  int free_shield = citygov_free_upkeep(pcity, g, O_SHIELD);
+  int free_food = citygov_free_upkeep(pcity, g, O_FOOD);
+  int free_gold = citygov_free_upkeep(pcity, g, O_GOLD);
 
   /* ??  This does the right thing for normal Republic and Democ -- dwp */
   free_happy += get_city_bonus(pcity, EFT_MAKE_CONTENT_MIL);
Index: common/city.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.h,v
retrieving revision 1.177
diff -u -r1.177 city.h
--- common/city.h       8 Dec 2004 07:48:24 -0000       1.177
+++ common/city.h       8 Dec 2004 08:28:45 -0000
@@ -465,9 +465,9 @@
 int city_name_compare(const void *p1, const void *p2);
 
 /* city free cost values depending on government: */
-int citygov_free_shield(const struct city *pcity, struct government *gov);
+int citygov_free_upkeep(const struct city *pcity,
+                       const struct government *gov, Output_type_id otype);
 int citygov_free_happy(const struct city *pcity, struct government *gov);
-int citygov_free_food(const struct city *pcity, struct government *gov);
 
 /* city style functions */
 int get_city_style(const struct city *pcity);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#11404) new function citygov_free_upkeep, Jason Short <=