[Freeciv-Dev] (PR#10008) "net income" is wrong
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=10008 >
Here is an improved patch:
- Better comments.
- Unit upkeep is not double-counted.
It should be applied to both branches.
jason
? newtiles
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.249
diff -u -r1.249 city.c
--- common/city.c 1 Oct 2004 17:53:02 -0000 1.249
+++ common/city.c 6 Oct 2004 04:38:14 -0000
@@ -1043,7 +1043,7 @@
/*************************************************************************
Calculate amount of gold remaining in city after paying for buildings
- and units.
+ and units. Does not count capitalization.
*************************************************************************/
int city_gold_surplus(const struct city *pcity, int tax_total)
{
Index: common/player.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/player.c,v
retrieving revision 1.157
diff -u -r1.157 player.c
--- common/player.c 29 Sep 2004 02:24:23 -0000 1.157
+++ common/player.c 6 Oct 2004 04:38:14 -0000
@@ -381,8 +381,10 @@
/**************************************************************************
Return the expected net income of the player this turn. This includes
- tax revenue and upkeep, but not one-time purchases or found gold. Does
- not depend on pcity->total_tax being set correctly.
+ tax revenue and upkeep, but not one-time purchases or found gold.
+
+ This function depends on pcity->tax_total being set for all cities, so
+ make sure the player's cities have been refreshed.
**************************************************************************/
int player_get_expected_income(struct player *pplayer)
{
@@ -390,20 +392,8 @@
/* City income/expenses. */
city_list_iterate(pplayer->cities, pcity) {
- int lux, tax, sci, trade = pcity->trade_prod;
-
- get_tax_income(pplayer, trade, &sci, &lux, &tax);
- income += tax;
- income += pcity->specialists[SP_TAXMAN]
- * game.rgame.specialists[SP_TAXMAN].bonus;
- income += get_city_tithes_bonus(pcity);
-
- /* Improvement upkeep. */
- impr_type_iterate(impr_id) {
- if (city_got_building(pcity, impr_id)) {
- income -= improvement_upkeep(pcity, impr_id);
- }
- } impr_type_iterate_end;
+ /* Gold suplus accounts for imcome plus building and unit upkeep. */
+ income += city_gold_surplus(pcity, pcity->tax_total);
/* Capitalization income. */
if (get_current_construction_bonus(pcity, EFT_PROD_TO_GOLD) > 0) {
@@ -411,11 +401,6 @@
}
} city_list_iterate_end;
- /* Unit upkeep. */
- unit_list_iterate(pplayer->units, punit) {
- income -= punit->upkeep_gold;
- } unit_list_iterate_end;
-
return income;
}
|
|