extern int off_support(coord, coord, natid, natid);
extern int def_support(coord, coord, natid, natid);
extern int oprange(struct empobj *);
+extern int in_oparea(struct empobj *, coord, coord);
extern int cando(int, int);
extern void show_mission(int, struct nstr_item *);
extern int air_defense(coord, coord, natid, struct emp_qelem *,
struct genlist *glp;
struct empobj *gp;
union empobj_storage item;
- int dist;
- int radius;
int relat;
struct sctstr sect;
} else if (relat > HOSTILE)
continue;
- dist = mapdist(x, y, gp->opx, gp->opy);
- if (dist > gp->radius)
- continue;
-
- /* Ok, it is within the operations range. */
- /* Now check from where the object actually is */
- dist = mapdist(x, y, gp->x, gp->y);
- radius = oprange(gp);
- if (dist > radius)
+ if (!in_oparea(gp, x, y))
continue;
- /* Ok, the object can get to where the x,y is */
if (opt_SLOW_WAR) {
if (mission != MI_AIR_DEFENSE) {
return -1;
}
+/*
+ * Does GP's mission op area cover X,Y?
+ */
+int
+in_oparea(struct empobj *gp, coord x, coord y)
+{
+ return mapdist(x, y, gp->opx, gp->opy) <= gp->radius
+ && mapdist(x, y, gp->x, gp->y) <= oprange(gp);
+}
+
/*
* Remove all planes who cannot go on
* the mission from the plane list.