Simplify how plane cargo is tracked

Fold struct plist members bombs (used for bombing runs) and misc (used
for everything else) into a single member load.
This commit is contained in:
Markus Armbruster 2009-10-03 16:25:50 -04:00
parent d3f5fee64b
commit 54b1c04686
7 changed files with 18 additions and 28 deletions

View file

@ -492,9 +492,9 @@ ac_dog(struct plist *ap, struct plist *dp)
def = pln_def(&dp->plane) * dp->plane.pln_effic / 100;
def = MAX(def, dp->pcp->pl_def / 2);
if ((ap->pcp->pl_flags & P_F) && ap->bombs + ap->misc != 0)
if ((ap->pcp->pl_flags & P_F) && ap->load != 0)
att -= 2;
if ((dp->pcp->pl_flags & P_F) && dp->bombs + ap->misc != 0)
if ((dp->pcp->pl_flags & P_F) && dp->load != 0)
def -= 2;
att += ap->pcp->pl_stealth / 25.0;
def += dp->pcp->pl_stealth / 25.0;
@ -837,8 +837,7 @@ getilists(struct emp_qelem *list, unsigned char *rel, natid intruder)
continue;
/* got one! */
ip = malloc(sizeof(*ip));
ip->bombs = 0;
ip->misc = 0;
ip->load = 0;
ip->pcp = &plchr[(int)plane.pln_type];
ip->plane = plane;
emp_insque(&ip->queue, &list[plane.pln_own]);

View file

@ -956,10 +956,7 @@ mission_pln_equip(struct plist *plp, struct ichrstr *ip, char mission)
if (item[itype] < needed)
return -1;
item[itype] -= needed;
if (itype == I_SHELL && (mission == 's' || mission == 'p'))
plp->bombs = needed;
else
plp->misc = needed;
plp->load = needed;
}
if (pp->pln_ship >= 0)
@ -1048,7 +1045,7 @@ air_damage(struct emp_qelem *bombers, coord x, coord y, int mission,
if ((mission == MI_SINTERDICT) && !(plp->pcp->pl_flags & P_A))
continue;
if (!plp->bombs)
if (!plp->load)
continue;
newdam = 0;

View file

@ -210,8 +210,7 @@ msl_sel(struct emp_qelem *list, coord x, coord y, natid victim,
continue;
/* got a valid interceptor */
irv = malloc(sizeof(*irv));
irv->bombs = 0;
irv->misc = 0;
irv->load = 0;
irv->pcp = &plchr[(int)plane.pln_type];
irv->plane = plane;
emp_insque(&irv->queue, list);

View file

@ -275,7 +275,7 @@ pln_dropoff(struct emp_qelem *list, struct ichrstr *ip, coord tx, coord ty,
amt = 0;
for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
plp = (struct plist *)qp;
amt += plp->misc;
amt += plp->load;
}
if (cno < 0) {
getsect(tx, ty, &sect);
@ -340,7 +340,7 @@ pln_mine(struct emp_qelem *list, coord tx, coord ty)
amt = 0;
for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
plp = (struct plist *)qp;
amt += plp->misc;
amt += plp->load;
}
if (amt > 0) {
@ -580,8 +580,7 @@ pln_sel(struct nstr_item *ni, struct emp_qelem *list, struct sctstr *ap,
plane.pln_mission = 0;
putplane(plane.pln_uid, &plane);
plp = malloc(sizeof(struct plist));
plp->misc = 0;
plp->bombs = 0;
plp->load = 0;
plp->pcp = pcp;
plp->plane = plane;
emp_insque(&plp->queue, list);
@ -716,10 +715,7 @@ pln_equip(struct plist *plp, struct ichrstr *ip, char mission)
return -1;
}
item[itype] -= needed;
if (itype == I_SHELL && (mission == 's' || mission == 'p'))
plp->bombs = needed;
else
plp->misc = needed;
plp->load = needed;
}
if (pp->pln_ship >= 0) {