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

@ -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));