Don't reduce mission op area when range shrinks

The mission command limits op area radius to the possible range.
That's okay, as it doesn't actually restrict possible op areas.  When
the mission is executed, it was limited again.  Don't do that; remove
the limiting code from build_mission_list_type() and show_mission().

The removed limiting had no effect, except when the range shrunk.
Then limiting reduced the op area more than necessary.  For instance,
consider an object O with initial range 3 on a mission around M with
range 3:

    - - - y - - -
     - - z y - -
    - - z x y - -
     - O x x M -
    - - z x y - -
     - - z y - -
    - - - y - - -

Initially, all sectors not marked - are in range and in the op area.
If the range drops to two, sectors marked O, x and z are still in
range of O.  But only the x are still in range of M.  The O and z got
excluded.

Range can currently shrink when plane range is reduced (range
command), or a ship, plane or land unit somehow loses tech (deity
intervention).
This commit is contained in:
Markus Armbruster 2008-11-21 08:05:24 -05:00
parent 8d0e1af5b7
commit 439fa2eadc
3 changed files with 18 additions and 36 deletions

View file

@ -484,7 +484,7 @@ extern int ground_interdict(coord, coord, natid, char *);
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 *, int *);
extern int oprange(struct empobj *);
extern int cando(int, int);
extern void show_mission(int, struct nstr_item *);
extern int air_defense(coord, coord, natid, struct emp_qelem *,

View file

@ -207,11 +207,13 @@ mission(void)
radius = 999;
if ((mission == MI_INTERDICT || mission == MI_SUPPORT ||
mission == MI_OSUPPORT || mission == MI_DSUPPORT ||
mission == MI_AIR_DEFENSE) &&
(oprange(gp, &radius) < dist)) {
pr("%s: out of range! (range %d)\n",
obj_nameof(gp), oprange(gp, &radius));
continue;
mission == MI_AIR_DEFENSE)) {
radius = oprange(gp);
if (radius < dist) {
pr("%s: out of range! (range %d)\n",
obj_nameof(gp), radius);
continue;
}
}
if (radius > desired_radius)

View file

@ -321,19 +321,13 @@ build_mission_list_type(struct genlist *mi, coord x, coord y, int mission,
continue;
dist = mapdist(x, y, gp->opx, gp->opy);
radius = gp->radius;
if (mission != MI_RESERVE) /* XXX */
oprange(gp, &radius);
if (dist > radius)
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 = 999;
oprange(gp, &radius);
radius = oprange(gp);
if (dist > radius)
continue;
/* Ok, the object can get to where the x,y is */
@ -788,10 +782,8 @@ show_mission(int type, struct nstr_item *np)
case MI_AIR_DEFENSE:
case MI_DSUPPORT:
case MI_OSUPPORT:
radius = gp->radius;
oprange(gp, &radius);
prxy(" %3d,%-3d", gp->opx, gp->opy, player->cnum);
pr(" %4d", radius);
pr(" %4d", gp->radius);
break;
case MI_RESERVE:
radius = item.land.lnd_rad_max;
@ -822,33 +814,21 @@ show_mission(int type, struct nstr_item *np)
}
int
oprange(struct empobj *gp, int *radius)
oprange(struct empobj *gp)
{
int range;
switch (gp->ef_type) {
case EF_SHIP:
range = ldround(shp_fire_range((struct shpstr *)gp), 1);
break;
return ldround(shp_fire_range((struct shpstr *)gp), 1);
case EF_LAND:
range = ldround(lnd_fire_range((struct lndstr *)gp), 1);
break;
return ldround(lnd_fire_range((struct lndstr *)gp), 1);
case EF_PLANE:
/* missiles go one way, so we can use all the range */
if (plchr[(int)gp->type].pl_flags & P_M)
range = ((struct plnstr *)gp)->pln_range;
else
range = ((struct plnstr *)gp)->pln_range / 2;
break;
default:
CANT_REACH();
range = -1;
return ((struct plnstr *)gp)->pln_range;
return ((struct plnstr *)gp)->pln_range / 2;
}
if (*radius > range)
*radius = range;
return range;
CANT_REACH();
return -1;
}
/*