4.0.2 made land unit mobility costs differ significantly from normal
move costs, but failed to make A* use these costs. This broke land unit path finding. Fix: (MOB_ROAD, MOB_MOVE, MOB_MARCH): Split MOB_ROAD into MOB_MOVE and MOB_MARCH. Users changed. (lnd_mobcost, sector_mcost): Move minimum mobcost logic to sector_mcost(), where it is visible to A*. Also fixes unit reaction path cost. (lnd_path): Fix confusing message: don't claim there's no path when all we really know is that there's no railway.
This commit is contained in:
parent
6ab05ae8a1
commit
5ad86bc7ce
11 changed files with 46 additions and 59 deletions
|
@ -45,12 +45,11 @@ sector_mcost(struct sctstr *sp, int do_bonus)
|
|||
{
|
||||
double d;
|
||||
|
||||
if (!(d = dchr[sp->sct_type].d_mcst))
|
||||
d = dchr[sp->sct_type].d_mcst;
|
||||
if (d <= 0)
|
||||
return -1.0;
|
||||
|
||||
/* Note, the best you can get is a 1.0 here. */
|
||||
|
||||
if (do_bonus == MOB_ROAD) {
|
||||
if (do_bonus == MOB_MOVE || do_bonus == MOB_MARCH) {
|
||||
d = d / (1.0 + sp->sct_road / 122.0);
|
||||
} else if (do_bonus == MOB_RAIL) {
|
||||
if (sp->sct_rail <= 0)
|
||||
|
@ -64,11 +63,13 @@ sector_mcost(struct sctstr *sp, int do_bonus)
|
|||
d = 1.0;
|
||||
if (dchr[sp->sct_type].d_mcst < 25)
|
||||
d = (d * 100.0 - sp->sct_effic) / 500.0;
|
||||
/* d = (200.0 + (d - 3.0) * sp->sct_effic) / 500.0;*/
|
||||
else
|
||||
d = (d * 10.0 - sp->sct_effic) / 115;
|
||||
|
||||
if (d <= 0.0 || d < MIN_MOBCOST)
|
||||
return MIN_MOBCOST;
|
||||
return d;
|
||||
if (do_bonus == MOB_MOVE)
|
||||
return MAX(d, MIN_MOBCOST);
|
||||
if (sp->sct_own != sp->sct_oldown && sp->sct_mobil <= 0
|
||||
&& do_bonus != MOB_RAIL)
|
||||
return MAX(d, LND_MINMOBCOST);
|
||||
return MAX(d, 0.01);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue