]> git.pond.sub.org Git - empserver/commitdiff
Don't reduce mission op area when range shrinks
authorMarkus Armbruster <armbru@pond.sub.org>
Fri, 21 Nov 2008 13:05:24 +0000 (08:05 -0500)
committerMarkus Armbruster <armbru@pond.sub.org>
Wed, 17 Dec 2008 16:36:49 +0000 (11:36 -0500)
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).

include/prototypes.h
src/lib/commands/miss.c
src/lib/subs/mission.c

index a8036ba57e84cb6df5a1dddb15d8fcb1e905cafc..6f971530165e1732f648316edbb0f56e2f3dd0ce 100644 (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 *,
index d251d9fc4750459ed4d1b36da765732b9f600df3..5811b68c670685fea787de7630c82f3b0d797fcd 100644 (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)
index c6644fa80be12c5dfbc78b44f5b823ede3c5b542..dd45fea642607ca9dac7336b21d0e9e5c0c0adb7 100644 (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;
 }
 
 /*