]> git.pond.sub.org Git - empserver/commitdiff
(P_SHELL, P_GUN, P_PETROL, P_IRON, P_DUST, P_BAR, P_FOOD, P_OIL)
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 5 Jun 2006 17:44:25 +0000 (17:44 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Mon, 5 Jun 2006 17:44:25 +0000 (17:44 +0000)
(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.

include/product.h
src/lib/commands/budg.c
src/lib/commands/prod.c
src/lib/common/type.c
src/lib/global/product.config
src/lib/global/sect.config
src/lib/subs/show.c
src/lib/update/produce.c
src/lib/update/sect.c

index 18c93a85a7e59d0b018ce20309f154a00eba976b..bb6dc86ee1248a90a81948a185028654fc895ccc 100644 (file)
@@ -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  
+#define        P_BAR   
+#define        P_FOOD  
+#define        P_OIL   
+#define        P_LCM   
+#define        P_HCM   
+#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];
 
index e7dd1623d5d7b3ccd365786f25c368871c637f7f..ce6c605d47841378f1e398f700c24f65b398a7f6 100644 (file)
@@ -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");
index 5f0c9a1a6d9d8b76a6e2a9cf0efcb025b7320ba0..2a254a5fd47cd42a85a65bc31186d3ee4e433af7 100644 (file)
@@ -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];
index a7b9941a80c443c82d43b8b2181b5f4e7572b6a2..5af263169cd9fa273483d3d21c0ffc6c411df3a7 100644 (file)
@@ -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),
index 59ce56f25b5d7420de71c7e828a0e93c49af0575..b67f635110ad86026cec2a1c90214dc0a15b2823 100644 (file)
 
 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
index 966d63a75a6d799f0ac478ee2d44211251b67071..c268115640ea0be407a147784b19c3468769ad54 100644 (file)
 
 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
index 5a4ca1b43e761dea50b1be213e5c614d9effeda8..06b408d9bfd22f91d70750927302ade72bc9c6ab 100644 (file)
@@ -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");
index 4f6ea82220af29c3d1f46c39b947e697827cb46e..ae7b20778c759ed8343ef0d186bf8a161a126f3c 100644 (file)
@@ -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 {
index 47f790b4d1f98b82e377bb7f2562221e7a172ebf..8a294187b0fcbed42dd205762485d95cb35991ea 100644 (file)
@@ -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);
        }