(pln_equip, mission_pln_equip): Rename item to itype. Use struct

ichrstr member i_vtype instead of pointer arithmetic to map from
`struct ichrstr *' to item type.  No functional changes.
This commit is contained in:
Markus Armbruster 2004-03-10 13:22:48 +00:00
parent 522f1cdf9a
commit e3390b9e0d
2 changed files with 32 additions and 32 deletions

View file

@ -1266,7 +1266,7 @@ mission_pln_equip(struct plist *plp, struct ichrstr *ip, int flags,
struct sctstr sect; struct sctstr sect;
int type; int type;
s_char *ptr; s_char *ptr;
int item; int itype;
int rval; int rval;
int vec[I_MAX + 1]; int vec[I_MAX + 1];
@ -1292,32 +1292,32 @@ mission_pln_equip(struct plist *plp, struct ichrstr *ip, int flags,
vec[I_PETROL] -= pcp->pl_fuel; vec[I_PETROL] -= pcp->pl_fuel;
rval = 0; rval = 0;
if (!(flags & P_F)) { if (!(flags & P_F)) {
item = 0; itype = 0;
needed = 0; needed = 0;
switch (mission) { switch (mission) {
case 's': case 's':
case 'p': case 'p':
if (pp->pln_nuketype == -1) { if (pp->pln_nuketype == -1) {
item = I_SHELL; itype = I_SHELL;
needed = pp->pln_load; needed = pp->pln_load;
} }
break; break;
case 't': case 't':
if ((pcp->pl_flags & P_C) == 0 || ip == 0) if ((pcp->pl_flags & P_C) == 0 || ip == 0)
break; break;
item = ip - ichr; itype = ip->i_vtype;
needed = (pp->pln_load * 2) / ip->i_lbs; needed = (pp->pln_load * 2) / ip->i_lbs;
break; break;
case 'd': case 'd':
if ((pcp->pl_flags & P_C) == 0 || ip == 0) if ((pcp->pl_flags & P_C) == 0 || ip == 0)
break; break;
item = ip - ichr; itype = ip->i_vtype;
needed = (pp->pln_load * 2) / ip->i_lbs; needed = (pp->pln_load * 2) / ip->i_lbs;
break; break;
case 'a': case 'a':
if ((pcp->pl_flags & (P_V | P_C)) == 0) if ((pcp->pl_flags & (P_V | P_C)) == 0)
break; break;
item = I_MILIT; itype = I_MILIT;
needed = pp->pln_load / ip->i_lbs; needed = pp->pln_load / ip->i_lbs;
break; break;
case 'n': case 'n':
@ -1326,26 +1326,26 @@ mission_pln_equip(struct plist *plp, struct ichrstr *ip, int flags,
break; break;
case 'i': /* missile interception */ case 'i': /* missile interception */
if (pp->pln_load) { if (pp->pln_load) {
item = I_SHELL; itype = I_SHELL;
needed = pp->pln_load; needed = pp->pln_load;
} }
break; break;
default: default:
break; break;
} }
if (rval < 0 || (item && needed <= 0)) { if (rval < 0 || (itype && needed <= 0)) {
return -1; return -1;
} }
if ((vec[item] < needed) && (item == I_SHELL)) if (vec[itype] < needed && (itype == I_SHELL))
vec[item] += supply_commod(plp->plane.pln_own, vec[itype] += supply_commod(plp->plane.pln_own,
plp->plane.pln_x, plp->plane.pln_y, plp->plane.pln_x, plp->plane.pln_y,
I_SHELL, needed); I_SHELL, needed);
if (vec[item] < needed) { if (vec[itype] < needed) {
return -1; return -1;
} else { } else {
vec[item] -= needed; vec[itype] -= needed;
} }
if (item == I_SHELL && (mission == 's' || mission == 'p')) if (itype == I_SHELL && (mission == 's' || mission == 'p'))
plp->bombs = needed; plp->bombs = needed;
else else
plp->misc = needed; plp->misc = needed;

View file

@ -522,7 +522,7 @@ pln_equip(struct plist *plp, struct ichrstr *ip, int flags, s_char mission)
struct sctstr sect; struct sctstr sect;
int type; int type;
s_char *ptr; s_char *ptr;
int item; int itype;
int rval; int rval;
int vec[I_MAX + 1]; int vec[I_MAX + 1];
int own; int own;
@ -561,31 +561,31 @@ pln_equip(struct plist *plp, struct ichrstr *ip, int flags, s_char mission)
vec[I_PETROL] -= pcp->pl_fuel; vec[I_PETROL] -= pcp->pl_fuel;
rval = 0; rval = 0;
if ((flags & P_F) == 0) { if ((flags & P_F) == 0) {
item = 0; itype = 0;
needed = 0; needed = 0;
switch (mission) { switch (mission) {
case 's': case 's':
case 'p': case 'p':
if (pp->pln_nuketype == -1) { if (pp->pln_nuketype == -1) {
item = I_SHELL; itype = I_SHELL;
needed = pp->pln_load; needed = pp->pln_load;
} }
break; break;
case 't': case 't':
if ((pcp->pl_flags & P_C) == 0 || ip == 0) if ((pcp->pl_flags & P_C) == 0 || ip == 0)
break; break;
item = ip - ichr; itype = ip->i_vtype;
needed = (pp->pln_load * 2) / ip->i_lbs; needed = (pp->pln_load * 2) / ip->i_lbs;
break; break;
case 'd': case 'd':
item = ip - ichr; itype = ip->i_vtype;
needed = (pp->pln_load * 2) / ip->i_lbs; needed = (pp->pln_load * 2) / ip->i_lbs;
/* Is this mine dropping excursion? */ /* Is this mine dropping excursion? */
if ((item == I_SHELL) && (pcp->pl_flags & P_MINE)) if (itype == I_SHELL && (pcp->pl_flags & P_MINE))
break; break;
/* Is this a cargo drop? */ /* Is this a cargo drop? */
if ((pcp->pl_flags & P_C) == 0 || ip == 0) { if ((pcp->pl_flags & P_C) == 0 || ip == 0) {
item = 0; itype = 0;
needed = 0; needed = 0;
break; break;
} }
@ -593,7 +593,7 @@ pln_equip(struct plist *plp, struct ichrstr *ip, int flags, s_char mission)
case 'a': case 'a':
if ((pcp->pl_flags & (P_V | P_C)) == 0) if ((pcp->pl_flags & (P_V | P_C)) == 0)
break; break;
item = I_MILIT; itype = I_MILIT;
needed = pp->pln_load / ip->i_lbs; needed = pp->pln_load / ip->i_lbs;
break; break;
case 'n': case 'n':
@ -603,24 +603,24 @@ pln_equip(struct plist *plp, struct ichrstr *ip, int flags, s_char mission)
default: default:
break; break;
} }
if (rval < 0 || (item && needed <= 0)) { if (rval < 0 || (itype && needed <= 0)) {
pr("%s can't contribute to mission\n", prplane(pp)); pr("%s can't contribute to mission\n", prplane(pp));
return -1; return -1;
} }
#if 0 #if 0
/* Supply is broken somewhere, so don't use it for now */ /* Supply is broken somewhere, so don't use it for now */
if ((vec[item] < needed) && (item == I_SHELL)) if (vec[itype] < needed && itype == I_SHELL)
vec[item] += supply_commod(plp->plane.pln_own, vec[itype] += supply_commod(plp->plane.pln_own,
plp->plane.pln_x, plp->plane.pln_y, plp->plane.pln_x, plp->plane.pln_y,
I_SHELL, needed); I_SHELL, needed);
#endif #endif
if (vec[item] < needed) { if (vec[itype] < needed) {
pr("Not enough %s for %s\n", ichr[item].i_name, prplane(pp)); pr("Not enough %s for %s\n", ichr[itype].i_name, prplane(pp));
return -1; return -1;
} else { } else {
vec[item] -= needed; vec[itype] -= needed;
} }
if (item == I_SHELL && (mission == 's' || mission == 'p')) if (itype == I_SHELL && (mission == 's' || mission == 'p'))
plp->bombs = needed; plp->bombs = needed;
else else
plp->misc = needed; plp->misc = needed;