Factor out land unit firing range calculation into lnd_fire_range()
This commit is contained in:
parent
ad5f8e8904
commit
76830b5b98
5 changed files with 15 additions and 6 deletions
|
@ -168,6 +168,7 @@ extern int l_dam(struct lchrstr *, int);
|
|||
extern int l_aaf(struct lchrstr *, int);
|
||||
|
||||
extern int lnd_fire(struct lndstr *);
|
||||
extern double lnd_fire_range(struct lndstr *);
|
||||
|
||||
/* src/lib/subs/lndsub.c */
|
||||
extern void lnd_sweep(struct emp_qelem *, int, int, natid);
|
||||
|
|
|
@ -362,7 +362,7 @@ multifire(void)
|
|||
continue;
|
||||
}
|
||||
|
||||
range = effrange(fland.lnd_frg, fland.lnd_tech);
|
||||
range = lnd_fire_range(&fland);
|
||||
range2 = roundrange(range);
|
||||
pr("range is %d.00 (%.2f)\n", range2, range);
|
||||
if (target == targ_sub) {
|
||||
|
@ -777,7 +777,7 @@ quiet_bigdef(int attacker, struct emp_qelem *list, natid own, natid aown,
|
|||
if ((land.lnd_own != own) && ((rel != ALLIED) || (rel2 != AT_WAR)))
|
||||
continue;
|
||||
|
||||
erange = effrange(land.lnd_frg, land.lnd_tech);
|
||||
erange = lnd_fire_range(&land);
|
||||
if (roundrange(erange) < ni.curdist)
|
||||
continue;
|
||||
|
||||
|
|
|
@ -264,6 +264,15 @@ shp_fire_range(struct shpstr *sp)
|
|||
return effrange(sp->shp_frnge, sp->shp_tech);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return firing range for land unit SP.
|
||||
*/
|
||||
double
|
||||
lnd_fire_range(struct lndstr *lp)
|
||||
{
|
||||
return effrange(lp->lnd_frg, lp->lnd_tech);
|
||||
}
|
||||
|
||||
int
|
||||
roundrange(double r)
|
||||
{
|
||||
|
|
|
@ -1137,7 +1137,7 @@ lnd_support(natid victim, natid attacker, coord x, coord y, int defending)
|
|||
/* are we in range? */
|
||||
dist = mapdist(land.lnd_x, land.lnd_y, x, y);
|
||||
|
||||
range = roundrange(effrange(land.lnd_frg, land.lnd_tech));
|
||||
range = roundrange(lnd_fire_range(&land));
|
||||
if (dist > range)
|
||||
continue;
|
||||
|
||||
|
|
|
@ -437,7 +437,7 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
|
|||
(md > land_max_interdiction_range))
|
||||
continue;
|
||||
|
||||
range = roundrange(effrange(lp->lnd_frg, lp->lnd_tech));
|
||||
range = roundrange(lnd_fire_range(lp));
|
||||
if (md > range)
|
||||
continue;
|
||||
|
||||
|
@ -838,8 +838,7 @@ oprange(struct empobj *gp, int *radius)
|
|||
range = ldround(shp_fire_range((struct shpstr *)gp), 1);
|
||||
break;
|
||||
case EF_LAND:
|
||||
range = ldround(effrange(((struct lndstr *)gp)->lnd_frg,
|
||||
((struct lndstr *)gp)->lnd_tech), 1);
|
||||
range = ldround(lnd_fire_range((struct lndstr *)gp), 1);
|
||||
break;
|
||||
case EF_PLANE:
|
||||
/* missiles go one way, so we can use all the range */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue