Add hysteresis to depot search max penalty in missing depot order mode

See: #345
This commit is contained in:
Jonathan G Rennison
2021-12-27 17:21:00 +00:00
parent 2c7ec68b76
commit f40191b3c0
2 changed files with 4 additions and 4 deletions

View File

@@ -6565,9 +6565,9 @@ static void CheckIfTrainNeedsService(Train *v)
default: NOT_REACHED();
}
FindDepotData tfdd = FindClosestTrainDepot(v, max_penalty);
FindDepotData tfdd = FindClosestTrainDepot(v, max_penalty * (v->current_order.IsType(OT_GOTO_DEPOT) ? 2 : 1));
/* Only go to the depot if it is not too far out of our way. */
if (tfdd.best_length == UINT_MAX || tfdd.best_length > max_penalty) {
if (tfdd.best_length == UINT_MAX || tfdd.best_length > max_penalty * (v->current_order.IsType(OT_GOTO_DEPOT) && v->current_order.GetDestination() == GetDepotIndex(tfdd.tile) ? 2 : 1)) {
if (v->current_order.IsType(OT_GOTO_DEPOT)) {
/* If we were already heading for a depot but it has
* suddenly moved farther away, we continue our normal