]> git.pond.sub.org Git - empserver/commit
budget: Fix treasury tracking
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 19 Jun 2016 09:32:36 +0000 (11:32 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 6 Aug 2017 18:00:00 +0000 (20:00 +0200)
commit10789a03650eb0c723b9a9900c8d38afc03c8a34
tree22724787f88190e4c20e53f9ca98d92e7935a078
parent058268595fea3651928dc3765545954a24804c83
budget: Fix treasury tracking

The update simply updates each nation's nat_money as it goes.  Works.
Except it doesn't update when it runs on behalf of budget.  But it
still checks nat_money to determine whether the nation is solvent.
These checks are all broken.  Leads to massive mispredictions when
you'd go broke or solvent during a real update.

Track money unconditionally in nat_budget[].money.  Delay update of
nat_money until prod_nat().  Replace separate money[] by new
nat_budget[].start_money.  Closes bug#235.

Remaining difference between budget and update in the update test:

* #1: budget mispredicts plane #100 gets built (to be fixed)

* #2: budget shows ship, plane and land unit maintenance when broke,
      but update damages them instead (correct)

* #2: sector -14,0 converts, quadrupling its taxes (correct)

* #4 & #5: bank with dust and bars taken over by che (correct)

* #4: plague deaths (correct)

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
14 files changed:
include/update.h
src/lib/commands/budg.c
src/lib/update/finish.c
src/lib/update/land.c
src/lib/update/main.c
src/lib/update/nat.c
src/lib/update/plane.c
src/lib/update/prepare.c
src/lib/update/produce.c
src/lib/update/sect.c
src/lib/update/ship.c
tests/update/02-2
tests/update/03-3
tests/update/journal.log