[Freeciv-Dev] (PR#11272) make pcity->xxx_bonus into an array
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=11272 >
This patch turns pcity->shield_bonus and the other bonus values into an
array pcity->bonus[] indexed by output type. The only changes that
aren't search-and-replace are in the struct city (in city.h) and in
create_city_virtual (in city.c).
jason
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.263
diff -u -r1.263 city.c
--- common/city.c 30 Nov 2004 08:37:03 -0000 1.263
+++ common/city.c 30 Nov 2004 21:09:08 -0000
@@ -1727,15 +1727,16 @@
static void add_buildings_effect(struct city *pcity)
{
/* this is the place to set them */
- pcity->tax_bonus = get_city_tax_bonus(pcity);
- pcity->luxury_bonus = get_city_luxury_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->luxury_bonus) / 100;
- pcity->tax_total = (pcity->tax_total * pcity->tax_bonus) / 100;
- pcity->science_total = (pcity->science_total * pcity->science_bonus) / 100;
+ pcity->bonus[O_GOLD] = get_city_tax_bonus(pcity);
+ pcity->bonus[O_LUXURY] = get_city_luxury_bonus(pcity);
+ pcity->bonus[O_SCIENCE] = get_city_science_bonus(pcity);
+ pcity->bonus[O_SHIELD] = get_city_shield_bonus(pcity);
+
+ pcity->shield_prod = (pcity->shield_prod * pcity->bonus[O_SHIELD]) / 100;
+ pcity->luxury_total = (pcity->luxury_total * pcity->bonus[O_LUXURY]) / 100;
+ pcity->tax_total = (pcity->tax_total * pcity->bonus[O_GOLD]) / 100;
+ pcity->science_total = (pcity->science_total
+ * pcity->bonus[O_SCIENCE]) / 100;
pcity->surplus[O_SHIELD] = pcity->shield_prod;
}
@@ -2518,10 +2519,9 @@
pcity->corruption = 0;
pcity->shield_waste = 0;
- pcity->shield_bonus = 100;
- pcity->luxury_bonus = 100;
- pcity->tax_bonus = 100;
- pcity->science_bonus = 100;
+ output_type_iterate(o) {
+ pcity->bonus[o] = 100;
+ } output_type_iterate_end;
pcity->client.occupied = FALSE;
pcity->client.happy = pcity->client.unhappy = FALSE;
Index: common/city.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.h,v
retrieving revision 1.171
diff -u -r1.171 city.h
--- common/city.h 30 Nov 2004 08:37:03 -0000 1.171
+++ common/city.h 30 Nov 2004 21:09:08 -0000
@@ -255,7 +255,7 @@
int corruption, tile_trade;
/* Cached values for CPU savings. */
- int shield_bonus, luxury_bonus, tax_bonus, science_bonus;
+ int bonus[O_MAX];
/* the totals */
int luxury_total, tax_total, science_total;
Index: common/aicore/cm.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/aicore/cm.c,v
retrieving revision 1.49
diff -u -r1.49 cm.c
--- common/aicore/cm.c 30 Nov 2004 08:37:03 -0000 1.49
+++ common/aicore/cm.c 30 Nov 2004 21:09:09 -0000
@@ -1544,7 +1544,7 @@
* production >= (surplus + usage)/factories
* Solving with surplus >= min_surplus, we get:
* production >= (min_surplus + usage)/factories
- * 'factories' is the pcity->shield_bonus/100. Increase it a bit to avoid
+ * 'factories' is the pcity->bonus[O_SHIELD]/100. Increase it a bit to avoid
* rounding errors.
*
* pcity->shield_prod = (factories-waste) * production.
@@ -1555,7 +1555,7 @@
usage[O_SHIELD] = pcity->shield_prod - pcity->surplus[O_SHIELD];
- sbonus = ((double)pcity->shield_bonus) / 100.0;
+ sbonus = ((double)pcity->bonus[O_SHIELD]) / 100.0;
sbonus += .1;
state->min_production[O_SHIELD]
= ((usage[O_SHIELD] + state->parameter.minimal_surplus[O_SHIELD])
@@ -1604,10 +1604,10 @@
+= pplayer->economic.tax * estimates[O_TRADE] / 100.0;
/* now add in the bonuses (none for food or trade) (in percentage) */
- estimates[O_SHIELD] *= pcity->shield_bonus / 100.0;
- estimates[O_LUXURY] *= pcity->luxury_bonus / 100.0;
- estimates[O_GOLD] *= pcity->tax_bonus / 100.0;
- estimates[O_SCIENCE] *= pcity->science_bonus / 100.0;
+ estimates[O_SHIELD] *= pcity->bonus[O_SHIELD] / 100.0;
+ estimates[O_LUXURY] *= pcity->bonus[O_LUXURY] / 100.0;
+ estimates[O_GOLD] *= pcity->bonus[O_GOLD] / 100.0;
+ estimates[O_SCIENCE] *= pcity->bonus[O_SCIENCE] / 100.0;
/* finally, sum it all up, weighted by the parameter, but give additional
* weight to luxuries to take account of disorder/happy constraints */
Index: server/citytools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v
retrieving revision 1.281
diff -u -r1.281 citytools.c
--- server/citytools.c 30 Nov 2004 08:37:03 -0000 1.281
+++ server/citytools.c 30 Nov 2004 21:09:09 -0000
@@ -499,7 +499,7 @@
**************************************************************************/
int city_shield_bonus(struct city *pcity)
{
- return pcity->shield_bonus;
+ return pcity->bonus[O_SHIELD];
}
/**************************************************************************
@@ -508,7 +508,7 @@
**************************************************************************/
int city_luxury_bonus(struct city *pcity)
{
- return pcity->luxury_bonus;
+ return pcity->bonus[O_LUXURY];
}
/**************************************************************************
@@ -517,7 +517,7 @@
**************************************************************************/
int city_tax_bonus(struct city *pcity)
{
- return pcity->tax_bonus;
+ return pcity->bonus[O_GOLD];
}
/**************************************************************************
@@ -526,7 +526,7 @@
**************************************************************************/
int city_science_bonus(struct city *pcity)
{
- return pcity->science_bonus;
+ return pcity->bonus[O_SCIENCE];
}
/*********************************************************************
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#11272) make pcity->xxx_bonus into an array,
Jason Short <=
|
|