Make look ahead distance vaiable with speed, within a reasonable range

This commit is contained in:
Jonathan G Rennison
2021-07-03 22:50:43 +01:00
parent 11e49ef99e
commit fb4e10626e

View File

@@ -99,8 +99,8 @@ static bool CheckTrainStayInWormHolePathReserve(Train *t, TileIndex tile);
* at the current position of the train is going to be invalid */ * at the current position of the train is going to be invalid */
static DateTicksScaled GetSpeedRestrictionTimeout(const Train *t) static DateTicksScaled GetSpeedRestrictionTimeout(const Train *t)
{ {
const int64 look_ahead_distance = 16; // In tiles
const int64 velocity = std::max<int64>(25, t->cur_speed); const int64 velocity = std::max<int64>(25, t->cur_speed);
const int64 look_ahead_distance = Clamp(t->cur_speed / 8, 6, 16); // In tiles, varying between 6 and 16 depending on current speed
// This assumes travel along the X or Y map axis, not diagonally. See GetAdvanceDistance, GetAdvanceSpeed. // This assumes travel along the X or Y map axis, not diagonally. See GetAdvanceDistance, GetAdvanceSpeed.
const int64 ticks_per_tile = (192 * 16 * 4 / 3) / velocity; const int64 ticks_per_tile = (192 * 16 * 4 / 3) / velocity;