budget: Fix military count (but not yet their pay)

When we add up military payroll, we discard fractions.  Payroll is
therefore lower than it should be, but I'm not fixing that now.  The
number of military budget reports is actually computed from payroll,
and therefore also low.

The obvious way to fix that would be adding another out parameter to
tax() and upd_slmilcosts().  However, budget and the update track cost
and count of numerous things (sector products, unit maintenance and
building, ...), and it's time for a common way to do that.

Create struct budget_item for tracking cost and count, and struct
budget nat_budget[MAXNOC] for tracking a nation's budget.  Track only
military for now; more to follow.

This fixes the military count.  The cost of military remains low,
because we discard fractions exactly as before.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2016-06-18 14:57:45 +02:00
parent 35d2671c71
commit bb495cac60
6 changed files with 75 additions and 47 deletions

View file

@ -43,7 +43,19 @@
#define SCT_MAINT (SCT_TYPE_MAX + 2)
#define SCT_BUDG_MAX SCT_MAINT
struct budg_item {
int money; /* money delta */
int count; /* #things making/consuming the money */
};
/* A nation's budget for an update */
struct budget {
/* military payroll */
struct budg_item mil;
};
/* main.c */
extern struct budget nat_budget[MAXNOC];
extern int money[MAXNOC];
extern int pops[MAXNOC];
extern int sea_money[MAXNOC];
@ -103,10 +115,11 @@ extern int 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 tax(struct sctstr *, int, int *, int *, int *, int *);
extern int upd_slmilcosts(natid, int);
extern void prepare_sects(int);
extern void tax(struct sctstr *, int, int *, int *, int *);
extern void upd_slmilcosts(int, natid);
extern int bank_income(struct sctstr *, int);
extern void pay_reserve(struct natstr *, int);
/* produce.c */
extern int produce(struct natstr *, struct sctstr *, int *);
extern int prod_materials_cost(struct pchrstr *, short[], int *);