struct budg_item prod[SCT_TYPE_MAX + 1];
/* building and maintenance */
struct budg_item bm[BUDG_BLD_MAX + 1];
- /* population, taxes, military payroll */
- struct budg_item civ, mil, uw;
+ /* population, taxes, military payroll, bank interest */
+ struct budg_item civ, mil, uw, bars;
};
/* main.c */
extern void prepare_sects(int);
extern void tax(struct sctstr *, int, int *);
extern void upd_slmilcosts(int, natid);
-extern int bank_income(struct sctstr *, int);
+extern void bank_income(struct sctstr *, int);
extern void pay_reserve(struct natstr *, int);
/* produce.c */
extern int produce(struct natstr *, struct sctstr *, int *);
#include "product.h"
#include "update.h"
-static struct budget *calc_all(int *bars, int *Nbars);
+static struct budget *calc_all(void);
static char *dotsprintf(char *buf, char *format, int data);
int
{ "Sector maintenance", "sector" }
};
int i;
- int bars, Nbars;
struct budget *budget;
int income, expenses, taxes;
struct natstr *np;
char buf[1024];
- char in[80];
np = getnatp(player->cnum);
player->simulation = 1;
- budget = calc_all(&bars, &Nbars);
+ budget = calc_all();
player->simulation = 0;
- income = bars;
- expenses = 0;
+ income = expenses = 0;
+
pr("Sector Type\t\t\tProduction\t\t\t Cost\n");
for (i = 0; i <= SCT_TYPE_MAX; i++) {
if (!budget->prod[i].money)
pr("Income from taxes\t\t%-32s%+8d\n", buf, taxes);
income += taxes;
}
- if (bars) {
- sprintf(in, "%d bar%s", Nbars, splur(Nbars));
- pr("Income from bars\t\t%-32s%+8d\n", in, bars);
+ if (budget->bars.money) {
+ snprintf(buf, sizeof(buf), "%d bar%s",
+ budget->bars.count, splur(budget->bars.count));
+ pr("Income from bars\t\t%-32s%+8d\n",
+ buf, budget->bars.money);
+ income += budget->bars.money;
}
pr("Total income%s\n", dotsprintf(buf, "%+60d", income));
pr("Balance forward\t\t\t\t\t\t %10d\n", np->nat_money);
}
static struct budget *
-calc_all(int *bars, int *Nbars)
+calc_all(void)
{
struct budget *budget = &nat_budget[player->cnum];
struct natstr *np;
int etu = etu_per_update;
memset(nat_budget, 0, sizeof(nat_budget));
- *bars = *Nbars = 0;
np = getnatp(player->cnum);
bp = bp_alloc();
if (sp->sct_own == player->cnum) {
sp->sct_updated = 0;
tax(sp, etu, &pop);
- if (sp->sct_type == SCT_BANK) {
- *bars += bank_income(sp, etu);
- *Nbars += sp->sct_item[I_BAR];
- }
+ if (sp->sct_type == SCT_BANK)
+ bank_income(sp, etu);
}
}
tpops[player->cnum] = pop;
guerrilla(sp);
do_plague(sp, etu);
populace(sp, etu);
- np = getnatp(sp->sct_own);
tax(sp, etu, &pops[sp->sct_own]);
if (sp->sct_type == SCT_BANK)
- np->nat_money += bank_income(sp, etu);
+ bank_income(sp, etu);
}
for (n = 0; NULL != (np = getnatp(n)); n++) {
upd_slmilcosts(etu, np->nat_cnum);
np->nat_money += nat_budget[n].mil.money;
np->nat_money += nat_budget[n].civ.money;
np->nat_money += nat_budget[n].uw.money;
+ np->nat_money += nat_budget[n].bars.money;
}
}
nat_budget[n].mil.money += mil * etu * money_mil;
}
-int
+void
bank_income(struct sctstr *sp, int etu)
{
- return (int)(sp->sct_item[I_BAR] * etu * bankint * sp->sct_effic / 100);
+ int inc;
+
+ inc = (int)(sp->sct_item[I_BAR] * etu * bankint * sp->sct_effic / 100);
+ nat_budget[sp->sct_own].bars.count += sp->sct_item[I_BAR];
+ nat_budget[sp->sct_own].bars.money += inc;
}
void