Intercept planes at their assembly point

Change ac_encounter() to start intercepting and running air defense
missions at the assembly point instead of the first sector entered
from there.

This also fixes a coding bug: when the flight path was empty, evaded
was used uninitialized when checking whether to intercept over the
target.  The compiler even warned about that.  Since the uninitialized
evaded typically read non-zero, interception triggered by ships and
land units didn't work.  Abusable: if you managed to make your target
sector an assembly point, e.g. by placing an own or allied ship there,
you could bomb it without getting intercepted or taking flak.
This commit is contained in:
Markus Armbruster 2008-09-24 22:09:59 -04:00
parent da363d621e
commit b5cb3cb37b

View file

@ -128,12 +128,7 @@ ac_encounter(struct emp_qelem *bomb_list, struct emp_qelem *esc_list,
} }
} }
while ((dir = *path++) && !QEMPTY(bomb_list)) { for (;;) {
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]);
getsect(x, y, &sect); getsect(x, y, &sect);
if (mission_flags & PM_R) { if (mission_flags & PM_R) {
@ -192,9 +187,7 @@ ac_encounter(struct emp_qelem *bomb_list, struct emp_qelem *esc_list,
} }
evaded = do_evade(bomb_list, esc_list); evaded = do_evade(bomb_list, esc_list);
if (evaded) if (!evaded) {
continue;
if (sect.sct_own != 0 && sect.sct_own != plane_owner if (sect.sct_own != 0 && sect.sct_own != plane_owner
&& getrel(getnatp(sect.sct_own), plane_owner) != ALLIED) { && getrel(getnatp(sect.sct_own), plane_owner) != ALLIED) {
overfly[sect.sct_own]++; overfly[sect.sct_own]++;
@ -219,9 +212,6 @@ ac_encounter(struct emp_qelem *bomb_list, struct emp_qelem *esc_list,
if (!no_air_defense) if (!no_air_defense)
air_defense(x, y, plane_owner, bomb_list, esc_list); air_defense(x, y, plane_owner, bomb_list, esc_list);
if (sect.sct_own == 0 || sect.sct_own == plane_owner)
continue;
if (unfriendly[sect.sct_own]) { if (unfriendly[sect.sct_own]) {
if (!gotilist[sect.sct_own]) { if (!gotilist[sect.sct_own]) {
getilist(&ilist[sect.sct_own], sect.sct_own); getilist(&ilist[sect.sct_own], sect.sct_own);
@ -232,6 +222,13 @@ ac_encounter(struct emp_qelem *bomb_list, struct emp_qelem *esc_list,
} }
} }
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 */ /* Let's report all of the overflights even if aborted */
for (cn = 1; cn < MAXNOC; cn++) { for (cn = 1; cn < MAXNOC; cn++) {
if (plane_owner == cn) if (plane_owner == cn)