New in_oparea(), factored out of build_mission_list_type()
This commit is contained in:
parent
439fa2eadc
commit
40d8357746
2 changed files with 12 additions and 12 deletions
|
@ -485,6 +485,7 @@ extern int unit_interdict(coord, coord, natid, char *, int, int);
|
|||
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 *,
|
||||
|
|
|
@ -289,8 +289,6 @@ build_mission_list_type(struct genlist *mi, coord x, coord y, int mission,
|
|||
struct genlist *glp;
|
||||
struct empobj *gp;
|
||||
union empobj_storage item;
|
||||
int dist;
|
||||
int radius;
|
||||
int relat;
|
||||
struct sctstr sect;
|
||||
|
||||
|
@ -320,18 +318,9 @@ build_mission_list_type(struct genlist *mi, coord x, coord y, int mission,
|
|||
} else if (relat > HOSTILE)
|
||||
continue;
|
||||
|
||||
dist = mapdist(x, y, gp->opx, gp->opy);
|
||||
if (dist > gp->radius)
|
||||
if (!in_oparea(gp, x, y))
|
||||
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)
|
||||
continue;
|
||||
/* Ok, the object can get to where the x,y is */
|
||||
|
||||
if (opt_SLOW_WAR) {
|
||||
if (mission != MI_AIR_DEFENSE) {
|
||||
getsect(x, y, §);
|
||||
|
@ -831,6 +820,16 @@ oprange(struct empobj *gp)
|
|||
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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue