From a46cee180a47c6653b7d83515f306f458dc60da3 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 10 Mar 2004 17:59:37 +0000 Subject: [PATCH] (populace): Remove parameter vec, work with sp->sct_item[] instead. This is safe, because the only caller passed a copy of the latter created with getvec(), and populace() doesn't change it. (tax): Replace getvec() by direct, read-only item access. --- include/prototypes.h | 3 +-- src/lib/update/populace.c | 13 +++++++------ src/lib/update/prepare.c | 14 +++++--------- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/include/prototypes.h b/include/prototypes.h index ed5cefa6..ec0cdbe0 100644 --- a/include/prototypes.h +++ b/include/prototypes.h @@ -595,8 +595,7 @@ extern int plague_people(struct natstr *, int *, u_short *, u_short *, int); /* plane.c */ extern int prod_plane(int, int, int *, int); /* populace.c */ -extern void populace(struct natstr *, register struct sctstr *, - register int *, int); +extern void populace(struct natstr *, register struct sctstr *, int); extern int total_work(register int, register int, register int, register int, register int); /* prepare.c */ diff --git a/src/lib/update/populace.c b/src/lib/update/populace.c index e4623dbf..586c4c5e 100644 --- a/src/lib/update/populace.c +++ b/src/lib/update/populace.c @@ -49,22 +49,23 @@ #include "lost.h" void -populace(struct natstr *np, register struct sctstr *sp, register int *vec, - int etu) +populace(struct natstr *np, register struct sctstr *sp, int etu) { float hap; float tech; float edu; float pct; int n; + int civ = sp->sct_item[I_CIVIL]; + int mil = sp->sct_item[I_MILIT]; - if (vec[I_CIVIL] == 0 && vec[I_MILIT] > 0) { + if (civ == 0 && mil > 0) { sp->sct_work = 100; sp->sct_loyal = 0; sp->sct_oldown = sp->sct_own; } - if (!vec[I_CIVIL] && !vec[I_MILIT] && !vec[I_UW] && - !has_units(sp->sct_x, sp->sct_y, sp->sct_own, 0)) { + if (!civ && !mil && !sp->sct_item[I_UW] + && !has_units(sp->sct_x, sp->sct_y, sp->sct_own, 0)) { makelost(EF_SECTOR, sp->sct_own, 0, sp->sct_x, sp->sct_y); sp->sct_own = 0; sp->sct_oldown = 0; @@ -93,7 +94,7 @@ populace(struct natstr *np, register struct sctstr *sp, register int *vec, n = 127; sp->sct_loyal = n; } - if (sp->sct_loyal > 65 && vec[I_MILIT] < vec[I_CIVIL] / 20) { + if (sp->sct_loyal > 65 && mil < civ / 20) { int work_red; work_red = sp->sct_loyal - (50 + (random() % 15)); diff --git a/src/lib/update/prepare.c b/src/lib/update/prepare.c index 07b08a75..e1b385f9 100644 --- a/src/lib/update/prepare.c +++ b/src/lib/update/prepare.c @@ -113,32 +113,28 @@ void tax(struct sctstr *sp, struct natstr *np, int etu, long *pop, int *civ_tax, int *uw_tax, int *mil_pay) { - int vec[I_MAX + 1]; - *civ_tax = 0; *uw_tax = 0; *mil_pay = 0; - if (getvec(VT_ITEM, vec, (s_char *)sp, EF_SECTOR) <= 0) - return; if (!player->simulation) - populace(np, sp, vec, etu); - *civ_tax = (int)(0.5 + vec[I_CIVIL] * sp->sct_effic * + populace(np, sp, etu); + *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 + vec[I_UW] * sp->sct_effic * + *uw_tax = (int)(0.5 + sp->sct_item[I_UW] * sp->sct_effic * etu * money_uw / 100); - *mil_pay = vec[I_MILIT] * etu * money_mil; + *mil_pay = sp->sct_item[I_MILIT] * etu * money_mil; /* * only non-captured civs add to census for nation */ if (sp->sct_oldown == sp->sct_own) - *pop += vec[I_CIVIL]; + *pop += sp->sct_item[I_CIVIL]; } int