Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2004:
[Freeciv-Dev] (PR#11606) rewrite calculation of production in generic_ci
Home

[Freeciv-Dev] (PR#11606) rewrite calculation of production in generic_ci

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#11606) rewrite calculation of production in generic_city_refresh
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 19 Dec 2004 12:56:53 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=11606 >

This patch rewrites the calculation of productions (pcity->prod[] and
pcity->waste[]) in generic_city_refresh.  It makes things simpler and
shorter and more general.  It also highlights some bugs in the current
system.

set_tax_income, add_buildings_effect, and set_food_trade_shields are all
removed.  Instead these are all merged into a single call to
get_citizen_output plus a new function set_city_productions().

This changes the order of operations slightly.  get_citizen_output fills
in the citizen_base array directly and fully, including output from tile
workers as well as from specialists.  set_city_productions then adds on
special bonuses (trade routes and tithes), output conversion
(trade->taxes), waste, and effects bonuses.

Behavior should be unchanged but this does highlight and document some
problems in the current system.  These problems relate to the cyclic
dependencies between calculating waste, calculating taxes, and adding on
bonuses.  In general:

* Bonuses must be added on after taxes are counted.
* Taxes must be counted after bonuses are added on (so that
EFT_TRADE_BONUS is accounted for).
* Waste must be counted after bonuses are added on (so that extra output
from factories is penalized).
* Taxes must be counted after waste is removed (so that corruption is
done before taxes).

Currently this works fine for the default ruleset since there is no
shield-waste and the trade bonus is always 100.  I believe there is a
bug (in 2.0 as well) in the civ2 ruleset: shield-waste is calculated
before the shield bonus (from factory, etc.) is added on.  Fixing all of
this without special casing probably means some things will have to be
calculated twice: including adding on the bonuses twice (fine, since
this is fast) and calculating waste twice (not fine).  But for now none
of this is changed and the new code should be comparable to or faster
than the current code.

-jason

Attachment: prod.diff
Description: Binary data


[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#11606) rewrite calculation of production in generic_city_refresh, Jason Short <=