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:
parent
8d0e1af5b7
commit
439fa2eadc
3 changed files with 18 additions and 36 deletions
|
@ -484,7 +484,7 @@ extern int ground_interdict(coord, coord, natid, char *);
|
||||||
extern int unit_interdict(coord, coord, natid, char *, int, int);
|
extern int unit_interdict(coord, coord, natid, char *, int, int);
|
||||||
extern int off_support(coord, coord, natid, natid);
|
extern int off_support(coord, coord, natid, natid);
|
||||||
extern int def_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 int cando(int, int);
|
||||||
extern void show_mission(int, struct nstr_item *);
|
extern void show_mission(int, struct nstr_item *);
|
||||||
extern int air_defense(coord, coord, natid, struct emp_qelem *,
|
extern int air_defense(coord, coord, natid, struct emp_qelem *,
|
||||||
|
|
|
@ -207,12 +207,14 @@ mission(void)
|
||||||
radius = 999;
|
radius = 999;
|
||||||
if ((mission == MI_INTERDICT || mission == MI_SUPPORT ||
|
if ((mission == MI_INTERDICT || mission == MI_SUPPORT ||
|
||||||
mission == MI_OSUPPORT || mission == MI_DSUPPORT ||
|
mission == MI_OSUPPORT || mission == MI_DSUPPORT ||
|
||||||
mission == MI_AIR_DEFENSE) &&
|
mission == MI_AIR_DEFENSE)) {
|
||||||
(oprange(gp, &radius) < dist)) {
|
radius = oprange(gp);
|
||||||
|
if (radius < dist) {
|
||||||
pr("%s: out of range! (range %d)\n",
|
pr("%s: out of range! (range %d)\n",
|
||||||
obj_nameof(gp), oprange(gp, &radius));
|
obj_nameof(gp), radius);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (radius > desired_radius)
|
if (radius > desired_radius)
|
||||||
radius = desired_radius;
|
radius = desired_radius;
|
||||||
|
|
|
@ -321,19 +321,13 @@ build_mission_list_type(struct genlist *mi, coord x, coord y, int mission,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
dist = mapdist(x, y, gp->opx, gp->opy);
|
dist = mapdist(x, y, gp->opx, gp->opy);
|
||||||
|
if (dist > gp->radius)
|
||||||
radius = gp->radius;
|
|
||||||
if (mission != MI_RESERVE) /* XXX */
|
|
||||||
oprange(gp, &radius);
|
|
||||||
|
|
||||||
if (dist > radius)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Ok, it is within the operations range. */
|
/* Ok, it is within the operations range. */
|
||||||
/* Now check from where the object actually is */
|
/* Now check from where the object actually is */
|
||||||
dist = mapdist(x, y, gp->x, gp->y);
|
dist = mapdist(x, y, gp->x, gp->y);
|
||||||
radius = 999;
|
radius = oprange(gp);
|
||||||
oprange(gp, &radius);
|
|
||||||
if (dist > radius)
|
if (dist > radius)
|
||||||
continue;
|
continue;
|
||||||
/* Ok, the object can get to where the x,y is */
|
/* 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_AIR_DEFENSE:
|
||||||
case MI_DSUPPORT:
|
case MI_DSUPPORT:
|
||||||
case MI_OSUPPORT:
|
case MI_OSUPPORT:
|
||||||
radius = gp->radius;
|
|
||||||
oprange(gp, &radius);
|
|
||||||
prxy(" %3d,%-3d", gp->opx, gp->opy, player->cnum);
|
prxy(" %3d,%-3d", gp->opx, gp->opy, player->cnum);
|
||||||
pr(" %4d", radius);
|
pr(" %4d", gp->radius);
|
||||||
break;
|
break;
|
||||||
case MI_RESERVE:
|
case MI_RESERVE:
|
||||||
radius = item.land.lnd_rad_max;
|
radius = item.land.lnd_rad_max;
|
||||||
|
@ -822,33 +814,21 @@ show_mission(int type, struct nstr_item *np)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
oprange(struct empobj *gp, int *radius)
|
oprange(struct empobj *gp)
|
||||||
{
|
{
|
||||||
int range;
|
|
||||||
|
|
||||||
switch (gp->ef_type) {
|
switch (gp->ef_type) {
|
||||||
case EF_SHIP:
|
case EF_SHIP:
|
||||||
range = ldround(shp_fire_range((struct shpstr *)gp), 1);
|
return ldround(shp_fire_range((struct shpstr *)gp), 1);
|
||||||
break;
|
|
||||||
case EF_LAND:
|
case EF_LAND:
|
||||||
range = ldround(lnd_fire_range((struct lndstr *)gp), 1);
|
return ldround(lnd_fire_range((struct lndstr *)gp), 1);
|
||||||
break;
|
|
||||||
case EF_PLANE:
|
case EF_PLANE:
|
||||||
/* missiles go one way, so we can use all the range */
|
/* missiles go one way, so we can use all the range */
|
||||||
if (plchr[(int)gp->type].pl_flags & P_M)
|
if (plchr[(int)gp->type].pl_flags & P_M)
|
||||||
range = ((struct plnstr *)gp)->pln_range;
|
return ((struct plnstr *)gp)->pln_range;
|
||||||
else
|
return ((struct plnstr *)gp)->pln_range / 2;
|
||||||
range = ((struct plnstr *)gp)->pln_range / 2;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
CANT_REACH();
|
|
||||||
range = -1;
|
|
||||||
}
|
}
|
||||||
|
CANT_REACH();
|
||||||
if (*radius > range)
|
return -1;
|
||||||
*radius = range;
|
|
||||||
|
|
||||||
return range;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue