changed provider priority

This commit is contained in:
monica
2023-01-10 10:03:34 -05:00
parent 368046c3aa
commit 2ecbace069
2 changed files with 8 additions and 7 deletions

View File

@@ -4,6 +4,7 @@ Date: 2022-1-9
Changes:
- Made the automatic allow list slightly more forgiving to stations where the last wagon would be on a curved rail
- Improved performance when fuel threshold is set to 1
- Prioritized distance from provider to requester over distance from train to provider
Bugfixes:
- Fixed a bug where it was possible for a single station to be updated twice per dispatch cycle, which could cause a crash
- Fixed a crash where trains would sometimes think a destroyed depot still exists

View File

@@ -349,7 +349,7 @@ local function tick_dispatch(map_data, mod_settings)
---@type uint
local j = 1
while j <= #p_stations do
local p_flag, r_flag, netand, best_p_train_id, best_t_prior, best_capacity, best_t_to_p_dist, effective_count, override_threshold, p_prior, best_p_dist
local p_flag, r_flag, netand, best_p_train_id, best_t_prior, best_capacity, best_t_to_p_dist, effective_count, override_threshold, p_prior, best_p_to_r_dist
local p_station_id = p_stations[j]
local p_station = stations[p_station_id]
@@ -387,6 +387,11 @@ local function tick_dispatch(map_data, mod_settings)
if p_prior < best_p_prior then
goto p_continue
end
best_p_to_r_dist = p_station.entity_stop.valid and r_station.entity_stop.valid and get_dist(p_station.entity_stop, r_station.entity_stop) or INF
if p_prior == best_p_prior and best_p_to_r_dist > best_dist then
goto p_continue
end
if correctness < 1 then
correctness = 1
closest_to_correct_p_station = p_station
@@ -466,15 +471,10 @@ local function tick_dispatch(map_data, mod_settings)
goto p_continue
end
best_p_dist = p_station.entity_stop.valid and r_station.entity_stop.valid and (best_t_to_p_dist + get_dist(p_station.entity_stop, r_station.entity_stop)) or INF
if p_prior == best_p_prior and best_p_dist > best_dist then
goto p_continue
end
p_station_i = j
best_train_id = best_p_train_id
best_p_prior = p_prior
best_dist = best_p_dist
best_dist = best_t_to_p_dist + best_p_to_r_dist
::p_continue::
j = j + 1
::p_continue_remove::