From b54454fbc487dc3b81dad4d82ac79c22c3cd7752 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 24 Sep 2008 07:21:19 -0400 Subject: [PATCH] Fix air defense and flak over sectors allied to the planes Planes were not subject to air defense and flak over allied sectors. Air defense was broken when Empire 2 changed it to happen after spotting. Flak was broken when 4.2.8 made ships and land units fire flak in every sector, not just the target sector. Although an allied sector doesn't fire flak, it may still contain hostile ships and land units. Also makes use of ilist[] more robust: before, if relations somehow went sour after unfriendly[] was initialized, the sector intercept would run with an invalid interceptor list, and crash. --- src/lib/subs/aircombat.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/lib/subs/aircombat.c b/src/lib/subs/aircombat.c index 683271279..8bb544bb4 100644 --- a/src/lib/subs/aircombat.c +++ b/src/lib/subs/aircombat.c @@ -91,7 +91,7 @@ ac_encounter(struct emp_qelem *bomb_list, struct emp_qelem *esc_list, 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; @@ -140,7 +140,6 @@ ac_encounter(struct emp_qelem *bomb_list, struct emp_qelem *esc_list, x = xnorm(x + diroff[val][0]); y = ynorm(y + diroff[val][1]); getsect(x, y, §); - over = getnatp(sect.sct_own); if (mission_flags & PM_R) { flags = plane_caps(bomb_list); @@ -196,14 +195,13 @@ ac_encounter(struct emp_qelem *bomb_list, struct emp_qelem *esc_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 (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) { overfly[sect.sct_own]++; PR(sect.sct_own, "%s planes spotted over %s\n", cname(plane_owner), xyas(x, y, sect.sct_own)); @@ -229,14 +227,14 @@ ac_encounter(struct emp_qelem *bomb_list, struct emp_qelem *esc_list, if (sect.sct_own == 0 || sect.sct_own == plane_owner) continue; - if (unfriendly[sect.sct_own] && !gotilist[sect.sct_own]) { - getilist(&ilist[sect.sct_own], sect.sct_own); - gotilist[sect.sct_own]++; + 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 (rel > HOSTILE) - continue; - ac_intercept(bomb_list, esc_list, &ilist[sect.sct_own], - sect.sct_own, x, y); } /* Let's report all of the overflights even if aborted */ -- 2.43.0