(total_work): Remove redundant conversion to int.
(total_work): New parameter maxpop. Callers changed. (newe, prod): Use total_work(). Old code failed to limit military workers, thus didn't match the update. (do_feed): Simplify.
This commit is contained in:
parent
43d07b458d
commit
5ba8cab9b5
6 changed files with 40 additions and 43 deletions
|
@ -774,8 +774,7 @@ extern int plague_people(struct natstr *, short *, int *, int *, int);
|
||||||
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 *, int);
|
extern void populace(struct natstr *, register struct sctstr *, int);
|
||||||
extern int total_work(register int, register int, register int,
|
extern int total_work(int, int, int, int, int, int);
|
||||||
register int, register int);
|
|
||||||
/* prepare.c */
|
/* prepare.c */
|
||||||
extern void tax(struct sctstr *, struct natstr *, int, long *, int *,
|
extern void tax(struct sctstr *, struct natstr *, int, long *, int *,
|
||||||
int *, int *);
|
int *, int *);
|
||||||
|
|
|
@ -71,14 +71,12 @@ newe(void)
|
||||||
uws = (1.0 + uwbrate * etu_per_update) * sect.sct_item[I_UW];
|
uws = (1.0 + uwbrate * etu_per_update) * sect.sct_item[I_UW];
|
||||||
natp = getnatp(sect.sct_own);
|
natp = getnatp(sect.sct_own);
|
||||||
maxpop = max_pop(natp->nat_level[NAT_RLEV], §);
|
maxpop = max_pop(natp->nat_level[NAT_RLEV], §);
|
||||||
civs = min(civs, maxpop);
|
|
||||||
uws = min(uws, maxpop);
|
|
||||||
/* This isn't quite right, since research might rise/fall */
|
/* This isn't quite right, since research might rise/fall */
|
||||||
/* during the update, but it's the best we can really do */
|
/* during the update, but it's the best we can really do */
|
||||||
wforce = (int)((civs * sect.sct_work) / 100.0
|
work = new_work(§,
|
||||||
+ uws + sect.sct_item[I_MILIT] * 2 / 5.0);
|
total_work(sect.sct_work, etu_per_update,
|
||||||
|
civs, sect.sct_item[I_MILIT], uws,
|
||||||
work = new_work(§, wforce * etu_per_update / 100);
|
maxpop));
|
||||||
bwork = work / 2;
|
bwork = work / 2;
|
||||||
|
|
||||||
type = sect.sct_type;
|
type = sect.sct_type;
|
||||||
|
|
|
@ -84,7 +84,6 @@ prod(void)
|
||||||
int there;
|
int there;
|
||||||
int unit_work; /* sum of component amounts */
|
int unit_work; /* sum of component amounts */
|
||||||
int used; /* production w/infinite workforce */
|
int used; /* production w/infinite workforce */
|
||||||
int wforce;
|
|
||||||
i_type it;
|
i_type it;
|
||||||
i_type vtype;
|
i_type vtype;
|
||||||
u_char *resource;
|
u_char *resource;
|
||||||
|
@ -113,15 +112,12 @@ prod(void)
|
||||||
uws = (1.0 + uwbrate * etu_per_update) * sect.sct_item[I_UW];
|
uws = (1.0 + uwbrate * etu_per_update) * sect.sct_item[I_UW];
|
||||||
natp = getnatp(sect.sct_own);
|
natp = getnatp(sect.sct_own);
|
||||||
maxpop = max_pop(natp->nat_level[NAT_RLEV], §);
|
maxpop = max_pop(natp->nat_level[NAT_RLEV], §);
|
||||||
civs = min(civs, maxpop);
|
|
||||||
uws = min(uws, maxpop);
|
|
||||||
|
|
||||||
/* This isn't quite right, since research might rise/fall */
|
/* This isn't quite right, since research might rise/fall */
|
||||||
/* during the update, but it's the best we can really do */
|
/* during the update, but it's the best we can really do */
|
||||||
wforce = (int)(((double)civs * sect.sct_work) / 100.0
|
work = new_work(§,
|
||||||
+ uws
|
total_work(sect.sct_work, etu_per_update,
|
||||||
+ sect.sct_item[I_MILIT] * 2.0 / 5.0);
|
civs, sect.sct_item[I_MILIT], uws, maxpop));
|
||||||
work = new_work(§, wforce * etu_per_update / 100);
|
|
||||||
bwork = work / 2;
|
bwork = work / 2;
|
||||||
|
|
||||||
if (sect.sct_off)
|
if (sect.sct_off)
|
||||||
|
@ -146,13 +142,11 @@ prod(void)
|
||||||
natp = getnatp(sect.sct_own);
|
natp = getnatp(sect.sct_own);
|
||||||
maxpop = max_population(natp->nat_level[NAT_RLEV],
|
maxpop = max_population(natp->nat_level[NAT_RLEV],
|
||||||
type, eff);
|
type, eff);
|
||||||
civs = min(civs, maxpop);
|
work = new_work(§,
|
||||||
uws = min(uws, maxpop);
|
total_work(sect.sct_work, etu_per_update,
|
||||||
wforce = (int)(((double)civs * sect.sct_work) / 100.0
|
civs, sect.sct_item[I_MILIT],
|
||||||
+ uws
|
uws, maxpop));
|
||||||
+ sect.sct_item[I_MILIT] * 2 / 5.0);
|
bwork = min(work / 2, bwork);
|
||||||
work = etu_per_update * wforce / 100;
|
|
||||||
bwork = min((int)(work / 2), bwork);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
twork = 100 - eff;
|
twork = 100 - eff;
|
||||||
|
|
|
@ -65,19 +65,17 @@ do_feed(struct sctstr *sp, struct natstr *np, short *vec,
|
||||||
int people;
|
int people;
|
||||||
int work_avail;
|
int work_avail;
|
||||||
int starved, sctwork;
|
int starved, sctwork;
|
||||||
int needed, dummy;
|
int needed;
|
||||||
int civvies, uws;
|
|
||||||
int mil;
|
|
||||||
int maxpop;
|
int maxpop;
|
||||||
|
|
||||||
/* grow people & stuff */
|
/* grow people & stuff */
|
||||||
sctwork = sp->sct_work;
|
sctwork = sp->sct_work;
|
||||||
|
|
||||||
maxpop = max_pop(np->nat_level[NAT_RLEV], sp);
|
maxpop = max_pop(np->nat_level[NAT_RLEV], sp);
|
||||||
civvies = (vec[I_CIVIL] > maxpop) ? maxpop : vec[I_CIVIL];
|
work_avail = new_work(sp,
|
||||||
uws = (vec[I_UW] > maxpop) ? maxpop : vec[I_UW];
|
total_work(sctwork, etu,
|
||||||
mil = (vec[I_MILIT] > maxpop) ? maxpop : vec[I_MILIT];
|
vec[I_CIVIL], vec[I_MILIT], vec[I_UW],
|
||||||
work_avail = new_work(sp, total_work(sctwork, etu, civvies, mil, uws));
|
maxpop));
|
||||||
|
|
||||||
people = vec[I_CIVIL] + vec[I_MILIT] + vec[I_UW];
|
people = vec[I_CIVIL] + vec[I_MILIT] + vec[I_UW];
|
||||||
if (sp->sct_type != SCT_SANCT) {
|
if (sp->sct_type != SCT_SANCT) {
|
||||||
|
@ -126,7 +124,7 @@ do_feed(struct sctstr *sp, struct natstr *np, short *vec,
|
||||||
sctwork = 100;
|
sctwork = 100;
|
||||||
if (!player->simulation)
|
if (!player->simulation)
|
||||||
sp->sct_work = sctwork;
|
sp->sct_work = sctwork;
|
||||||
dummy = grow_people(sp, etu, np, &work_avail, sctwork, vec);
|
grow_people(sp, etu, np, &work_avail, sctwork, vec);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
sctwork = sp->sct_work = 100;
|
sctwork = sp->sct_work = 100;
|
||||||
|
@ -307,7 +305,7 @@ grow_people(struct sctstr *sp, int etu,
|
||||||
*/
|
*/
|
||||||
if (opt_NOFOOD == 0 && (newciv || newuw))
|
if (opt_NOFOOD == 0 && (newciv || newuw))
|
||||||
vec[I_FOOD] -= roundavg((newciv + newuw) * babyeat);
|
vec[I_FOOD] -= roundavg((newciv + newuw) * babyeat);
|
||||||
*workp += total_work(sctwork, etu, newciv, 0, newuw);
|
*workp += total_work(sctwork, etu, newciv, 0, newuw, ITEM_MAX);
|
||||||
return newciv + newuw;
|
return newciv + newuw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -131,9 +131,14 @@ populace(struct natstr *np, struct sctstr *sp, int etu)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
total_work(int sctwork, int etu, int civil,
|
total_work(int sctwork, int etu, int civil, int milit, int uw, int maxpop)
|
||||||
int milit, int uw)
|
|
||||||
{
|
{
|
||||||
return ((int)((((civil * sctwork) / 100.0 +
|
if (civil > maxpop)
|
||||||
(milit * 2 / 5.0) + uw)) * etu) / 100);
|
civil = maxpop;
|
||||||
|
if (milit > maxpop)
|
||||||
|
milit = maxpop;
|
||||||
|
if (uw > maxpop)
|
||||||
|
uw = maxpop;
|
||||||
|
|
||||||
|
return (civil * sctwork / 100.0 + milit * 0.4 + uw) * etu / 100.0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,7 +172,8 @@ upd_ship(struct shpstr *sp, int etus,
|
||||||
oil_gained = roundavg(total_work(100, etus,
|
oil_gained = roundavg(total_work(100, etus,
|
||||||
sp->shp_item[I_CIVIL],
|
sp->shp_item[I_CIVIL],
|
||||||
sp->shp_item[I_MILIT],
|
sp->shp_item[I_MILIT],
|
||||||
sp->shp_item[I_UW])
|
sp->shp_item[I_UW],
|
||||||
|
ITEM_MAX)
|
||||||
* (double)sp->shp_effic / 100.0
|
* (double)sp->shp_effic / 100.0
|
||||||
* (double)sectp->sct_oil / 100.0
|
* (double)sectp->sct_oil / 100.0
|
||||||
* prod_eff(product, sp->shp_tech));
|
* prod_eff(product, sp->shp_tech));
|
||||||
|
@ -190,12 +191,14 @@ upd_ship(struct shpstr *sp, int etus,
|
||||||
}
|
}
|
||||||
if ((mp->m_flags & M_FOOD) && sectp->sct_type == SCT_WATER) {
|
if ((mp->m_flags & M_FOOD) && sectp->sct_type == SCT_WATER) {
|
||||||
product = &pchr[P_FOOD];
|
product = &pchr[P_FOOD];
|
||||||
sp->shp_item[I_FOOD] += roundavg(total_work(100, etus,
|
sp->shp_item[I_FOOD]
|
||||||
|
+= roundavg(total_work(100, etus,
|
||||||
sp->shp_item[I_CIVIL],
|
sp->shp_item[I_CIVIL],
|
||||||
sp->shp_item[I_MILIT],
|
sp->shp_item[I_MILIT],
|
||||||
sp->shp_item[I_UW])
|
sp->shp_item[I_UW],
|
||||||
* (double)sp->shp_effic / 100.0
|
ITEM_MAX)
|
||||||
* (double)sectp->sct_fertil / 100.0
|
* sp->shp_effic / 100.0
|
||||||
|
* sectp->sct_fertil / 100.0
|
||||||
* prod_eff(product, sp->shp_tech));
|
* prod_eff(product, sp->shp_tech));
|
||||||
}
|
}
|
||||||
if ((n = feed_ship(sp, etus, &needed, 1)) > 0) {
|
if ((n = feed_ship(sp, etus, &needed, 1)) > 0) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue