(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.
This commit is contained in:
parent
5fb761ab45
commit
a46cee180a
3 changed files with 13 additions and 17 deletions
|
@ -595,8 +595,7 @@ extern int plague_people(struct natstr *, int *, u_short *, u_short *, int);
|
||||||
/* plane.c */
|
/* plane.c */
|
||||||
extern int prod_plane(int, int, int *, int);
|
extern int prod_plane(int, int, int *, int);
|
||||||
/* populace.c */
|
/* populace.c */
|
||||||
extern void populace(struct natstr *, register struct sctstr *,
|
extern void populace(struct natstr *, register struct sctstr *, int);
|
||||||
register int *, int);
|
|
||||||
extern int total_work(register int, register int, register int,
|
extern int total_work(register int, register int, register int,
|
||||||
register int, register int);
|
register int, register int);
|
||||||
/* prepare.c */
|
/* prepare.c */
|
||||||
|
|
|
@ -49,22 +49,23 @@
|
||||||
#include "lost.h"
|
#include "lost.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
populace(struct natstr *np, register struct sctstr *sp, register int *vec,
|
populace(struct natstr *np, register struct sctstr *sp, int etu)
|
||||||
int etu)
|
|
||||||
{
|
{
|
||||||
float hap;
|
float hap;
|
||||||
float tech;
|
float tech;
|
||||||
float edu;
|
float edu;
|
||||||
float pct;
|
float pct;
|
||||||
int n;
|
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_work = 100;
|
||||||
sp->sct_loyal = 0;
|
sp->sct_loyal = 0;
|
||||||
sp->sct_oldown = sp->sct_own;
|
sp->sct_oldown = sp->sct_own;
|
||||||
}
|
}
|
||||||
if (!vec[I_CIVIL] && !vec[I_MILIT] && !vec[I_UW] &&
|
if (!civ && !mil && !sp->sct_item[I_UW]
|
||||||
!has_units(sp->sct_x, sp->sct_y, sp->sct_own, 0)) {
|
&& !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);
|
makelost(EF_SECTOR, sp->sct_own, 0, sp->sct_x, sp->sct_y);
|
||||||
sp->sct_own = 0;
|
sp->sct_own = 0;
|
||||||
sp->sct_oldown = 0;
|
sp->sct_oldown = 0;
|
||||||
|
@ -93,7 +94,7 @@ populace(struct natstr *np, register struct sctstr *sp, register int *vec,
|
||||||
n = 127;
|
n = 127;
|
||||||
sp->sct_loyal = n;
|
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;
|
int work_red;
|
||||||
|
|
||||||
work_red = sp->sct_loyal - (50 + (random() % 15));
|
work_red = sp->sct_loyal - (50 + (random() % 15));
|
||||||
|
|
|
@ -113,32 +113,28 @@ void
|
||||||
tax(struct sctstr *sp, struct natstr *np, int etu, long *pop, int *civ_tax,
|
tax(struct sctstr *sp, struct natstr *np, int etu, long *pop, int *civ_tax,
|
||||||
int *uw_tax, int *mil_pay)
|
int *uw_tax, int *mil_pay)
|
||||||
{
|
{
|
||||||
int vec[I_MAX + 1];
|
|
||||||
|
|
||||||
*civ_tax = 0;
|
*civ_tax = 0;
|
||||||
*uw_tax = 0;
|
*uw_tax = 0;
|
||||||
*mil_pay = 0;
|
*mil_pay = 0;
|
||||||
if (getvec(VT_ITEM, vec, (s_char *)sp, EF_SECTOR) <= 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!player->simulation)
|
if (!player->simulation)
|
||||||
populace(np, sp, vec, etu);
|
populace(np, sp, etu);
|
||||||
*civ_tax = (int)(0.5 + vec[I_CIVIL] * sp->sct_effic *
|
*civ_tax = (int)(0.5 + sp->sct_item[I_CIVIL] * sp->sct_effic *
|
||||||
etu * money_civ / 100);
|
etu * money_civ / 100);
|
||||||
/*
|
/*
|
||||||
* captured civs only pay 1/4 taxes
|
* captured civs only pay 1/4 taxes
|
||||||
*/
|
*/
|
||||||
if (sp->sct_own != sp->sct_oldown)
|
if (sp->sct_own != sp->sct_oldown)
|
||||||
*civ_tax = *civ_tax / 4;
|
*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);
|
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
|
* only non-captured civs add to census for nation
|
||||||
*/
|
*/
|
||||||
if (sp->sct_oldown == sp->sct_own)
|
if (sp->sct_oldown == sp->sct_own)
|
||||||
*pop += vec[I_CIVIL];
|
*pop += sp->sct_item[I_CIVIL];
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue