Change: Add lock penalty to ship pathfinder. (#14603)

This commit is contained in:
Kuhnovic
2025-09-20 22:52:59 +02:00
committed by dP
parent 4f5ef4e720
commit 726da5e7b2

View File

@@ -388,6 +388,13 @@ public:
uint8_t speed_frac = (GetEffectiveWaterClass(n.GetTile()) == WATER_CLASS_SEA) ? svi->ocean_speed_frac : svi->canal_speed_frac;
if (speed_frac > 0) c += YAPF_TILE_LENGTH * (1 + tf->tiles_skipped) * speed_frac / (256 - speed_frac);
/* Lock penalty. */
if (IsTileType(n.GetTile(), MP_WATER) && IsLock(n.GetTile()) && GetLockPart(n.GetTile()) == LOCK_PART_MIDDLE) {
const uint canal_speed = svi->ApplyWaterClassSpeedFrac(svi->max_speed, false);
/* Cost is proportional to the vehicle's speed as the vehicle stops in the lock. */
c += (TILE_HEIGHT * YAPF_TILE_LENGTH * canal_speed) / 128;
}
/* Apply it. */
n.cost = n.parent->cost + c;
return true;