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:
parent
26110320c0
commit
520446ef39
14 changed files with 170 additions and 449 deletions
|
@ -54,17 +54,6 @@ typedef enum {
|
|||
STAT_GOD /* deity powers */
|
||||
} 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
|
||||
|
@ -73,7 +62,6 @@ enum { /* Priorities */
|
|||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
struct realmstr {
|
||||
/* initial part must match struct genitem */
|
||||
|
@ -117,7 +105,6 @@ struct natstr {
|
|||
unsigned char nat_relate[MAXNOC];
|
||||
unsigned char nat_contact[MAXNOC];
|
||||
unsigned char nat_rejects[MAXNOC];
|
||||
signed char nat_priorities[PRI_MAX+1]; /* budget priority */
|
||||
long nat_flags; /* nation flags */
|
||||
};
|
||||
|
||||
|
|
|
@ -793,8 +793,7 @@ extern void sail_ship(natid);
|
|||
extern void do_fallout(struct sctstr *, int);
|
||||
extern void spread_fallout(struct sctstr *, int);
|
||||
extern void decay_fallout(struct sctstr *, int);
|
||||
extern void produce_sect(int natnum, int etu, int *bp,
|
||||
long (*p_sect)[2], int sector_type);
|
||||
extern void produce_sect(int, int, int *, long [][2]);
|
||||
/* ship.c */
|
||||
extern int prod_ship(int, int, int *, int);
|
||||
|
||||
|
|
|
@ -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
|
||||
otherwise plague the people
|
||||
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
|
||||
|
||||
2) Then, in order of country #, deal with each country:
|
||||
a) pay for military reserves.
|
||||
b) in order of set priorities, 1-39, 1 going first, then 2, etc.
|
||||
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
|
||||
c) ship maintenance
|
||||
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
|
||||
finally, if option SAIL is enabled, follow sail paths
|
||||
e) If plane maintenance is not yet done, do it now
|
||||
f) If plane building is not yet done, do it now
|
||||
g) If unit maintenance is not yet done, do it now
|
||||
e) plane maintenance
|
||||
f) plane building
|
||||
planes that are stopped are skipped (see info stop)
|
||||
g) land unit maintenance
|
||||
pay maintenance, then feed and plague people on board
|
||||
h) If unit building is not yet done, do it now
|
||||
i) produce for all sectors that have not yet produced
|
||||
a) if the sector is a cap, it costs $$ equal to
|
||||
the # of etus: np->nat_money -= etus;
|
||||
h) land unit building
|
||||
land units that are stopped are skipped (see info stop)
|
||||
i) produce for all sectors
|
||||
a) if the sector is a cap, it costs $1 per etu since
|
||||
the last update
|
||||
b) people in non-sanctuary sectors eat
|
||||
1) If not enough is available, the sector
|
||||
uses the supply routines to draw more.
|
||||
|
|
114
info/budget.t
114
info/budget.t
|
@ -1,25 +1,26 @@
|
|||
.TH Command BUDGET
|
||||
.NA budget "Look at a national balance sheet & set priorities"
|
||||
.NA budget "Look at a national balance sheet"
|
||||
.LV Basic
|
||||
.SY "budget [<sector type|P|S|L|M|N|A|C> <PRIORITY|~>]"
|
||||
budget with no arguments produces:
|
||||
.SY "budget"
|
||||
The budget command predicts expenses and income for the next update.
|
||||
.s1
|
||||
.EX budget
|
||||
.NF
|
||||
Sector Type Abbr Production Priority Cost
|
||||
park p 850 happy 7650
|
||||
defense plant d 115 guns 3600
|
||||
shell industry i 679 shells 2097
|
||||
technical center t 66 tech 27000
|
||||
research lab r 7 medical 900
|
||||
library/school l 1616 edu 14544
|
||||
refinery % 388 petrol 425
|
||||
enlistment center e 930 mil 2790
|
||||
Unit building L 6 units 358
|
||||
Unit maintenance A 85 units 28992
|
||||
Ship building S 2 ships 480
|
||||
Ship maintenance M 25 ships 6327
|
||||
Plane building P 9 planes 2508
|
||||
Plane maintenance N 219 planes 8874
|
||||
Sector Type Production Cost
|
||||
park 850 happy 7650
|
||||
defense plant 115 guns 3600
|
||||
shell industry 679 shells 2097
|
||||
technical center 66 tech 27000
|
||||
research lab 7 medical 900
|
||||
library/school 1616 edu 14544
|
||||
refinery 388 petrol 425
|
||||
enlistment center 930 mil 2790
|
||||
Unit building 6 units 358
|
||||
Unit maintenance 85 units 28992
|
||||
Ship building 2 ships 480
|
||||
Ship maintenance 25 ships 6327
|
||||
Plane building 9 planes 2508
|
||||
Plane maintenance 219 planes 8874
|
||||
Sector building 2398
|
||||
Military payroll 7648 mil, 338 res 38247
|
||||
City maintenance 5 cities 300
|
||||
|
@ -32,57 +33,40 @@ Estimated delta +40855
|
|||
Estimated new treasury.............................................82472
|
||||
.FI
|
||||
.s1
|
||||
Budget with an argument sets the priority of the given sector type
|
||||
(or L for unit building, or A for unit maintenance, or
|
||||
P for plane building, or S for ship building, or M for ship
|
||||
maintenance, or N for plane maintenance, or C to clear all)
|
||||
The estimated delta may not be correct, due to events during updates:
|
||||
starvation, plague, sector revolts, etc.
|
||||
.s1
|
||||
Priorities are a positive number, or 0, or ~.
|
||||
.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,
|
||||
Budget takes into account avail and materials in headquarters,
|
||||
harbors and airports, and will
|
||||
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
|
||||
to work on all units/planes/ships.
|
||||
or materials to work on all units/planes/ships.
|
||||
.s1
|
||||
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),
|
||||
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).
|
||||
because you will not have enough money.
|
||||
.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"
|
||||
|
|
|
@ -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++)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)));
|
||||
|
|
|
@ -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>",
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -154,8 +154,6 @@ main(int argc, char *argv[])
|
|||
nat.nat_money = 123456789;
|
||||
nat.nat_cnum = 0;
|
||||
nat.nat_flags |= NF_FLASH;
|
||||
for (i = 0; i <= PRI_MAX; i++)
|
||||
nat.nat_priorities[i] = -1;
|
||||
putnat((&nat));
|
||||
printf("All praise to %s!\n", nat.nat_cnam);
|
||||
memset(&nat, 0, sizeof(nat));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue