(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:
Markus Armbruster 2006-06-05 17:44:25 +00:00
parent 08937006d7
commit f284b0beab
9 changed files with 62 additions and 60 deletions

View file

@ -58,21 +58,21 @@ struct pchrstr {
char *p_sname; /* short (7 char or less) name of product */ char *p_sname; /* short (7 char or less) name of product */
}; };
#define P_SHELL 1 #define P_SHELL 0
#define P_GUN 2 #define P_GUN 1
#define P_PETROL 3 #define P_PETROL 2
#define P_IRON 4 #define P_IRON 3
#define P_DUST 5 #define P_DUST 4
#define P_BAR 6 #define P_BAR 5
#define P_FOOD 7 #define P_FOOD 6
#define P_OIL 8 #define P_OIL 7
#define P_LCM 9 #define P_LCM 8
#define P_HCM 10 #define P_HCM 9
#define P_TLEV 11 #define P_TLEV 10
#define P_RLEV 12 #define P_RLEV 11
#define P_ELEV 13 #define P_ELEV 12
#define P_HLEV 14 #define P_HLEV 13
#define P_URAN 15 #define P_URAN 14
extern struct pchrstr pchr[P_URAN + 2]; extern struct pchrstr pchr[P_URAN + 2];

View file

@ -96,7 +96,7 @@ budg(void)
pr("%-17s\t\t", dchr[i].d_name); pr("%-17s\t\t", dchr[i].d_name);
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 (dchr[i].d_prd >= 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");

View file

@ -213,7 +213,7 @@ prod(void)
continue; continue;
} }
if (dchr[type].d_prd == 0) if (dchr[type].d_prd < 0)
continue; continue;
unit_work = 0; unit_work = 0;
pp = &pchr[dchr[type].d_prd]; pp = &pchr[dchr[type].d_prd];

View file

@ -95,9 +95,9 @@ ef_elt_byname(int type, char *name)
offsetof(struct ichrstr, i_name), offsetof(struct ichrstr, i_name),
sizeof(ichr[0])); sizeof(ichr[0]));
case EF_PRODUCT: case EF_PRODUCT:
return 1 + stmtch(name, pchr + 1, return stmtch(name, pchr,
offsetof(struct pchrstr, p_sname), offsetof(struct pchrstr, p_sname),
sizeof(pchr[0])); sizeof(pchr[0]));
case EF_TABLE: case EF_TABLE:
return stmtch(name, empfile, return stmtch(name, empfile,
offsetof(struct empfile, name), offsetof(struct empfile, name),

View file

@ -43,20 +43,19 @@
config product 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 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" 0 "shells" l h -1 2 1 0 s none 3 0 0 tech 20 10 "shells"
1 "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 "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 "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 "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 "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 "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 "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 "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 "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 "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 "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 "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 "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 "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"
15 "rad" -1 -1 -1 0 0 0 r none 2 uran 35 tech 40 10 "radioactive materials"
/config /config

View file

@ -48,40 +48,40 @@
config sect-chr config sect-chr
uid mnem prd peff mcst nav pkg ostr dstr val cost bui lcm hcm maxp name 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" 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" 2 "s" -1 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" 3 "\134" -1 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" 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 is for big cities. # Uncomment one of the following two. The second one is for big cities.
5 "c" 0 0 2 land norm 1.0 2.0 30 0 1 0 0 999 "capital" 5 "c" -1 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" # 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" 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" 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" 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" 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" 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" 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" 12 "h" -1 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" 13 "w" -1 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" 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" 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" 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" 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" 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" 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" 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" 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" 24 "+" -1 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" 25 ")" -1 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" 26 "!" -1 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" 27 "#" -1 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" 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" 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" 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" 31 "e" -1 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" 32 "~" -1 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" 33 "@" -1 0 1 land norm 1.0 1.5 4 -1 1 0 0 999 "bridge tower"
/config /config

View file

@ -559,7 +559,7 @@ show_sect_capab(int foo)
char *tmpstr; char *tmpstr;
for (x = 0; x <= SCT_MAXDEF; 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) {
pr(" --- level --- reso \n"); pr(" --- level --- reso \n");

View file

@ -70,9 +70,9 @@ produce(struct natstr *np, struct sctstr *sp, short *vec, int work,
int material_consume; int material_consume;
int val; int val;
product = &pchr[dchr[desig].d_prd]; if (dchr[desig].d_prd < 0)
if (product == &pchr[0])
return 0; return 0;
product = &pchr[dchr[desig].d_prd];
item = product->p_type; item = product->p_type;
*amount = 0; *amount = 0;
*cost = 0; *cost = 0;
@ -230,6 +230,9 @@ prod_eff(int type, float level)
struct dchrstr *dp = &dchr[type]; struct dchrstr *dp = &dchr[type];
struct pchrstr *pp = &pchr[dp->d_prd]; struct pchrstr *pp = &pchr[dp->d_prd];
if (CANT_HAPPEN(dp->d_prd < 0))
return 0.0;
if (pp->p_nlndx < 0) if (pp->p_nlndx < 0)
level_p_e = 1.0; level_p_e = 1.0;
else { else {

View file

@ -361,7 +361,7 @@ 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 >= 0)
work -= produce(np, sp, vec, work, desig, neweff, work -= produce(np, sp, vec, work, desig, neweff,
&pcost, &amount); &pcost, &amount);
} }