Refactor interception over ships and land units
ac_encounter() lets all owners of ships and land units in the target sector intercept, but not more than once. Move the interception code behind reporting of both ships and land units. Before, it was duplicated for ships and land units. Land units didn't get reported when no bombers got through interception triggered by ships.
This commit is contained in:
parent
2030decb99
commit
99cf705530
1 changed files with 4 additions and 34 deletions
|
@ -97,7 +97,6 @@ ac_encounter(struct emp_qelem *bomb_list, struct emp_qelem *esc_list,
|
||||||
int evaded;
|
int evaded;
|
||||||
struct shiplist *head = NULL;
|
struct shiplist *head = NULL;
|
||||||
int changed = 0;
|
int changed = 0;
|
||||||
int intown = 0; /* Last owner to intercept */
|
|
||||||
/* We want to only intercept once per sector per owner. So, if we overfly
|
/* We want to only intercept once per sector per owner. So, if we overfly
|
||||||
a sector, and then overfly some land units or ships, we don't want to
|
a sector, and then overfly some land units or ships, we don't want to
|
||||||
potentially intercept 3 times. */
|
potentially intercept 3 times. */
|
||||||
|
@ -253,7 +252,6 @@ ac_encounter(struct emp_qelem *bomb_list, struct emp_qelem *esc_list,
|
||||||
continue;
|
continue;
|
||||||
ac_intercept(bomb_list, esc_list, &ilist[sect.sct_own],
|
ac_intercept(bomb_list, esc_list, &ilist[sect.sct_own],
|
||||||
sect.sct_own, x, y);
|
sect.sct_own, x, y);
|
||||||
intown = sect.sct_own;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Let's report all of the overflights even if aborted */
|
/* Let's report all of the overflights even if aborted */
|
||||||
|
@ -292,55 +290,27 @@ ac_encounter(struct emp_qelem *bomb_list, struct emp_qelem *esc_list,
|
||||||
for (cn = 1; cn < MAXNOC && !QEMPTY(bomb_list); cn++) {
|
for (cn = 1; cn < MAXNOC && !QEMPTY(bomb_list); cn++) {
|
||||||
if (plane_owner == cn)
|
if (plane_owner == cn)
|
||||||
continue;
|
continue;
|
||||||
intown = -1;
|
|
||||||
/* Are there ships owned by this country? */
|
|
||||||
if (nats[cn] != 0) {
|
if (nats[cn] != 0) {
|
||||||
/* Yes. */
|
|
||||||
PR(plane_owner, "Flying over %s ships in %s\n",
|
PR(plane_owner, "Flying over %s ships in %s\n",
|
||||||
cname(cn), xyas(x, y, plane_owner));
|
cname(cn), xyas(x, y, plane_owner));
|
||||||
PR(cn, "%s planes spotted over ships in %s\n",
|
PR(cn, "%s planes spotted over ships in %s\n",
|
||||||
cname(plane_owner), xyas(x, y, cn));
|
cname(plane_owner), xyas(x, y, cn));
|
||||||
if (opt_HIDDEN)
|
|
||||||
setcont(cn, plane_owner, FOUND_FLY);
|
|
||||||
if (unfriendly[cn]) {
|
|
||||||
/* They are unfriendly too */
|
|
||||||
if (!gotilist[cn]) {
|
|
||||||
getilist(&ilist[cn], cn);
|
|
||||||
gotilist[cn]++;
|
|
||||||
}
|
}
|
||||||
/* This makes going for ships in harbors tough */
|
|
||||||
if (!evaded) {
|
|
||||||
/* We already fired flak up above. Now we intercept again if we haven't already */
|
|
||||||
/* Flag that we intercepted */
|
|
||||||
intown = 1;
|
|
||||||
/* And now intercept again */
|
|
||||||
ac_intercept(bomb_list, esc_list, &ilist[cn],
|
|
||||||
cn, x, y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Are there units owned by this country? */
|
|
||||||
if (lnats[cn] != 0) {
|
if (lnats[cn] != 0) {
|
||||||
/* Yes. */
|
|
||||||
PR(plane_owner, "Flying over %s land units in %s\n",
|
PR(plane_owner, "Flying over %s land units in %s\n",
|
||||||
cname(cn), xyas(x, y, plane_owner));
|
cname(cn), xyas(x, y, plane_owner));
|
||||||
PR(cn, "%s planes spotted over land units in %s\n",
|
PR(cn, "%s planes spotted over land units in %s\n",
|
||||||
cname(plane_owner), xyas(x, y, cn));
|
cname(plane_owner), xyas(x, y, cn));
|
||||||
|
}
|
||||||
|
if (nats[cn] || lnats[cn]) {
|
||||||
if (opt_HIDDEN)
|
if (opt_HIDDEN)
|
||||||
setcont(cn, plane_owner, FOUND_FLY);
|
setcont(cn, plane_owner, FOUND_FLY);
|
||||||
if (unfriendly[cn]) {
|
if (unfriendly[cn] && !evaded) {
|
||||||
/* They are unfriendly too */
|
|
||||||
if (!gotilist[cn]) {
|
if (!gotilist[cn]) {
|
||||||
getilist(&ilist[cn], cn);
|
getilist(&ilist[cn], cn);
|
||||||
gotilist[cn]++;
|
gotilist[cn]++;
|
||||||
}
|
}
|
||||||
if (!evaded) {
|
ac_intercept(bomb_list, esc_list, &ilist[cn], cn, x, y);
|
||||||
if (intown == -1) {
|
|
||||||
/* We haven't intercepted yet, so intercept */
|
|
||||||
ac_intercept(bomb_list, esc_list, &ilist[cn],
|
|
||||||
cn, x, y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue