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

@ -124,8 +124,7 @@ struct plchrstr {
struct plist {
struct emp_qelem queue; /* list of planes */
int bombs; /* bombs carried for bombing mission */
int misc; /* amount of random item being transported */
int load; /* number of bombs or items carried */
struct plchrstr *pcp; /* pointer to desc of plane */
struct plnstr plane; /* struct plane */
};

View file

@ -344,7 +344,7 @@ eff_bomb(struct emp_qelem *list, struct sctstr *target)
plp = (struct plist *)qp;
if (changed_plane_aborts(plp))
continue;
if (plp->bombs || nuk_on_plane(&plp->plane) >= 0)
if (plp->load || nuk_on_plane(&plp->plane) >= 0)
dam += pln_damage(&plp->plane, target->sct_x, target->sct_y,
'p', &nukedam, 1);
}
@ -422,7 +422,7 @@ comm_bomb(struct emp_qelem *list, struct sctstr *target)
plp = (struct plist *)qp;
if (changed_plane_aborts(plp))
continue;
if (plp->bombs || nuk_on_plane(&plp->plane) >= 0)
if (plp->load || nuk_on_plane(&plp->plane) >= 0)
dam += pln_damage(&plp->plane, target->sct_x, target->sct_y,
'p', &nukedam, 1);
}
@ -484,7 +484,7 @@ ship_bomb(struct emp_qelem *list, struct sctstr *target)
continue;
}
(void)sprintf(prompt, "%s, %d bombs. Target ('~' to skip)? ",
prplane(&plp->plane), plp->bombs);
prplane(&plp->plane), plp->load);
shipno = -1;
while (shipno < 0) {
if (!(q = getstring(prompt, buf)))
@ -605,7 +605,7 @@ plane_bomb(struct emp_qelem *list, struct sctstr *target)
continue;
}
(void)sprintf(prompt, "%s, %d bombs. Target ('~' to skip)? ",
prplane(&plp->plane), plp->bombs);
prplane(&plp->plane), plp->load);
planeno = -1;
while (planeno < 0) {
if (!(q = getstring(prompt, buf)))
@ -709,7 +709,7 @@ land_bomb(struct emp_qelem *list, struct sctstr *target)
continue;
}
(void)sprintf(prompt, "%s, %d bombs. Target ('~' to skip)? ",
prplane(&plp->plane), plp->bombs);
prplane(&plp->plane), plp->load);
unitno = -1;
while (unitno < 0) {
if (!(q = getstring(prompt, buf)))
@ -796,7 +796,7 @@ strat_bomb(struct emp_qelem *list, struct sctstr *target)
for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
plp = (struct plist *)qp;
if (plp->bombs || nuk_on_plane(&plp->plane) >= 0)
if (plp->load || nuk_on_plane(&plp->plane) >= 0)
dam += pln_damage(&plp->plane, target->sct_x, target->sct_y,
's', &nukedam, 1);
}

View file

@ -144,7 +144,7 @@ paradrop(struct emp_qelem *list, coord x, coord y)
att_combat_init(off, EF_PLANE);
for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
plp = (struct plist *)qp;
off->troops += plp->misc;
off->troops += plp->load;
}
off->mil = off->troops;
if (att_abort(A_PARA, off, def)) {

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) {