]> git.pond.sub.org Git - empserver/commitdiff
(mission, build_mission_list_type, show_mission, oprange): Remove the
authorRon Koenderink <rkoenderink@yahoo.ca>
Sun, 9 Jul 2006 10:57:24 +0000 (10:57 +0000)
committerRon Koenderink <rkoenderink@yahoo.ca>
Sun, 9 Jul 2006 10:57:24 +0000 (10:57 +0000)
type parameter as it can be determined from the empobj parameter.

(oprange): Remove getting the unit information again as it is contained
in the empobj parameter passed in.

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

index d2c856c958b9361b2620437b5b2097b38ac6dc39..509ec4956772798d53b7c20b0b9c287f6c447f7d 100644 (file)
@@ -495,7 +495,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, int *);
+extern int oprange(struct empobj *, int *);
 extern int cando(int, int);
 extern void show_mission(int, struct nstr_item *);
 extern int air_defense(coord, coord, natid, struct emp_qelem *,
index 6d6d70fb05f64921a493fe0b113570a13f7d0d93..8ea878a3d3a9ed70e6e9403e7b18ae275bf88606 100644 (file)
@@ -228,9 +228,9 @@ mission(void)
        if ((mission == MI_INTERDICT || mission == MI_SUPPORT ||
             mission == MI_OSUPPORT || mission == MI_DSUPPORT ||
             mission == MI_AIR_DEFENSE) &&
-           (oprange(gp, type, &radius) < dist)) {
+           (oprange(gp, &radius) < dist)) {
            pr("%s: out of range! (range %d)\n",
-              nameofitem(gp, type), oprange(gp, type, &radius));
+              nameofitem(gp, type), oprange(gp, &radius));
            continue;
        }
 
index 5776d5a30f7102b866c64ccdb0ef5fc9e1aa6010..039a26ee9761d0bbc2ab7562a3d364c56d2641f2 100644 (file)
@@ -326,7 +326,7 @@ build_mission_list_type(struct genlist *mi, coord x, coord y, int mission,
 
        radius = gp->radius;
        if (mission != MI_RESERVE)      /* XXX */
-           oprange(gp, type, &radius);
+           oprange(gp, &radius);
 
        if (dist > radius)
            continue;
@@ -335,7 +335,7 @@ build_mission_list_type(struct genlist *mi, coord x, coord y, int mission,
        /* Now check from where the object actually is */
        dist = mapdist(x, y, gp->x, gp->y);
        radius = 999;
-       oprange(gp, type, &radius);
+       oprange(gp, &radius);
        if (dist > radius)
            continue;
        /* Ok, the object can get to where the x,y is */
@@ -864,7 +864,7 @@ show_mission(int type, struct nstr_item *np)
            gp->mission == MI_OSUPPORT ||
            gp->mission == MI_DSUPPORT || gp->mission == MI_AIR_DEFENSE) {
            radius = 999;
-           oprange(gp, type, &radius);
+           oprange(gp, &radius);
            prxy(" %3d,%-3d", gp->opx, gp->opy, player->cnum);
            if (radius < gp->radius)
                pr("  %4d", radius);
@@ -897,29 +897,25 @@ show_mission(int type, struct nstr_item *np)
 }
 
 int
-oprange(struct empobj *gp, int type, int *radius)
+oprange(struct empobj *gp, int *radius)
 {
     int range;
-    struct shpstr ship;
-    struct lndstr land;
-    struct plnstr plane;
 
-    switch (type) {
+    switch (gp->ef_type) {
     case EF_SHIP:
-       getship(gp->uid, &ship);
-       range = ldround(effrange(ship.shp_frnge, ship.shp_tech), 1);
+       range = ldround(effrange(((struct shpstr *)gp)->shp_frnge,
+                                ((struct shpstr *)gp)->shp_tech), 1);
        break;
     case EF_LAND:
-       getland(gp->uid, &land);
-       range = ldround(effrange(land.lnd_frg, land.lnd_tech), 1);
+       range = ldround(effrange(((struct lndstr *)gp)->lnd_frg,
+                                ((struct lndstr *)gp)->lnd_tech), 1);
        break;
     case EF_PLANE:
-       getplane(gp->uid, &plane);
        /* missiles go one way, so we can use all the range */
-       if (plchr[(int)plane.pln_type].pl_flags & P_M)
-           range = plane.pln_range;
+       if (plchr[(int)gp->type].pl_flags & P_M)
+           range = ((struct plnstr *)gp)->pln_range;
        else
-           range = plane.pln_range / 2;
+           range = ((struct plnstr *)gp)->pln_range / 2;
        break;
     default:
        CANT_HAPPEN("bad TYPE");