From: Ron Koenderink Date: Sun, 9 Jul 2006 10:57:24 +0000 (+0000) Subject: (mission, build_mission_list_type, show_mission, oprange): Remove the X-Git-Tag: v4.3.7~51 X-Git-Url: http://git.pond.sub.org/?p=empserver;a=commitdiff_plain;h=5ea9060132a8b51c2c702f708a6bbbf02fce17d4 (mission, build_mission_list_type, show_mission, oprange): Remove the 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. --- diff --git a/include/prototypes.h b/include/prototypes.h index d2c856c95..509ec4956 100644 --- a/include/prototypes.h +++ b/include/prototypes.h @@ -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 *, diff --git a/src/lib/commands/miss.c b/src/lib/commands/miss.c index 6d6d70fb0..8ea878a3d 100644 --- a/src/lib/commands/miss.c +++ b/src/lib/commands/miss.c @@ -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; } diff --git a/src/lib/subs/mission.c b/src/lib/subs/mission.c index 5776d5a30..039a26ee9 100644 --- a/src/lib/subs/mission.c +++ b/src/lib/subs/mission.c @@ -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");