Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2004:
[Freeciv-Dev] (PR#9366) separate luxury_bonus from tax_bonus
Home

[Freeciv-Dev] (PR#9366) separate luxury_bonus from tax_bonus

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#9366) separate luxury_bonus from tax_bonus
From: "Jason Dorje Short" <jdorje@xxxxxxxxxxx>
Date: Tue, 13 Jul 2004 01:54:43 -0700
Reply-to: rt@xxxxxxxxxxx

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

This patch separates the luxury_bonus from the tax_bonus.

New globals:
   get_city_luxury_bonus() => in city.h
   pcity->luxury_bonus => in city.h
   city_luxury_bonus() => just a wrapper, in citytools.h

And the new values are used in place of the tax bonus in all the 
relevant locations.  Of course the tax bonus and the luxury bonus will 
still be equal until someone writes more code for them.

As a side note the city_xxx_bonus wrappers are quite useless.  They're 
declared globally inside the server but are only used inside 
citytools.c.  They should just be dropped.

jason

Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.226
diff -u -r1.226 city.c
--- common/city.c       12 Jul 2004 03:03:28 -0000      1.226
+++ common/city.c       13 Jul 2004 08:53:46 -0000
@@ -1735,8 +1735,7 @@
 }
 
 /**************************************************************************
- Return the factor (in %) by which the tax and luxury should be
- multiplied.
+  Return the factor (in %) by which the tax should be multiplied.
 **************************************************************************/
 int get_city_tax_bonus(const struct city *pcity)
 {
@@ -1756,6 +1755,15 @@
 }
 
 /**************************************************************************
+  Return the factor (in %) by which the luxury should be multiplied.
+**************************************************************************/
+int get_city_luxury_bonus(const struct city *pcity)
+{
+  /* Currently the luxury bonus is equivalent to the tax bonus. */
+  return get_city_tax_bonus(pcity);
+}
+
+/**************************************************************************
   Return the amount of gold generated by buildings under "tithe" attribute
   governments.
 **************************************************************************/
@@ -1945,12 +1953,13 @@
 static void add_buildings_effect(struct city *pcity)
 {
   /* this is the place to set them */
+  pcity->luxury_bonus = get_city_luxury_bonus(pcity);
   pcity->tax_bonus = get_city_tax_bonus(pcity);
   pcity->science_bonus = get_city_science_bonus(pcity);
   pcity->shield_bonus = get_city_shield_bonus(pcity);
 
   pcity->shield_prod = (pcity->shield_prod * pcity->shield_bonus) / 100;
-  pcity->luxury_total = (pcity->luxury_total * pcity->tax_bonus) / 100;
+  pcity->luxury_total = (pcity->luxury_total * pcity->luxury_bonus) / 100;
   pcity->tax_total = (pcity->tax_total * pcity->tax_bonus) / 100;
   pcity->science_total = (pcity->science_total * pcity->science_bonus) / 100;
   pcity->shield_surplus = pcity->shield_prod;
@@ -2756,6 +2765,7 @@
   pcity->corruption = 0;
   pcity->shield_waste = 0;
   pcity->shield_bonus = 100;
+  pcity->luxury_bonus = 100;
   pcity->tax_bonus = 100;
   pcity->science_bonus = 100;
 
Index: common/city.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.h,v
retrieving revision 1.151
diff -u -r1.151 city.h
--- common/city.h       12 Jul 2004 03:03:28 -0000      1.151
+++ common/city.h       13 Jul 2004 08:53:46 -0000
@@ -239,7 +239,9 @@
   /* Shield production is shields produced minus shield_waste*/
   int shield_prod, shield_surplus, shield_waste; 
   int trade_prod, corruption, tile_trade;
-  int shield_bonus, tax_bonus, science_bonus; /* more CPU savings! */
+
+  /* Cached values for CPU savings. */
+  int shield_bonus, luxury_bonus, tax_bonus, science_bonus;
 
   /* the totals */
   int luxury_total, tax_total, science_total;
@@ -484,6 +486,7 @@
 int get_cathedral_power(const struct city *pcity);
 int get_colosseum_power(const struct city *pcity);
 int get_city_tax_bonus(const struct city *pcity);
+int get_city_luxury_bonus(const struct city *pcity);
 int get_city_shield_bonus(const struct city *pcity);
 int get_city_science_bonus(const struct city *pcity);
 bool city_built_last_turn(const struct city *pcity);
Index: common/aicore/cm.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/aicore/cm.c,v
retrieving revision 1.29
diff -u -r1.29 cm.c
--- common/aicore/cm.c  11 Jul 2004 05:27:20 -0000      1.29
+++ common/aicore/cm.c  13 Jul 2004 08:53:46 -0000
@@ -1095,15 +1095,15 @@
    * Estimate an upper limit for the luxury. We assume that the player
    * has set the luxury rate to 100%. There are two extremal cases: all
    * citizen are entertainers (yielding a luxury of "(pcity->size * 2
-   * * get_city_tax_bonus(pcity))/100" = A) or all citizen are
+   * * get_city_luxury_bonus(pcity))/100" = A) or all citizen are
    * working on tiles and the resulting trade is converted to luxury
-   * (yielding a luxury of "(total_trade * get_city_tax_bonus(pcity))
+   * (yielding a luxury of "(total_trade * get_city_luxury_bonus(pcity))
    * / 100" = B) . We can't use MAX(A, B) since there may be cases in
    * between them which are better than these two exremal cases. So we
    * use A+B as upper limit.
    */
-  luxury =
-      ((pcity->size * 2 + total_trade) * get_city_tax_bonus(pcity)) / 100;
+  luxury
+    = ((pcity->size * 2 + total_trade) * get_city_luxury_bonus(pcity)) / 100;
 
   /* +1 because we want to index from 0 to pcity->size inclusive */
   if (pcity->size + 1 > cache2.allocated_size) {
Index: server/citytools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v
retrieving revision 1.261
diff -u -r1.261 citytools.c
--- server/citytools.c  14 Jun 2004 23:43:08 -0000      1.261
+++ server/citytools.c  13 Jul 2004 08:53:48 -0000
@@ -486,9 +486,10 @@
   j *= SHIELD_WEIGHTING * city_shield_bonus(pcity);
   j /= 100;
 
-  k = city_get_trade_tile(x, y, pcity) * pcity->ai.trade_want *
-      (city_tax_bonus(pcity) * (plr->economic.tax + plr->economic.luxury) +
-       city_science_bonus(pcity) * plr->economic.science) / 10000;
+  k = (city_get_trade_tile(x, y, pcity) * pcity->ai.trade_want
+       * (city_tax_bonus(pcity) * plr->economic.tax
+         + city_luxury_bonus(pcity) * plr->economic.luxury
+         + city_science_bonus(pcity) * plr->economic.science)) / 10000;
 
   return(i + j + k);
 }  
@@ -617,7 +618,8 @@
 }
 
 /**************************************************************************
-...
+  Return the cached shield bonus rate.  Don't confuse this with
+  get_city_shield_bonus which recomputes the value from scratch.
 **************************************************************************/
 int city_shield_bonus(struct city *pcity)
 {
@@ -625,7 +627,17 @@
 }
 
 /**************************************************************************
-...
+  Return the cached luxury bonus rate.  Don't confuse this with
+  get_city_luxury_bonus which recomputes the value from scratch.
+**************************************************************************/
+int city_luxury_bonus(struct city *pcity)
+{
+  return pcity->luxury_bonus;
+}
+
+/**************************************************************************
+  Return the cached tax bonus rate.  Don't confuse this with
+  get_city_tax_bonus which recomputes the value from scratch.
 **************************************************************************/
 int city_tax_bonus(struct city *pcity)
 {
@@ -633,7 +645,8 @@
 }
 
 /**************************************************************************
-...
+  Return the cached science bonus rate.  Don't confuse this with
+  get_city_science_bonus which recomputes the value from scratch.
 **************************************************************************/
 int city_science_bonus(struct city *pcity)
 {
Index: server/citytools.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/citytools.h,v
retrieving revision 1.51
diff -u -r1.51 citytools.h
--- server/citytools.h  14 Feb 2004 02:21:26 -0000      1.51
+++ server/citytools.h  13 Jul 2004 08:53:48 -0000
@@ -42,6 +42,7 @@
 bool built_elsewhere(struct city *pc, Impr_Type_id wonder);
 int do_make_unit_veteran(struct city *pcity, Unit_Type_id id);
 int city_shield_bonus(struct city *pcity);
+int city_luxury_bonus(struct city *pcity);
 int city_science_bonus(struct city *pcity);
 int city_tax_bonus(struct city *pcity);
 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#9366) separate luxury_bonus from tax_bonus, Jason Dorje Short <=