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:
parent
da363d621e
commit
b5cb3cb37b
1 changed files with 39 additions and 42 deletions
|
@ -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, §);
|
getsect(x, y, §);
|
||||||
|
|
||||||
if (mission_flags & PM_R) {
|
if (mission_flags & PM_R) {
|
||||||
|
@ -192,44 +187,46 @@ 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
|
||||||
|
&& getrel(getnatp(sect.sct_own), plane_owner) != ALLIED) {
|
||||||
if (sect.sct_own != 0 && sect.sct_own != plane_owner
|
overfly[sect.sct_own]++;
|
||||||
&& getrel(getnatp(sect.sct_own), plane_owner) != ALLIED) {
|
PR(sect.sct_own, "%s planes spotted over %s\n",
|
||||||
overfly[sect.sct_own]++;
|
cname(plane_owner), xyas(x, y, sect.sct_own));
|
||||||
PR(sect.sct_own, "%s planes spotted over %s\n",
|
if (opt_HIDDEN)
|
||||||
cname(plane_owner), xyas(x, y, sect.sct_own));
|
setcont(sect.sct_own, plane_owner, FOUND_FLY);
|
||||||
if (opt_HIDDEN)
|
}
|
||||||
setcont(sect.sct_own, plane_owner, FOUND_FLY);
|
|
||||||
}
|
/* Fire flak */
|
||||||
|
if (unfriendly[sect.sct_own])
|
||||||
/* Fire flak */
|
ac_doflak(bomb_list, §);
|
||||||
if (unfriendly[sect.sct_own])
|
/* If bombers left, fire flak from units and ships */
|
||||||
ac_doflak(bomb_list, §);
|
if (!QEMPTY(bomb_list))
|
||||||
/* If bombers left, fire flak from units and ships */
|
ac_landflak(bomb_list, x, y);
|
||||||
if (!QEMPTY(bomb_list))
|
if (!QEMPTY(bomb_list))
|
||||||
ac_landflak(bomb_list, x, y);
|
ac_shipflak(bomb_list, x, y);
|
||||||
if (!QEMPTY(bomb_list))
|
/* mission planes aborted due to flak -- don't send escorts */
|
||||||
ac_shipflak(bomb_list, x, y);
|
if (QEMPTY(bomb_list))
|
||||||
/* mission planes aborted due to flak -- don't send escorts */
|
break;
|
||||||
if (QEMPTY(bomb_list))
|
|
||||||
break;
|
if (!no_air_defense)
|
||||||
|
air_defense(x, y, plane_owner, bomb_list, esc_list);
|
||||||
if (!no_air_defense)
|
|
||||||
air_defense(x, y, plane_owner, bomb_list, esc_list);
|
if (unfriendly[sect.sct_own]) {
|
||||||
|
if (!gotilist[sect.sct_own]) {
|
||||||
if (sect.sct_own == 0 || sect.sct_own == plane_owner)
|
getilist(&ilist[sect.sct_own], sect.sct_own);
|
||||||
continue;
|
gotilist[sect.sct_own]++;
|
||||||
|
}
|
||||||
if (unfriendly[sect.sct_own]) {
|
ac_intercept(bomb_list, esc_list, &ilist[sect.sct_own],
|
||||||
if (!gotilist[sect.sct_own]) {
|
sect.sct_own, x, y);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue