struct lchrstr *lcp;
if (lp->lnd_effic < LAND_MINEFF) {
- makelost(EF_LAND, lp->lnd_own, lp->lnd_uid, lp->lnd_x, lp->lnd_y);
- lp->lnd_own = 0;
putland(lp->lnd_uid, lp);
return 0;
}
struct lchrstr *lcp;
if (lp->lnd_effic < LAND_MINEFF) {
- makelost(EF_LAND, lp->lnd_own, lp->lnd_uid, lp->lnd_x, lp->lnd_y);
- lp->lnd_own = 0;
putland(lp->lnd_uid, lp);
return 0;
}
int taken;
int nowhere_to_go = 0;
struct sctstr rsect;
- double mobcost;
+ double mobcost, bmcost;
signed char orig;
int mob;
continue;
if (sect.sct_type == SCT_MOUNT)
continue;
+ mobcost = lnd_mobcost(&llp->land, &rsect);
+ if (mobcost < 0)
+ continue;
++nowned;
civs = sect.sct_item[I_CIVIL];
if (civs > biggest) {
biggest = civs;
bx = sect.sct_x;
by = sect.sct_y;
+ bmcost = mobcost;
}
}
if (!nowned)
llp->land.lnd_x = bx;
llp->land.lnd_y = by;
getsect(bx, by, &rsect);
- mobcost = lnd_mobcost(&llp->land, &rsect, MOB_ROAD);
- mob = llp->land.lnd_mobil - (int)mobcost;
+ mob = llp->land.lnd_mobil - (int)bmcost;
if (mob < -127)
mob = -127;
orig = llp->land.lnd_mobil;
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;
}
pr("%4d ", lnd->lnd_uid);
pr("%-16.16s ", llp->lcp->l_name);
prxy("%4d,%-4d ", lnd->lnd_x, lnd->lnd_y, llp->land.lnd_own);
- pr("%c", lnd->lnd_army);
+ pr("%1.1s", &lnd->lnd_army);
pr("%4d%%", lnd->lnd_effic);
pr("%4d", lnd->lnd_item[I_SHELL]);
pr("%4d", lnd->lnd_item[I_GUN]);
}
double
-lnd_mobcost(struct lndstr *lp, struct sctstr *sp, int mobtype)
+lnd_pathcost(struct lndstr *lp, double pathcost)
{
- double mobcost;
- double smobcost;
+ double effspd;
- /* supply unit's speed depends on their eff, since
- that is their purpose */
+ effspd = lp->lnd_spd;
if (lchr[(int)lp->lnd_type].l_flags & L_SUPPLY)
- mobcost = lp->lnd_effic * 0.01 * lp->lnd_spd;
- else
- mobcost = lp->lnd_spd;
- if (mobcost < 0.01)
- mobcost = 0.01;
-
-/* sector_mcost now takes 2 different arguments, a sector pointer, and
- whether or not to figure in the highway bonus, rail bonus or none.
- bridge heads, bridges and highways have built-in highways bonus
- because they are a 1, and this will discount that. */
-
- smobcost = sector_mcost(sp, mobtype);
- if (smobcost < 0.01)
- smobcost = 0.01;
-
-/* marching through 0 mobility conquered sectors takes lots of mobility,
- unless you are a train. Capturing railways is a good thing. */
-
- if (sp->sct_own != sp->sct_oldown && sp->sct_mobil <= 0 &&
- smobcost < LND_MINMOBCOST && mobtype != MOB_RAIL)
- smobcost = LND_MINMOBCOST;
+ effspd *= lp->lnd_effic * 0.01;
+
+ /*
+ * 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 pathcost * 5.0 * speed_factor(effspd, lp->lnd_tech);
+}
- mobcost = smobcost * 5.0 * 480.0 /
- (mobcost + techfact(lp->lnd_tech, mobcost));
+int
+lnd_mobtype(struct lndstr *lp)
+{
+ return (lchr[(int)lp->lnd_type].l_flags & L_TRAIN)
+ ? MOB_RAIL : MOB_MARCH;
+}
- return mobcost;
+double
+lnd_mobcost(struct lndstr *lp, struct sctstr *sp)
+{
+ return lnd_pathcost(lp, sector_mcost(sp, lnd_mobtype(lp)));
}
int
}
llp->land.lnd_x = newx;
llp->land.lnd_y = newy;
- if (lchr[(int)llp->land.lnd_type].l_flags & L_TRAIN) {
- llp->mobil -= lnd_mobcost(&llp->land, §, MOB_RAIL);
- } else {
- llp->mobil -= lnd_mobcost(&llp->land, §, MOB_ROAD);
- }
+ llp->mobil -= lnd_mobcost(&llp->land, §);
llp->land.lnd_mobil = (int)llp->mobil;
llp->land.lnd_harden = 0;
putland(llp->land.lnd_uid, &llp->land);
* find all artillery units belonging
* to the attacker or defender that can fire.
* Each arty unit adds +1%/damage point
- *
*/
int
lnd_support(natid victim, natid attacker, coord x, coord y, int defending)
continue;
if (land.lnd_land >= 0)
continue;
- if (land.lnd_mission > 0)
- continue;
if (land.lnd_effic < LAND_MINFIREEFF)
continue;
/* Do we have mil? */
struct sctstr d_sect, sect;
char *cp;
double dummy;
+ int mtype;
if (!sarg_xy(buf, &destx, &desty))
return 0;
return 0;
}
getsect(lp->lnd_x, lp->lnd_y, §);
- if (lchr[(int)lp->lnd_type].l_flags & L_TRAIN)
- cp = BestLandPath(buf, §, &d_sect, &dummy, MOB_RAIL);
- else
- cp = BestLandPath(buf, §, &d_sect, &dummy, MOB_ROAD);
+ mtype = lnd_mobtype(lp);
+ cp = BestLandPath(buf, §, &d_sect, &dummy, mtype);
if (!cp) {
- pr("No owned path from %s to %s!\n",
+ pr("No owned %s from %s to %s!\n",
+ mtype == MOB_RAIL ? "railway" : "path",
xyas(lp->lnd_x, lp->lnd_y, player->cnum),
xyas(d_sect.sct_x, d_sect.sct_y, player->cnum));
return 0;