*
* Known contributors to this file:
* Ville Virrankoski, 1995
- * Markus Armbruster, 2004-2013
+ * Markus Armbruster, 2004-2016
*/
#ifndef BUDG_H
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];
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 */
#define NUKE_H
#include <time.h>
+#include "item.h"
#include "types.h"
#define N_MAXNUKE 20
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 */
#define PLANE_H
#include <time.h>
+#include "item.h"
#include "queue.h"
#include "types.h"
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 */
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 */
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 */
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 */
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");
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");
* 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;
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");
* Dave Pare
* Ken Stevens, 1995
* Steve McClure, 1998-2000
- * Markus Armbruster, 2004-2013
+ * Markus Armbruster, 2004-2016
* Ron Koenderink, 2005-2008
*/
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;
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;
}
*
* Known contributors to this file:
* Steve McClure, 2000
- * Markus Armbruster, 2004-2014
+ * Markus Armbruster, 2004-2016
*/
#include <config.h>
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;
-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;
-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(§);
}
*
* Known contributors to this file:
* Steve McClure, 2000
- * Markus Armbruster, 2006-2011
+ * Markus Armbruster, 2006-2016
*/
#include <config.h>
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) {
{"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},
#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},
{"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,
{"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},
#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},
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;
}
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;
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);
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);
}
}
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);
}
}
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);
}
}
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);
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;
*
* 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;
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;
}
}
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);
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;
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);
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;
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