(PRI_SMAINT, PRI_PMAINT, PRI_LMAINT, PRI_SBUILD, PRI_PBUILD,
PRI_LBUILD): Turn macros into enumeration constants. Value SCT_MAXDEF+1 was previously unused; use it. (PRI_MAX): New; replacing the horrible SCT_MAXDEF+8. (show_sect_build): Simply examine all sector types, don't skip the first five. The code ignores them just fine. (show_sect_build, show_sect_stats, show_sect_capab): Don't try to show sector types beyond SCT_MAXDEF. The table has some empty extra slots, for whatever reasons; no use examining them.
This commit is contained in:
parent
cff2deba4a
commit
0ebb14c8be
6 changed files with 30 additions and 27 deletions
|
@ -40,6 +40,17 @@
|
||||||
|
|
||||||
#define MAXNOR 50 /* max # realms */
|
#define MAXNOR 50 /* max # realms */
|
||||||
|
|
||||||
|
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
|
||||||
|
};
|
||||||
|
|
||||||
struct boundstr {
|
struct boundstr {
|
||||||
short b_xl, b_xh; /* horizontal bounds */
|
short b_xl, b_xh; /* horizontal bounds */
|
||||||
short b_yl, b_yh; /* vertical bounds */
|
short b_yl, b_yh; /* vertical bounds */
|
||||||
|
@ -75,20 +86,12 @@ struct natstr {
|
||||||
struct boundstr nat_b[MAXNOR]; /* realm bounds */
|
struct boundstr nat_b[MAXNOR]; /* realm bounds */
|
||||||
short nat_relate[MAXNOC];
|
short nat_relate[MAXNOC];
|
||||||
short nat_contact[MAXNOC];
|
short nat_contact[MAXNOC];
|
||||||
short nat_rejects[(MAXNOC + 3) / 4]; /* four bits for each country */
|
short nat_rejects[(MAXNOC + 3) / 4]; /* four bits for each country */
|
||||||
s_char nat_priorities[SCT_MAXDEF + 8]; /* priority for each SCT_MAXDEF+8 */
|
s_char nat_priorities[PRI_MAX+1]; /* budget priority */
|
||||||
long nat_flags; /* nation flags */
|
long nat_flags; /* nation flags */
|
||||||
char nat_spare[15];
|
char nat_spare[15];
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Priorities */
|
|
||||||
#define PRI_SMAINT SCT_MAXDEF+2
|
|
||||||
#define PRI_PMAINT SCT_MAXDEF+3
|
|
||||||
#define PRI_LMAINT SCT_MAXDEF+4
|
|
||||||
#define PRI_SBUILD SCT_MAXDEF+5
|
|
||||||
#define PRI_PBUILD SCT_MAXDEF+6
|
|
||||||
#define PRI_LBUILD SCT_MAXDEF+7
|
|
||||||
|
|
||||||
/* nation status types */
|
/* nation status types */
|
||||||
#define STAT_INUSE bit(0) /* cnum in use */
|
#define STAT_INUSE bit(0) /* cnum in use */
|
||||||
#define STAT_SANCT bit(1) /* country in sanctuary */
|
#define STAT_SANCT bit(1) /* country in sanctuary */
|
||||||
|
|
|
@ -230,7 +230,7 @@ add(void)
|
||||||
} else
|
} else
|
||||||
pr("No special initializations done...\n");
|
pr("No special initializations done...\n");
|
||||||
|
|
||||||
for (i = 0; i < SCT_MAXDEF + 8; i++)
|
for (i = 0; i <= PRI_MAX; i++)
|
||||||
natp->nat_priorities[i] = -1;
|
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;
|
||||||
|
|
|
@ -65,7 +65,7 @@ budg(void)
|
||||||
{
|
{
|
||||||
s_char stype = 0, *pq;
|
s_char stype = 0, *pq;
|
||||||
int priority, x;
|
int priority, x;
|
||||||
long p_sect[SCT_MAXDEF + 1][2];
|
long p_sect[SCT_MAXDEF+1][2];
|
||||||
int taxes = 0, bars = 0, mil = 0;
|
int taxes = 0, bars = 0, mil = 0;
|
||||||
int Ncivs = 0, Nuws = 0, Nbars = 0;
|
int Ncivs = 0, Nuws = 0, Nbars = 0;
|
||||||
int n, etu;
|
int n, etu;
|
||||||
|
@ -108,11 +108,11 @@ budg(void)
|
||||||
if (pq != (s_char *)0) {
|
if (pq != (s_char *)0) {
|
||||||
if (isdigit(*pq)) {
|
if (isdigit(*pq)) {
|
||||||
priority = (atoi(pq) < 0 ? -1 * atoi(pq) : atoi(pq));
|
priority = (atoi(pq) < 0 ? -1 * atoi(pq) : atoi(pq));
|
||||||
if (priority >= SCT_MAXDEF + 8) {
|
if (priority > PRI_MAX) {
|
||||||
pr("Priorities must be less than %d!\n", SCT_MAXDEF + 8);
|
pr("Priorities must be less than %d!\n", PRI_MAX + 1);
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
for (x = 0; x < SCT_MAXDEF + 8; x++)
|
for (x = 0; x <= PRI_MAX; x++)
|
||||||
if (priority && (np->nat_priorities[x] == priority)) {
|
if (priority && (np->nat_priorities[x] == priority)) {
|
||||||
pr("Priorities must be unique!\n");
|
pr("Priorities must be unique!\n");
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
|
@ -158,7 +158,7 @@ budg(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (which == -1) {
|
if (which == -1) {
|
||||||
for (x = 0; x < SCT_MAXDEF + 8; x++) {
|
for (x = 0; x <= PRI_MAX; x++) {
|
||||||
np->nat_priorities[x] = -1;
|
np->nat_priorities[x] = -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -175,7 +175,7 @@ budg(void)
|
||||||
|
|
||||||
income = taxes + bars;
|
income = taxes + bars;
|
||||||
pr("Sector Type\t\tAbbr\tProduction\tPriority\t Cost\n");
|
pr("Sector Type\t\tAbbr\tProduction\tPriority\t Cost\n");
|
||||||
for (x = 0; x < SCT_MAXDEF + 1; x++) {
|
for (x = 0; x <= SCT_MAXDEF; x++) {
|
||||||
if (!p_sect[x][1] && np->nat_priorities[x] == -1)
|
if (!p_sect[x][1] && np->nat_priorities[x] == -1)
|
||||||
continue;
|
continue;
|
||||||
if (!pchr[dchr[x].d_prd].p_cost &&
|
if (!pchr[dchr[x].d_prd].p_cost &&
|
||||||
|
@ -355,8 +355,8 @@ calc_all(long int (*p_sect)[2], int *taxes, int *Ncivs, int *Nuws,
|
||||||
|
|
||||||
*mil += (int)upd_slmilcosts(np->nat_cnum, etu);
|
*mil += (int)upd_slmilcosts(np->nat_cnum, etu);
|
||||||
|
|
||||||
for (y = 1; y < SCT_MAXDEF + 8; y++) {
|
for (y = 1; y <= PRI_MAX; y++) {
|
||||||
for (z = 0; z < SCT_MAXDEF + 8; z++)
|
for (z = 0; z <= PRI_MAX; z++)
|
||||||
if (np->nat_priorities[z] == y)
|
if (np->nat_priorities[z] == y)
|
||||||
switch (z) {
|
switch (z) {
|
||||||
case PRI_SMAINT:
|
case PRI_SMAINT:
|
||||||
|
|
|
@ -624,7 +624,7 @@ show_sect_build(int foo)
|
||||||
{
|
{
|
||||||
register int x, first = 1;
|
register int x, first = 1;
|
||||||
|
|
||||||
for (x = 5; x < SCT_MAXDEF + 2; x++) {
|
for (x = 0; x <= SCT_MAXDEF; x++) {
|
||||||
if (dchr[x].d_mnem == 0)
|
if (dchr[x].d_mnem == 0)
|
||||||
continue;
|
continue;
|
||||||
if ((dchr[x].d_cost > 0) || (dchr[x].d_build != 1) ||
|
if ((dchr[x].d_cost > 0) || (dchr[x].d_build != 1) ||
|
||||||
|
@ -658,7 +658,7 @@ show_sect_stats(int foo)
|
||||||
natp = getnatp(player->cnum);
|
natp = getnatp(player->cnum);
|
||||||
/* We fake this */
|
/* We fake this */
|
||||||
sect.sct_effic = 100;
|
sect.sct_effic = 100;
|
||||||
for (x = 0; x < SCT_MAXDEF + 2; x++) {
|
for (x = 0; x <= SCT_MAXDEF; x++) {
|
||||||
if (dchr[x].d_mnem == 0)
|
if (dchr[x].d_mnem == 0)
|
||||||
continue;
|
continue;
|
||||||
if (first) {
|
if (first) {
|
||||||
|
@ -686,7 +686,7 @@ show_sect_capab(int foo)
|
||||||
register int x, first = 1, i, j;
|
register int x, first = 1, i, j;
|
||||||
char *tmpstr;
|
char *tmpstr;
|
||||||
|
|
||||||
for (x = 0; x < SCT_MAXDEF + 2; x++) {
|
for (x = 0; x <= SCT_MAXDEF; x++) {
|
||||||
if ((dchr[x].d_mnem == 0) || (dchr[x].d_prd == 0))
|
if ((dchr[x].d_mnem == 0) || (dchr[x].d_prd == 0))
|
||||||
continue;
|
continue;
|
||||||
if (first) {
|
if (first) {
|
||||||
|
|
|
@ -112,7 +112,7 @@ update_main(void *unused)
|
||||||
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, sb = 0, sm = 0, pb = 0, pm = 0, lm = 0, lb = 0;
|
||||||
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));
|
||||||
mil_dbl_pay = 0;
|
mil_dbl_pay = 0;
|
||||||
|
@ -126,8 +126,8 @@ 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 < SCT_MAXDEF + 8; y++) {
|
for (y = 1; y <= PRI_MAX; y++) {
|
||||||
for (z = 0; z < SCT_MAXDEF + 8; z++) {
|
for (z = 0; z <= PRI_MAX; z++) {
|
||||||
if (np->nat_priorities[z] == y) {
|
if (np->nat_priorities[z] == y) {
|
||||||
do_prod(z, etu, x, bp, p_sect,
|
do_prod(z, etu, x, bp, p_sect,
|
||||||
&sb, &sm, &pb, &pm, &lb, &lm);
|
&sb, &sm, &pb, &pm, &lb, &lm);
|
||||||
|
|
|
@ -138,8 +138,8 @@ 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 (x = 0; x < SCT_MAXDEF + 8; x++)
|
for (i = 0; i <= PRI_MAX; i++)
|
||||||
nat.nat_priorities[x] = -1;
|
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));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue