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

@ -54,17 +54,6 @@ typedef enum {
STAT_GOD /* deity powers */ STAT_GOD /* deity powers */
} nat_status; } nat_status;
enum { /* Priorities */
/* sector types are also priorities */
PRI_SMAINT = SCT_MAXDEF+1, /* ship maintenance */
PRI_PMAINT, /* plane maintenance */
PRI_LMAINT, /* land unit maintenance */
PRI_SBUILD, /* ship building */
PRI_PBUILD, /* plane building */
PRI_LBUILD, /* land building */
PRI_MAX = PRI_LBUILD
};
/* /*
* TODO * TODO
@ -73,7 +62,6 @@ enum { /* Priorities */
* *
* The only user of r_cnum and r_realm appears to be xdump. * The only user of r_cnum and r_realm appears to be xdump.
* If we had working virtual selectors, we could remove r_cnum and r_realm. * If we had working virtual selectors, we could remove r_cnum and r_realm.
*
*/ */
struct realmstr { struct realmstr {
/* initial part must match struct genitem */ /* initial part must match struct genitem */
@ -117,7 +105,6 @@ struct natstr {
unsigned char nat_relate[MAXNOC]; unsigned char nat_relate[MAXNOC];
unsigned char nat_contact[MAXNOC]; unsigned char nat_contact[MAXNOC];
unsigned char nat_rejects[MAXNOC]; unsigned char nat_rejects[MAXNOC];
signed char nat_priorities[PRI_MAX+1]; /* budget priority */
long nat_flags; /* nation flags */ long nat_flags; /* nation flags */
}; };

View file

@ -793,8 +793,7 @@ extern void sail_ship(natid);
extern void do_fallout(struct sctstr *, int); extern void do_fallout(struct sctstr *, int);
extern void spread_fallout(struct sctstr *, int); extern void spread_fallout(struct sctstr *, int);
extern void decay_fallout(struct sctstr *, int); extern void decay_fallout(struct sctstr *, int);
extern void produce_sect(int natnum, int etu, int *bp, extern void produce_sect(int, int, int *, long [][2]);
long (*p_sect)[2], int sector_type);
/* ship.c */ /* ship.c */
extern int prod_ship(int, int, int *, int); extern int prod_ship(int, int, int *, int);

View file

@ -13,27 +13,27 @@ This document gives a rough order of events during the update.
c) if the sector doesn't have the plague, see if it catches it c) if the sector doesn't have the plague, see if it catches it
otherwise plague the people otherwise plague the people
d) if there are no civs or mil in the sector, it reverts to the deity d) if there are no civs or mil in the sector, it reverts to the deity
e) taxes are collected from civs & uws. Mil are paid. e) taxes are collected from civs & uws; mil are paid.
f) if the sector is a bank it makes $$ proportional to its efficiency f) if the sector is a bank it makes $$ proportional to its efficiency
2) Then, in order of country #, deal with each country: 2) Then, in order of country #, deal with each country:
a) pay for military reserves. a) pay for military reserves.
b) in order of set priorities, 1-39, 1 going first, then 2, etc. c) ship maintenance
produce for owned sectors, maintain and build ships,
planes and units; see below for details
c) If ship maintenance is not yet done, do it now
pay maintenance, produce, then feed and plague people on board pay maintenance, produce, then feed and plague people on board
d) If ship building is not yet done, do it now d) ship building
ships that are stopped are skipped (see info stop)
ships execute their orders right after building ships execute their orders right after building
finally, if option SAIL is enabled, follow sail paths finally, if option SAIL is enabled, follow sail paths
e) If plane maintenance is not yet done, do it now e) plane maintenance
f) If plane building is not yet done, do it now f) plane building
g) If unit maintenance is not yet done, do it now planes that are stopped are skipped (see info stop)
g) land unit maintenance
pay maintenance, then feed and plague people on board pay maintenance, then feed and plague people on board
h) If unit building is not yet done, do it now h) land unit building
i) produce for all sectors that have not yet produced land units that are stopped are skipped (see info stop)
a) if the sector is a cap, it costs $$ equal to i) produce for all sectors
the # of etus: np->nat_money -= etus; a) if the sector is a cap, it costs $1 per etu since
the last update
b) people in non-sanctuary sectors eat b) people in non-sanctuary sectors eat
1) If not enough is available, the sector 1) If not enough is available, the sector
uses the supply routines to draw more. uses the supply routines to draw more.

View file

@ -1,25 +1,26 @@
.TH Command BUDGET .TH Command BUDGET
.NA budget "Look at a national balance sheet & set priorities" .NA budget "Look at a national balance sheet"
.LV Basic .LV Basic
.SY "budget [<sector type|P|S|L|M|N|A|C> <PRIORITY|~>]" .SY "budget"
budget with no arguments produces: The budget command predicts expenses and income for the next update.
.s1
.EX budget .EX budget
.NF .NF
Sector Type Abbr Production Priority Cost Sector Type Production Cost
park p 850 happy 7650 park 850 happy 7650
defense plant d 115 guns 3600 defense plant 115 guns 3600
shell industry i 679 shells 2097 shell industry 679 shells 2097
technical center t 66 tech 27000 technical center 66 tech 27000
research lab r 7 medical 900 research lab 7 medical 900
library/school l 1616 edu 14544 library/school 1616 edu 14544
refinery % 388 petrol 425 refinery 388 petrol 425
enlistment center e 930 mil 2790 enlistment center 930 mil 2790
Unit building L 6 units 358 Unit building 6 units 358
Unit maintenance A 85 units 28992 Unit maintenance 85 units 28992
Ship building S 2 ships 480 Ship building 2 ships 480
Ship maintenance M 25 ships 6327 Ship maintenance 25 ships 6327
Plane building P 9 planes 2508 Plane building 9 planes 2508
Plane maintenance N 219 planes 8874 Plane maintenance 219 planes 8874
Sector building 2398 Sector building 2398
Military payroll 7648 mil, 338 res 38247 Military payroll 7648 mil, 338 res 38247
City maintenance 5 cities 300 City maintenance 5 cities 300
@ -32,57 +33,40 @@ Estimated delta +40855
Estimated new treasury.............................................82472 Estimated new treasury.............................................82472
.FI .FI
.s1 .s1
Budget with an argument sets the priority of the given sector type The estimated delta may not be correct, due to events during updates:
(or L for unit building, or A for unit maintenance, or starvation, plague, sector revolts, etc.
P for plane building, or S for ship building, or M for ship
maintenance, or N for plane maintenance, or C to clear all)
.s1 .s1
Priorities are a positive number, or 0, or ~. Budget takes into account avail and materials in headquarters,
.s1
By default, budget lists only items which cost something. Non-producing
items will be listed if they are given a priority.
.s1
Update order:
.s1
Please see info \*QUpdate-sequence\*U for more details on the order things
happen in during the update..
.s1
.L "Turning sectors off"
.s1
Sector designations (or ship or plane building) with a 0 priority will not
produce, build efficiency, or gain avail.
.s1
If a sector of a type with 0 priority has been re-designated, the sector will
be torn down and rebuilt as usual (and may produce as well, depending on the
amount of work available, as normal)
.s1
If a sector of a type with a non-zero priority has been re-designated to a
type with a 0 priority, the sector will be torn down to 0%, and the designation
changed, but no further work will be done.
.s1
For other ways to control sector production, see the \*Qstart\*U and \*Qstop\*U
commands.
.s1
Costs for each sector type include costs for building efficiency in sectors
of that type. (This is true even if the sector will change to a different
type as a result of that work. For example, costs for libraries will include
all costs for work done in library sectors, even if one of the sectors is
being turned into an agribusiness)
.s1
Estimated Delta
.s1
The estimated delta may not be correct, due to events during updates.
(starvation, plague, sector revolts, etc).
.s1
Budget takes into account avail in headquarters,
harbors and airports, and will harbors and airports, and will
only show you how much you'll pay for work that will actually get done only show you how much you'll pay for work that will actually get done
in cases where your headquarters/airports/harbors will not have enough avail in cases where your headquarters/airports/harbors will not have enough avail
to work on all units/planes/ships. or materials to work on all units/planes/ships.
.s1 .s1
If a cost is in [brackets], then that means that you will not pay it If a cost is in [brackets], then that means that you will not pay it
because you will not have enough money. If a cost is in (parenthesises), because you will not have enough money.
then that means that you will not pay it because you have chosen not
to pay that cost (i.e. you have set the priority of that item to 0).
.s1 .s1
.SA "show, Sector-types, Nations, Updates" .L "Going broke"
.s1
The first thing you need to know about going broke: don't! Stuff you
can't afford will not be made. Lack of maintenance will damage your
assets. Worst of all, because many commands are not available while
you're broke, you'll be helpless until you become solvent again
.s1
There is no easy way to predict what exactly will still be paid for
when you go broke during an update. Try info \*QUpdate-sequence\*U.
.s1
.L "Cutting cost"
.s1
The orthodox way to balance your budget is to sack a neighbor. In
case that isn't possible right now, a few tips:
.s1
Stop expensive sectors, ships, planes and land units. See the
\*Qstart\*U and \*Qstop\*U commands for how.
.s1
Instead of stopping a sector, you can throttle it by moving out some
of the raw materials required for production. The \*Qproduction\*U
command can help you fine tune.
.s1
Trim your military. Consider demobilizing.
.s1
.SA "Sector-types, Maintenance, Nations, Updates, Update-sequence, demobilize, production, start, stop"

View file

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

View file

@ -31,6 +31,7 @@
* Thomas Ruschak, 1992 * Thomas Ruschak, 1992
* Ville Virrankoski, 1995 * Ville Virrankoski, 1995
* Steve McClure, 1997-2000 * Steve McClure, 1997-2000
* Markus Armbruster, 2004-2006
*/ */
#include <config.h> #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 *ships, int *sbuild, int *nsbuild, int *smaint,
int *units, int *lbuild, int *nlbuild, int *lmaint, int *units, int *lbuild, int *nlbuild, int *lmaint,
int *planes, int *pbuild, int *npbuild, int *pmaint); 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 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 int
budg(void) budg(void)
@ -79,13 +79,6 @@ budg(void)
etu = etu_per_update; etu = etu_per_update;
np = getnatp(player->cnum); 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; player->simulation = 1;
calc_all(p_sect, calc_all(p_sect,
@ -93,84 +86,59 @@ budg(void)
&ships, &sbuild, &nsbuild, &smaint, &ships, &sbuild, &nsbuild, &smaint,
&units, &lbuild, &nlbuild, &lmaint, &units, &lbuild, &nlbuild, &lmaint,
&planes, &pbuild, &npbuild, &pmaint); &planes, &pbuild, &npbuild, &pmaint);
player->simulation = 0;
income = taxes + bars; income = taxes + bars;
expenses = 0; 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++) { 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; continue;
if (!pchr[dchr[i].d_prd].p_cost && pr("%-17s\t\t", dchr[i].d_name);
np->nat_priorities[i] == -1 && i != SCT_ENLIST)
continue;
pr("%-17s\t%c\t", dchr[i].d_name, dchr[i].d_mnem);
if (i == SCT_ENLIST) if (i == SCT_ENLIST)
pr("%ld mil \t", p_sect[i][0]); pr("%ld mil \t", p_sect[i][0]);
else if (pchr[dchr[i].d_prd].p_cost != 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); pr("%ld %-7s\t", p_sect[i][0], pchr[dchr[i].d_prd].p_sname);
else else
pr("\t\t"); pr("\t\t");
prexpense(np->nat_money + income, &expenses, p_sect[i][1]);
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);
} }
if (sbuild) { if (sbuild) {
sprintf(buf, "%d ship%s", nsbuild, splur(nsbuild)); sprintf(buf, "%d ship%s", nsbuild, splur(nsbuild));
pr("Ship building\t\tS\t%-16s", buf); pr("Ship building\t\t\t%-16s", buf);
if (np->nat_priorities[PRI_SBUILD] != -1) prexpense(np->nat_money + income, &expenses, -sbuild);
pr("%d", np->nat_priorities[PRI_SBUILD]);
prexpense(np->nat_money + income, &expenses,
np->nat_priorities[PRI_SBUILD], -1 * sbuild);
} }
if (smaint) { if (smaint) {
sprintf(buf, "%d ship%s", ships, splur(ships)); sprintf(buf, "%d ship%s", ships, splur(ships));
pr("Ship maintenance\tM\t%-16s", buf); pr("Ship maintenance\t\t%-16s", buf);
if (np->nat_priorities[PRI_SMAINT] != -1) prexpense(np->nat_money + income, &expenses, -smaint);
pr("%d", np->nat_priorities[PRI_SMAINT]);
prexpense(np->nat_money + income, &expenses,
np->nat_priorities[PRI_SMAINT], -1 * smaint);
} }
if (pbuild) { if (pbuild) {
sprintf(buf, "%d plane%s", npbuild, splur(npbuild)); sprintf(buf, "%d plane%s", npbuild, splur(npbuild));
pr("Plane building\t\tP\t%-16s", buf); pr("Plane building\t\t\t%-16s", buf);
if (np->nat_priorities[PRI_PBUILD] != -1) prexpense(np->nat_money + income, &expenses, -pbuild);
pr("%d", np->nat_priorities[PRI_PBUILD]);
prexpense(np->nat_money + income, &expenses,
np->nat_priorities[PRI_PBUILD], -1 * pbuild);
} }
if (pmaint) { if (pmaint) {
sprintf(buf, "%d plane%s", planes, splur(planes)); sprintf(buf, "%d plane%s", planes, splur(planes));
pr("Plane maintenance\tN\t%-16s", buf); pr("Plane maintenance\t\t%-16s", buf);
if (np->nat_priorities[PRI_PMAINT] != -1) prexpense(np->nat_money + income, &expenses, -pmaint);
pr("%d", np->nat_priorities[PRI_PMAINT]);
prexpense(np->nat_money + income, &expenses,
np->nat_priorities[PRI_PMAINT], -1 * 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]) { if (p_sect[SCT_EFFIC][1]) {
pr("Sector building\t\t\t\t%8ld sct(s)\t\t%8ld\n", pr("Sector building\t\t\t\t%8ld sct(s)\t\t%8ld\n",
p_sect[SCT_EFFIC][0], p_sect[SCT_EFFIC][1]); 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"); pr("Sectors will not produce, distribute, or deliver!\n\n");
} }
player->simulation = 0;
return RET_OK; return RET_OK;
} }
@ -225,16 +192,12 @@ calc_all(long p_sect[][2],
{ {
int y, z; int y, z;
struct natstr *np; struct natstr *np;
int sm = 0, sb = 0, pm = 0, pb = 0, lm = 0, lb = 0;
int *bp; int *bp;
long pop = 0; long pop = 0;
int n, civ_tax, uw_tax, mil_pay; int n, civ_tax, uw_tax, mil_pay;
struct sctstr *sp; struct sctstr *sp;
int etu = etu_per_update; 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; mil_dbl_pay = 0;
memset(p_sect, 0, sizeof(**p_sect) * (SCT_MAXDEF+1) * 2); memset(p_sect, 0, sizeof(**p_sect) * (SCT_MAXDEF+1) * 2);
*taxes = *Ncivs = *Nuws = *bars = *Nbars = *mil = 0; *taxes = *Ncivs = *Nuws = *bars = *Nbars = *mil = 0;
@ -262,154 +225,41 @@ calc_all(long p_sect[][2],
tpops[player->cnum] = pop; tpops[player->cnum] = pop;
*mil += (int)(np->nat_reserve * money_res * etu); *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++) { /* Maintain and build ships */
for (z = 0; z <= PRI_MAX; z++) sea_money[player->cnum] = 0;
if (np->nat_priorities[z] == y) *ships = prod_ship(etu, player->cnum, bp, 0);
switch (z) { *smaint = sea_money[player->cnum];
case PRI_SMAINT: sea_money[player->cnum] = 0;
tmp_money = lnd_money[player->cnum]; *nsbuild = prod_ship(etu, player->cnum, bp, 1);
*ships = prod_ship(etu, player->cnum, bp, 0); *sbuild = sea_money[player->cnum];
*smaint = lnd_money[player->cnum] - tmp_money; sea_money[player->cnum] = 0;
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;
}
/* produce all sects that haven't produced yet */ /* Maintain and build planes */
produce_sect(player->cnum, etu, bp, p_sect, -1);
lnd_money[player->cnum] = sea_money[player->cnum] = 0;
air_money[player->cnum] = 0; 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); 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 * static char *
dotsprintf(char *buf, char *format, int data) dotsprintf(char *buf, char *format, int data)
{ {
@ -418,19 +268,13 @@ dotsprintf(char *buf, char *format, int data)
} }
static void static void
prexpense(long cash, int *expensesp, int priority, int amount) prexpense(long cash, int *expensesp, int amount)
{ {
if (cash > *expensesp) { if (cash > *expensesp) {
if (priority) { pr("\t\t%8d\n", amount);
pr("\t\t%8d\n", amount); *expensesp += amount;
*expensesp += amount;
} else
pr("\t\t(%7d)\n", amount);
} else { } else {
if (priority) { pr("\t\t[%7d]\n", amount);
pr("\t\t[%7d]\n", amount); *expensesp += amount;
*expensesp += amount;
} else
pr("\t\t[(%6d)]\n", amount);
} }
} }

View file

@ -323,9 +323,6 @@ prod(void)
} }
if (enlisted < 0) if (enlisted < 0)
enlisted = 0; enlisted = 0;
if (natp->nat_priorities[type] == 0) {
maxmil = 0;
}
pr(" %4d%c 1.00 $%-5d%4dc %4dc %5d\n", pr(" %4d%c 1.00 $%-5d%4dc %4dc %5d\n",
enlisted, ichr[I_MILIT].i_mnem, enlisted * 3, enlisted, ichr[I_MILIT].i_mnem, enlisted * 3,
enlisted, enlisted, maxmil); enlisted, enlisted, maxmil);
@ -347,10 +344,6 @@ prod(void)
else else
pr(" "); pr(" ");
} }
if (natp->nat_priorities[type] == 0) {
max = 0;
maxr = 0;
}
if (vtype != I_NONE || pp->p_level == NAT_ELEV if (vtype != I_NONE || pp->p_level == NAT_ELEV
|| pp->p_level == NAT_HLEV) || pp->p_level == NAT_HLEV)
pr(" %5d\n", MIN(999, (int)(max * prodeff + 0.5))); 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>", {"bomb <bomber-PLANES> <fighter-PLANES> <pin|strat> <ap-SECT> <PATH|DESTINATION>",
2, bomb, C_MOD, NORM + MONEY + CAP}, 2, bomb, C_MOD, NORM + MONEY + CAP},
{"break {sanctuary}", 1, brea, C_MOD, SANCT}, {"break {sanctuary}", 1, brea, C_MOD, SANCT},
{"budget [<sector type|P|S|L|A|M|N|C> <PRIORITY|~>]", {"budget", 1, budg, 0, NORM},
1, budg, 0, NORM},
{"build <s|l|b|p|n|t> <SECTS> <type|dir> [<number> <tech> <sure?>]", {"build <s|l|b|p|n|t> <SECTS> <type|dir> [<number> <tech> <sure?>]",
1, buil, C_MOD, NORM + MONEY + CAP}, 1, buil, C_MOD, NORM + MONEY + CAP},
{"buy <COMM> <LOT#> <BID/UNIT> <DEST>", {"buy <COMM> <LOT#> <BID/UNIT> <DEST>",

View file

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

View file

@ -61,9 +61,6 @@ long tpops[MAXNOC];
int update_pending = 0; int update_pending = 0;
static void do_prod(int, int, int, int *, long (*)[2], int *, int *,
int *, int *, int *, int *);
/*ARGSUSED*/ /*ARGSUSED*/
void void
update_main(void *unused) update_main(void *unused)
@ -113,7 +110,7 @@ update_main(void *unused)
logerror("done preparing sectors."); logerror("done preparing sectors.");
logerror("producing for countries..."); logerror("producing for countries...");
for (x = 0; x < MAXNOC; x++) { 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]; long p_sect[SCT_MAXDEF+1][2];
memset(p_sect, 0, sizeof(p_sect)); 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); 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 */ /* 0 is maintain, 1 is build */
if (!sm) prod_ship(etu, x, bp, 0);
prod_ship(etu, x, bp, 0); prod_ship(etu, x, bp, 1);
if (!sb) prod_plane(etu, x, bp, 0);
prod_ship(etu, x, bp, 1); prod_plane(etu, x, bp, 1);
if (!pm) prod_land(etu, x, bp, 0);
prod_plane(etu, x, bp, 0); prod_land(etu, x, bp, 1);
if (!pb)
prod_plane(etu, x, bp, 1);
if (!lm)
prod_land(etu, x, bp, 0);
if (!lb)
prod_land(etu, x, bp, 1);
/* produce all sects that haven't produced yet */ /* 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]; np->nat_money -= p_sect[SCT_CAPIT][1];
} }
logerror("done producing for countries."); logerror("done producing for countries.");
@ -208,37 +191,3 @@ update_main(void *unused)
empth_exit(); empth_exit();
/*NOTREACHED*/ /*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: * Known contributors to this file:
* Dave Pare, 1986 * Dave Pare, 1986
* Steve McClure, 1998 * Steve McClure, 1998
* Markus Armbruster, 2006
*/ */
#include <config.h> #include <config.h>
@ -101,16 +102,14 @@ upd_plane(struct plnstr *pp, int etus,
int mult, cost, eff; int mult, cost, eff;
if (build == 1) { if (build == 1) {
if (np->nat_priorities[PRI_PBUILD] == 0 || np->nat_money < 0) if (np->nat_money >= 0)
return; planerepair(pp, np, bp, etus);
planerepair(pp, np, bp, etus);
} else { } else {
mult = 1; mult = 1;
if (np->nat_level[NAT_TLEV] < pp->pln_tech * 0.85) if (np->nat_level[NAT_TLEV] < pp->pln_tech * 0.85)
mult = 2; mult = 2;
cost = -(mult * etus * MIN(0.0, pcp->pl_cost * money_plane)); cost = -(mult * etus * MIN(0.0, pcp->pl_cost * money_plane));
if ((np->nat_priorities[PRI_PMAINT] == 0 || np->nat_money < cost) if (np->nat_money < cost && !player->simulation) {
&& !player->simulation) {
if ((eff = pp->pln_effic - etus / 5) < PLANE_MINEFF) { if ((eff = pp->pln_effic - etus / 5) < PLANE_MINEFF) {
wu(0, pp->pln_own, wu(0, pp->pln_own,
"%s lost to lack of maintenance\n", prplane(pp)); "%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); buildeff_work = MIN((int)(*workp / 2), buildeff_work);
} }
} }
if (np->nat_priorities[*desig]) { if (*desig == sp->sct_newtype) {
if (*desig == sp->sct_newtype) { work_cost = 100 - neweff;
work_cost = 100 - neweff; if (work_cost > buildeff_work)
if (work_cost > buildeff_work) work_cost = buildeff_work;
work_cost = buildeff_work;
if (dchr[*desig].d_lcms > 0) { if (dchr[*desig].d_lcms > 0) {
lcms = vec[I_LCM]; lcms = vec[I_LCM];
lcms /= dchr[*desig].d_lcms; lcms /= dchr[*desig].d_lcms;
if (work_cost > lcms) if (work_cost > lcms)
work_cost = lcms; work_cost = lcms;
} }
if (dchr[*desig].d_hcms > 0) { if (dchr[*desig].d_hcms > 0) {
hcms = vec[I_HCM]; hcms = vec[I_HCM];
hcms /= dchr[*desig].d_hcms; hcms /= dchr[*desig].d_hcms;
if (work_cost > hcms) if (work_cost > hcms)
work_cost = hcms; work_cost = hcms;
} }
neweff += work_cost; neweff += work_cost;
*cost += work_cost * dchr[*desig].d_build; *cost += work_cost * dchr[*desig].d_build;
buildeff_work -= work_cost; buildeff_work -= work_cost;
if ((dchr[*desig].d_lcms > 0) || (dchr[*desig].d_hcms > 0)) { if ((dchr[*desig].d_lcms > 0) || (dchr[*desig].d_hcms > 0)) {
vec[I_LCM] -= work_cost * dchr[*desig].d_lcms; vec[I_LCM] -= work_cost * dchr[*desig].d_lcms;
vec[I_HCM] -= work_cost * dchr[*desig].d_hcms; vec[I_HCM] -= work_cost * dchr[*desig].d_hcms;
}
} }
} }
*workp = (*workp + 1) / 2 + buildeff_work; *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 * Produce only a set sector type for a specific nation
* (or all, if sector_type == -1)
*
*/ */
void void
produce_sect(int natnum, int etu, int *bp, long (*p_sect)[2], produce_sect(int natnum, int etu, int *bp, long p_sect[][2])
int sector_type)
{ {
struct sctstr *sp; struct sctstr *sp;
struct natstr *np; struct natstr *np;
@ -287,8 +282,6 @@ produce_sect(int natnum, int etu, int *bp, long (*p_sect)[2],
continue; continue;
if (sp->sct_updated != 0) if (sp->sct_updated != 0)
continue; continue;
if (sp->sct_type != sector_type && sector_type != -1)
continue;
if ((sp->sct_type == SCT_CAPIT) && (sp->sct_effic > 60)) { if ((sp->sct_type == SCT_CAPIT) && (sp->sct_effic > 60)) {
p_sect[SCT_CAPIT][0]++; 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; sp->sct_off = 0;
continue; 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; neweff = sp->sct_effic;
amount = 0; 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 && if (desig == SCT_ENLIST && neweff >= 60 &&
sp->sct_own == sp->sct_oldown) { sp->sct_own == sp->sct_oldown) {
p_sect[desig][0] += enlist(vec, etu, &ecost); 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 (neweff >= 60) {
if (np->nat_money > 0 && dchr[desig].d_prd) if (np->nat_money > 0 && dchr[desig].d_prd)
work -= work -= produce(np, sp, vec, work, desig, neweff,
produce(np, sp, vec, work, desig, neweff, &pcost, &amount); &pcost, &amount);
} }
pt_bg_nmbr(bp, sp, I_MAX + 1, work); pt_bg_nmbr(bp, sp, I_MAX + 1, work);

View file

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

View file

@ -154,8 +154,6 @@ main(int argc, char *argv[])
nat.nat_money = 123456789; nat.nat_money = 123456789;
nat.nat_cnum = 0; nat.nat_cnum = 0;
nat.nat_flags |= NF_FLASH; nat.nat_flags |= NF_FLASH;
for (i = 0; i <= PRI_MAX; i++)
nat.nat_priorities[i] = -1;
putnat((&nat)); putnat((&nat));
printf("All praise to %s!\n", nat.nat_cnam); printf("All praise to %s!\n", nat.nat_cnam);
memset(&nat, 0, sizeof(nat)); memset(&nat, 0, sizeof(nat));