Pass only PM_* mission flags to ac_encounter()

Since the previous two commits, ac_encounter() checks its
mission_flags argument only for proper mission flags PM_R and PM_S,
not for plane flags P_A, P_S, P_I.

This makes the code to put plane flags into mission flags useless.
Remove it from bomb(), drop(), fly(), para(), reco(),
perform_mission(), mission_pln_arm(), air_defense(), pln_arm().

Much of that code was useless even before: P_X and P_H since Chainsaw
3 option STEALTHV became mandatory in Empire 2, and P_MINE since
commit cc0c3e4f (v4.3.0) cleaned up mine drops.
This commit is contained in:
Markus Armbruster 2008-09-21 10:25:59 -04:00
parent 4ea1d3acff
commit b624ce30dd
8 changed files with 33 additions and 120 deletions

View file

@ -552,8 +552,7 @@ extern int pln_airbase_ok(struct plnstr *, int, int);
extern int carrier_planes(struct shpstr *, int); extern int carrier_planes(struct shpstr *, int);
extern void pln_sel(struct nstr_item *, struct emp_qelem *, extern void pln_sel(struct nstr_item *, struct emp_qelem *,
struct sctstr *, int, int, int, int); struct sctstr *, int, int, int, int);
extern int pln_arm(struct emp_qelem *, int, char, struct ichrstr *, extern void pln_arm(struct emp_qelem *, int, char, struct ichrstr *, int);
int, int);
extern int pln_mobcost(int, struct plnstr *, int); extern int pln_mobcost(int, struct plnstr *, int);
extern void pln_put(struct emp_qelem *); extern void pln_put(struct emp_qelem *);
extern void pln_put1(struct plist *); extern void pln_put1(struct plist *);

View file

@ -81,7 +81,6 @@ int
bomb(void) bomb(void)
{ {
char *p; char *p;
int mission_flags;
coord tx, ty; coord tx, ty;
coord ax, ay; coord ax, ay;
int ap_to_target; int ap_to_target;
@ -128,7 +127,6 @@ bomb(void)
/* /*
* select planes within range * select planes within range
*/ */
mission_flags = 0;
pln_sel(&ni_bomb, &bomb_list, &ap_sect, ap_to_target, pln_sel(&ni_bomb, &bomb_list, &ap_sect, ap_to_target,
2, wantflags, P_M | P_O); 2, wantflags, P_M | P_O);
pln_sel(&ni_esc, &esc_list, &ap_sect, ap_to_target, pln_sel(&ni_esc, &esc_list, &ap_sect, ap_to_target,
@ -136,18 +134,13 @@ bomb(void)
/* /*
* now arm and equip the bombers, transports, whatever. * now arm and equip the bombers, transports, whatever.
*/ */
mission_flags |= P_X; /* stealth (shhh) */ pln_arm(&bomb_list, 2 * ap_to_target, mission, ip, 0);
mission_flags |= P_H; /* gets turned off if not all choppers */
mission_flags = pln_arm(&bomb_list, 2 * ap_to_target, mission,
ip, 0, mission_flags);
if (QEMPTY(&bomb_list)) { if (QEMPTY(&bomb_list)) {
pr("No planes could be equipped for the mission.\n"); pr("No planes could be equipped for the mission.\n");
return RET_FAIL; return RET_FAIL;
} }
mission_flags = pln_arm(&esc_list, 2 * ap_to_target, mission, pln_arm(&esc_list, 2 * ap_to_target, mission, ip, P_F | P_ESC);
ip, P_F | P_ESC, mission_flags); ac_encounter(&bomb_list, &esc_list, ax, ay, flightpath, 0, 0);
ac_encounter(&bomb_list, &esc_list, ax, ay,
flightpath, mission_flags, 0);
if (QEMPTY(&bomb_list)) { if (QEMPTY(&bomb_list)) {
pr("No planes got through fighter defenses\n"); pr("No planes got through fighter defenses\n");
} else if (target.sct_type == SCT_SANCT) { } else if (target.sct_type == SCT_SANCT) {

View file

@ -42,7 +42,6 @@
int int
drop(void) drop(void)
{ {
int mission_flags;
coord tx, ty; coord tx, ty;
coord ax, ay; coord ax, ay;
int ap_to_target; int ap_to_target;
@ -97,7 +96,6 @@ drop(void)
/* /*
* select planes within range * select planes within range
*/ */
mission_flags = 0;
pln_sel(&ni_bomb, &bomb_list, &ap_sect, ap_to_target, pln_sel(&ni_bomb, &bomb_list, &ap_sect, ap_to_target,
2, wantflags, P_M | P_O); 2, wantflags, P_M | P_O);
if (QEMPTY(&bomb_list)) { if (QEMPTY(&bomb_list)) {
@ -109,20 +107,15 @@ drop(void)
/* /*
* now arm and equip the bombers, transports, whatever. * now arm and equip the bombers, transports, whatever.
*/ */
mission_flags |= P_X; /* stealth (shhh) */ pln_arm(&bomb_list, 2 * ap_to_target,
mission_flags |= P_H; /* gets turned off if not all choppers */
mission_flags |= P_MINE;
mission_flags = pln_arm(&bomb_list, 2 * ap_to_target,
wantflags & P_MINE ? 'm' : 'd', wantflags & P_MINE ? 'm' : 'd',
ip, 0, mission_flags); ip, 0);
if (QEMPTY(&bomb_list)) { if (QEMPTY(&bomb_list)) {
pr("No planes could be equipped for the mission.\n"); pr("No planes could be equipped for the mission.\n");
return RET_FAIL; return RET_FAIL;
} }
mission_flags = pln_arm(&esc_list, 2 * ap_to_target, 'd', pln_arm(&esc_list, 2 * ap_to_target, 'd', ip, P_ESC | P_F);
ip, P_ESC | P_F, mission_flags); ac_encounter(&bomb_list, &esc_list, ax, ay, flightpath, 0, 0);
ac_encounter(&bomb_list, &esc_list, ax, ay,
flightpath, mission_flags, 0);
if (QEMPTY(&bomb_list)) { if (QEMPTY(&bomb_list)) {
pr("No planes got through fighter defenses\n"); pr("No planes got through fighter defenses\n");
} else { } else {

View file

@ -44,7 +44,6 @@
int int
fly(void) fly(void)
{ {
int mission_flags;
coord tx, ty; coord tx, ty;
coord ax, ay; coord ax, ay;
int ap_to_target; int ap_to_target;
@ -95,7 +94,6 @@ fly(void)
/* /*
* select planes within range * select planes within range
*/ */
mission_flags = 0;
pln_sel(&ni_bomb, &bomb_list, &ap_sect, ap_to_target, pln_sel(&ni_bomb, &bomb_list, &ap_sect, ap_to_target,
1, wantflags, P_M | P_O); 1, wantflags, P_M | P_O);
if (QEMPTY(&bomb_list)) { if (QEMPTY(&bomb_list)) {
@ -113,18 +111,14 @@ fly(void)
/* /*
* now arm and equip the bombers, transports, whatever. * now arm and equip the bombers, transports, whatever.
*/ */
mission_flags |= P_X; /* stealth (shhh) */ pln_arm(&bomb_list, ap_to_target, 't', ip, 0);
mission_flags |= P_H; /* gets turned off if not all choppers */
mission_flags = pln_arm(&bomb_list, ap_to_target, 't',
ip, 0, mission_flags);
if (QEMPTY(&bomb_list)) { if (QEMPTY(&bomb_list)) {
pr("No planes could be equipped for the mission.\n"); pr("No planes could be equipped for the mission.\n");
return RET_FAIL; return RET_FAIL;
} }
mission_flags = pln_arm(&esc_list, ap_to_target, 't', pln_arm(&esc_list, ap_to_target, 't', ip, P_ESC | P_F);
ip, P_ESC | P_F, mission_flags);
ac_encounter(&bomb_list, &esc_list, ax, ay, ac_encounter(&bomb_list, &esc_list, ax, ay,
flightpath, mission_flags, 0); flightpath, 0, 0);
if (QEMPTY(&bomb_list)) { if (QEMPTY(&bomb_list)) {
pr("No planes got through fighter defenses\n"); pr("No planes got through fighter defenses\n");
} else { } else {

View file

@ -48,7 +48,6 @@ static int paradrop(struct emp_qelem *list, coord x, coord y);
int int
para(void) para(void)
{ {
int mission_flags;
coord tx, ty; coord tx, ty;
coord ax, ay; coord ax, ay;
int ap_to_target; int ap_to_target;
@ -91,19 +90,13 @@ para(void)
/* /*
* now arm and equip the bombers, transports, whatever. * now arm and equip the bombers, transports, whatever.
*/ */
mission_flags = 0; pln_arm(&bomb_list, 2 * ap_to_target, 'a', &ichr[I_MILIT], 0);
mission_flags |= P_X; /* stealth (shhh) */
mission_flags |= P_H; /* gets turned off if not all choppers */
mission_flags = pln_arm(&bomb_list, 2 * ap_to_target, 'a',
&ichr[I_MILIT], 0, mission_flags);
if (QEMPTY(&bomb_list)) { if (QEMPTY(&bomb_list)) {
pr("No planes could be equipped for the mission.\n"); pr("No planes could be equipped for the mission.\n");
return RET_FAIL; return RET_FAIL;
} }
mission_flags = pln_arm(&esc_list, 2 * ap_to_target, 'a', pln_arm(&esc_list, 2 * ap_to_target, 'a', &ichr[I_MILIT], P_ESC | P_F);
&ichr[I_MILIT], P_ESC | P_F, mission_flags); ac_encounter(&bomb_list, &esc_list, ax, ay, flightpath, 0, 0);
ac_encounter(&bomb_list, &esc_list, ax, ay,
flightpath, mission_flags, 0);
if (QEMPTY(&bomb_list)) { if (QEMPTY(&bomb_list)) {
pr("No planes got through fighter defenses\n"); pr("No planes got through fighter defenses\n");
} else { } else {

View file

@ -41,7 +41,6 @@
int int
reco(void) reco(void)
{ {
int mission_flags;
coord tx, ty; coord tx, ty;
coord ax, ay; coord ax, ay;
int ap_to_target; int ap_to_target;
@ -72,7 +71,6 @@ reco(void)
pr("target is %s\n", xyas(tx, ty, player->cnum)); pr("target is %s\n", xyas(tx, ty, player->cnum));
getsect(tx, ty, &target); getsect(tx, ty, &target);
cno = -1; cno = -1;
mission_flags = 0;
if (pln_onewaymission(&target, &cno, &wantflags) < 0) if (pln_onewaymission(&target, &cno, &wantflags) < 0)
return RET_SYN; return RET_SYN;
ap_to_target = strlen(flightpath); ap_to_target = strlen(flightpath);
@ -99,23 +97,15 @@ reco(void)
/* /*
* now arm and equip the bombers, transports, whatever. * now arm and equip the bombers, transports, whatever.
*/ */
mission_flags |= P_X; /* stealth (shhh) */ pln_arm(&bomb_list, ap_to_target, 'r', 0, P_S | P_I);
mission_flags |= P_H; /* gets turned off if not all choppers */
mission_flags = pln_arm(&bomb_list, ap_to_target, 'r',
0, P_S | P_I, mission_flags);
if (QEMPTY(&bomb_list)) { if (QEMPTY(&bomb_list)) {
pr("No planes could be equipped for the mission.\n"); pr("No planes could be equipped for the mission.\n");
return RET_FAIL; return RET_FAIL;
} }
mission_flags = pln_arm(&esc_list, ap_to_target, 'r', pln_arm(&esc_list, ap_to_target, 'r', 0, P_F | P_ESC);
0, P_F | P_ESC, mission_flags); ac_encounter(&bomb_list, &esc_list, ax, ay, flightpath,
mission_flags |= PM_R; *player->argp[0] == 's' ? PM_R | PM_S : PM_R,
0);
if (*player->argp[0] == 's')
mission_flags |= PM_S;
ac_encounter(&bomb_list, &esc_list, ax, ay,
flightpath, mission_flags, 0);
if (QEMPTY(&bomb_list)) { if (QEMPTY(&bomb_list)) {
pr("No planes got through fighter defenses\n"); pr("No planes got through fighter defenses\n");
} else { } else {

View file

@ -69,8 +69,8 @@ static void build_mission_list_type(struct genlist *, coord, coord, int,
static void divide(struct emp_qelem *, struct emp_qelem *, coord, coord); static void divide(struct emp_qelem *, struct emp_qelem *, coord, coord);
static int dosupport(struct genlist *, coord, coord, natid, natid); static int dosupport(struct genlist *, coord, coord, natid, natid);
static int find_airport(struct emp_qelem *, coord, coord); static int find_airport(struct emp_qelem *, coord, coord);
static int mission_pln_arm(struct emp_qelem *, coord, coord, int, static void mission_pln_arm(struct emp_qelem *, coord, coord, int,
int, struct ichrstr *, int, int); int, struct ichrstr *, int);
static void mission_pln_sel(struct emp_qelem *, int, int, int); static void mission_pln_sel(struct emp_qelem *, int, int, int);
static int perform_mission(coord, coord, natid, struct emp_qelem *, int, static int perform_mission(coord, coord, natid, struct emp_qelem *, int,
char *, int); char *, int);
@ -386,7 +386,7 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
struct sctstr sect; struct sctstr sect;
struct mchrstr *mcp; struct mchrstr *mcp;
struct plchrstr *pcp; struct plchrstr *pcp;
int dam = 0, dam2, mission_flags; int dam = 0, dam2;
natid plane_owner = 0; natid plane_owner = 0;
int md, range, air_dam = 0; int md, range, air_dam = 0;
double hitchance, vrange; double hitchance, vrange;
@ -609,18 +609,12 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
/* Split off the escorts at this base into e */ /* Split off the escorts at this base into e */
divide(&escorts, &e, air->x, air->y); divide(&escorts, &e, air->x, air->y);
mission_flags = 0; mission_pln_arm(&b, air->x, air->y, 2 * md, 'p', 0, 0);
mission_flags |= P_X; /* stealth (shhh) */
mission_flags |= P_H; /* gets turned off if not all choppers */
mission_flags = mission_pln_arm(&b, air->x, air->y, 2 * md, 'p', 0,
0, mission_flags);
if (QEMPTY(&b)) if (QEMPTY(&b))
continue; continue;
mission_flags = mission_pln_arm(&e, air->x, air->y, 2 * md, 'p', 0, mission_pln_arm(&e, air->x, air->y, 2 * md, 'p', 0, P_F | P_ESC);
P_F | P_ESC, mission_flags);
pp = BestAirPath(buf, air->x, air->y, x, y); pp = BestAirPath(buf, air->x, air->y, x, y);
if (CANT_HAPPEN(!pp)) if (CANT_HAPPEN(!pp))
@ -636,7 +630,7 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
xyas(x, y, air->own)); xyas(x, y, air->own));
} }
ac_encounter(&b, &e, air->x, air->y, pp, mission_flags, 0); ac_encounter(&b, &e, air->x, air->y, pp, 0, 0);
if (!QEMPTY(&b)) if (!QEMPTY(&b))
air_dam += air_dam +=
@ -843,10 +837,9 @@ mission_pln_sel(struct emp_qelem *list, int wantflags, int nowantflags,
/* /*
* Arm only the planes at x,y * Arm only the planes at x,y
*/ */
static int static void
mission_pln_arm(struct emp_qelem *list, coord x, coord y, int dist, mission_pln_arm(struct emp_qelem *list, coord x, coord y, int dist,
int mission, struct ichrstr *ip, int flags, int mission, struct ichrstr *ip, int flags)
int mission_flags)
{ {
struct emp_qelem *qp; struct emp_qelem *qp;
struct emp_qelem *next; struct emp_qelem *next;
@ -869,28 +862,11 @@ mission_pln_arm(struct emp_qelem *list, coord x, coord y, int dist,
free(qp); free(qp);
continue; continue;
} }
if (flags & (P_S | P_I)) {
if (plp->pcp->pl_flags & P_S)
mission_flags |= P_S;
if (plp->pcp->pl_flags & P_I)
mission_flags |= P_I;
}
if (!(plp->pcp->pl_flags & P_H))
/* no stealth on this mission */
mission_flags &= ~P_H;
if (!(plp->pcp->pl_flags & P_X))
/* no stealth on this mission */
mission_flags &= ~P_X;
if (!(plp->pcp->pl_flags & P_MINE)) {
/* no asw on this mission */
mission_flags &= ~P_MINE;
}
pp->pln_flags |= PLN_LAUNCHED; pp->pln_flags |= PLN_LAUNCHED;
pp->pln_mobil -= pln_mobcost(dist, pp, flags); pp->pln_mobil -= pln_mobcost(dist, pp, flags);
putplane(pp->pln_uid, pp); putplane(pp->pln_uid, pp);
} }
return mission_flags;
} }
int int
@ -1146,7 +1122,7 @@ air_defense(coord x, coord y, natid victim, struct emp_qelem *bomb_list,
struct emp_qelem *esc_list) struct emp_qelem *esc_list)
{ {
int dam = 0, cn; int dam = 0, cn;
int mission_flags, combat = 0, rel, dist, z; int combat = 0, rel, dist, z;
struct emp_qelem *qp, interceptors, airp, i, empty, *next; struct emp_qelem *qp, interceptors, airp, i, empty, *next;
struct plist *plp; struct plist *plp;
struct genlist *glp; struct genlist *glp;
@ -1256,10 +1232,6 @@ air_defense(coord x, coord y, natid victim, struct emp_qelem *bomb_list,
/* Split off the interceptors at this base into i */ /* Split off the interceptors at this base into i */
divide(&interceptors, &i, air->x, air->y); divide(&interceptors, &i, air->x, air->y);
mission_flags = 0;
mission_flags |= P_X; /* stealth (shhh) */
/* gets turned off if not all choppers */
mission_flags |= P_H;
sam_intercept(bomb_list, &i, cn, victim, x, y, 0); sam_intercept(bomb_list, &i, cn, victim, x, y, 0);
sam_intercept(esc_list, &i, cn, victim, x, y, 1); sam_intercept(esc_list, &i, cn, victim, x, y, 1);
@ -1273,9 +1245,7 @@ air_defense(coord x, coord y, natid victim, struct emp_qelem *bomb_list,
pln_put(&i); pln_put(&i);
continue; continue;
} }
mission_flags = mission_pln_arm(&i, air->x, air->y, 2 * dist, 0, 0, P_F);
mission_pln_arm(&i, air->x, air->y, 2 * dist, 0, 0, P_F,
mission_flags);
/* Did we run out of interceptors? */ /* Did we run out of interceptors? */
if (QEMPTY(&i)) if (QEMPTY(&i))
@ -1306,8 +1276,7 @@ air_defense(coord x, coord y, natid victim, struct emp_qelem *bomb_list,
/* Now, fly the planes to the sector */ /* Now, fly the planes to the sector */
emp_initque(&empty); emp_initque(&empty);
ac_encounter(&i, &empty, air->x, air->y, ac_encounter(&i, &empty, air->x, air->y, path, 0, 1);
path, mission_flags, 1);
/* If none made it, continue */ /* If none made it, continue */
if (QEMPTY(&i)) if (QEMPTY(&i))

View file

@ -562,9 +562,9 @@ pln_sel(struct nstr_item *ni, struct emp_qelem *list, struct sctstr *ap,
} }
} }
int void
pln_arm(struct emp_qelem *list, int dist, char mission, struct ichrstr *ip, pln_arm(struct emp_qelem *list, int dist, char mission, struct ichrstr *ip,
int flags, int mission_flags) int flags)
{ {
struct emp_qelem *qp; struct emp_qelem *qp;
struct emp_qelem *next; struct emp_qelem *next;
@ -582,29 +582,11 @@ pln_arm(struct emp_qelem *list, int dist, char mission, struct ichrstr *ip,
free(qp); free(qp);
continue; continue;
} }
if (flags & (P_S | P_I)) {
if (plp->pcp->pl_flags & P_S)
mission_flags |= P_S;
if (plp->pcp->pl_flags & P_I)
mission_flags |= P_I;
}
if (!(plp->pcp->pl_flags & P_H))
/* no stealth on this mission */
mission_flags &= ~P_H;
if (!(plp->pcp->pl_flags & P_X))
/* no stealth on this mission */
mission_flags &= ~P_X;
if (!(plp->pcp->pl_flags & P_MINE)) {
/* no asw on this mission */
mission_flags &= ~P_MINE;
/* FIXME no effect */
}
pp->pln_flags |= PLN_LAUNCHED; pp->pln_flags |= PLN_LAUNCHED;
pp->pln_mobil -= pln_mobcost(dist, pp, flags); pp->pln_mobil -= pln_mobcost(dist, pp, flags);
putplane(pp->pln_uid, pp); putplane(pp->pln_uid, pp);
pr("%s equipped\n", prplane(pp)); pr("%s equipped\n", prplane(pp));
} }
return mission_flags;
} }
static int static int