budget: Fix for ship, plane, land unit building abroad

The budget command simulates an update by running selected parts of
the update code.  It skips parts that depend on hidden information
such as guerrilla warfare.  For speed, it also skips parts it doesn't
need, such as distribution and foreign sectors, ships, planes and land
units.

Skipping foreign sectors is wrong when any of the player's ships,
planes or land units will be repaired in foreign sectors, because it
makes budget use old materials and work instead of new.

Skipping foreign ships, planes and land units is wrong when they
compete with the player's for materials and work.

The bug goes back to Chainsaw's option BUDGET.  See the previous
commit for more detailed historical notes.  The update test
demonstrates it in several variations.

Fix it with the sledgehammer: don't skip foreign sectors, ships,
planes and land units.  This makes budget almost twenty times slower
in my testing.  Probably tolerable on a reasonably beefy machine, but
we can do better; the next few commits will claw back most of the lost
performance.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2016-07-10 21:15:15 +02:00
parent 459dec0af0
commit 70f69640e1
8 changed files with 57 additions and 51 deletions

View file

@ -128,9 +128,7 @@ extern void prod_plane(int, int, struct bp *, int);
extern void populace(struct sctstr *, int);
extern int total_work(int, int, int, int, int, int);
/* prepare.c */
extern void prepare_sects(int);
extern void tax(struct sctstr *, int);
extern void bank_income(struct sctstr *, int);
extern void prepare_sects(int, struct bp *);
extern void pay_reserve(struct natstr *, int);
/* produce.c */
extern void produce(struct natstr *, struct sctstr *);