]> git.pond.sub.org Git - empserver/commitdiff
config: Generalize unit build materials storage
authorMarkus Armbruster <armbru@pond.sub.org>
Fri, 27 May 2016 12:17:08 +0000 (14:17 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 6 Aug 2017 12:05:11 +0000 (14:05 +0200)
Use a single array member instead of multiple scalar members.  Only
the array elements that replace scalar members are can be non-zero for
now.

This is a first step to permitting more build materials.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
17 files changed:
include/budg.h
include/land.h
include/nuke.h
include/plane.h
include/ship.h
src/lib/commands/buil.c
src/lib/commands/powe.c
src/lib/commands/scra.c
src/lib/commands/tran.c
src/lib/common/nsc.c
src/lib/subs/plnsub.c
src/lib/subs/show.c
src/lib/update/land.c
src/lib/update/material.c
src/lib/update/plane.c
src/lib/update/ship.c
tests/version/journal.log

index c58ea913c457110444e65a488a09269ce5a15e66..389c024cf40cf29afb4ab1574915e44ee5dcbc68 100644 (file)
@@ -28,7 +28,7 @@
  *
  *  Known contributors to this file:
  *     Ville Virrankoski, 1995
- *     Markus Armbruster, 2004-2013
+ *     Markus Armbruster, 2004-2016
  */
 
 #ifndef BUDG_H
@@ -49,7 +49,7 @@ void bp_put_items(struct bp *, struct sctstr *, short *);
 int bp_get_avail(struct bp *, struct sctstr *);
 void bp_put_avail(struct bp *, struct sctstr *, int);
 
-int get_materials(struct sctstr *, struct bp *, int *, int);
+int get_materials(struct sctstr *, struct bp *, short[], int);
 
 extern int money[MAXNOC];
 extern int pops[MAXNOC];
index 2f9d3e95334c4f9945ca34c46b9ea00025b62f82..42d98147b1adbf7bc909570393f5669e03226c20 100644 (file)
@@ -81,11 +81,8 @@ struct lndstr {
 struct lchrstr {
     short l_item[I_MAX+1];     /* load limit */
     char *l_name;              /* full name of type of land unit */
-    int l_lcm;                 /* units of lcm to build */
-    int l_hcm;                 /* units of hcm to build */
-    int l_mil;                 /* how many mil it takes to build (unused) */
-    int l_gun;                 /* how many guns it takes to build (unused) */
-    int l_shell;               /* #shells it takes to build (unused) */
+    short l_mat[I_MAX+1];      /* materials to build 100% */
+                               /* only I_LCM and I_HCM non-zero */
     int l_bwork;               /* work to build 100% */
     int l_tech;                        /* tech required to build */
     int l_cost;                        /* how much it costs to build */
index 51c1a05016db20b6a9f06e5d74da78ff438f05fa..2ef7bf01ea76a1d6d090c5067b63b9eaa264a2b4 100644 (file)
@@ -35,6 +35,7 @@
 #define NUKE_H
 
 #include <time.h>
+#include "item.h"
 #include "types.h"
 
 #define N_MAXNUKE      20
@@ -64,12 +65,10 @@ struct nukstr {
 
 struct nchrstr {
     char *n_name;              /* warhead unit name */
-    int n_lcm;                 /* costs to build */
-    int n_hcm;
-    int n_oil;
-    int n_rad;
     int n_blast;               /* blast radius */
     int n_dam;                 /* damage at center */
+    short n_mat[I_MAX+1];      /* materials to build 100% */
+                               /* only I_LCM, I_HCM, I_OIL, I_RAD non-zero */
     int n_bwork;               /* work to build 100% */
     int n_tech;                        /* tech needed to build */
     int n_cost;                        /* how much it costs to build */
index 2a66decbb3fb2278fe36e80c3a02eb6538b7f42f..a434b78d6c16ff47b10ef7d2ea6c64e95689ee6a 100644 (file)
@@ -37,6 +37,7 @@
 #define PLANE_H
 
 #include <time.h>
+#include "item.h"
 #include "queue.h"
 #include "types.h"
 
@@ -79,8 +80,8 @@ struct plnstr {
 
 struct plchrstr {
     char *pl_name;             /* full name of type of plane */
-    int pl_lcm;                        /* costs to build */
-    int pl_hcm;
+    short pl_mat[I_MAX+1];     /* materials to build 100% */
+                               /* only I_LCM, I_HCM, I_MILIT non-zero */
     int pl_bwork;              /* work to build 100% */
     int pl_tech;               /* tech needed to build */
     int pl_cost;               /* how much it costs to build */
@@ -89,7 +90,6 @@ struct plchrstr {
     int pl_att;                        /* air-air attack/defense strengths */
     int pl_def;
     int pl_range;              /* how many sectors it can fly */
-    int pl_crew;               /* number of mil to crew it */
     int pl_fuel;               /* fuel consumption */
     int pl_stealth;            /* how stealthy is it? */
     int pl_flags;              /* description of capability */
index f6c9d3929bedcd578a538c9caa7d7025dfa53c64..36a01ca6984bf2d4ffc4d5d2a4df096bdc967025 100644 (file)
@@ -82,8 +82,6 @@ struct shpstr {
 
 struct mchrstr {
     short m_item[I_MAX+1];     /* load limit */
-    int m_lcm;                 /* units of lcm to build */
-    int m_hcm;                 /* units of hcm to build */
     int m_armor;               /* how well armored it is */
     int m_speed;               /* how fast it can go */
     int m_visib;               /* how well it can be seen */
@@ -93,6 +91,8 @@ struct mchrstr {
     unsigned char m_nxlight;   /* maximum number of xlight planes */
     unsigned char m_nchoppers; /* maximum number of choppers */
     char *m_name;              /* full name of type of ship */
+    short m_mat[I_MAX+1];      /* materials to build 100% */
+                               /* only I_LCM and I_HCM non-zero */
     int m_bwork;               /* work to build 100% */
     int m_tech;                        /* tech required to build */
     int m_cost;                        /* how much it costs to build */
index d6fa4d4fc6182b39d86d66cf66a20c07908d1d60..b893f3136020ba7daa3a8fa5ff0165a296684029 100644 (file)
@@ -213,9 +213,7 @@ build_ship(struct sctstr *sp, int type, int tlev)
     short mat[I_MAX+1];
     struct shpstr ship;
 
-    memset(mat, 0, sizeof(mat));
-    mat[I_LCM] = mp->m_lcm;
-    mat[I_HCM] = mp->m_hcm;
+    memcpy(mat, mp->m_mat, sizeof(mat));
 
     if (sp->sct_type != SCT_HARBR && !player->god) {
        pr("Ships must be built in harbours.\n");
@@ -264,9 +262,7 @@ build_land(struct sctstr *sp, int type, int tlev)
     short mat[I_MAX+1];
     struct lndstr land;
 
-    memset(mat, 0, sizeof(mat));
-    mat[I_LCM] = lp->l_lcm;
-    mat[I_HCM] = lp->l_hcm;
+    memcpy(mat, lp->l_mat, sizeof(mat));
 
     if (sp->sct_type != SCT_HEADQ && !player->god) {
        pr("Land units must be built in headquarters.\n");
@@ -323,11 +319,7 @@ build_nuke(struct sctstr *sp, int type, int tlev)
      * make them start at 20%.  Since they don't have efficiency
      * now, we charge all the work right away.
      */
-    memset(mat, 0, sizeof(mat));
-    mat[I_LCM] = np->n_lcm;
-    mat[I_HCM] = np->n_hcm;
-    mat[I_OIL] = np->n_oil;
-    mat[I_RAD] = np->n_rad;
+    memcpy(mat, np->n_mat, sizeof(mat));
 
     if (!sector_can_build(sp, mat, np->n_bwork, 100, np->n_name))
        return 0;
@@ -358,10 +350,7 @@ build_plane(struct sctstr *sp, int type, int tlev)
     short mat[I_MAX+1];
     struct plnstr plane;
 
-    memset(mat, 0, sizeof(mat));
-    mat[I_MILIT] = pp->pl_crew;
-    mat[I_LCM] = pp->pl_lcm;
-    mat[I_HCM] = pp->pl_hcm;
+    memcpy(mat, pp->pl_mat, sizeof(mat));
 
     if (sp->sct_type != SCT_AIRPT && !player->god) {
        pr("Planes must be built in airports.\n");
index 6c778e3014f90c9df9a48e6c5445fc07231d0ef3..113c3c48d79a84f071c2295214351003ee4b73a5 100644 (file)
@@ -30,7 +30,7 @@
  *     Dave Pare
  *     Ken Stevens, 1995
  *     Steve McClure, 1998-2000
- *     Markus Armbruster, 2004-2013
+ *     Markus Armbruster, 2004-2016
  *     Ron Koenderink, 2005-2008
  */
 
@@ -244,8 +244,10 @@ gen_power(struct powstr *powbuf, int save)
            continue;
        pow = &powbuf[land.lnd_own];
        addtopow(land.lnd_item, pow);
-       f = (lchr[(int)land.lnd_type].l_lcm / 10.0) * (land.lnd_effic / 100.0);
-       f += (lchr[(int)land.lnd_type].l_hcm / 10.0) * (land.lnd_effic / 100.0);
+       f = (lchr[land.lnd_type].l_mat[I_LCM] / 10.0)
+           * (land.lnd_effic / 100.0);
+       f += (lchr[land.lnd_type].l_mat[I_HCM] / 10.0)
+           * (land.lnd_effic / 100.0);
        pow->p_power += f * 2;
        if (!(lchr[(int)land.lnd_type].l_flags & L_SPY))
            pow->p_units += 1.0;
@@ -256,8 +258,10 @@ gen_power(struct powstr *powbuf, int save)
            continue;
        pow = &powbuf[ship.shp_own];
        addtopow(ship.shp_item, pow);
-       f = (mchr[(int)ship.shp_type].m_lcm / 10.0) * (ship.shp_effic / 100.0);
-       f += (mchr[(int)ship.shp_type].m_hcm / 10.0) * (ship.shp_effic / 100.0);
+       f = (mchr[ship.shp_type].m_mat[I_LCM] / 10.0)
+           * (ship.shp_effic / 100.0);
+       f += (mchr[ship.shp_type].m_mat[I_HCM] / 10.0)
+           * (ship.shp_effic / 100.0);
        pow->p_power += f * 2;
        pow->p_ships += 1.0;
     }
index a338991db23827e97c76a6d8d5d07e98acfb1f0f..dab777d645f7168190dbfe8e8ae2dc5d34a37354 100644 (file)
@@ -28,7 +28,7 @@
  *
  *  Known contributors to this file:
  *     Steve McClure, 2000
- *     Markus Armbruster, 2004-2014
+ *     Markus Armbruster, 2004-2016
  */
 
 #include <config.h>
@@ -55,6 +55,8 @@ scra(void)
     char prompt[128];
     char buf[1024];
     float eff;
+    short *mvec;
+    int amt;
 
     if (!(p = getstarg(player->argp[1], "Ship, land, or plane? ", buf)))
        return RET_SYN;
@@ -148,8 +150,7 @@ scra(void)
                                 -item.ship.shp_item[i]))
                    sect.sct_item[i] += item.ship.shp_item[i];
            }
-           sect.sct_item[I_LCM] += mp->m_lcm * 2 / 3 * eff;
-           sect.sct_item[I_HCM] += mp->m_hcm * 2 / 3 * eff;
+           mvec = mp->m_mat;
            if (item.ship.shp_pstage == PLG_INFECT
                && sect.sct_pstage == PLG_HEALTHY)
                sect.sct_pstage = PLG_EXPOSED;
@@ -161,23 +162,25 @@ scra(void)
                                 -item.land.lnd_item[i]))
                    sect.sct_item[i] += item.land.lnd_item[i];
            }
-           sect.sct_item[I_LCM] += lp->l_lcm * 2 / 3 * eff;
-           sect.sct_item[I_HCM] += lp->l_hcm * 2 / 3 * eff;
+           mvec = lp->l_mat;
            if (item.land.lnd_pstage == PLG_INFECT
                && sect.sct_pstage == PLG_HEALTHY)
                sect.sct_pstage = PLG_EXPOSED;
        } else {
            eff = item.land.lnd_effic / 100.0;
            pp = &plchr[(int)item.plane.pln_type];
-           sect.sct_item[I_LCM] += pp->pl_lcm * 2 / 3 * eff;
-           sect.sct_item[I_HCM] += pp->pl_hcm * 2 / 3 * eff;
-           sect.sct_item[I_MILIT] += roundavg(pp->pl_crew * eff);
+           mvec = pp->pl_mat;
        }
        item.gen.effic = 0;
        put_empobj(type, item.gen.uid, &item.gen);
        for (i = I_NONE + 1; i <= I_MAX; i++) {
-           if (sect.sct_item[i] > ITEM_MAX)
-               sect.sct_item[i] = ITEM_MAX;
+           if (i == I_CIVIL || i == I_MILIT || i == I_UW)
+               amt = sect.sct_item[i] + mvec[i] * eff;
+           else
+               amt = sect.sct_item[i] + mvec[i] * 2 / 3 * eff;
+           if (amt > ITEM_MAX)
+               amt = ITEM_MAX;
+           sect.sct_item[i] = amt;
        }
        putsect(&sect);
     }
index 0fd9f245edee518b0cd22f0743554eb6fc0868c3..5a71023f5d6e46c6a23aaca14c93c099e06c2629 100644 (file)
@@ -28,7 +28,7 @@
  *
  *  Known contributors to this file:
  *     Steve McClure, 2000
- *     Markus Armbruster, 2006-2011
+ *     Markus Armbruster, 2006-2016
  */
 
 #include <config.h>
@@ -193,7 +193,7 @@ tran_plane(void)
                return RET_FAIL;
            }
        }
-       weight += plchr[type].pl_lcm + (plchr[type].pl_hcm * 2);
+       weight += plchr[type].pl_mat[I_LCM] + (plchr[type].pl_mat[I_HCM] * 2);
        ++count;
     }
     if (count == 0) {
index 3758b110ec1512008d7dc940d66acdfa2ddab5f5..6c5102a533492e42003fa587d64fe732169b187d 100644 (file)
@@ -261,8 +261,8 @@ struct castr mchr_ca[] = {
     {"type", fldoff(m_type), NSC_CHAR, 0, NULL, EF_SHIP_CHR, 0},
     {"name", fldoff(m_name), NSC_STRING, 0, NULL, EF_BAD, 0},
     NSC_IVEC(fldoff(m_item), ""),
-    {"l_build", fldoff(m_lcm), NSC_INT, 0, NULL, EF_BAD, 0},
-    {"h_build", fldoff(m_hcm), NSC_INT, 0, NULL, EF_BAD, 0},
+    {"l_build", fldoff(m_mat[I_LCM]), NSC_SHORT, 0, NULL, EF_BAD, 0},
+    {"h_build", fldoff(m_mat[I_HCM]), NSC_SHORT, 0, NULL, EF_BAD, 0},
     {"armor", fldoff(m_armor), NSC_INT, 0, NULL, EF_BAD, 0},
     {"speed", fldoff(m_speed), NSC_INT, 0, NULL, EF_BAD, 0},
     {"visib", fldoff(m_visib), NSC_INT, 0, NULL, EF_BAD, 0},
@@ -305,8 +305,8 @@ struct castr plchr_ca[] = {
 #define CURSTR struct plchrstr
     {"type", fldoff(pl_type), NSC_CHAR, 0, NULL, EF_PLANE_CHR, 0},
     {"name", fldoff(pl_name), NSC_STRING, 0, NULL, EF_BAD, 0},
-    {"l_build", fldoff(pl_lcm), NSC_INT, 0, NULL, EF_BAD, 0},
-    {"h_build", fldoff(pl_hcm), NSC_INT, 0, NULL, EF_BAD, 0},
+    {"l_build", fldoff(pl_mat[I_LCM]), NSC_SHORT, 0, NULL, EF_BAD, 0},
+    {"h_build", fldoff(pl_mat[I_HCM]), NSC_SHORT, 0, NULL, EF_BAD, 0},
     {"bwork", fldoff(pl_bwork), NSC_INT, 0, NULL, EF_BAD, 0},
     {"tech", fldoff(pl_tech), NSC_INT, 0, NULL, EF_BAD, 0},
     {"cost", fldoff(pl_cost), NSC_INT, 0, NULL, EF_BAD, 0},
@@ -315,7 +315,7 @@ struct castr plchr_ca[] = {
     {"att", fldoff(pl_att), NSC_INT, 0, NULL, EF_BAD, 0},
     {"def", fldoff(pl_def), NSC_INT, 0, NULL, EF_BAD, 0},
     {"range", fldoff(pl_range), NSC_INT, 0, NULL, EF_BAD, 0},
-    {"crew", fldoff(pl_crew), NSC_INT, 0, NULL, EF_BAD, 0},
+    {"crew", fldoff(pl_mat[I_MILIT]), NSC_SHORT, 0, NULL, EF_BAD, 0},
     {"fuel", fldoff(pl_fuel), NSC_INT, 0, NULL, EF_BAD, 0},
     {"stealth", fldoff(pl_stealth), NSC_INT, 0, NULL, EF_BAD, 0},
     {"flags", fldoff(pl_flags), NSC_INT, 0, NULL,
@@ -367,8 +367,8 @@ struct castr lchr_ca[] = {
     {"type", fldoff(l_type), NSC_CHAR, 0, NULL, EF_LAND_CHR, 0},
     {"name", fldoff(l_name), NSC_STRING, 0, NULL, EF_BAD, 0},
     NSC_IVEC(fldoff(l_item), ""),
-    {"l_build", fldoff(l_lcm), NSC_INT, 0, NULL, EF_BAD, 0},
-    {"h_build", fldoff(l_hcm), NSC_INT, 0, NULL, EF_BAD, 0},
+    {"l_build", fldoff(l_mat[I_LCM]), NSC_SHORT, 0, NULL, EF_BAD, 0},
+    {"h_build", fldoff(l_mat[I_HCM]), NSC_SHORT, 0, NULL, EF_BAD, 0},
     {"bwork", fldoff(l_bwork), NSC_INT, 0, NULL, EF_BAD, 0},
     {"tech", fldoff(l_tech), NSC_INT, 0, NULL, EF_BAD, 0},
     {"cost", fldoff(l_cost), NSC_INT, 0, NULL, EF_BAD, 0},
@@ -405,10 +405,10 @@ struct castr nchr_ca[] = {
 #define CURSTR struct nchrstr
     {"type", fldoff(n_type), NSC_CHAR, 0, NULL, EF_NUKE_CHR, 0},
     {"name", fldoff(n_name), NSC_STRING, 0, NULL, EF_BAD, 0},
-    {"l_build", fldoff(n_lcm), NSC_INT, 0, NULL, EF_BAD, 0},
-    {"h_build", fldoff(n_hcm), NSC_INT, 0, NULL, EF_BAD, 0},
-    {"o_build", fldoff(n_oil), NSC_INT, 0, NULL, EF_BAD, 0},
-    {"r_build", fldoff(n_rad), NSC_INT, 0, NULL, EF_BAD, 0},
+    {"l_build", fldoff(n_mat[I_LCM]), NSC_SHORT, 0, NULL, EF_BAD, 0},
+    {"h_build", fldoff(n_mat[I_HCM]), NSC_SHORT, 0, NULL, EF_BAD, 0},
+    {"o_build", fldoff(n_mat[I_OIL]), NSC_SHORT, 0, NULL, EF_BAD, 0},
+    {"r_build", fldoff(n_mat[I_RAD]), NSC_SHORT, 0, NULL, EF_BAD, 0},
     {"blast", fldoff(n_blast), NSC_INT, 0, NULL, EF_BAD, 0},
     {"dam", fldoff(n_dam), NSC_INT, 0, NULL, EF_BAD, 0},
     {"bwork", fldoff(n_bwork), NSC_INT, 0, NULL, EF_BAD, 0},
index cb6eee76003d31079188c2de5e948a4f11097257..f8eeaa613775fd93837324dc2f144af5537c8d4c 100644 (file)
@@ -239,7 +239,7 @@ pln_newlanding(struct emp_qelem *list, coord tx, coord ty, int cno)
                       cname(player->cnum), prplane(&plp->plane),
                       prship(&ship));
                }
-               if (plp->pcp->pl_crew && plp->pstage == PLG_INFECT
+               if (plp->pcp->pl_mat[I_MILIT] && plp->pstage == PLG_INFECT
                    && ship.shp_pstage == PLG_HEALTHY)
                    ship.shp_pstage = PLG_EXPOSED;
            }
@@ -253,7 +253,7 @@ pln_newlanding(struct emp_qelem *list, coord tx, coord ty, int cno)
                   cname(player->cnum),
                   prplane(&plp->plane), xyas(tx, ty, sect.sct_own));
            }
-           if (plp->pcp->pl_crew && plp->pstage == PLG_INFECT
+           if (plp->pcp->pl_mat[I_MILIT] && plp->pstage == PLG_INFECT
                && sect.sct_pstage == PLG_HEALTHY)
                sect.sct_pstage = PLG_EXPOSED;
            plp->plane.pln_ship = cno;
index 29acdfa2abbf17d63ba17c6961f99ef09d063fc3..52409e6d07854b37cbbaa87bb79f5bb69c71358f 100644 (file)
@@ -198,8 +198,8 @@ show_nuke_build(int tlev)
     for (i = 0; i < n; i++) {
        np = &nchr[chridx[i].type];
        pr("%-13.13s %3d %3d %4d %4d %5d %4d %3.0f $%6d\n",
-          np->n_name, np->n_lcm, np->n_hcm, np->n_oil,
-          np->n_rad, np->n_bwork, np->n_tech,
+          np->n_name, np->n_mat[I_LCM], np->n_mat[I_HCM],
+          np->n_mat[I_OIL], np->n_mat[I_RAD], np->n_bwork, np->n_tech,
           drnuke_const > MIN_DRNUKE_CONST ?
                ceil(np->n_tech * drnuke_const) : 0.0,
           np->n_cost);
@@ -240,7 +240,7 @@ show_ship_build(int tlev)
     for (i = 0; i < n; i++) {
        mp = &mchr[chridx[i].type];
        pr("%-25.25s %3d %3d %5d %4d $%d\n",
-          mp->m_name, mp->m_lcm, mp->m_hcm,
+          mp->m_name, mp->m_mat[I_LCM], mp->m_mat[I_HCM],
           mp->m_bwork, mp->m_tech, mp->m_cost);
     }
 }
@@ -331,8 +331,8 @@ show_plane_build(int tlev)
     for (i = 0; i < n; i++) {
        pp = &plchr[chridx[i].type];
        pr("%-25.25s %3d %3d %4d %5d %4d $%d\n",
-          pp->pl_name, pp->pl_lcm,
-          pp->pl_hcm, pp->pl_crew,
+          pp->pl_name, pp->pl_mat[I_LCM],
+          pp->pl_mat[I_HCM], pp->pl_mat[I_MILIT],
           pp->pl_bwork, pp->pl_tech, pp->pl_cost);
     }
 }
@@ -349,9 +349,9 @@ show_land_build(int tlev)
     for (i = 0; i < n; i++) {
        lp = &lchr[chridx[i].type];
        pr("%-25.25s %3d %3d %4d %5d %4d $%d\n",
-          lp->l_name, lp->l_lcm,
-          lp->l_hcm,
-          lp->l_gun,
+          lp->l_name, lp->l_mat[I_LCM],
+          lp->l_mat[I_HCM],
+          lp->l_mat[I_GUN],
           lp->l_bwork, lp->l_tech, lp->l_cost);
     }
 }
index 63ccf5fe17ffd7fd89f7f18057b4127cecb4fc60..9c25137fbed6f6af73335c1d2f3e8382ba186504 100644 (file)
@@ -200,7 +200,6 @@ landrepair(struct lndstr *land, struct natstr *np, struct bp *bp, int etus)
     int build;
     int avail;
     int mult;
-    int mvec[I_MAX + 1];
 
     lp = &lchr[(int)land->lnd_type];
     sp = getsectp(land->lnd_x, land->lnd_y);
@@ -230,10 +229,7 @@ landrepair(struct lndstr *land, struct natstr *np, struct bp *bp, int etus)
     if (delta > 100 - land->lnd_effic)
        delta = 100 - land->lnd_effic;
 
-    memset(mvec, 0, sizeof(mvec));
-    mvec[I_LCM] = lp->l_lcm;
-    mvec[I_HCM] = lp->l_hcm;
-    build = get_materials(sp, bp, mvec, delta);
+    build = get_materials(sp, bp, lp->l_mat, delta);
 
     if ((sp->sct_type != SCT_HEADQ) && (sp->sct_type != SCT_FORTR))
        build /= 3;
index 091aa15b57af3d367fe2eb9911fc48c583388a9c..4fa3f185c98bbb6e62d5223256a618634b6aa717 100644 (file)
@@ -28,7 +28,7 @@
  *
  *  Known contributors to this file:
  *     Ville Virrankoski, 1996
- *     Markus Armbruster, 2007
+ *     Markus Armbruster, 2007-2016
  */
 
 #include <config.h>
 /*
  * Get build materials from sector @sp.
  * @bp is the sector's build pointer.
- * @mvec[] defines the materials needed to build 100%.
+ * Array @mvec[ITEM_MAX+1] defines the materials needed to build 100%.
  * @pct is the percentage to build.
  * Adjust build percentage downwards so that available materials
  * suffice.  Remove the materials.
  * Return adjusted build percentage.
  */
 int
-get_materials(struct sctstr *sp, struct bp *bp, int *mvec, int pct)
+get_materials(struct sctstr *sp, struct bp *bp, short mvec[], int pct)
 {
     int i, amt;
 
index 059a96107b0fa38af6a11078662bd92ee42f33f8..74ad33e2cd357aded848e5a9ed7281ac223c154a 100644 (file)
@@ -116,7 +116,7 @@ upd_plane(struct plnstr *pp, int etus,
            np->nat_money -= cost;
        }
        /* flight pay is 5x the pay received by other military */
-       np->nat_money += etus * pcp->pl_crew * money_mil * 5;
+       np->nat_money += etus * pcp->pl_mat[I_MILIT] * money_mil * 5;
     }
 }
 
@@ -124,7 +124,6 @@ static void
 planerepair(struct plnstr *pp, struct natstr *np, struct bp *bp, int etus)
 {
     int build;
-    int mvec[I_MAX + 1];
     struct shpstr *carrier;
     struct plchrstr *pcp = &plchr[(int)pp->pln_type];
     struct sctstr *sp = getsectp(pp->pln_x, pp->pln_y);
@@ -173,11 +172,7 @@ planerepair(struct plnstr *pp, struct natstr *np, struct bp *bp, int etus)
     if (delta > 100 - pp->pln_effic)
        delta = 100 - pp->pln_effic;
 
-    memset(mvec, 0, sizeof(mvec));
-    mvec[I_MILIT] = pcp->pl_crew;
-    mvec[I_LCM] = pcp->pl_lcm;
-    mvec[I_HCM] = pcp->pl_hcm;
-    build = get_materials(sp, bp, mvec, delta);
+    build = get_materials(sp, bp, pcp->pl_mat, delta);
 
     if (carrier)
        build = delta;
index 598a2e72e3c803daebffc4fc73b80e04eb57e5da..0768deccb4ad6477309ae7e8eaab02c89a21cf00 100644 (file)
@@ -248,7 +248,6 @@ shiprepair(struct shpstr *ship, struct natstr *np, struct bp *bp, int etus)
     int wf;
     int avail;
     int mult;
-    int mvec[I_MAX + 1];
 
     mp = &mchr[(int)ship->shp_type];
     sp = getsectp(ship->shp_x, ship->shp_y);
@@ -293,10 +292,7 @@ shiprepair(struct shpstr *ship, struct natstr *np, struct bp *bp, int etus)
     if (delta > 100 - ship->shp_effic)
        delta = 100 - ship->shp_effic;
 
-    memset(mvec, 0, sizeof(mvec));
-    mvec[I_LCM] = mp->m_lcm;
-    mvec[I_HCM] = mp->m_hcm;
-    build = get_materials(sp, bp, mvec, delta);
+    build = get_materials(sp, bp, mp->m_mat, delta);
 
     if (sp->sct_type != SCT_HARBR)
        build = delta;
index 027781be5d2516568737718825e2b64846951779..f580c261636ab472e7b87ac52670efc8ede49681 100644 (file)
     Play#0 output Play#0 1 "hcm" 6 0 0 -1
     Play#0 output Play#0 1 "uw" 6 0 0 -1
     Play#0 output Play#0 1 "rad" 6 0 0 -1
-    Play#0 output Play#0 1 "l_build" 8 0 0 -1
-    Play#0 output Play#0 1 "h_build" 8 0 0 -1
+    Play#0 output Play#0 1 "l_build" 6 0 0 -1
+    Play#0 output Play#0 1 "h_build" 6 0 0 -1
     Play#0 output Play#0 1 "armor" 8 0 0 -1
     Play#0 output Play#0 1 "speed" 8 0 0 -1
     Play#0 output Play#0 1 "visib" 8 0 0 -1
     Play#0 output Play#0 1 XDUMP meta plane-chr 0
     Play#0 output Play#0 1 "type" 4 0 0 20
     Play#0 output Play#0 1 "name" 3 0 0 -1
-    Play#0 output Play#0 1 "l_build" 8 0 0 -1
-    Play#0 output Play#0 1 "h_build" 8 0 0 -1
+    Play#0 output Play#0 1 "l_build" 6 0 0 -1
+    Play#0 output Play#0 1 "h_build" 6 0 0 -1
     Play#0 output Play#0 1 "bwork" 8 0 0 -1
     Play#0 output Play#0 1 "tech" 8 0 0 -1
     Play#0 output Play#0 1 "cost" 8 0 0 -1
     Play#0 output Play#0 1 "att" 8 0 0 -1
     Play#0 output Play#0 1 "def" 8 0 0 -1
     Play#0 output Play#0 1 "range" 8 0 0 -1
-    Play#0 output Play#0 1 "crew" 8 0 0 -1
+    Play#0 output Play#0 1 "crew" 6 0 0 -1
     Play#0 output Play#0 1 "fuel" 8 0 0 -1
     Play#0 output Play#0 1 "stealth" 8 0 0 -1
     Play#0 output Play#0 1 "flags" 8 8 0 43
     Play#0 output Play#0 1 "hcm" 6 0 0 -1
     Play#0 output Play#0 1 "uw" 6 0 0 -1
     Play#0 output Play#0 1 "rad" 6 0 0 -1
-    Play#0 output Play#0 1 "l_build" 8 0 0 -1
-    Play#0 output Play#0 1 "h_build" 8 0 0 -1
+    Play#0 output Play#0 1 "l_build" 6 0 0 -1
+    Play#0 output Play#0 1 "h_build" 6 0 0 -1
     Play#0 output Play#0 1 "bwork" 8 0 0 -1
     Play#0 output Play#0 1 "tech" 8 0 0 -1
     Play#0 output Play#0 1 "cost" 8 0 0 -1
     Play#0 output Play#0 1 XDUMP meta nuke-chr 0
     Play#0 output Play#0 1 "type" 4 0 0 22
     Play#0 output Play#0 1 "name" 3 0 0 -1
-    Play#0 output Play#0 1 "l_build" 8 0 0 -1
-    Play#0 output Play#0 1 "h_build" 8 0 0 -1
-    Play#0 output Play#0 1 "o_build" 8 0 0 -1
-    Play#0 output Play#0 1 "r_build" 8 0 0 -1
+    Play#0 output Play#0 1 "l_build" 6 0 0 -1
+    Play#0 output Play#0 1 "h_build" 6 0 0 -1
+    Play#0 output Play#0 1 "o_build" 6 0 0 -1
+    Play#0 output Play#0 1 "r_build" 6 0 0 -1
     Play#0 output Play#0 1 "blast" 8 0 0 -1
     Play#0 output Play#0 1 "dam" 8 0 0 -1
     Play#0 output Play#0 1 "bwork" 8 0 0 -1