budget: Track sector expenses in nat_budget[]
The update summarizes sector production, building and maintenance for budget in a two-dimensional array int p_sect[SCT_BUDG_MAX+1][2]. All references into this array use literals as second subscript. Bzzzt, wrong data type. Add two one-dimensional arrays to nat_budget[], one for production, and one for building and maintenance. p_sect[i] becomes nat_budget[cnum].prod[i] for production, and .bm[j] for building and maintenance. p_sect[i][0] becomes .count, and -p_sect[i][1] becomes .money. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
bb495cac60
commit
16f9a393c4
4 changed files with 44 additions and 40 deletions
|
@ -39,9 +39,11 @@
|
|||
#define IMPORT 0
|
||||
#define EXPORT 1
|
||||
|
||||
#define SCT_EFFIC (SCT_TYPE_MAX + 1)
|
||||
#define SCT_MAINT (SCT_TYPE_MAX + 2)
|
||||
#define SCT_BUDG_MAX SCT_MAINT
|
||||
enum {
|
||||
BUDG_SCT_BUILD,
|
||||
BUDG_SCT_MAINT,
|
||||
BUDG_BLD_MAX = BUDG_SCT_MAINT
|
||||
};
|
||||
|
||||
struct budg_item {
|
||||
int money; /* money delta */
|
||||
|
@ -50,6 +52,10 @@ struct budg_item {
|
|||
|
||||
/* A nation's budget for an update */
|
||||
struct budget {
|
||||
/* production by sector type */
|
||||
struct budg_item prod[SCT_TYPE_MAX + 1];
|
||||
/* building and maintenance */
|
||||
struct budg_item bm[BUDG_BLD_MAX + 1];
|
||||
/* military payroll */
|
||||
struct budg_item mil;
|
||||
};
|
||||
|
@ -135,7 +141,7 @@ extern double buildeff(struct sctstr *);
|
|||
extern void do_fallout(struct sctstr *, int);
|
||||
extern void spread_fallout(struct sctstr *, int);
|
||||
extern void decay_fallout(struct sctstr *, int);
|
||||
extern void produce_sect(struct natstr *, int, struct bp *, int[][2]);
|
||||
extern void produce_sect(struct natstr *, int, struct bp *);
|
||||
/* ship.c */
|
||||
extern int prod_ship(int, int, struct bp *, int);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue