static int plane_caps(struct emp_qelem *);
static void ac_intercept(struct emp_qelem *, struct emp_qelem *,
struct emp_qelem *, natid, coord, coord);
-static int all_missiles(struct emp_qelem *);
static void ac_dog(struct plist *, struct plist *);
static void ac_planedamage(struct plist *, natid, int, natid, int,
int, char *);
coord x, coord y, char *path, int mission_flags,
int no_air_defense)
{
- int val, non_missiles;
+ int val;
int rel;
int dir;
int nats[MAXNOC];
int unfriendly[MAXNOC];
int overfly[MAXNOC];
int flags;
- struct emp_qelem ilist[MAXNOC], *qp;
- char mypath[1024];
- int myp;
+ struct emp_qelem ilist[MAXNOC];
int civ, mil;
natid plane_owner;
struct sctstr sect;
struct lndstr land;
struct nstr_item ni;
natid cn;
- struct natstr *over, *mynatp;
+ struct natstr *mynatp;
struct plist *plp;
int evaded;
struct shiplist *head = NULL;
plp = (struct plist *)bomb_list->q_forw;
plane_owner = plp->plane.pln_own;
- strncpy(mypath, path, sizeof(mypath));
- myp = 0;
-
memset(overfly, 0, sizeof(overfly));
memset(gotilist, 0, sizeof(gotilist));
memset(unfriendly, 0, sizeof(unfriendly));
}
}
- while ((dir = mypath[myp++]) && !QEMPTY(bomb_list)) {
- if ((val = diridx(dir)) == DIR_STOP)
- break;
- /* XXX using xnorm is probably bad */
- x = xnorm(x + diroff[val][0]);
- y = ynorm(y + diroff[val][1]);
+ for (;;) {
getsect(x, y, §);
- over = getnatp(sect.sct_own);
if (mission_flags & PM_R) {
flags = plane_caps(bomb_list);
changed += map_set(plane_owner, sect.sct_x, sect.sct_y,
dchr[sect.sct_type].d_mnem, 0);
}
- if ((rel = getrel(over, plane_owner)) == ALLIED)
- continue;
evaded = do_evade(bomb_list, esc_list);
-
- if (sect.sct_own != 0 && sect.sct_own != plane_owner && !evaded) {
- /* We only show planes overhead if they didn't
- * evade radar */
- overfly[sect.sct_own]++;
- PR(sect.sct_own, "%s planes spotted over %s\n",
- cname(plane_owner), xyas(x, y, sect.sct_own));
- if (opt_HIDDEN)
- setcont(sect.sct_own, plane_owner, FOUND_FLY);
- }
-
if (!evaded) {
+ if (sect.sct_own != 0 && sect.sct_own != plane_owner
+ && getrel(getnatp(sect.sct_own), plane_owner) != ALLIED) {
+ overfly[sect.sct_own]++;
+ PR(sect.sct_own, "%s planes spotted over %s\n",
+ cname(plane_owner), xyas(x, y, sect.sct_own));
+ if (opt_HIDDEN)
+ setcont(sect.sct_own, plane_owner, FOUND_FLY);
+ }
+
/* Fire flak */
if (unfriendly[sect.sct_own])
ac_doflak(bomb_list, §);
ac_landflak(bomb_list, x, y);
if (!QEMPTY(bomb_list))
ac_shipflak(bomb_list, x, y);
- }
- /* mission planes aborted due to flak -- don't send escorts */
- if (QEMPTY(bomb_list))
- break;
- if (!no_air_defense && !evaded)
- air_defense(x, y, plane_owner, bomb_list, esc_list);
+ /* mission planes aborted due to flak -- don't send escorts */
+ if (QEMPTY(bomb_list))
+ break;
- if (sect.sct_own == 0 || sect.sct_own == plane_owner)
- continue;
+ if (!no_air_defense)
+ air_defense(x, y, plane_owner, bomb_list, esc_list);
- if (evaded)
- continue;
-
- non_missiles = 0;
- for (qp = bomb_list->q_forw; qp != bomb_list; qp = qp->q_forw) {
- struct plist *ip = (struct plist *)qp;
- if (!(plchr[(int)ip->plane.pln_type].pl_flags & P_M))
- non_missiles = 1;
+ if (unfriendly[sect.sct_own]) {
+ if (!gotilist[sect.sct_own]) {
+ getilist(&ilist[sect.sct_own], sect.sct_own);
+ gotilist[sect.sct_own]++;
+ }
+ ac_intercept(bomb_list, esc_list, &ilist[sect.sct_own],
+ sect.sct_own, x, y);
+ }
}
- if (!non_missiles)
- continue;
-
- if (unfriendly[sect.sct_own] && !gotilist[sect.sct_own]) {
- getilist(&ilist[sect.sct_own], sect.sct_own);
- gotilist[sect.sct_own]++;
- }
- if (rel > HOSTILE)
- continue;
- ac_intercept(bomb_list, esc_list, &ilist[sect.sct_own],
- sect.sct_own, x, y);
+ dir = *path++;
+ if (!dir || QEMPTY(bomb_list) || (val = diridx(dir)) == DIR_STOP)
+ break;
+ x = xnorm(x + diroff[val][0]);
+ y = ynorm(y + diroff[val][1]);
}
/* Let's report all of the overflights even if aborted */
return fl;
}
-static int
-count_non_missiles(struct emp_qelem *list)
-{
- struct emp_qelem *qp;
- struct plist *plp;
- int att_count = 0;
-
- /* don't intercept missiles */
- for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
- plp = (struct plist *)qp;
- if (!(plp->pcp->pl_flags & P_M))
- att_count++;
- }
- return att_count;
-}
-
void
sam_intercept(struct emp_qelem *att_list, struct emp_qelem *def_list,
natid def_own, natid plane_owner, coord x, coord y,
aqp != att_list && dqp != def_list; aqp = anext) {
anext = aqp->q_forw;
aplp = (struct plist *)aqp;
- if (aplp->pcp->pl_flags & P_M)
- continue;
if (aplp->pcp->pl_cost < 1000)
continue;
for (; dqp != def_list; dqp = dnext) {
continue;
if (dplp->plane.pln_range <
- mapdist(x, y, dplp->plane.pln_x, dplp->plane.pln_y)) {
- emp_remque(dqp);
- free(dqp);
+ mapdist(x, y, dplp->plane.pln_x, dplp->plane.pln_y))
continue;
- }
if (CANT_HAPPEN(dplp->plane.pln_flags & PLN_LAUNCHED)
|| mission_pln_equip(dplp, 0, P_F, 0) < 0) {
emp_remque(dqp);
plp = (struct plist *)bomb_list->q_forw;
plane_owner = plp->plane.pln_own;
- icount = 0;
-
sam_intercept(bomb_list, def_list, def_own, plane_owner, x, y, 0);
- sam_intercept(esc_list, def_list, def_own, plane_owner, x, y, 1);
- if (!(att_count = count_non_missiles(bomb_list) +
- count_non_missiles(esc_list)))
+ sam_intercept(esc_list, def_list, def_own, plane_owner, x, y, 0);
+
+ att_count = 0;
+ for (qp = bomb_list->q_forw; qp != bomb_list; qp = qp->q_forw)
+ att_count++;
+ for (qp = esc_list->q_forw; qp != esc_list; qp = qp->q_forw)
+ att_count++;
+ if (!att_count)
return;
emp_initque(&int_list);
+ icount = 0;
for (qp = def_list->q_forw; qp != def_list; qp = next) {
next = qp->q_forw;
plp = (struct plist *)qp;
in_next = in->q_forw;
att_next = att->q_forw;
attacker = (struct plist *)att;
-
- /* skip missiles. If only missiles left, we're done */
- if (plchr[(int)attacker->plane.pln_type].pl_flags & P_M) {
- att = att_next;
- if (att == att_list) {
- more_att = 0;
- if (QEMPTY(att_list))
- more_int = 0;
- else
- att = att->q_forw;
- }
- if (all_missiles(att_list))
- more_att = 0;
- continue;
- }
interceptor = (struct plist *)in;
nplanes = attacker->plane.pln_effic;
if (nplanes > interceptor->plane.pln_effic)
}
}
-static int
-all_missiles(struct emp_qelem *att_list)
-{
- struct emp_qelem *qp;
- struct plist *p;
-
- qp = att_list->q_forw;
- while (qp != att_list) {
- p = (struct plist *)qp;
- if (!(plchr[(int)p->plane.pln_type].pl_flags & P_M))
- return 0;
-
- qp = qp->q_forw;
- }
- return 1;
-}
-
static void
ac_dog(struct plist *ap, struct plist *dp)
{