(I_NONE, I_CIVIL, I_MILIT, I_SHELL, I_GUN, I_PETROL, I_IRON, I_DUST,

I_BAR, I_FOOD, I_OIL, I_LCM, I_HCM, I_UW, I_RAD, I_MAX): Turn macros
into enumeration constants.
(i_type): New.  Use where appropriate.  No functional changes, except
that I_NONE is now catched properly in a few places.
This commit is contained in:
Marc Olzheim 2004-09-16 21:18:01 +00:00
parent 308430e751
commit d30942632b
38 changed files with 143 additions and 134 deletions

View file

@ -33,8 +33,8 @@
void fill_update_array(int *bp, struct sctstr *sp); void fill_update_array(int *bp, struct sctstr *sp);
int *get_wp(int *bp, struct sctstr *sp, int cm); int *get_wp(int *bp, struct sctstr *sp, int cm);
int gt_bg_nmbr(int *bp, struct sctstr *sp, int comm); int gt_bg_nmbr(int *bp, struct sctstr *sp, i_type comm);
void pt_bg_nmbr(int *bp, struct sctstr *sp, int comm, int amount); void pt_bg_nmbr(int *bp, struct sctstr *sp, i_type comm, int amount);
void get_materials(struct sctstr *sp, int *bp, int *mvec, int check); void get_materials(struct sctstr *sp, int *bp, int *mvec, int check);
extern long money[MAXNOC]; extern long money[MAXNOC];

View file

@ -40,7 +40,7 @@ struct comstr {
short ef_type; short ef_type;
natid com_owner; natid com_owner;
short com_uid; short com_uid;
int com_type; i_type com_type;
int com_amount; int com_amount;
float com_price; float com_price;
int com_maxbidder; int com_maxbidder;

View file

@ -46,9 +46,28 @@ enum {
NUMPKG = BPKG + 1 NUMPKG = BPKG + 1
}; };
typedef enum {
I_NONE,
I_CIVIL,
I_MILIT,
I_SHELL,
I_GUN,
I_PETROL,
I_IRON,
I_DUST,
I_BAR,
I_FOOD,
I_OIL,
I_LCM,
I_HCM,
I_UW,
I_RAD,
I_MAX = I_RAD
} ATTRIBUTE((packed)) i_type;
struct ichrstr { struct ichrstr {
int i_mnem; /* usually the initial letter */ int i_mnem; /* usually the initial letter */
int i_vtype; /* var type */ i_type i_vtype; /* var type */
int i_value; /* mortgage value */ int i_value; /* mortgage value */
int i_sell; /* can this be sold? */ int i_sell; /* can this be sold? */
int i_lbs; /* how hard to move */ int i_lbs; /* how hard to move */

View file

@ -65,6 +65,14 @@ typedef enum {
} nsc_type; } nsc_type;
typedef char packed_nsc_type; typedef char packed_nsc_type;
/* Return nsc_type for a signed integer with the same size as TYPE. */
#define NSC_SITYPE(type) \
(sizeof(type) == 1 ? NSC_CHAR \
: sizeof(type) == sizeof(short) ? NSC_SHORT \
: sizeof(type) == sizeof(int) ? NSC_INT \
: sizeof(type) == sizeof(long) ? NSC_LONG \
: 1/0)
/* Value category */ /* Value category */
typedef enum { typedef enum {
NSC_NOCAT, NSC_NOCAT,

View file

@ -41,9 +41,9 @@
enum { MAXPRCON = 3 }; enum { MAXPRCON = 3 };
struct pchrstr { struct pchrstr {
u_char p_ctype[MAXPRCON]; /* constituent types */ i_type p_ctype[MAXPRCON]; /* constituent types */
u_short p_camt[MAXPRCON]; /* constituent amounts */ u_short p_camt[MAXPRCON]; /* constituent amounts */
int p_type; /* product item type, or I_NONE if level */ i_type p_type; /* product item type, or I_NONE if level */
int p_level; /* level index (NAT_?LEV), or -1 if item */ int p_level; /* level index (NAT_?LEV), or -1 if item */
int p_cost; /* dollars / product unit */ int p_cost; /* dollars / product unit */
int p_nrndx; /* index into sect of natural resource */ int p_nrndx; /* index into sect of natural resource */

View file

@ -65,9 +65,9 @@ extern int check_market(void);
extern void set_coastal(struct sctstr *); extern void set_coastal(struct sctstr *);
extern int sendmessage(struct natstr *, struct natstr *, char *, int); extern int sendmessage(struct natstr *, struct natstr *, char *, int);
extern void gift(int, int, s_char *, int, s_char *); extern void gift(int, int, s_char *, int, s_char *);
extern int display_mark(int, int); extern int display_mark(i_type, int);
extern int want_to_abandon(struct sctstr *, int, int, struct lndstr *); extern int want_to_abandon(struct sctstr *, i_type, int, struct lndstr *);
extern int would_abandon(struct sctstr *, int, int, struct lndstr *); extern int would_abandon(struct sctstr *, i_type, int, struct lndstr *);
extern int nav_map(int, int, int); extern int nav_map(int, int, int);
extern int count_pop(register int); extern int count_pop(register int);
extern int scuttle_tradeship(struct shpstr *, int); extern int scuttle_tradeship(struct shpstr *, int);
@ -102,7 +102,7 @@ extern void planedamage(struct plnstr *, int);
extern int nukedamage(struct nchrstr *, int, int); extern int nukedamage(struct nchrstr *, int, int);
extern int effdamage(register int, int); extern int effdamage(register int, int);
extern void item_damage(int, short *); extern void item_damage(int, short *);
extern int commdamage(register int, int, int); extern int commdamage(int, int, i_type);
/* check.c */ /* check.c */
extern int check_sect_ok(struct sctstr *); extern int check_sect_ok(struct sctstr *);
extern int check_ship_ok(struct shpstr *); extern int check_ship_ok(struct shpstr *);
@ -511,9 +511,9 @@ extern int snxtitem(register struct nstr_item *, int, s_char *);
extern int snxtsct(register struct nstr_sect *, s_char *); extern int snxtsct(register struct nstr_sect *, s_char *);
/* supply.c */ /* supply.c */
extern void resupply_all(struct lndstr *); extern void resupply_all(struct lndstr *);
extern void resupply_commod(struct lndstr *, int); extern void resupply_commod(struct lndstr *, i_type);
extern int supply_commod(int, int, int, int, int); extern int supply_commod(int, int, int, i_type, int);
extern int try_supply_commod(int, int, int, int, int); extern int try_supply_commod(int, int, int, i_type, int);
extern int has_supply(struct lndstr *); extern int has_supply(struct lndstr *);
extern int use_supply(struct lndstr *); extern int use_supply(struct lndstr *);
/* takeover.c */ /* takeover.c */
@ -578,10 +578,10 @@ extern void prod_nat(int);
extern int nav_ship(register struct shpstr *); extern int nav_ship(register struct shpstr *);
/* nav_util.c */ /* nav_util.c */
extern int check_nav(struct sctstr *); extern int check_nav(struct sctstr *);
extern int load_it(register struct shpstr *, register struct sctstr *, extern int load_it(struct shpstr *, struct sctstr *,
int); int);
extern void unload_it(register struct shpstr *); extern void unload_it(struct shpstr *);
extern void auto_fuel_ship(register struct shpstr *); extern void auto_fuel_ship(struct shpstr *);
/* nxtitemp.c */ /* nxtitemp.c */
extern s_char *nxtitemp(struct nstr_item *, int); extern s_char *nxtitemp(struct nstr_item *, int);
/* nxtsctp.c */ /* nxtsctp.c */

View file

@ -82,8 +82,8 @@ struct shpstr {
short shp_glim; short shp_glim;
coord shp_destx[2]; /* location for ship destination */ coord shp_destx[2]; /* location for ship destination */
coord shp_desty[2]; coord shp_desty[2];
s_char shp_tstart[TMAX]; /* what goods to pick up at start point */ i_type shp_tstart[TMAX]; /* what goods to pick up at start point */
s_char shp_tend[TMAX]; /* what goods to pick up at end point */ i_type shp_tend[TMAX]; /* what goods to pick up at end point */
short shp_lstart[TMAX]; /* How much do we pick up at the start */ short shp_lstart[TMAX]; /* How much do we pick up at the start */
short shp_lend[TMAX]; /* How much do we pick up at the end */ short shp_lend[TMAX]; /* How much do we pick up at the end */
u_char shp_autonav; /* autonavigation flags */ u_char shp_autonav; /* autonavigation flags */

View file

@ -40,21 +40,4 @@
#define PLG_INCUBATE 3 #define PLG_INCUBATE 3
#define PLG_EXPOSED 4 #define PLG_EXPOSED 4
#define I_NONE 0
#define I_CIVIL 1
#define I_MILIT 2
#define I_SHELL 3
#define I_GUN 4
#define I_PETROL 5
#define I_IRON 6
#define I_DUST 7
#define I_BAR 8
#define I_FOOD 9
#define I_OIL 10
#define I_LCM 11
#define I_HCM 12
#define I_UW 13
#define I_RAD 14
#define I_MAX 14
#endif /* _VAR_H_ */ #endif /* _VAR_H_ */

View file

@ -65,7 +65,7 @@ static void plane_bomb(struct emp_qelem *list, struct sctstr *target);
static void land_bomb(struct emp_qelem *list, struct sctstr *target); static void land_bomb(struct emp_qelem *list, struct sctstr *target);
static void ship_bomb(struct emp_qelem *list, struct sctstr *target); static void ship_bomb(struct emp_qelem *list, struct sctstr *target);
static int bombcomm[] = { static i_type bombcomm[] = {
I_CIVIL, I_CIVIL,
I_MILIT, I_MILIT,
I_SHELL, I_SHELL,

View file

@ -237,7 +237,7 @@ check_market(void)
tleft = 0; tleft = 0;
if (tleft > 0.0) if (tleft > 0.0)
continue; continue;
if (CANT_HAPPEN((unsigned)comm.com_type > I_MAX)) if (CANT_HAPPEN(comm.com_type <= I_NONE || comm.com_type > I_MAX))
continue; continue;
sect = getsectp(comm.com_x, comm.com_y); sect = getsectp(comm.com_x, comm.com_y);
m = sect->sct_item[comm.com_type]; m = sect->sct_item[comm.com_type];

View file

@ -101,7 +101,7 @@ coll(void)
} }
pay = dchr[sect.sct_type].d_value * ((float)sect.sct_effic + 100.0); pay = dchr[sect.sct_type].d_value * ((float)sect.sct_effic + 100.0);
for (i = 0; ichr[i].i_name; i++) { for (i = 0; ichr[i].i_name; i++) {
if (ichr[i].i_value == 0 || ichr[i].i_vtype == 0) if (ichr[i].i_value == 0 || ichr[i].i_vtype == I_NONE)
continue; continue;
val = sect.sct_item[ichr[i].i_vtype]; val = sect.sct_item[ichr[i].i_vtype];
pay += val * ichr[i].i_value; pay += val * ichr[i].i_value;

View file

@ -56,7 +56,7 @@ explore(void)
double weight; double weight;
int mcost, dam; int mcost, dam;
int infected; int infected;
int vtype; i_type vtype;
int amt_src; int amt_src;
int amt_dst; int amt_dst;
struct ichrstr *ip; struct ichrstr *ip;

View file

@ -737,7 +737,7 @@ static int
load_comm_ship(struct sctstr *sectp, struct shpstr *sp, load_comm_ship(struct sctstr *sectp, struct shpstr *sp,
struct ichrstr *ich, int load_unload, int *nshipsp) struct ichrstr *ich, int load_unload, int *nshipsp)
{ {
register int item = ich->i_vtype; i_type item = ich->i_vtype;
struct mchrstr *mcp = &mchr[(int)sp->shp_type]; struct mchrstr *mcp = &mchr[(int)sp->shp_type];
int ship_amt, ship_max, sect_amt, move_amt; int ship_amt, ship_max, sect_amt, move_amt;
int amount; int amount;
@ -940,7 +940,7 @@ static int
load_comm_land(struct sctstr *sectp, struct lndstr *lp, load_comm_land(struct sctstr *sectp, struct lndstr *lp,
struct ichrstr *ich, int load_unload, int *nunitsp) struct ichrstr *ich, int load_unload, int *nunitsp)
{ {
register int item = ich->i_vtype; i_type item = ich->i_vtype;
struct lchrstr *lcp = &lchr[(int)lp->lnd_type]; struct lchrstr *lcp = &lchr[(int)lp->lnd_type];
int land_amt, land_max, sect_amt, move_amt; int land_amt, land_max, sect_amt, move_amt;
int amount; int amount;

View file

@ -92,14 +92,14 @@ pr_mark(struct comstr *comm)
} }
int int
display_mark(int only_itype, int only_cheapest) display_mark(i_type only_itype, int only_cheapest)
{ {
struct comstr comm; struct comstr comm;
struct comstr comm2; struct comstr comm2;
int sellers = 0; int sellers = 0;
int cnt = 0; int cnt = 0;
int cheapest_items[I_MAX + 1]; int cheapest_items[I_MAX + 1];
int i; i_type i;
/* Execute trades so report lists only lots that are still available. */ /* Execute trades so report lists only lots that are still available. */
check_market(); check_market();
@ -111,12 +111,13 @@ display_mark(int only_itype, int only_cheapest)
pr(" --- ------------- -- --------- ----- ---- ------ ------\n"); pr(" --- ------------- -- --------- ----- ---- ------ ------\n");
if (only_cheapest) { if (only_cheapest) {
for (i = 0; i < I_MAX + 1; i++) for (i = I_NONE + 1; i <= I_MAX; i++)
cheapest_items[i] = -1; cheapest_items[i] = -1;
for (sellers = 0; getcomm(sellers, &comm); sellers++) { for (sellers = 0; getcomm(sellers, &comm); sellers++) {
if (comm.com_owner == 0) if (comm.com_owner == 0)
continue; continue;
if (CANT_HAPPEN((unsigned)comm.com_type > I_MAX)) if (CANT_HAPPEN(comm.com_type <= I_NONE
|| comm.com_type > I_MAX))
continue; continue;
if (cheapest_items[comm.com_type] != -1) { if (cheapest_items[comm.com_type] != -1) {
getcomm(cheapest_items[comm.com_type], &comm2); getcomm(cheapest_items[comm.com_type], &comm2);
@ -128,7 +129,7 @@ display_mark(int only_itype, int only_cheapest)
} }
} }
CANT_HAPPEN(only_itype != I_NONE); /* not implemented */ CANT_HAPPEN(only_itype != I_NONE); /* not implemented */
for (i = 0; i < I_MAX + 1; i++) { for (i = I_NONE + 1; i <= I_MAX; i++) {
if (cheapest_items[i] == -1) if (cheapest_items[i] == -1)
continue; continue;
getcomm(cheapest_items[i], &comm); getcomm(cheapest_items[i], &comm);

View file

@ -61,7 +61,7 @@ move(void)
int left; int left;
int mcost, dam; int mcost, dam;
int infected; int infected;
int vtype; i_type vtype;
int amt_src; int amt_src;
int amt_dst; int amt_dst;
struct ichrstr *ip; struct ichrstr *ip;
@ -347,7 +347,7 @@ cmd_move_map(s_char *what, coord curx, coord cury, s_char *arg)
} }
int int
want_to_abandon(struct sctstr *sp, int vtype, int amnt, struct lndstr *lp) want_to_abandon(struct sctstr *sp, i_type vtype, int amnt, struct lndstr *lp)
{ {
char prompt[80]; char prompt[80];
@ -368,7 +368,7 @@ want_to_abandon(struct sctstr *sp, int vtype, int amnt, struct lndstr *lp)
} }
int int
would_abandon(struct sctstr *sp, int vtype, int amnt, struct lndstr *lp) would_abandon(struct sctstr *sp, i_type vtype, int amnt, struct lndstr *lp)
{ {
int mil, civs, loyalcivs; int mil, civs, loyalcivs;

View file

@ -238,7 +238,7 @@ orde(void)
level = 0; /* prevent negatives. */ level = 0; /* prevent negatives. */
pr("You must use positive number! Level set to 0.\n"); pr("You must use positive number! Level set to 0.\n");
} }
ship.shp_tstart[sub] = (s_char)i1->i_vtype; ship.shp_tstart[sub] = i1->i_vtype;
ship.shp_lstart[sub] = level; ship.shp_lstart[sub] = level;
pr("Order Set \n"); pr("Order Set \n");
break; break;
@ -258,7 +258,7 @@ orde(void)
level = 0; level = 0;
pr("You must use positive number! Level set to 0.\n"); pr("You must use positive number! Level set to 0.\n");
} }
ship.shp_tend[sub] = (s_char)i1->i_vtype; ship.shp_tend[sub] = i1->i_vtype;
ship.shp_lend[sub] = level; ship.shp_lend[sub] = level;
pr("Order Set \n"); pr("Order Set \n");
break; break;
@ -286,7 +286,7 @@ orde(void)
&& (ship.shp_lstart[1] != ' '))) { && (ship.shp_lstart[1] != ' '))) {
coord tcord; coord tcord;
s_char tcomm; i_type tcomm;
short lev[TMAX]; short lev[TMAX];
int i; int i;
@ -354,10 +354,10 @@ eta_calc(struct shpstr *sp, s_char *path, int *len, int *nupdates)
} }
static void static void
prhold(int hold, int itype, int amt) prhold(int hold, i_type itype, int amt)
{ {
if (itype != I_NONE && amt != 0) { if (itype != I_NONE && amt != 0) {
if (CANT_HAPPEN((unsigned)itype > I_MAX)) if (CANT_HAPPEN(itype <= I_NONE || itype > I_MAX))
return; return;
pr("%d-", hold + 1); pr("%d-", hold + 1);
pr("%c", ichr[itype].i_mnem); pr("%c", ichr[itype].i_mnem);

View file

@ -86,8 +86,8 @@ prod(void)
int unit_work; /* sum of component amounts */ int unit_work; /* sum of component amounts */
int used; /* production w/infinite workforce */ int used; /* production w/infinite workforce */
int wforce; int wforce;
int it; i_type it;
u_char vtype; i_type vtype;
s_char *resource; s_char *resource;
s_char maxc[MAXPRCON][10]; s_char maxc[MAXPRCON][10];
s_char use[MAXPRCON][10]; s_char use[MAXPRCON][10];
@ -249,7 +249,7 @@ prod(void)
real = dmin(999.0, (double)act * prodeff); real = dmin(999.0, (double)act * prodeff);
maxr = dmin(999.0, (double)max * prodeff); maxr = dmin(999.0, (double)max * prodeff);
if (vtype != 0) { if (vtype != I_NONE) {
if (real < 0.0) if (real < 0.0)
real = 0.0; real = 0.0;
/* production backlog? */ /* production backlog? */
@ -305,7 +305,7 @@ prod(void)
pr(" %3.0f%%", p_e * 100.0); pr(" %3.0f%%", p_e * 100.0);
pr(" %4d", wforce); pr(" %4d", wforce);
if (vtype != 0) { if (vtype != I_NONE) {
pr(" %4d", (int)(real + 0.5)); pr(" %4d", (int)(real + 0.5));
} else if (type != SCT_ENLIST) { } else if (type != SCT_ENLIST) {
switch (pp->p_level) { switch (pp->p_level) {
@ -369,7 +369,7 @@ prod(void)
max = 0; max = 0;
maxr = 0; maxr = 0;
} }
if (vtype != 0 || pp->p_level == NAT_ELEV if (vtype != I_NONE || pp->p_level == NAT_ELEV
|| pp->p_level == NAT_HLEV) || pp->p_level == NAT_HLEV)
pr(" %4d\n", min(999, (int)(max * prodeff + 0.05))); pr(" %4d\n", min(999, (int)(max * prodeff + 0.05)));
else else

View file

@ -116,7 +116,7 @@ rese(void)
pr("The destination sector must be at least 60%% efficient.\n"); pr("The destination sector must be at least 60%% efficient.\n");
return RET_OK; return RET_OK;
} }
if (CANT_HAPPEN((unsigned)comm.com_type > I_MAX)) { if (CANT_HAPPEN(comm.com_type <= I_NONE || comm.com_type > I_MAX)) {
pr("The goods have been eaten by a grue."); pr("The goods have been eaten by a grue.");
return RET_OK; return RET_OK;
} }

View file

@ -58,7 +58,7 @@ rout(void)
int row; int row;
int y; int y;
int ry; int ry;
int i_del; i_type i_del;
int dir; int dir;
s_char *p; s_char *p;
s_char what[64]; s_char what[64];

View file

@ -63,7 +63,7 @@ scra(void)
struct plchrstr *pp; struct plchrstr *pp;
struct lchrstr *lp; struct lchrstr *lp;
s_char *p; s_char *p;
int i; i_type i;
struct nstr_item ni2; struct nstr_item ni2;
struct plnstr plane; struct plnstr plane;
struct lndstr land; struct lndstr land;
@ -187,7 +187,7 @@ scra(void)
} }
pr("%s", prship(&item.ship)); pr("%s", prship(&item.ship));
/* FIXME obey ITEM_MAX */ /* FIXME obey ITEM_MAX */
for (i = 1; i <= I_MAX; i++) { for (i = I_NONE + 1; i <= I_MAX; i++) {
sect.sct_item[i] += 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_LCM] += mp->m_lcm * 2 / 3 * eff;
@ -254,7 +254,7 @@ scra(void)
lp = &lchr[(int)item.land.lnd_type]; lp = &lchr[(int)item.land.lnd_type];
pr("%s", prland(&item.land)); pr("%s", prland(&item.land));
/* FIXME obey ITEM_MAX */ /* FIXME obey ITEM_MAX */
for (i = 1; i <= I_MAX; i++) { for (i = I_NONE + 1; i <= I_MAX; i++) {
sect.sct_item[i] += 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_LCM] += lp->l_lcm * 2 / 3 * eff;

View file

@ -54,7 +54,7 @@ shoo(void)
int nshot; int nshot;
int mob_cost; int mob_cost;
double m; double m;
int item; i_type item;
struct ichrstr *ip; struct ichrstr *ip;
struct lndstr land; struct lndstr land;
int targets; int targets;

View file

@ -55,7 +55,7 @@ thre(void)
struct ichrstr *ip; struct ichrstr *ip;
s_char *p; s_char *p;
int thresh; int thresh;
int type; i_type type;
s_char prompt[128]; s_char prompt[128];
s_char buf[128]; s_char buf[128];

View file

@ -82,14 +82,6 @@
/* Selector descriptors for characteristics tables */ /* Selector descriptors for characteristics tables */
/* FIXME belongs into src/lib/global/ */ /* FIXME belongs into src/lib/global/ */
/* Return nsc_type for a signed integer with the same size as TYPE. */
#define NSC_SITYPE(type) \
(sizeof(type) == 1 ? NSC_CHAR \
: sizeof(type) == sizeof(short) ? NSC_SHORT \
: sizeof(type) == sizeof(int) ? NSC_INT \
: sizeof(type) == sizeof(long) ? NSC_LONG \
: 1/0)
static struct castr dchr_ca[] = { static struct castr dchr_ca[] = {
{NSC_STRING, 0, 0, offsetof(struct dchrstr, d_name), "name"}, {NSC_STRING, 0, 0, offsetof(struct dchrstr, d_name), "name"},
{NSC_INT, 0, 0, offsetof(struct dchrstr, d_mnem), "mnem"}, {NSC_INT, 0, 0, offsetof(struct dchrstr, d_mnem), "mnem"},
@ -110,7 +102,7 @@ static struct castr dchr_ca[] = {
static struct castr ichr_ca[] = { static struct castr ichr_ca[] = {
{NSC_STRING, 0, 0, offsetof(struct ichrstr, i_name), "name"}, {NSC_STRING, 0, 0, offsetof(struct ichrstr, i_name), "name"},
{NSC_INT, 0, 0, offsetof(struct ichrstr, i_mnem), "mnem"}, {NSC_INT, 0, 0, offsetof(struct ichrstr, i_mnem), "mnem"},
{NSC_INT, 0, 0, offsetof(struct ichrstr, i_vtype), "vtype"}, {NSC_SITYPE(i_type), 0, 0, offsetof(struct ichrstr, i_vtype), "vtype"},
{NSC_INT, 0, 0, offsetof(struct ichrstr, i_value), "value"}, {NSC_INT, 0, 0, offsetof(struct ichrstr, i_value), "value"},
{NSC_INT, 0, 0, offsetof(struct ichrstr, i_sell), "sell"}, {NSC_INT, 0, 0, offsetof(struct ichrstr, i_sell), "sell"},
{NSC_INT, 0, 0, offsetof(struct ichrstr, i_lbs), "lbs"}, {NSC_INT, 0, 0, offsetof(struct ichrstr, i_lbs), "lbs"},
@ -166,9 +158,9 @@ static struct castr mchr_ca[] = {
static struct castr pchr_ca[] = { static struct castr pchr_ca[] = {
{NSC_STRING, 0, 0, offsetof(struct pchrstr, p_name), "name"}, {NSC_STRING, 0, 0, offsetof(struct pchrstr, p_name), "name"},
{NSC_STRING, 0, 0, offsetof(struct pchrstr, p_sname), "sname"}, {NSC_STRING, 0, 0, offsetof(struct pchrstr, p_sname), "sname"},
{NSC_UCHAR, 0, MAXPRCON, offsetof(struct pchrstr, p_ctype), "ctype"}, {NSC_SITYPE(i_type), 0, MAXPRCON, offsetof(struct pchrstr, p_ctype), "ctype"},
{NSC_USHORT, 0, MAXPRCON, offsetof(struct pchrstr, p_camt), "camt"}, {NSC_USHORT, 0, MAXPRCON, offsetof(struct pchrstr, p_camt), "camt"},
{NSC_INT, 0, 0, offsetof(struct pchrstr, p_type), "type"}, {NSC_SITYPE(i_type), 0, 0, offsetof(struct pchrstr, p_type), "type"},
{NSC_INT, 0, 0, offsetof(struct pchrstr, p_level), "level"}, {NSC_INT, 0, 0, offsetof(struct pchrstr, p_level), "level"},
{NSC_INT, 0, 0, offsetof(struct pchrstr, p_cost), "cost"}, {NSC_INT, 0, 0, offsetof(struct pchrstr, p_cost), "cost"},
{NSC_INT, 0, 0, offsetof(struct pchrstr, p_nrndx), "nrndx"}, {NSC_INT, 0, 0, offsetof(struct pchrstr, p_nrndx), "nrndx"},

View file

@ -52,9 +52,10 @@
void void
item_damage(int pct, short *item) item_damage(int pct, short *item)
{ {
int i, lose; int lose;
i_type i;
for (i = 1; i <= I_MAX; ++i) { for (i = I_NONE + 1; i <= I_MAX; ++i) {
if (opt_SUPER_BARS && i == I_BAR) if (opt_SUPER_BARS && i == I_BAR)
continue; continue;
lose = roundavg((double)item[i] * pct * 0.01); lose = roundavg((double)item[i] * pct * 0.01);
@ -192,7 +193,7 @@ effdamage(register int amt, int dam)
} }
int int
commdamage(register int amt, int dam, int vtype) commdamage(int amt, int dam, i_type vtype)
{ {
int lost; int lost;

View file

@ -141,8 +141,8 @@ struct castr ship_ca[] = {
{NSC_XCOORD, 0, 0, fldoff(shpstr, shp_destx[1]), "xend"}, {NSC_XCOORD, 0, 0, fldoff(shpstr, shp_destx[1]), "xend"},
{NSC_YCOORD, 0, 0, fldoff(shpstr, shp_desty[0]), "ystart"}, {NSC_YCOORD, 0, 0, fldoff(shpstr, shp_desty[0]), "ystart"},
{NSC_YCOORD, 0, 0, fldoff(shpstr, shp_desty[1]), "yend"}, {NSC_YCOORD, 0, 0, fldoff(shpstr, shp_desty[1]), "yend"},
{NSC_CHAR, 0, TMAX, fldoff(shpstr, shp_tstart), "cargostart"}, {NSC_SITYPE(i_type), 0, TMAX, fldoff(shpstr, shp_tstart), "cargostart"},
{NSC_CHAR, 0, TMAX, fldoff(shpstr, shp_tend), "cargoend"}, {NSC_SITYPE(i_type), 0, TMAX, fldoff(shpstr, shp_tend), "cargoend"},
{NSC_SHORT, 0, TMAX, fldoff(shpstr, shp_lstart), "amtstart"}, {NSC_SHORT, 0, TMAX, fldoff(shpstr, shp_lstart), "amtstart"},
{NSC_SHORT, 0, TMAX, fldoff(shpstr, shp_lend), "amtend"}, {NSC_SHORT, 0, TMAX, fldoff(shpstr, shp_lend), "amtend"},
{NSC_UCHAR, 0, 0, fldoff(shpstr, shp_autonav), "autonav"}, {NSC_UCHAR, 0, 0, fldoff(shpstr, shp_autonav), "autonav"},
@ -279,7 +279,7 @@ struct castr lost_ca[] = {
struct castr commodity_ca[] = { struct castr commodity_ca[] = {
{NSC_NATID, 0, 0, fldoff(comstr, com_owner), "owner"}, {NSC_NATID, 0, 0, fldoff(comstr, com_owner), "owner"},
{NSC_SHORT, 0, 0, fldoff(comstr, com_uid), "uid"}, {NSC_SHORT, 0, 0, fldoff(comstr, com_uid), "uid"},
{NSC_INT, 0, 0, fldoff(comstr, com_type), "type"}, {NSC_SITYPE(i_type), 0, 0, fldoff(comstr, com_type), "type"},
{NSC_INT, 0, 0, fldoff(comstr, com_amount), "amount"}, {NSC_INT, 0, 0, fldoff(comstr, com_amount), "amount"},
{NSC_INT, 0, 0, fldoff(comstr, com_maxbidder), "maxbidder"}, {NSC_INT, 0, 0, fldoff(comstr, com_maxbidder), "maxbidder"},
{NSC_TIME, 0, 0, fldoff(comstr, com_markettime), "markettime"}, {NSC_TIME, 0, 0, fldoff(comstr, com_markettime), "markettime"},

View file

@ -1264,7 +1264,7 @@ mission_pln_equip(struct plist *plp, struct ichrstr *ip, int flags,
struct lndstr land; struct lndstr land;
struct shpstr ship; struct shpstr ship;
struct sctstr sect; struct sctstr sect;
int itype; i_type itype;
int rval; int rval;
short *item; short *item;

View file

@ -567,7 +567,7 @@ pln_equip(struct plist *plp, struct ichrstr *ip, int flags, s_char mission)
struct lndstr land; struct lndstr land;
struct shpstr ship; struct shpstr ship;
struct sctstr sect; struct sctstr sect;
int itype; i_type itype;
int rval; int rval;
short *item; short *item;
int own; int own;

View file

@ -419,8 +419,9 @@ show_ship_stats(int tlev)
void void
show_ship_capab(int tlev) show_ship_capab(int tlev)
{ {
register struct mchrstr *mp; struct mchrstr *mp;
register int i; i_type i;
int j;
int scount; int scount;
int n; int n;
s_char *p; s_char *p;
@ -436,14 +437,14 @@ show_ship_capab(int tlev)
pr("%-25.25s ", mp->m_name); pr("%-25.25s ", mp->m_name);
for (i = 0; i <= I_MAX; ++i) for (i = I_NONE + 1; i <= I_MAX; ++i)
if (mp->m_item[i]) if (mp->m_item[i])
pr(" %d%c", mp->m_item[i], ichr[i].i_mnem); pr(" %d%c", mp->m_item[i], ichr[i].i_mnem);
pr(" "); pr(" ");
for (i = n = 0; i < 32; i++) { for (j = n = 0; j < 32; j++) {
if (!(mp->m_flags & bit(i))) if (!(mp->m_flags & bit(j)))
continue; continue;
if (NULL != (p = lookup(bit(i), ship_flags))) { if (NULL != (p = lookup(bit(j), ship_flags))) {
if (n++ > 0) if (n++ > 0)
pr(" "); pr(" ");
pr(p); pr(p);
@ -546,8 +547,9 @@ show_land_capab(int tlev)
{ {
struct lchrstr *lcp; struct lchrstr *lcp;
int lcount; int lcount;
register int i, n; i_type i;
register s_char *p; int j, n;
s_char *p;
pr("%25s capabilities\n", ""); pr("%25s capabilities\n", "");
@ -559,14 +561,14 @@ show_land_capab(int tlev)
pr("%-25s ", lcp->l_name); pr("%-25s ", lcp->l_name);
for (i = 0; i <= I_MAX; ++i) for (i = I_NONE + 1; i <= I_MAX; ++i)
if (lcp->l_item[i]) if (lcp->l_item[i])
pr(" %d%c", lcp->l_item[i], ichr[i].i_mnem); pr(" %d%c", lcp->l_item[i], ichr[i].i_mnem);
pr(" "); pr(" ");
for (i = n = 0; i < 32; i++) { for (j = n = 0; j < 32; j++) {
if (!(lcp->l_flags & bit(i))) if (!(lcp->l_flags & bit(j)))
continue; continue;
if (NULL != (p = lookup(bit(i), land_flags))) { if (NULL != (p = lookup(bit(j), land_flags))) {
if (n++ > 0) if (n++ > 0)
pr(" "); pr(" ");
pr(p); pr(p);

View file

@ -49,8 +49,8 @@
#include "player.h" #include "player.h"
#include "prototypes.h" #include "prototypes.h"
static int get_minimum(struct lndstr *, int); static int get_minimum(struct lndstr *, i_type);
static int s_commod(int, int, int, int, int, int); static int s_commod(int, int, int, i_type, int, int);
/* /*
* We want to get enough guns to be maxed out, enough shells to * We want to get enough guns to be maxed out, enough shells to
@ -84,7 +84,7 @@ resupply_all(struct lndstr *lp)
*/ */
void void
resupply_commod(struct lndstr *lp, int type) resupply_commod(struct lndstr *lp, i_type type)
{ {
int amt; int amt;
struct lchrstr *lcp; struct lchrstr *lcp;
@ -131,7 +131,7 @@ resupply_commod(struct lndstr *lp, int type)
* Actually get the commod * Actually get the commod
*/ */
int int
supply_commod(int own, int x, int y, int type, int total_wanted) supply_commod(int own, int x, int y, i_type type, int total_wanted)
{ {
if (total_wanted < 0) if (total_wanted < 0)
return 0; return 0;
@ -142,7 +142,7 @@ supply_commod(int own, int x, int y, int type, int total_wanted)
* Just return the number you COULD get, without doing it * Just return the number you COULD get, without doing it
*/ */
int int
try_supply_commod(int own, int x, int y, int type, int total_wanted) try_supply_commod(int own, int x, int y, i_type type, int total_wanted)
{ {
if (total_wanted < 0) if (total_wanted < 0)
return 0; return 0;
@ -152,7 +152,7 @@ try_supply_commod(int own, int x, int y, int type, int total_wanted)
/* Get supplies of a certain type */ /* Get supplies of a certain type */
static int static int
s_commod(int own, int x, int y, int type, int total_wanted, s_commod(int own, int x, int y, i_type type, int total_wanted,
int actually_doit) int actually_doit)
{ {
int wanted = total_wanted; int wanted = total_wanted;
@ -433,7 +433,7 @@ s_commod(int own, int x, int y, int type, int total_wanted,
*/ */
static int static int
get_minimum(struct lndstr *lp, int type) get_minimum(struct lndstr *lp, i_type type)
{ {
struct lchrstr *lcp; struct lchrstr *lcp;
int max, want = 0; int max, want = 0;

View file

@ -133,7 +133,7 @@ trade_desc(struct trdstr *tp, union trdgenstr *tgp)
pr("(%3d) tech %d %d%% %s [", pr("(%3d) tech %d %d%% %s [",
tp->trd_owner, sp->shp_tech, sp->shp_effic, prship(sp)); tp->trd_owner, sp->shp_tech, sp->shp_effic, prship(sp));
for (i = 1; i <= I_MAX; ++i) { for (i = I_NONE + 1; i <= I_MAX; ++i) {
if (sp->shp_item[i]) if (sp->shp_item[i])
pr("%c:%d ", ichr[i].i_mnem, sp->shp_item[i]); pr("%c:%d ", ichr[i].i_mnem, sp->shp_item[i]);
} }
@ -191,7 +191,7 @@ trade_desc(struct trdstr *tp, union trdgenstr *tgp)
pr("(%3d) tech %d %d%% %s [", pr("(%3d) tech %d %d%% %s [",
tp->trd_owner, tp->trd_owner,
lp->lnd_tech, lp->lnd_effic, lchr[(int)lp->lnd_type].l_name); lp->lnd_tech, lp->lnd_effic, lchr[(int)lp->lnd_type].l_name);
for (i = 1; i <= I_MAX; ++i) { for (i = I_NONE + 1; i <= I_MAX; ++i) {
if (lp->lnd_item[i]) if (lp->lnd_item[i])
pr("%c:%d ", ichr[i].i_mnem, lp->lnd_item[i]); pr("%c:%d ", ichr[i].i_mnem, lp->lnd_item[i]);
} }
@ -252,7 +252,7 @@ get_couval(int cnum)
secttot += (long)(dchr[sp->sct_type].d_value * secttot += (long)(dchr[sp->sct_type].d_value *
((float)sp->sct_effic + 100.0)); ((float)sp->sct_effic + 100.0));
for (k = 0; ichr[k].i_name; k++) { for (k = 0; ichr[k].i_name; k++) {
if (ichr[k].i_value == 0 || ichr[k].i_vtype == 0) if (ichr[k].i_value == 0 || ichr[k].i_vtype == I_NONE)
continue; continue;
val = sp->sct_item[ichr[k].i_vtype]; val = sp->sct_item[ichr[k].i_vtype];
secttot += val * ichr[k].i_value; secttot += val * ichr[k].i_value;

View file

@ -52,7 +52,7 @@ get_wp(int *bp, struct sctstr *sp, int cm)
} }
int int
gt_bg_nmbr(int *bp, struct sctstr *sp, int comm) gt_bg_nmbr(int *bp, struct sctstr *sp, i_type comm)
{ {
int *wp; int *wp;
int cm; int cm;
@ -66,7 +66,7 @@ gt_bg_nmbr(int *bp, struct sctstr *sp, int comm)
} }
void void
pt_bg_nmbr(int *bp, struct sctstr *sp, int comm, int amount) pt_bg_nmbr(int *bp, struct sctstr *sp, i_type comm, int amount)
{ {
int *wp; int *wp;
int cm; int cm;
@ -80,10 +80,11 @@ pt_bg_nmbr(int *bp, struct sctstr *sp, int comm, int amount)
void void
fill_update_array(int *bp, struct sctstr *sp) fill_update_array(int *bp, struct sctstr *sp)
{ {
int i, k; int k;
int *wp; int *wp;
i_type i;
for (i = 1; i <= I_MAX; i++) for (i = I_NONE + 1; i <= I_MAX; i++)
if ((k = bud_key[i]) != 0) { if ((k = bud_key[i]) != 0) {
wp = get_wp(bp, sp, k); wp = get_wp(bp, sp, k);
*wp = sp->sct_item[i]; *wp = sp->sct_item[i];

View file

@ -45,11 +45,11 @@
#define DELIVER_BONUS 4.0 #define DELIVER_BONUS 4.0
static int static int
deliver(register struct sctstr *from, struct ichrstr *ip, int dir, deliver(struct sctstr *from, struct ichrstr *ip, int dir,
int thresh, int amt_src, int plague, i_packing packing) int thresh, int amt_src, int plague, i_packing packing)
{ {
register struct sctstr *to; struct sctstr *to;
int vtype; /* item vartype */ i_type vtype; /* item vartype */
int amt_moved; int amt_moved;
int amt_dst; int amt_dst;
int mobility; int mobility;
@ -119,7 +119,7 @@ deliver(register struct sctstr *from, struct ichrstr *ip, int dir,
void void
dodeliver(struct sctstr *sp) dodeliver(struct sctstr *sp)
{ {
register int i; i_type i;
int thresh; int thresh;
int dir; int dir;
int plague; int plague;
@ -130,7 +130,7 @@ dodeliver(struct sctstr *sp)
return; return;
plague = sp->sct_pstage; plague = sp->sct_pstage;
packing = sp->sct_effic >= 60 ? dchr[sp->sct_type].d_pkg : IPKG; packing = sp->sct_effic >= 60 ? dchr[sp->sct_type].d_pkg : IPKG;
for (i = 1; i <= I_MAX; i++) { for (i = I_NONE + 1; i <= I_MAX; i++) {
if (sp->sct_del[i] == 0) if (sp->sct_del[i] == 0)
continue; continue;
thresh = sp->sct_del[i] & ~0x7; thresh = sp->sct_del[i] & ~0x7;

View file

@ -69,7 +69,7 @@ dodistribute(struct sctstr *sp, int imex, s_char *path, double dist_i_cost,
int pack; int pack;
double mcost; double mcost;
int diff; int diff;
int item; i_type item;
int changed; int changed;
int rplague; int rplague;
int lplague; int lplague;
@ -91,7 +91,7 @@ dodistribute(struct sctstr *sp, int imex, s_char *path, double dist_i_cost,
sect_packing = sp->sct_effic >= 60 ? dchr[sp->sct_type].d_pkg : IPKG; sect_packing = sp->sct_effic >= 60 ? dchr[sp->sct_type].d_pkg : IPKG;
lplague = rplague = changed = 0; lplague = rplague = changed = 0;
for (item = 1; item < I_MAX + 1; item++) { for (item = I_NONE + 1; item <= I_MAX; item++) {
if (sp->sct_dist[item] == 0) if (sp->sct_dist[item] == 0)
continue; continue;
ip = &ichr[item]; ip = &ichr[item];

View file

@ -53,7 +53,7 @@ get_materials(struct sctstr *sp, int *bp, int *mvec, int check)
int i; int i;
int still_left; int still_left;
for (i = 1; i <= I_MAX; i++) { for (i = I_NONE + 1; i <= I_MAX; i++) {
if (mvec[i] == 0) if (mvec[i] == 0)
continue; continue;

View file

@ -52,7 +52,7 @@
#include "common.h" #include "common.h"
#include <stdlib.h> #include <stdlib.h>
static void swap(register struct shpstr *); static void swap(struct shpstr *);
static void static void
scuttle_it(register struct shpstr *sp) scuttle_it(register struct shpstr *sp)
@ -116,10 +116,10 @@ nav_check_atdest(register struct shpstr *sp)
/* CZ 6/1/94 */ /* CZ 6/1/94 */
static void static void
swap(register struct shpstr *sp) swap(struct shpstr *sp)
{ {
coord tcord; coord tcord;
s_char tcomm[TMAX]; i_type tcomm[TMAX];
short lev[TMAX]; short lev[TMAX];
int i; int i;

View file

@ -82,16 +82,17 @@ check_nav(struct sctstr *sect)
* Chad Zabel 6/1/94 * Chad Zabel 6/1/94
*/ */
int int
load_it(register struct shpstr *sp, register struct sctstr *psect, int i) load_it(struct shpstr *sp, struct sctstr *psect, int i)
{ {
int comm, shipown, amount, ship_amt, sect_amt; int shipown, amount, ship_amt, sect_amt;
int abs_max, max_amt, transfer; int abs_max, max_amt, transfer;
i_type comm;
struct mchrstr *vship; struct mchrstr *vship;
amount = sp->shp_lend[i]; amount = sp->shp_lend[i];
shipown = sp->shp_own; shipown = sp->shp_own;
comm = sp->shp_tend[i]; comm = sp->shp_tend[i];
if (CANT_HAPPEN((unsigned)comm > I_MAX)) if (CANT_HAPPEN(comm <= I_NONE || comm > I_MAX))
return 0; return 0;
ship_amt = sp->shp_item[comm]; ship_amt = sp->shp_item[comm];
@ -157,13 +158,13 @@ load_it(register struct shpstr *sp, register struct sctstr *psect, int i)
* Chad Zabel 6/1/94 * Chad Zabel 6/1/94
*/ */
void void
unload_it(register struct shpstr *sp) unload_it(struct shpstr *sp)
{ {
struct sctstr *sectp; struct sctstr *sectp;
int i; int i;
int landowner; int landowner;
int shipown; int shipown;
int comm; i_type comm;
int sect_amt; int sect_amt;
int ship_amt; int ship_amt;
int max_amt; int max_amt;
@ -182,7 +183,7 @@ unload_it(register struct shpstr *sp)
continue; continue;
comm = sp->shp_tend[i]; comm = sp->shp_tend[i];
if (CANT_HAPPEN((unsigned)comm > I_MAX)) if (CANT_HAPPEN(comm <= I_NONE || comm > I_MAX))
continue; continue;
ship_amt = sp->shp_item[comm]; ship_amt = sp->shp_item[comm];
sect_amt = sectp->sct_item[comm]; sect_amt = sectp->sct_item[comm];
@ -221,7 +222,7 @@ unload_it(register struct shpstr *sp)
*/ */
void void
auto_fuel_ship(register struct shpstr *sp) auto_fuel_ship(struct shpstr *sp)
{ {
double d; double d;
int totalfuel = 0; int totalfuel = 0;

View file

@ -63,7 +63,7 @@ produce(struct natstr *np, struct sctstr *sp, short *vec, int work,
double output; double output;
int actual; int actual;
int unit_work; int unit_work;
int item; i_type item;
int worker_limit; int worker_limit;
int material_limit; int material_limit;
int material_consume; int material_consume;
@ -199,7 +199,8 @@ materials_cost(struct pchrstr *pp, short *vec, int *costp)
static void static void
materials_charge(struct pchrstr *pp, short *vec, int count) materials_charge(struct pchrstr *pp, short *vec, int count)
{ {
int i, item, n; int i, n;
i_type item;
for (i = 0; i < MAXPRCON; ++i) { for (i = 0; i < MAXPRCON; ++i) {
item = pp->p_ctype[i]; item = pp->p_ctype[i];

View file

@ -167,13 +167,13 @@ enlist(short *vec, int etu, int *cost)
/* Fallout is calculated here. */ /* Fallout is calculated here. */
static void static void
meltitems(int etus, int fallout, int own, short *vec, int type, int x, int y, meltitems(int etus, int fallout, int own, short *vec, i_type type, int x, int y,
int uid) int uid)
{ {
int n; i_type n;
int melt; int melt;
for (n = 1; n <= I_MAX; n++) { for (n = I_NONE + 1; n <= I_MAX; n++) {
melt = roundavg(vec[n] * etus * (long)fallout melt = roundavg(vec[n] * etus * (long)fallout
/ (1000.0 * melt_item_denom[n])); / (1000.0 * melt_item_denom[n]));
if (melt > vec[n]) if (melt > vec[n])