extern int lnd_interdict(struct emp_qelem *, coord, coord, natid);
extern void lnd_sel(struct nstr_item *, struct emp_qelem *);
extern int lnd_check_mines(struct emp_qelem *);
+extern double lnd_pathcost(struct lndstr *, double);
extern double lnd_mobcost(struct lndstr *, struct sctstr *, int);
extern char *lnd_path(int, struct lndstr *, char *);
extern void direrr(char *, char *, char *);
extern void pathrange(coord, coord, char *, int, struct range *);
-extern double sector_mcost(struct sctstr *sp, int do_bonus);
+extern double sector_mcost(struct sctstr *, int);
+extern double speed_factor(double, int);
#define MAX_PATH_LEN 1024
return MAX(d, LND_MINMOBCOST);
return MAX(d, 0.01);
}
+
+double
+speed_factor(double effspd, int tech)
+{
+ return 480.0 / (effspd + techfact(tech, effspd));
+}
int dtotal;
int new_land = 0;
double mobcost;
- double move_cost;
+ double pathcost;
int dist;
int radius;
int origx, origy;
continue;
getsect(def->x, def->y, &dsect);
- if (!BestLandPath(buf, §, &dsect, &move_cost, MOB_MARCH))
+ if (!BestLandPath(buf, §, &dsect, &pathcost, MOB_MARCH))
continue;
- mobcost = land.lnd_effic * 0.01 * lchr[(int)land.lnd_type].l_spd;
- if (mobcost < 0.01)
- mobcost = 0.01;
- mobcost = 480.0 / (mobcost + techfact(land.lnd_tech, mobcost));
- mobcost *= move_cost * 5.0;
-
+ mobcost = lnd_pathcost(&land, pathcost);
if (land.lnd_mobil < mobcost)
continue;
struct llist *llp;
struct sctstr sect;
int mines, m, max, sshells, lshells;
- double mobcost;
for (qp = land_list->q_back; qp != land_list; qp = next) {
next = qp->q_back;
continue;
}
if (takemob) {
-/* mobcost = llp->land.lnd_effic * 0.01 * llp->lcp->l_spd;*/
- mobcost = llp->land.lnd_spd;
- mobcost = 480.0 / (mobcost +
- techfact(llp->land.lnd_tech, mobcost));
- llp->mobil -= mobcost;
+ llp->mobil -= lnd_pathcost(&llp->land, 0.2);
llp->land.lnd_mobil = (int)llp->mobil;
llp->land.lnd_harden = 0;
}
}
double
-lnd_mobcost(struct lndstr *lp, struct sctstr *sp, int mobtype)
+lnd_pathcost(struct lndstr *lp, double pathcost)
{
double effspd;
effspd *= lp->lnd_effic * 0.01;
/*
- * The return value must be sector_mcost(...) times a factor that
- * depends only on the land unit. Anything else breaks path
- * finding. In particular, you can't add or enforce a minimum
- * cost here. Do it in sector_mcost().
+ * The return value must be pathcost times a factor that depends
+ * only on the land unit. Anything else breaks path finding. In
+ * particular, you can't add or enforce a minimum cost here. Do
+ * it in sector_mcost().
*/
- return sector_mcost(sp, mobtype) * 5.0 * 480.0
- / (effspd + techfact(lp->lnd_tech, effspd));
+ return pathcost * 5.0 * speed_factor(effspd, lp->lnd_tech);
+}
+
+double
+lnd_mobcost(struct lndstr *lp, struct sctstr *sp, int mobtype)
+{
+ return lnd_pathcost(lp, sector_mcost(sp, mobtype));
}
int
double
shp_mobcost(struct shpstr *sp)
{
- double effspd = sp->shp_effic * 0.01 * sp->shp_speed;
- return 480.0 / (effspd + techfact(sp->shp_tech, effspd));
+ return speed_factor(sp->shp_effic * 0.01 * sp->shp_speed,
+ sp->shp_tech);
}
/*