]> git.pond.sub.org Git - empserver/commit
update: Don't double-round money, fixing mil pay and more
authorMarkus Armbruster <armbru@pond.sub.org>
Wed, 6 Jul 2016 17:36:33 +0000 (19:36 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 6 Aug 2017 18:07:55 +0000 (20:07 +0200)
commit25a6cf92b2399c98216c6aadbcd9c2008ecf638d
treecc7ea9a1b5afd09c50c3f5bc7e3d7c4f906c98bb
parent10789a03650eb0c723b9a9900c8d38afc03c8a34
update: Don't double-round money, fixing mil pay and more

The update tallies income and expenses in full dollars.  Each debit or
credit is rounded before it is added to the tally.  Different things
are rounded differently.  Examples:

* Each sector's military pay is rounded down.  In the stock game, 1m
  is paid $4.999998, so n mil cost n*$5 -$1, for all practical n.  10m
  in one sector cost $49, but spread over ten sectors they cost only
  $40.

* Total pay for military in ships and land units is rounded down.

* Each plane's military pay is rounded down (used to be rounded up
  except for broke countries until recent commit 2eb08f4).  In the
  stock game, flight pay is 5 * $4.999998 = $24.99999.  For a plane
  with n mil, that's n * $25 - $1.  Filed under plane maintenance, not
  military payroll.

* Each sector's civilian tax is rounded.  In the stock game, 1c pays
  $0.499998.  10c in one sector pay $5, but spread over ten sectors
  they pay nothing.

* An occupied sector's civilian tax is first rounded, then divided by
  four and rounded down *boggle*.

* Each sector's uw tax is rounded.  In the stock game, 1u pays
  $0.106662.  1-4u in one sector pay nothing.  5-14u pay $1.

This is madness.  Has always been that way.

Drop the rounding and track money in type double throughout the
update.  Round only the final amount, randomly.  This is similar to
how commands accumulate a money delta in player->dolcost.

Likewise, tally the subtotals for budget in type double.  Display them
rounded to full dollars.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
14 files changed:
include/update.h
src/lib/commands/budg.c
src/lib/update/land.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/smoke/final.xdump
tests/smoke/journal.log
tests/update/02-2
tests/update/final.xdump
tests/update/journal.log