From: Markus Armbruster Date: Sun, 14 Dec 2008 19:05:40 +0000 (-0500) Subject: Remove oprange()'s mission parameter X-Git-Tag: v4.3.20~102 X-Git-Url: http://git.pond.sub.org/?p=empserver;a=commitdiff_plain;h=d5f371cc1db4a9fbe1fc24277f7e3adbec67b168 Remove oprange()'s mission parameter Use the current mission instead. Make mission() set it before calling oprange(), and clean up somewhat. --- diff --git a/include/prototypes.h b/include/prototypes.h index cef69112e..82db0acdf 100644 --- a/include/prototypes.h +++ b/include/prototypes.h @@ -483,7 +483,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 in_oparea(struct empobj *, coord, coord); extern int cando(int, int); 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 c8110e16a..08d03bdb7 100644 --- a/src/lib/commands/miss.c +++ b/src/lib/commands/miss.c @@ -54,7 +54,7 @@ mission(void) int type; int mission; coord x, y; - int desired_radius, radius; + int radius, range; union empobj_storage item; struct empobj *gp; int num = 0, mobmax, mobused; @@ -158,14 +158,13 @@ mission(void) } if (player->argp[5] != NULL) { - desired_radius = atoi(player->argp[5]); - if (desired_radius < 0) { - pr("Radius must be greater than zero!\n"); + radius = atoi(player->argp[5]); + if (radius < 0) { + pr("Radius can't be negative!\n"); return RET_FAIL; } - } else { - desired_radius = 9999; - } + } else + radius = 9999; if ((mobmax = get_empobj_mob_max(type)) == -1) return RET_FAIL; @@ -255,27 +254,23 @@ mission(void) y = gp->y; } - radius = oprange(gp, mission); - if (radius < mapdist(gp->x, gp->y, x, y)) { + gp->mobil -= mobused; + gp->mission = mission; + range = oprange(gp); + if (range < mapdist(gp->x, gp->y, x, y)) { pr("%s: out of range! (range %d)\n", - obj_nameof(gp), radius); + obj_nameof(gp), range); continue; } - - if (radius > desired_radius) - radius = desired_radius; - num++; /* good one.. go with it */ - - pr("%s on %s mission, centered on %s, radius %d\n", - obj_nameof(gp), mission_name(mission), - xyas(x, y, player->cnum), radius); - gp->mobil -= mobused; - - gp->mission = mission; gp->opx = x; gp->opy = y; - gp->radius = radius; + gp->radius = MIN(range, radius); put_empobj(type, gp->uid, gp); + num++; + + pr("%s on %s mission, centered on %s, radius %d\n", + obj_nameof(gp), mission_name(mission), + xyas(x, y, player->cnum), gp->radius); } if (num == 0) { pr("No %s%s\n", ef_nameof(type), splur(num)); diff --git a/src/lib/subs/mission.c b/src/lib/subs/mission.c index e39f4a771..3b79c4a45 100644 --- a/src/lib/subs/mission.c +++ b/src/lib/subs/mission.c @@ -741,14 +741,20 @@ mission_name(short mission) return "a mysterious"; } +/* + * Maximum distance GP can perform its mission. + * Note: this has nothing to do with the radius of the op-area. + * oprange() governs where the unit *can* strike, the op-area governs + * where the player wants it to strike. + */ int -oprange(struct empobj *gp, int mission) +oprange(struct empobj *gp) { switch (gp->ef_type) { case EF_SHIP: return ldround(shp_fire_range((struct shpstr *)gp), 1); case EF_LAND: - if (mission == MI_RESERVE) + if (gp->mission == MI_RESERVE) return lnd_reaction_range((struct lndstr *)gp); return ldround(lnd_fire_range((struct lndstr *)gp), 1); case EF_PLANE: @@ -768,7 +774,7 @@ int in_oparea(struct empobj *gp, coord x, coord y) { return mapdist(x, y, gp->opx, gp->opy) <= gp->radius - && mapdist(x, y, gp->x, gp->y) <= oprange(gp, gp->mission); + && mapdist(x, y, gp->x, gp->y) <= oprange(gp); } /*