(max_pop): Use it. Don't support null argument anymore.
(nati, gen_power): Use max_population() instead of max_pop() with null
argument.
(show_sect_stats): Use max_population() to simplify the code.
(prod, upd_buildeff): Use max_population() to get correct new maximum
population for limiting work when tearing down a big city.
Previously, this was broken in upd_buildeff(). In prod(), it was
broken when the new designation had odd maximum population, which
should not occur.
extern s_char *BestAirPath(s_char *, int, int, int, int);
extern double pathcost(struct sctstr *, s_char *, int);
/* res_pop.c */
+extern int max_population(float, int, int);
extern int max_pop(float, struct sctstr *);
/* sectdamage.c */
extern int sect_damage(struct sctstr *, int, struct emp_qelem *);
pr(" Plague factor : %6.2f%%\n", pfac);
pr("\n");
- poplimit = max_pop(natp->nat_level[NAT_RLEV], 0);
+ poplimit = max_population(natp->nat_level[NAT_RLEV], SCT_MINE, 0);
pr("Max population : %d\n", poplimit);
safepop =
if (opt_RES_POP) {
np = getnatp(i);
- maxpop = max_pop(np->nat_level[NAT_RLEV], 0);
+ maxpop = max_population(np->nat_level[NAT_RLEV], SCT_MINE, 0);
f = 1.0 + (((float)maxpop) / 10000.0);
}
powbuf[i].p_power *= f;
if (!eff && dchr[otype].d_pkg == UPKG &&
dchr[type].d_pkg != UPKG) {
natp = getnatp(sect.sct_own);
- civs = min(civs, max_pop(natp->nat_level[NAT_RLEV], 0));
- uws = min(uws, max_pop(natp->nat_level[NAT_RLEV], 0));
+ maxpop = max_population(natp->nat_level[NAT_RLEV],
+ type, eff);
+ civs = min(civs, maxpop);
+ uws = min(uws, maxpop);
wforce = (int)(((double)civs * sect.sct_work) / 100.0
+ uws
+ sect.sct_item[I_MILIT] * 2 / 5.0);
#include "common.h"
int
-max_pop(float research, struct sctstr *sp)
+max_population(float research, int desig, int eff)
{
- int maxpop = dchr[sp ? sp->sct_type : SCT_MINE].d_maxpop;
+ int maxpop = dchr[desig].d_maxpop;
if (opt_RES_POP) {
/* research limits maximum population */
if (opt_BIG_CITY) {
/* city efficiency limits maximum population */
- if (sp && dchr[sp->sct_type].d_pkg == UPKG)
- maxpop = (int)(maxpop * ((9.0 * sp->sct_effic) / 100 + 1));
+ if (dchr[desig].d_pkg == UPKG)
+ maxpop *= 1 + 9.0 * eff / 100;
if (CANT_HAPPEN(maxpop > 9999))
maxpop = 9999;
}
+
return maxpop;
}
+
+int
+max_pop(float research, struct sctstr *sp)
+{
+ return max_population(research, sp->sct_type, sp->sct_effic);
+}
show_sect_stats(int foo)
{
int x, first = 1;
- struct sctstr sect;
struct natstr *natp;
natp = getnatp(player->cnum);
- /* We fake this */
- sect.sct_effic = 100;
for (x = 0; x <= SCT_MAXDEF; x++) {
if (dchr[x].d_mnem == 0)
continue;
pr(" sector type mcost off def mil uw civ bar other pop\n");
first = 0;
}
- sect.sct_type = x;
pr("%c %-23s %3d %5.2f %5.2f %3d %3d %3d %3d %5d %5d\n",
dchr[x].d_mnem, dchr[x].d_name,
dchr[x].d_mcst, dchr[x].d_ostr,
ichr[I_CIVIL].i_pkg[dchr[x].d_pkg],
ichr[I_BAR].i_pkg[dchr[x].d_pkg],
ichr[I_LCM].i_pkg[dchr[x].d_pkg],
- max_pop(natp->nat_level[NAT_RLEV], §));
+ max_population(natp->nat_level[NAT_RLEV], x, 100));
}
}
if (opt_BIG_CITY) {
if (!n && dchr[old_type].d_pkg == UPKG &&
dchr[*desig].d_pkg != UPKG) {
- int maxpop = max_pop(np->nat_level[NAT_RLEV], sp);
+ int maxpop = max_population(np->nat_level[NAT_RLEV], *desig, n);
if (vec[I_CIVIL] > maxpop)
vec[I_CIVIL] = maxpop;
if (vec[I_UW] > maxpop)