(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

@ -52,7 +52,7 @@ get_wp(int *bp, struct sctstr *sp, int cm)
}
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 cm;
@ -66,7 +66,7 @@ gt_bg_nmbr(int *bp, struct sctstr *sp, int comm)
}
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 cm;
@ -80,10 +80,11 @@ pt_bg_nmbr(int *bp, struct sctstr *sp, int comm, int amount)
void
fill_update_array(int *bp, struct sctstr *sp)
{
int i, k;
int k;
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) {
wp = get_wp(bp, sp, k);
*wp = sp->sct_item[i];

View file

@ -45,11 +45,11 @@
#define DELIVER_BONUS 4.0
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)
{
register struct sctstr *to;
int vtype; /* item vartype */
struct sctstr *to;
i_type vtype; /* item vartype */
int amt_moved;
int amt_dst;
int mobility;
@ -119,7 +119,7 @@ deliver(register struct sctstr *from, struct ichrstr *ip, int dir,
void
dodeliver(struct sctstr *sp)
{
register int i;
i_type i;
int thresh;
int dir;
int plague;
@ -130,7 +130,7 @@ dodeliver(struct sctstr *sp)
return;
plague = sp->sct_pstage;
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)
continue;
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;
double mcost;
int diff;
int item;
i_type item;
int changed;
int rplague;
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;
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)
continue;
ip = &ichr[item];

View file

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

View file

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

View file

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

View file

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

View file

@ -167,13 +167,13 @@ enlist(short *vec, int etu, int *cost)
/* Fallout is calculated here. */
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 n;
i_type n;
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
/ (1000.0 * melt_item_denom[n]));
if (melt > vec[n])