From a9b2d9c7f3782626f1845fde9e44c311ef5a6f12 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sat, 22 Nov 2008 14:52:20 -0500 Subject: [PATCH] Make escort mission obey op-area Before, the escort mission didn't support an op-area, and planes on escort mission escorted anywhere. Change mission() to define the op-area for escort missions as well. Show it in mission() and show_mission(). Check it in find_escorts(). --- info/mission.t | 3 ++- src/lib/commands/miss.c | 8 ++++---- src/lib/subs/mission.c | 12 ++---------- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/info/mission.t b/info/mission.t index b7f67064..f299f442 100644 --- a/info/mission.t +++ b/info/mission.t @@ -222,7 +222,8 @@ Only planes with the 'tactical' ability can fly support missions. ESCORT MISSIONS (planes only) .s1 When given an escort mission, an escort or intercept capable plane will attempt -to escort any plane flying a support or interdict mission from the same airport. +to escort any plane flying a support or interdict mission from the +same airport into its op-area. If even 1 plane flies a support or interdiction mission from an airport, all planes on escort duty at that airport will attempt to escort. Planes with escort duty will NOT attempt to escort planes taking off from other airports, so it diff --git a/src/lib/commands/miss.c b/src/lib/commands/miss.c index e59f23f7..d2c7e7a2 100644 --- a/src/lib/commands/miss.c +++ b/src/lib/commands/miss.c @@ -148,7 +148,7 @@ mission(void) return RET_FAIL; } - if (mission && mission != MI_ESCORT) { + if (mission) { if ((p = getstarg(player->argp[4], "operations point? ", buf)) == 0 || *p == 0) return RET_SYN; @@ -207,7 +207,7 @@ mission(void) radius = 999; if (mission == MI_INTERDICT || mission == MI_SUPPORT || mission == MI_OSUPPORT || mission == MI_DSUPPORT || - mission == MI_RESERVE || + mission == MI_RESERVE || mission == MI_ESCORT || mission == MI_AIR_DEFENSE) { radius = oprange(gp, mission); if (radius < dist) { @@ -285,7 +285,7 @@ mission(void) if (mission == MI_INTERDICT || mission == MI_SUPPORT || mission == MI_OSUPPORT || mission == MI_DSUPPORT || - mission == MI_RESERVE || + mission == MI_RESERVE || mission == MI_ESCORT || mission == MI_AIR_DEFENSE) gp->radius = radius; else @@ -293,7 +293,7 @@ mission(void) if (mission == MI_SUPPORT || mission == MI_OSUPPORT || mission == MI_DSUPPORT || mission == MI_INTERDICT || - mission == MI_RESERVE || + mission == MI_RESERVE || mission == MI_ESCORT || mission == MI_AIR_DEFENSE) { pr("%s on %s mission, centered on %s, radius %d\n", obj_nameof(gp), mission_name(mission), diff --git a/src/lib/subs/mission.c b/src/lib/subs/mission.c index dbad24fb..c4243b4f 100644 --- a/src/lib/subs/mission.c +++ b/src/lib/subs/mission.c @@ -355,20 +355,15 @@ find_escorts(coord x, coord y, natid cn, struct emp_qelem *escorts) struct nstr_item ni; struct plist *plp; struct plnstr plane; - int dist; snxtitem_all(&ni, EF_PLANE); while (nxtitem(&ni, &plane)) { if (plane.pln_own != cn) continue; - if (plane.pln_mission != MI_ESCORT) continue; - - dist = mapdist(x, y, plane.pln_x, plane.pln_y); - if (dist > plane.pln_range / 2) + if (!in_oparea((struct empobj *)&plane, x, y)) continue; - plp = malloc(sizeof(struct plist)); memset(plp, 0, sizeof(struct plist)); plp->pcp = &plchr[(int)plane.pln_type]; @@ -768,16 +763,13 @@ show_mission(int type, struct nstr_item *np) case MI_INTERDICT: case MI_SUPPORT: case MI_RESERVE: + case MI_ESCORT: case MI_AIR_DEFENSE: case MI_DSUPPORT: case MI_OSUPPORT: prxy(" %3d,%-3d", gp->opx, gp->opy, player->cnum); pr(" %4d", gp->radius); break; - case MI_ESCORT: - pr(" "); - pr(" %4d", item.plane.pln_range / 2); - break; default: CANT_REACH(); /* fall through */