budget: Track taxes in nat_budget[]
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
cfdf52740b
commit
c12d1e137f
3 changed files with 34 additions and 29 deletions
|
@ -62,8 +62,8 @@ struct budget {
|
|||
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;
|
||||
/* population, taxes, military payroll */
|
||||
struct budg_item civ, mil, uw;
|
||||
};
|
||||
|
||||
/* main.c */
|
||||
|
@ -128,7 +128,7 @@ 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, int *, int *, int *);
|
||||
extern void tax(struct sctstr *, int, int *);
|
||||
extern void upd_slmilcosts(int, natid);
|
||||
extern int bank_income(struct sctstr *, int);
|
||||
extern void pay_reserve(struct natstr *, int);
|
||||
|
|
|
@ -42,8 +42,7 @@
|
|||
#include "product.h"
|
||||
#include "update.h"
|
||||
|
||||
static struct budget *calc_all(int *taxes, int *Ncivs,
|
||||
int *Nuws, int *bars, int *Nbars);
|
||||
static struct budget *calc_all(int *bars, int *Nbars);
|
||||
static char *dotsprintf(char *buf, char *format, int data);
|
||||
|
||||
int
|
||||
|
@ -63,9 +62,9 @@ budg(void)
|
|||
{ "Sector maintenance", "sector" }
|
||||
};
|
||||
int i;
|
||||
int taxes, Ncivs, Nuws, bars, Nbars;
|
||||
int bars, Nbars;
|
||||
struct budget *budget;
|
||||
int income, expenses;
|
||||
int income, expenses, taxes;
|
||||
struct natstr *np;
|
||||
char buf[1024];
|
||||
char in[80];
|
||||
|
@ -73,10 +72,10 @@ budg(void)
|
|||
np = getnatp(player->cnum);
|
||||
|
||||
player->simulation = 1;
|
||||
budget = calc_all(&taxes, &Ncivs, &Nuws, &bars, &Nbars);
|
||||
budget = calc_all(&bars, &Nbars);
|
||||
player->simulation = 0;
|
||||
|
||||
income = taxes + bars;
|
||||
income = bars;
|
||||
expenses = 0;
|
||||
pr("Sector Type\t\t\tProduction\t\t\t Cost\n");
|
||||
for (i = 0; i <= SCT_TYPE_MAX; i++) {
|
||||
|
@ -114,10 +113,13 @@ budg(void)
|
|||
}
|
||||
|
||||
pr("Total expenses%s\n", dotsprintf(buf, "%58d", expenses));
|
||||
taxes = budget->civ.money + budget->uw.money;
|
||||
if (taxes) {
|
||||
sprintf(in, "%d civ%s, %d uw%s",
|
||||
Ncivs, splur(Ncivs), Nuws, splur(Nuws));
|
||||
pr("Income from taxes\t\t%-32s%+8d\n", in, taxes);
|
||||
snprintf(buf, sizeof(buf), "%d civ%s, %d uw%s",
|
||||
budget->civ.count, splur(budget->civ.count),
|
||||
budget->uw.count, splur(budget->uw.count));
|
||||
pr("Income from taxes\t\t%-32s%+8d\n", buf, taxes);
|
||||
income += taxes;
|
||||
}
|
||||
if (bars) {
|
||||
sprintf(in, "%d bar%s", Nbars, splur(Nbars));
|
||||
|
@ -137,18 +139,18 @@ budg(void)
|
|||
}
|
||||
|
||||
static struct budget *
|
||||
calc_all(int *taxes, int *Ncivs, int *Nuws, int *bars, int *Nbars)
|
||||
calc_all(int *bars, int *Nbars)
|
||||
{
|
||||
struct budget *budget = &nat_budget[player->cnum];
|
||||
struct natstr *np;
|
||||
struct bp *bp;
|
||||
int pop = 0;
|
||||
int n, civ_tax, uw_tax;
|
||||
int n;
|
||||
struct sctstr *sp;
|
||||
int etu = etu_per_update;
|
||||
|
||||
memset(nat_budget, 0, sizeof(nat_budget));
|
||||
*taxes = *Ncivs = *Nuws = *bars = *Nbars = 0;
|
||||
*bars = *Nbars = 0;
|
||||
|
||||
np = getnatp(player->cnum);
|
||||
bp = bp_alloc();
|
||||
|
@ -156,10 +158,7 @@ calc_all(int *taxes, int *Ncivs, int *Nuws, int *bars, int *Nbars)
|
|||
bp_set_from_sect(bp, sp);
|
||||
if (sp->sct_own == player->cnum) {
|
||||
sp->sct_updated = 0;
|
||||
tax(sp, etu, &pop, &civ_tax, &uw_tax);
|
||||
*Ncivs += sp->sct_item[I_CIVIL];
|
||||
*Nuws += sp->sct_item[I_UW];
|
||||
*taxes += civ_tax + uw_tax;
|
||||
tax(sp, etu, &pop);
|
||||
if (sp->sct_type == SCT_BANK) {
|
||||
*bars += bank_income(sp, etu);
|
||||
*Nbars += sp->sct_item[I_BAR];
|
||||
|
|
|
@ -51,7 +51,7 @@ prepare_sects(int etu)
|
|||
{
|
||||
struct sctstr *sp;
|
||||
struct natstr *np;
|
||||
int n, civ_tax, uw_tax;
|
||||
int n;
|
||||
|
||||
memset(levels, 0, sizeof(levels));
|
||||
|
||||
|
@ -95,8 +95,7 @@ prepare_sects(int etu)
|
|||
do_plague(sp, etu);
|
||||
populace(sp, etu);
|
||||
np = getnatp(sp->sct_own);
|
||||
tax(sp, etu, &pops[sp->sct_own], &civ_tax, &uw_tax);
|
||||
np->nat_money += civ_tax + uw_tax;
|
||||
tax(sp, etu, &pops[sp->sct_own]);
|
||||
if (sp->sct_type == SCT_BANK)
|
||||
np->nat_money += bank_income(sp, etu);
|
||||
}
|
||||
|
@ -104,24 +103,31 @@ prepare_sects(int etu)
|
|||
upd_slmilcosts(etu, np->nat_cnum);
|
||||
pay_reserve(np, etu);
|
||||
np->nat_money += nat_budget[n].mil.money;
|
||||
np->nat_money += nat_budget[n].civ.money;
|
||||
np->nat_money += nat_budget[n].uw.money;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
tax(struct sctstr *sp, int etu, int *pop, int *civ_tax, int *uw_tax)
|
||||
tax(struct sctstr *sp, int etu, int *pop)
|
||||
{
|
||||
struct budget *budget = &nat_budget[sp->sct_own];
|
||||
int mil_pay;
|
||||
int civ_tax, uw_tax, mil_pay;
|
||||
|
||||
*civ_tax = (int)(0.5 + sp->sct_item[I_CIVIL] * sp->sct_effic *
|
||||
etu * money_civ / 100);
|
||||
civ_tax = (int)(0.5 + sp->sct_item[I_CIVIL] * sp->sct_effic *
|
||||
etu * money_civ / 100);
|
||||
/*
|
||||
* captured civs only pay 1/4 taxes
|
||||
*/
|
||||
if (sp->sct_own != sp->sct_oldown)
|
||||
*civ_tax = *civ_tax / 4;
|
||||
*uw_tax = (int)(0.5 + sp->sct_item[I_UW] * sp->sct_effic *
|
||||
etu * money_uw / 100);
|
||||
civ_tax /= 4;
|
||||
budget->civ.count += sp->sct_item[I_CIVIL];
|
||||
budget->civ.money += civ_tax;
|
||||
|
||||
uw_tax = (int)(0.5 + sp->sct_item[I_UW] * sp->sct_effic *
|
||||
etu * money_uw / 100);
|
||||
budget->uw.count += sp->sct_item[I_UW];
|
||||
budget->uw.money += uw_tax;
|
||||
|
||||
mil_pay = sp->sct_item[I_MILIT] * etu * money_mil;
|
||||
budget->mil.count += sp->sct_item[I_MILIT];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue