Use relations_with() in getilists()

No functional change, even though this changes rel[intruder] from
NEUTRAL to ALLIED.  Uses of rel[]:

* getilists() and ac_encounter() compare rel[cn] to HOSTILE.  No
  change, because NEUTRAL and ALLIED are both greater than HOSTILE.

* ac_encounter() compares rel[cn] to ALLIED, but only when cn !=
  plane_owner.  Because it passes plane_owner as argument for
  getilists() parameter intruder, rel[cn] can't refer to the changed
  element of rel[] here.

The new value of rel[plane_owner] permits simplifying cn ==
plane_owner || rel[cn] == ALLIED to just rel[cn] == ALLIED.
This commit is contained in:
Markus Armbruster 2011-01-30 17:37:36 +01:00
parent 58cc82589e
commit 5245cde582

View file

@ -172,7 +172,7 @@ ac_encounter(struct emp_qelem *bomb_list, struct emp_qelem *esc_list,
if (!evaded) { if (!evaded) {
overfly[sect.sct_own]++; overfly[sect.sct_own]++;
for (cn = 1; cn < MAXNOC; cn++) { for (cn = 1; cn < MAXNOC; cn++) {
if (cn == plane_owner || rel[cn] == ALLIED) if (rel[cn] == ALLIED)
continue; continue;
if (cn != sect.sct_own && !gotships[cn] && !gotlands[cn]) if (cn != sect.sct_own && !gotships[cn] && !gotlands[cn])
continue; continue;
@ -220,8 +220,6 @@ ac_encounter(struct emp_qelem *bomb_list, struct emp_qelem *esc_list,
/* 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)
continue;
if (overfly[cn] > 0 && rel[cn] != ALLIED) if (overfly[cn] > 0 && rel[cn] != ALLIED)
nreport(plane_owner, N_OVFLY_SECT, cn, overfly[cn]); nreport(plane_owner, N_OVFLY_SECT, cn, overfly[cn]);
} }
@ -762,7 +760,7 @@ getilists(struct emp_qelem *list, unsigned char *rel, natid intruder)
rel[0] = NEUTRAL; rel[0] = NEUTRAL;
for (cn = 1; cn < MAXNOC; cn++) { for (cn = 1; cn < MAXNOC; cn++) {
rel[cn] = getrel(getnatp(cn), intruder); rel[cn] = relations_with(cn, intruder);
emp_initque(&list[cn]); emp_initque(&list[cn]);
} }