Remove budget priorities:

(budg, player_coms): Remove command arguments.
(PRI_SMAINT, PRI_PMAINT, PRI_LMAINT, PRI_SBUILD, PRI_PBUILD)
(PRI_LBUILD, PRI_MAX): Remove.
(natstr): Remove member nat_priorities.
(add, main): Remove its initialization.
(budg, cal_call, prexpense, prod, update_main, upd_land, upd_plane)
(upd_buildeff, produce_sect, upd_ship): Simplify.
(produce_sect): Last parameter now superflous, remove & simplify.
(change_prio, do_prod): Unused, remove.

(budg): Move land units output down, to match update sequence.
This commit is contained in:
Markus Armbruster 2006-05-29 20:43:30 +00:00
parent 26110320c0
commit 520446ef39
14 changed files with 170 additions and 449 deletions

View file

@ -221,8 +221,6 @@ add(void)
} else
pr("No special initializations done...\n");
for (i = 0; i <= PRI_MAX; i++)
natp->nat_priorities[i] = -1;
natp->nat_flags =
NF_FLASH | NF_BEEP | NF_COASTWATCH | NF_SONAR | NF_TECHLISTS;
for (i = 0; i < MAXNOC; i++)

View file

@ -31,6 +31,7 @@
* Thomas Ruschak, 1992
* Ville Virrankoski, 1995
* Steve McClure, 1997-2000
* Markus Armbruster, 2004-2006
*/
#include <config.h>
@ -57,9 +58,8 @@ static void calc_all(long (*p_sect)[2], int *taxes, int *Ncivs,
int *ships, int *sbuild, int *nsbuild, int *smaint,
int *units, int *lbuild, int *nlbuild, int *lmaint,
int *planes, int *pbuild, int *npbuild, int *pmaint);
static int change_prio(struct natstr *np, char code, char *newval);
static char *dotsprintf(char *buf, char *format, int data);
static void prexpense(long cash, int *expensesp, int priority, int amount);
static void prexpense(long cash, int *expensesp, int amount);
int
budg(void)
@ -79,13 +79,6 @@ budg(void)
etu = etu_per_update;
np = getnatp(player->cnum);
if (player->argp[1]) {
res = change_prio(np, player->argp[1][0], player->argp[2]);
if (res != RET_OK) {
putnat(np);
return res;
}
}
player->simulation = 1;
calc_all(p_sect,
@ -93,84 +86,59 @@ budg(void)
&ships, &sbuild, &nsbuild, &smaint,
&units, &lbuild, &nlbuild, &lmaint,
&planes, &pbuild, &npbuild, &pmaint);
player->simulation = 0;
income = taxes + bars;
expenses = 0;
pr("Sector Type\t\tAbbr\tProduction\tPriority\t Cost\n");
pr("Sector Type\t\t\tProduction\t\t\t Cost\n");
for (i = 0; i <= SCT_MAXDEF; i++) {
if (!p_sect[i][1] && np->nat_priorities[i] == -1)
if (!p_sect[i][1] || i == SCT_CAPIT)
continue;
if (!pchr[dchr[i].d_prd].p_cost &&
np->nat_priorities[i] == -1 && i != SCT_ENLIST)
continue;
pr("%-17s\t%c\t", dchr[i].d_name, dchr[i].d_mnem);
pr("%-17s\t\t", dchr[i].d_name);
if (i == SCT_ENLIST)
pr("%ld mil \t", p_sect[i][0]);
else if (pchr[dchr[i].d_prd].p_cost != 0)
pr("%ld %-7s\t", p_sect[i][0], pchr[dchr[i].d_prd].p_sname);
else
pr("\t\t");
if (np->nat_priorities[i] != -1)
pr("%d", np->nat_priorities[i]);
prexpense(np->nat_money + income, &expenses,
np->nat_priorities[i], p_sect[i][1]);
}
if (lbuild) {
sprintf(buf, "%d unit%s", nlbuild, splur(nlbuild));
pr("Unit building\t\tL\t%-16s", buf);
if (np->nat_priorities[PRI_LBUILD] != -1)
pr("%d", np->nat_priorities[PRI_LBUILD]);
prexpense(np->nat_money + income, &expenses,
np->nat_priorities[PRI_LBUILD], -1 * lbuild);
}
if (lmaint) {
sprintf(buf, "%d unit%s", units, splur(units));
pr("Unit maintenance\tA\t%-16s", buf);
if (np->nat_priorities[PRI_LMAINT] != -1)
pr("%d", np->nat_priorities[PRI_LMAINT]);
prexpense(np->nat_money + income, &expenses,
np->nat_priorities[PRI_LMAINT], -1 * lmaint);
prexpense(np->nat_money + income, &expenses, p_sect[i][1]);
}
if (sbuild) {
sprintf(buf, "%d ship%s", nsbuild, splur(nsbuild));
pr("Ship building\t\tS\t%-16s", buf);
if (np->nat_priorities[PRI_SBUILD] != -1)
pr("%d", np->nat_priorities[PRI_SBUILD]);
prexpense(np->nat_money + income, &expenses,
np->nat_priorities[PRI_SBUILD], -1 * sbuild);
pr("Ship building\t\t\t%-16s", buf);
prexpense(np->nat_money + income, &expenses, -sbuild);
}
if (smaint) {
sprintf(buf, "%d ship%s", ships, splur(ships));
pr("Ship maintenance\tM\t%-16s", buf);
if (np->nat_priorities[PRI_SMAINT] != -1)
pr("%d", np->nat_priorities[PRI_SMAINT]);
prexpense(np->nat_money + income, &expenses,
np->nat_priorities[PRI_SMAINT], -1 * smaint);
pr("Ship maintenance\t\t%-16s", buf);
prexpense(np->nat_money + income, &expenses, -smaint);
}
if (pbuild) {
sprintf(buf, "%d plane%s", npbuild, splur(npbuild));
pr("Plane building\t\tP\t%-16s", buf);
if (np->nat_priorities[PRI_PBUILD] != -1)
pr("%d", np->nat_priorities[PRI_PBUILD]);
prexpense(np->nat_money + income, &expenses,
np->nat_priorities[PRI_PBUILD], -1 * pbuild);
pr("Plane building\t\t\t%-16s", buf);
prexpense(np->nat_money + income, &expenses, -pbuild);
}
if (pmaint) {
sprintf(buf, "%d plane%s", planes, splur(planes));
pr("Plane maintenance\tN\t%-16s", buf);
if (np->nat_priorities[PRI_PMAINT] != -1)
pr("%d", np->nat_priorities[PRI_PMAINT]);
prexpense(np->nat_money + income, &expenses,
np->nat_priorities[PRI_PMAINT], -1 * pmaint);
pr("Plane maintenance\t\t%-16s", buf);
prexpense(np->nat_money + income, &expenses, -pmaint);
}
if (lbuild) {
sprintf(buf, "%d unit%s", nlbuild, splur(nlbuild));
pr("Unit building\t\t\t%-16s", buf);
prexpense(np->nat_money + income, &expenses, -lbuild);
}
if (lmaint) {
sprintf(buf, "%d unit%s", units, splur(units));
pr("Unit maintenance\t\t%-16s", buf);
prexpense(np->nat_money + income, &expenses, -lmaint);
}
if (p_sect[SCT_EFFIC][1]) {
pr("Sector building\t\t\t\t%8ld sct(s)\t\t%8ld\n",
p_sect[SCT_EFFIC][0], p_sect[SCT_EFFIC][1]);
@ -212,7 +180,6 @@ budg(void)
pr("Sectors will not produce, distribute, or deliver!\n\n");
}
player->simulation = 0;
return RET_OK;
}
@ -225,16 +192,12 @@ calc_all(long p_sect[][2],
{
int y, z;
struct natstr *np;
int sm = 0, sb = 0, pm = 0, pb = 0, lm = 0, lb = 0;
int *bp;
long pop = 0;
int n, civ_tax, uw_tax, mil_pay;
struct sctstr *sp;
int etu = etu_per_update;
long tmp_money;
lnd_money[player->cnum] = sea_money[player->cnum] = 0;
air_money[player->cnum] = 0;
mil_dbl_pay = 0;
memset(p_sect, 0, sizeof(**p_sect) * (SCT_MAXDEF+1) * 2);
*taxes = *Ncivs = *Nuws = *bars = *Nbars = *mil = 0;
@ -262,154 +225,41 @@ calc_all(long p_sect[][2],
tpops[player->cnum] = pop;
*mil += (int)(np->nat_reserve * money_res * etu);
*mil += (int)upd_slmilcosts(np->nat_cnum, etu);
*mil += upd_slmilcosts(np->nat_cnum, etu);
for (y = 1; y <= PRI_MAX; y++) {
for (z = 0; z <= PRI_MAX; z++)
if (np->nat_priorities[z] == y)
switch (z) {
case PRI_SMAINT:
tmp_money = lnd_money[player->cnum];
*ships = prod_ship(etu, player->cnum, bp, 0);
*smaint = lnd_money[player->cnum] - tmp_money;
sm = 1;
break;
case PRI_SBUILD:
tmp_money = sea_money[player->cnum];
*nsbuild = prod_ship(etu, player->cnum, bp, 1);
*sbuild = sea_money[player->cnum] - tmp_money;
sb = 1;
break;
case PRI_LMAINT:
tmp_money = lnd_money[player->cnum];
*units = prod_land(etu, player->cnum, bp, 0);
*lmaint = lnd_money[player->cnum] - tmp_money;
lm = 1;
break;
case PRI_LBUILD:
tmp_money = lnd_money[player->cnum];
*nlbuild = prod_land(etu, player->cnum, bp, 1);
*lbuild = lnd_money[player->cnum] - tmp_money;
lb = 1;
break;
case PRI_PMAINT:
tmp_money = air_money[player->cnum];
*planes = prod_plane(etu, player->cnum, bp, 0);
*pmaint = air_money[player->cnum] - tmp_money;
pm = 1;
break;
case PRI_PBUILD:
tmp_money = air_money[player->cnum];
*npbuild = prod_plane(etu, player->cnum, bp, 1);
*pbuild = air_money[player->cnum] - tmp_money;
pb = 1;
break;
default:
produce_sect(player->cnum, etu, bp, p_sect, z);
break;
}
}
/* 0 is maintain, 1 is build */
if (!sm) {
tmp_money = sea_money[player->cnum];
*ships = prod_ship(etu, player->cnum, bp, 0);
*smaint = sea_money[player->cnum] - tmp_money;
}
if (!sb) {
tmp_money = sea_money[player->cnum];
*nsbuild = prod_ship(etu, player->cnum, bp, 1);
*sbuild = sea_money[player->cnum] - tmp_money;
}
if (!lm) {
tmp_money = lnd_money[player->cnum];
*units = prod_land(etu, player->cnum, bp, 0);
*lmaint = lnd_money[player->cnum] - tmp_money;
}
if (!lb) {
tmp_money = lnd_money[player->cnum];
*nlbuild = prod_land(etu, player->cnum, bp, 1);
*lbuild = lnd_money[player->cnum] - tmp_money;
}
if (!pm) {
tmp_money = air_money[player->cnum];
*planes = prod_plane(etu, player->cnum, bp, 0);
*pmaint = air_money[player->cnum] - tmp_money;
}
if (!pb) {
tmp_money = air_money[player->cnum];
*npbuild = prod_plane(etu, player->cnum, bp, 1);
*pbuild = air_money[player->cnum] - tmp_money;
}
/* Maintain and build ships */
sea_money[player->cnum] = 0;
*ships = prod_ship(etu, player->cnum, bp, 0);
*smaint = sea_money[player->cnum];
sea_money[player->cnum] = 0;
*nsbuild = prod_ship(etu, player->cnum, bp, 1);
*sbuild = sea_money[player->cnum];
sea_money[player->cnum] = 0;
/* produce all sects that haven't produced yet */
produce_sect(player->cnum, etu, bp, p_sect, -1);
lnd_money[player->cnum] = sea_money[player->cnum] = 0;
/* Maintain and build planes */
air_money[player->cnum] = 0;
*planes = prod_plane(etu, player->cnum, bp, 0);
*pmaint = air_money[player->cnum];
air_money[player->cnum] = 0;
*npbuild = prod_plane(etu, player->cnum, bp, 1);
*pbuild = air_money[player->cnum];
air_money[player->cnum] = 0;
/* Maintain and build land units */
lnd_money[player->cnum] = 0;
*units = prod_land(etu, player->cnum, bp, 0);
*lmaint = lnd_money[player->cnum];
lnd_money[player->cnum] = 0;
*nlbuild = prod_land(etu, player->cnum, bp, 1);
*lbuild = lnd_money[player->cnum];
lnd_money[player->cnum] = 0;
/* Produce */
produce_sect(player->cnum, etu, bp, p_sect);
free(bp);
}
static int
change_prio(struct natstr *np, char code, char *newval)
{
int idx, i, prio;
char *p;
char buf[1024];
switch (code) {
case 'P':
idx = PRI_PBUILD;
break;
case 'S':
idx = PRI_SBUILD;
break;
case 'L':
idx = PRI_LBUILD;
break;
case 'A':
idx = PRI_LMAINT;
break;
case 'M':
idx = PRI_SMAINT;
break;
case 'N':
idx = PRI_PMAINT;
break;
case 'C':
for (i = 0; i <= PRI_MAX; ++i)
np->nat_priorities[i] = -1;
return RET_OK;
default:
idx = sct_typematch(player->argp[1]);
if (idx < 0 || idx == SCT_CAPIT)
return RET_SYN;
}
if (!(p = getstarg(newval, "Priority? ", buf)))
return RET_SYN;
if (isdigit(p[0])) {
prio = atoi(p);
if (prio < 0 || PRI_MAX < prio) {
pr("Priorities must be between 0 and %d!\n", PRI_MAX);
return RET_FAIL;
}
for (i = 0; i <= PRI_MAX; i++) {
if (i != idx && prio && np->nat_priorities[i] == prio) {
pr("Priorities must be unique!\n");
return RET_FAIL;
}
}
} else if (p[0] == '~')
prio = -1;
else
return RET_SYN;
np->nat_priorities[idx] = prio;
return RET_OK;
}
static char *
dotsprintf(char *buf, char *format, int data)
{
@ -418,19 +268,13 @@ dotsprintf(char *buf, char *format, int data)
}
static void
prexpense(long cash, int *expensesp, int priority, int amount)
prexpense(long cash, int *expensesp, int amount)
{
if (cash > *expensesp) {
if (priority) {
pr("\t\t%8d\n", amount);
*expensesp += amount;
} else
pr("\t\t(%7d)\n", amount);
pr("\t\t%8d\n", amount);
*expensesp += amount;
} else {
if (priority) {
pr("\t\t[%7d]\n", amount);
*expensesp += amount;
} else
pr("\t\t[(%6d)]\n", amount);
pr("\t\t[%7d]\n", amount);
*expensesp += amount;
}
}

View file

@ -323,9 +323,6 @@ prod(void)
}
if (enlisted < 0)
enlisted = 0;
if (natp->nat_priorities[type] == 0) {
maxmil = 0;
}
pr(" %4d%c 1.00 $%-5d%4dc %4dc %5d\n",
enlisted, ichr[I_MILIT].i_mnem, enlisted * 3,
enlisted, enlisted, maxmil);
@ -347,10 +344,6 @@ prod(void)
else
pr(" ");
}
if (natp->nat_priorities[type] == 0) {
max = 0;
maxr = 0;
}
if (vtype != I_NONE || pp->p_level == NAT_ELEV
|| pp->p_level == NAT_HLEV)
pr(" %5d\n", MIN(999, (int)(max * prodeff + 0.5)));

View file

@ -61,8 +61,7 @@ struct cmndstr player_coms[] = {
{"bomb <bomber-PLANES> <fighter-PLANES> <pin|strat> <ap-SECT> <PATH|DESTINATION>",
2, bomb, C_MOD, NORM + MONEY + CAP},
{"break {sanctuary}", 1, brea, C_MOD, SANCT},
{"budget [<sector type|P|S|L|A|M|N|C> <PRIORITY|~>]",
1, budg, 0, NORM},
{"budget", 1, budg, 0, NORM},
{"build <s|l|b|p|n|t> <SECTS> <type|dir> [<number> <tech> <sure?>]",
1, buil, C_MOD, NORM + MONEY + CAP},
{"buy <COMM> <LOT#> <BID/UNIT> <DEST>",

View file

@ -31,6 +31,7 @@
* Dave Pare, 1986
* Thomas Ruschak, 1992
* Steve McClure, 1996
* Markus Armbruster, 2006
*/
#include <config.h>
@ -131,9 +132,8 @@ upd_land(struct lndstr *lp, int etus,
lcp = &lchr[(int)lp->lnd_type];
if (build == 1) {
if (np->nat_priorities[PRI_LBUILD] == 0 || np->nat_money < 0)
return;
landrepair(lp, np, bp, etus);
if (np->nat_money >= 0)
landrepair(lp, np, bp, etus);
} else {
mult = 1;
if (np->nat_level[NAT_TLEV] < lp->lnd_tech * 0.85)
@ -141,8 +141,7 @@ upd_land(struct lndstr *lp, int etus,
if (lcp->l_flags & L_ENGINEER)
mult *= 3;
cost = -(mult * etus * MIN(0.0, money_land * lcp->l_cost));
if ((np->nat_priorities[PRI_LMAINT] == 0 || np->nat_money < cost)
&& !player->simulation) {
if (np->nat_money < cost && !player->simulation) {
if ((eff = lp->lnd_effic - etus / 5) < LAND_MINEFF) {
wu(0, lp->lnd_own,
"%s lost to lack of maintenance\n", prland(lp));

View file

@ -61,9 +61,6 @@ long tpops[MAXNOC];
int update_pending = 0;
static void do_prod(int, int, int, int *, long (*)[2], int *, int *,
int *, int *, int *, int *);
/*ARGSUSED*/
void
update_main(void *unused)
@ -113,7 +110,7 @@ update_main(void *unused)
logerror("done preparing sectors.");
logerror("producing for countries...");
for (x = 0; x < MAXNOC; x++) {
int y, z, sb = 0, sm = 0, pb = 0, pm = 0, lm = 0, lb = 0;
int y, z;
long p_sect[SCT_MAXDEF+1][2];
memset(p_sect, 0, sizeof(p_sect));
@ -128,30 +125,16 @@ update_main(void *unused)
}
np->nat_money += (int)(np->nat_reserve * money_res * etu);
for (y = 1; y <= PRI_MAX; y++) {
for (z = 0; z <= PRI_MAX; z++) {
if (np->nat_priorities[z] == y) {
do_prod(z, etu, x, bp, p_sect,
&sb, &sm, &pb, &pm, &lb, &lm);
}
}
}
/* 0 is maintain, 1 is build */
if (!sm)
prod_ship(etu, x, bp, 0);
if (!sb)
prod_ship(etu, x, bp, 1);
if (!pm)
prod_plane(etu, x, bp, 0);
if (!pb)
prod_plane(etu, x, bp, 1);
if (!lm)
prod_land(etu, x, bp, 0);
if (!lb)
prod_land(etu, x, bp, 1);
prod_ship(etu, x, bp, 0);
prod_ship(etu, x, bp, 1);
prod_plane(etu, x, bp, 0);
prod_plane(etu, x, bp, 1);
prod_land(etu, x, bp, 0);
prod_land(etu, x, bp, 1);
/* produce all sects that haven't produced yet */
produce_sect(x, etu, bp, p_sect, -1);
produce_sect(x, etu, bp, p_sect);
np->nat_money -= p_sect[SCT_CAPIT][1];
}
logerror("done producing for countries.");
@ -208,37 +191,3 @@ update_main(void *unused)
empth_exit();
/*NOTREACHED*/
}
static void
do_prod(int sector_type, int etu, int n, int *bp, long (*p_sect)[2],
int *ship_build, int *ship_maint, int *plane_build,
int *plane_maint, int *land_build, int *land_maint)
{
struct natstr *np;
np = getnatp(n);
if (sector_type == PRI_SMAINT) {
prod_ship(etu, n, bp, 0);
*ship_maint = 1;
} else if (sector_type == PRI_SBUILD) {
prod_ship(etu, n, bp, 1);
*ship_build = 1;
} else if (sector_type == PRI_PMAINT) {
prod_plane(etu, n, bp, 0);
*plane_maint = 1;
} else if (sector_type == PRI_PBUILD) {
prod_plane(etu, n, bp, 1);
*plane_build = 1;
} else if (sector_type == PRI_LMAINT) {
if (*land_build)
np->nat_money -= (int)(money_mil * etu * mil_dbl_pay);
prod_land(etu, n, bp, 0);
*land_maint = 1;
} else if (sector_type == PRI_LBUILD) {
prod_land(etu, n, bp, 1);
*land_build = 1;
} else {
produce_sect(n, etu, bp, p_sect, sector_type);
}
}

View file

@ -30,6 +30,7 @@
* Known contributors to this file:
* Dave Pare, 1986
* Steve McClure, 1998
* Markus Armbruster, 2006
*/
#include <config.h>
@ -101,16 +102,14 @@ upd_plane(struct plnstr *pp, int etus,
int mult, cost, eff;
if (build == 1) {
if (np->nat_priorities[PRI_PBUILD] == 0 || np->nat_money < 0)
return;
planerepair(pp, np, bp, etus);
if (np->nat_money >= 0)
planerepair(pp, np, bp, etus);
} else {
mult = 1;
if (np->nat_level[NAT_TLEV] < pp->pln_tech * 0.85)
mult = 2;
cost = -(mult * etus * MIN(0.0, pcp->pl_cost * money_plane));
if ((np->nat_priorities[PRI_PMAINT] == 0 || np->nat_money < cost)
&& !player->simulation) {
if (np->nat_money < cost && !player->simulation) {
if ((eff = pp->pln_effic - etus / 5) < PLANE_MINEFF) {
wu(0, pp->pln_own,
"%s lost to lack of maintenance\n", prplane(pp));

View file

@ -100,33 +100,31 @@ upd_buildeff(struct natstr *np, struct sctstr *sp, int *workp,
buildeff_work = MIN((int)(*workp / 2), buildeff_work);
}
}
if (np->nat_priorities[*desig]) {
if (*desig == sp->sct_newtype) {
work_cost = 100 - neweff;
if (work_cost > buildeff_work)
work_cost = buildeff_work;
if (*desig == sp->sct_newtype) {
work_cost = 100 - neweff;
if (work_cost > buildeff_work)
work_cost = buildeff_work;
if (dchr[*desig].d_lcms > 0) {
lcms = vec[I_LCM];
lcms /= dchr[*desig].d_lcms;
if (work_cost > lcms)
work_cost = lcms;
}
if (dchr[*desig].d_hcms > 0) {
hcms = vec[I_HCM];
hcms /= dchr[*desig].d_hcms;
if (work_cost > hcms)
work_cost = hcms;
}
if (dchr[*desig].d_lcms > 0) {
lcms = vec[I_LCM];
lcms /= dchr[*desig].d_lcms;
if (work_cost > lcms)
work_cost = lcms;
}
if (dchr[*desig].d_hcms > 0) {
hcms = vec[I_HCM];
hcms /= dchr[*desig].d_hcms;
if (work_cost > hcms)
work_cost = hcms;
}
neweff += work_cost;
*cost += work_cost * dchr[*desig].d_build;
buildeff_work -= work_cost;
neweff += work_cost;
*cost += work_cost * dchr[*desig].d_build;
buildeff_work -= work_cost;
if ((dchr[*desig].d_lcms > 0) || (dchr[*desig].d_hcms > 0)) {
vec[I_LCM] -= work_cost * dchr[*desig].d_lcms;
vec[I_HCM] -= work_cost * dchr[*desig].d_hcms;
}
if ((dchr[*desig].d_lcms > 0) || (dchr[*desig].d_hcms > 0)) {
vec[I_LCM] -= work_cost * dchr[*desig].d_lcms;
vec[I_HCM] -= work_cost * dchr[*desig].d_hcms;
}
}
*workp = (*workp + 1) / 2 + buildeff_work;
@ -266,12 +264,9 @@ decay_fallout(struct sctstr *sp, int etus)
/*
* Produce only a set sector type for a specific nation
* (or all, if sector_type == -1)
*
*/
void
produce_sect(int natnum, int etu, int *bp, long (*p_sect)[2],
int sector_type)
produce_sect(int natnum, int etu, int *bp, long p_sect[][2])
{
struct sctstr *sp;
struct natstr *np;
@ -287,8 +282,6 @@ produce_sect(int natnum, int etu, int *bp, long (*p_sect)[2],
continue;
if (sp->sct_updated != 0)
continue;
if (sp->sct_type != sector_type && sector_type != -1)
continue;
if ((sp->sct_type == SCT_CAPIT) && (sp->sct_effic > 60)) {
p_sect[SCT_CAPIT][0]++;
@ -333,16 +326,6 @@ produce_sect(int natnum, int etu, int *bp, long (*p_sect)[2],
sp->sct_off = 0;
continue;
}
if ((np->nat_priorities[sp->sct_type] == 0) &&
(sp->sct_type == sp->sct_newtype) &&
((pchr[dchr[sp->sct_type].d_prd].p_cost != 0) ||
(sp->sct_type == SCT_ENLIST))) {
if (!player->simulation) {
logerror("Skipping %s production for country %s\n",
dchr[sp->sct_type].d_name, np->nat_cnam);
}
continue;
}
neweff = sp->sct_effic;
amount = 0;
@ -365,16 +348,6 @@ produce_sect(int natnum, int etu, int *bp, long (*p_sect)[2],
}
}
if ((np->nat_priorities[desig] == 0) &&
((pchr[dchr[desig].d_prd].p_cost != 0) ||
(desig == SCT_ENLIST))) {
if (!player->simulation) {
logerror("Skipping %s production for country %s\n",
dchr[sp->sct_type].d_name, np->nat_cnam);
}
continue;
}
if (desig == SCT_ENLIST && neweff >= 60 &&
sp->sct_own == sp->sct_oldown) {
p_sect[desig][0] += enlist(vec, etu, &ecost);
@ -389,8 +362,8 @@ produce_sect(int natnum, int etu, int *bp, long (*p_sect)[2],
if (neweff >= 60) {
if (np->nat_money > 0 && dchr[desig].d_prd)
work -=
produce(np, sp, vec, work, desig, neweff, &pcost, &amount);
work -= produce(np, sp, vec, work, desig, neweff,
&pcost, &amount);
}
pt_bg_nmbr(bp, sp, I_MAX + 1, work);

View file

@ -31,6 +31,7 @@
* Dave Pare, 1986
* Steve McClure, 1996
* Ron Koenderink, 2004
* Markus Armbruster, 2006
*/
#include <config.h>
@ -135,16 +136,14 @@ upd_ship(struct shpstr *sp, int etus,
mp = &mchr[(int)sp->shp_type];
if (build == 1) {
if (np->nat_priorities[PRI_SBUILD] == 0 || np->nat_money < 0)
return;
shiprepair(sp, np, bp, etus);
if (np->nat_money >= 0)
shiprepair(sp, np, bp, etus);
} else {
mult = 1;
if (np->nat_level[NAT_TLEV] < sp->shp_tech * 0.85)
mult = 2;
cost = -(mult * etus * MIN(0.0, money_ship * mp->m_cost));
if ((np->nat_priorities[PRI_SMAINT] == 0 || np->nat_money < cost)
&& !player->simulation) {
if (np->nat_money < cost && !player->simulation) {
if ((eff = sp->shp_effic - etus / 5) < SHIP_MINEFF) {
wu(0, sp->shp_own,
"%s lost to lack of maintenance\n", prship(sp));