(P_SHELL, P_GUN, P_PETROL, P_IRON, P_DUST, P_BAR, P_FOOD, P_OIL)
(P_LCM, P_HCM, P_TLEV, P_RLEV, P_ELEV, P_HLEV, P_URAN): Use -1 instead of 0 for `no product', shift down product indexes and update product.config and sector.config accordingly. (budg, prod, show_sect_capab, produce, produce_sect): Adapt test for no product. (ef_elt_byname): Remove the hack to hide pchr[0]. (prod_eff): Oops on no product.
This commit is contained in:
parent
08937006d7
commit
f284b0beab
9 changed files with 62 additions and 60 deletions
|
@ -58,21 +58,21 @@ struct pchrstr {
|
|||
char *p_sname; /* short (7 char or less) name of product */
|
||||
};
|
||||
|
||||
#define P_SHELL 1
|
||||
#define P_GUN 2
|
||||
#define P_PETROL 3
|
||||
#define P_IRON 4
|
||||
#define P_DUST 5
|
||||
#define P_BAR 6
|
||||
#define P_FOOD 7
|
||||
#define P_OIL 8
|
||||
#define P_LCM 9
|
||||
#define P_HCM 10
|
||||
#define P_TLEV 11
|
||||
#define P_RLEV 12
|
||||
#define P_ELEV 13
|
||||
#define P_HLEV 14
|
||||
#define P_URAN 15
|
||||
#define P_SHELL 0
|
||||
#define P_GUN 1
|
||||
#define P_PETROL 2
|
||||
#define P_IRON 3
|
||||
#define P_DUST 4
|
||||
#define P_BAR 5
|
||||
#define P_FOOD 6
|
||||
#define P_OIL 7
|
||||
#define P_LCM 8
|
||||
#define P_HCM 9
|
||||
#define P_TLEV 10
|
||||
#define P_RLEV 11
|
||||
#define P_ELEV 12
|
||||
#define P_HLEV 13
|
||||
#define P_URAN 14
|
||||
|
||||
extern struct pchrstr pchr[P_URAN + 2];
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ budg(void)
|
|||
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)
|
||||
else if (dchr[i].d_prd >= 0)
|
||||
pr("%ld %-7s\t", p_sect[i][0], pchr[dchr[i].d_prd].p_sname);
|
||||
else
|
||||
pr("\t\t");
|
||||
|
|
|
@ -213,7 +213,7 @@ prod(void)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (dchr[type].d_prd == 0)
|
||||
if (dchr[type].d_prd < 0)
|
||||
continue;
|
||||
unit_work = 0;
|
||||
pp = &pchr[dchr[type].d_prd];
|
||||
|
|
|
@ -95,9 +95,9 @@ ef_elt_byname(int type, char *name)
|
|||
offsetof(struct ichrstr, i_name),
|
||||
sizeof(ichr[0]));
|
||||
case EF_PRODUCT:
|
||||
return 1 + stmtch(name, pchr + 1,
|
||||
offsetof(struct pchrstr, p_sname),
|
||||
sizeof(pchr[0]));
|
||||
return stmtch(name, pchr,
|
||||
offsetof(struct pchrstr, p_sname),
|
||||
sizeof(pchr[0]));
|
||||
case EF_TABLE:
|
||||
return stmtch(name, empfile,
|
||||
offsetof(struct empfile, name),
|
||||
|
|
|
@ -43,20 +43,19 @@
|
|||
|
||||
config product
|
||||
uid sname ct(0) ct(1) ct(2) ca(0) ca(1) ca(2) type lev cost nrndx nrdep nlndx nlmin nllag name
|
||||
0 "" -1 -1 -1 0 0 0 -1 0 0 0 0 tech 0 0 "unused"
|
||||
1 "shells" l h -1 2 1 0 s none 3 0 0 tech 20 10 "shells"
|
||||
2 "guns" o l h 1 5 10 g none 30 0 0 tech 20 10 "guns"
|
||||
3 "petrol" o -1 -1 1 0 0 p none 1 0 0 tech 20 10 "petrol"
|
||||
4 "iron" -1 -1 -1 0 0 0 i none 0 min 0 none 0 0 "iron ore"
|
||||
5 "dust" -1 -1 -1 0 0 0 d none 0 gold 20 none 0 0 "gold dust"
|
||||
6 "bars" d -1 -1 5 0 0 b none 10 0 0 none 0 0 "gold bars"
|
||||
7 "food" -1 -1 -1 0 0 0 f none 0 fert 0 tech -10 10 "food"
|
||||
8 "oil" -1 -1 -1 0 0 0 o none 0 ocon 10 tech -10 10 "oil"
|
||||
9 "lcm" i -1 -1 1 0 0 l none 0 0 0 tech -10 10 "light construction materials"
|
||||
10 "hcm" i -1 -1 2 0 0 h none 0 0 0 tech -10 10 "heavy construction materials"
|
||||
11 "tech" d o l 1 5 10 -1 tech 300 0 0 edu 5 10 "technological breakthroughs"
|
||||
12 "medical" d o l 1 5 10 -1 res 90 0 0 edu 5 10 "medical discoveries"
|
||||
13 "edu" l -1 -1 1 0 0 -1 edu 9 0 0 none 0 0 "a class of graduates"
|
||||
14 "happy" l -1 -1 1 0 0 -1 hap 9 0 0 none 0 0 "happy strollers"
|
||||
15 "rad" -1 -1 -1 0 0 0 r none 2 uran 35 tech 40 10 "radioactive materials"
|
||||
0 "shells" l h -1 2 1 0 s none 3 0 0 tech 20 10 "shells"
|
||||
1 "guns" o l h 1 5 10 g none 30 0 0 tech 20 10 "guns"
|
||||
2 "petrol" o -1 -1 1 0 0 p none 1 0 0 tech 20 10 "petrol"
|
||||
3 "iron" -1 -1 -1 0 0 0 i none 0 min 0 none 0 0 "iron ore"
|
||||
4 "dust" -1 -1 -1 0 0 0 d none 0 gold 20 none 0 0 "gold dust"
|
||||
5 "bars" d -1 -1 5 0 0 b none 10 0 0 none 0 0 "gold bars"
|
||||
6 "food" -1 -1 -1 0 0 0 f none 0 fert 0 tech -10 10 "food"
|
||||
7 "oil" -1 -1 -1 0 0 0 o none 0 ocon 10 tech -10 10 "oil"
|
||||
8 "lcm" i -1 -1 1 0 0 l none 0 0 0 tech -10 10 "light construction materials"
|
||||
9 "hcm" i -1 -1 2 0 0 h none 0 0 0 tech -10 10 "heavy construction materials"
|
||||
10 "tech" d o l 1 5 10 -1 tech 300 0 0 edu 5 10 "technological breakthroughs"
|
||||
11 "medical" d o l 1 5 10 -1 res 90 0 0 edu 5 10 "medical discoveries"
|
||||
12 "edu" l -1 -1 1 0 0 -1 edu 9 0 0 none 0 0 "a class of graduates"
|
||||
13 "happy" l -1 -1 1 0 0 -1 hap 9 0 0 none 0 0 "happy strollers"
|
||||
14 "rad" -1 -1 -1 0 0 0 r none 2 uran 35 tech 40 10 "radioactive materials"
|
||||
/config
|
||||
|
|
|
@ -48,40 +48,40 @@
|
|||
|
||||
config sect-chr
|
||||
uid mnem prd peff mcst nav pkg ostr dstr val cost bui lcm hcm maxp name
|
||||
0 "." 0 0 0 sea norm 0.0 0.0 0 -1 0 0 0 0 "sea"
|
||||
0 "." -1 0 0 sea norm 0.0 0.0 0 -1 0 0 0 0 "sea"
|
||||
1 "^" dust 75 25 land norm 1.0 4.0 5 -1 1 0 0 99 "mountain"
|
||||
2 "s" 0 0 0 land norm 0.0 99.0 127 -1 0 0 0 999 "sanctuary"
|
||||
3 "\134" 0 0 0 land norm 0.0 99.0 0 -1 0 0 0 0 "wasteland"
|
||||
4 "-" 0 0 3 land norm 1.0 2.0 1 0 0 0 0 999 "wilderness"
|
||||
# Uncomment one of the following two. The second is for big cities.
|
||||
5 "c" 0 0 2 land norm 1.0 2.0 30 0 1 0 0 999 "capital"
|
||||
# 5 "c" 0 0 2 cana urba 1.0 2.0 30 0 10 1 2 999 "city"
|
||||
2 "s" -1 0 0 land norm 0.0 99.0 127 -1 0 0 0 999 "sanctuary"
|
||||
3 "\134" -1 0 0 land norm 0.0 99.0 0 -1 0 0 0 0 "wasteland"
|
||||
4 "-" -1 0 3 land norm 1.0 2.0 1 0 0 0 0 999 "wilderness"
|
||||
# Uncomment one of the following two. The second one is for big cities.
|
||||
5 "c" -1 0 2 land norm 1.0 2.0 30 0 1 0 0 999 "capital"
|
||||
# 5 "c" -1 0 2 cana urba 1.0 2.0 30 0 10 1 2 999 "city"
|
||||
6 "u" rad 100 2 land norm 1.0 2.0 15 0 1 0 0 999 "uranium mine"
|
||||
7 "p" hap 100 2 land norm 1.0 1.5 5 0 1 0 0 999 "park"
|
||||
8 "d" gun 100 2 land norm 1.0 1.5 7 0 1 0 0 999 "defense plant"
|
||||
9 "i" sh 100 2 land norm 1.0 1.5 6 0 1 0 0 999 "shell industry"
|
||||
10 "m" iron 100 2 land norm 1.0 2.0 5 0 1 0 0 999 "mine"
|
||||
11 "g" dust 100 2 land norm 1.0 2.0 8 0 1 0 0 999 "gold mine"
|
||||
12 "h" 0 0 2 harb ware 1.0 1.5 12 0 1 0 0 999 "harbor"
|
||||
13 "w" 0 0 2 land ware 1.0 1.5 7 0 1 0 0 999 "warehouse"
|
||||
14 "*" 0 0 2 land norm 1.0 1.25 12 0 1 0 0 999 "airfield"
|
||||
12 "h" -1 0 2 harb ware 1.0 1.5 12 0 1 0 0 999 "harbor"
|
||||
13 "w" -1 0 2 land ware 1.0 1.5 7 0 1 0 0 999 "warehouse"
|
||||
14 "*" -1 0 2 land norm 1.0 1.25 12 0 1 0 0 999 "airfield"
|
||||
15 "a" food 900 2 land norm 1.0 1.5 2 0 1 0 0 999 "agribusiness"
|
||||
16 "o" oil 100 2 land norm 1.0 1.5 5 0 1 0 0 999 "oil field"
|
||||
17 "j" lcm 100 2 land norm 1.0 1.5 3 0 1 0 0 999 "light manufacturing"
|
||||
18 "k" hcm 100 2 land norm 1.0 1.5 4 0 1 0 0 999 "heavy manufacturing"
|
||||
19 "f" 0 0 2 land norm 2.0 4.0 10 0 5 0 1 999 "fortress"
|
||||
19 "f" -1 0 2 land norm 2.0 4.0 10 0 5 0 1 999 "fortress"
|
||||
20 "t" tech 100 2 land norm 1.0 1.5 10 0 1 0 0 999 "technical center"
|
||||
21 "r" med 100 2 land norm 1.0 1.5 9 0 1 0 0 999 "research lab"
|
||||
22 "n" 0 0 2 land norm 1.0 2.0 10 0 1 0 0 999 "nuclear plant"
|
||||
22 "n" -1 0 2 land norm 1.0 2.0 10 0 1 0 0 999 "nuclear plant"
|
||||
23 "l" edu 100 2 land norm 1.0 1.5 4 0 1 0 0 999 "library/school"
|
||||
24 "+" 0 0 1 land norm 1.0 1.0 3 0 1 0 0 999 "highway"
|
||||
25 ")" 0 0 2 land norm 1.0 1.5 4 0 1 0 0 999 "radar installation"
|
||||
26 "!" 0 0 2 land norm 1.0 1.5 12 0 1 0 0 999 "headquarters"
|
||||
27 "#" 0 0 1 land norm 1.0 1.5 4 0 1 0 0 999 "bridge head"
|
||||
28 "=" 0 0 1 brid norm 1.0 1.0 5 -1 1 0 0 999 "bridge span"
|
||||
24 "+" -1 0 1 land norm 1.0 1.0 3 0 1 0 0 999 "highway"
|
||||
25 ")" -1 0 2 land norm 1.0 1.5 4 0 1 0 0 999 "radar installation"
|
||||
26 "!" -1 0 2 land norm 1.0 1.5 12 0 1 0 0 999 "headquarters"
|
||||
27 "#" -1 0 1 land norm 1.0 1.5 4 0 1 0 0 999 "bridge head"
|
||||
28 "=" -1 0 1 brid norm 1.0 1.0 5 -1 1 0 0 999 "bridge span"
|
||||
29 "b" bars 100 2 land bank 1.0 2.25 10 0 1 0 0 999 "bank"
|
||||
30 "%" pet 1000 2 land norm 1.0 1.5 2 0 1 0 0 999 "refinery"
|
||||
31 "e" 0 0 2 land norm 1.0 2.0 7 0 1 0 0 999 "enlistment center"
|
||||
32 "~" 0 0 2 land norm 1.0 1.5 1 -1 1 0 0 49 "plains"
|
||||
33 "@" 0 0 1 land norm 1.0 1.5 4 -1 1 0 0 999 "bridge tower"
|
||||
31 "e" -1 0 2 land norm 1.0 2.0 7 0 1 0 0 999 "enlistment center"
|
||||
32 "~" -1 0 2 land norm 1.0 1.5 1 -1 1 0 0 49 "plains"
|
||||
33 "@" -1 0 1 land norm 1.0 1.5 4 -1 1 0 0 999 "bridge tower"
|
||||
/config
|
||||
|
|
|
@ -559,7 +559,7 @@ show_sect_capab(int foo)
|
|||
char *tmpstr;
|
||||
|
||||
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;
|
||||
if (first) {
|
||||
pr(" --- level --- reso \n");
|
||||
|
|
|
@ -70,9 +70,9 @@ produce(struct natstr *np, struct sctstr *sp, short *vec, int work,
|
|||
int material_consume;
|
||||
int val;
|
||||
|
||||
product = &pchr[dchr[desig].d_prd];
|
||||
if (product == &pchr[0])
|
||||
if (dchr[desig].d_prd < 0)
|
||||
return 0;
|
||||
product = &pchr[dchr[desig].d_prd];
|
||||
item = product->p_type;
|
||||
*amount = 0;
|
||||
*cost = 0;
|
||||
|
@ -230,6 +230,9 @@ prod_eff(int type, float level)
|
|||
struct dchrstr *dp = &dchr[type];
|
||||
struct pchrstr *pp = &pchr[dp->d_prd];
|
||||
|
||||
if (CANT_HAPPEN(dp->d_prd < 0))
|
||||
return 0.0;
|
||||
|
||||
if (pp->p_nlndx < 0)
|
||||
level_p_e = 1.0;
|
||||
else {
|
||||
|
|
|
@ -361,7 +361,7 @@ produce_sect(int natnum, int etu, int *bp, long p_sect[][2])
|
|||
*/
|
||||
|
||||
if (neweff >= 60) {
|
||||
if (np->nat_money > 0 && dchr[desig].d_prd)
|
||||
if (np->nat_money > 0 && dchr[desig].d_prd >= 0)
|
||||
work -= produce(np, sp, vec, work, desig, neweff,
|
||||
&pcost, &amount);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue