mirror of
https://github.com/Xevion/project-cybersyn.git
synced 2025-12-06 07:15:58 -06:00
fixed a crash in the planner
This commit is contained in:
@@ -395,7 +395,7 @@ local function tick_dispatch(map_data, mod_settings)
|
|||||||
end
|
end
|
||||||
local max_threshold = INF
|
local max_threshold = INF
|
||||||
while true do
|
while true do
|
||||||
local r_station_id = nil
|
local r_station_i = nil
|
||||||
local r_threshold = nil
|
local r_threshold = nil
|
||||||
local best_prior = -INF
|
local best_prior = -INF
|
||||||
local best_lru = INF
|
local best_lru = INF
|
||||||
@@ -405,20 +405,20 @@ local function tick_dispatch(map_data, mod_settings)
|
|||||||
if station and station.deliveries_total < station.entity_stop.trains_limit then
|
if station and station.deliveries_total < station.entity_stop.trains_limit then
|
||||||
local threshold = station.p_count_or_r_threshold_per_item[item_name]
|
local threshold = station.p_count_or_r_threshold_per_item[item_name]
|
||||||
if threshold <= max_threshold and (station.priority > best_prior or (station.priority == best_prior and station.last_delivery_tick < best_lru)) then
|
if threshold <= max_threshold and (station.priority > best_prior or (station.priority == best_prior and station.last_delivery_tick < best_lru)) then
|
||||||
r_station_id = id
|
r_station_i = i
|
||||||
r_threshold = threshold
|
r_threshold = threshold
|
||||||
best_prior = station.priority
|
best_prior = station.priority
|
||||||
best_lru = station.last_delivery_tick
|
best_lru = station.last_delivery_tick
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not r_station_id then
|
if not r_station_i then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local r_station_id = r_stations[r_station_i]
|
||||||
local r_station = stations[r_station_id]
|
local r_station = stations[r_station_id]
|
||||||
|
|
||||||
local pre_max_threshold = max_threshold
|
|
||||||
max_threshold = 0
|
max_threshold = 0
|
||||||
local best_i = 0
|
local best_i = 0
|
||||||
local best_depot = nil
|
local best_depot = nil
|
||||||
@@ -445,9 +445,8 @@ local function tick_dispatch(map_data, mod_settings)
|
|||||||
can_be_serviced = true
|
can_be_serviced = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif effective_count < pre_max_threshold and effective_count > max_threshold then
|
end
|
||||||
--set the max_threshold to the highest seen number that is strictly lower that the previous used
|
if effective_count > max_threshold then
|
||||||
--due to where in the algorithm we are this will find a valid request and provide pair or abort in just one iteration
|
|
||||||
max_threshold = effective_count
|
max_threshold = effective_count
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -466,6 +465,8 @@ local function tick_dispatch(map_data, mod_settings)
|
|||||||
r_station.display_failed_request = true
|
r_station.display_failed_request = true
|
||||||
r_station.display_update = true
|
r_station.display_update = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
table_remove(r_stations, r_station_i)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
---@param map_data MapData
|
---@param map_data MapData
|
||||||
|
|||||||
Reference in New Issue
Block a user