mirror of
https://github.com/Xevion/project-cybersyn.git
synced 2025-12-10 06:08:11 -06:00
Merge branch 'experimental' of github.com:mamoniot/project-cybersyn into experimental
This commit is contained in:
@@ -326,20 +326,13 @@ local function tick_dispatch(map_data, mod_settings)
|
|||||||
end
|
end
|
||||||
local trains = map_data.available_trains[network_name]
|
local trains = map_data.available_trains[network_name]
|
||||||
local is_fluid = item_type == "fluid"
|
local is_fluid = item_type == "fluid"
|
||||||
|
if not is_fluid and r_station.is_stack then
|
||||||
|
r_threshold = r_threshold*get_stack_size(map_data, item_name)
|
||||||
|
end
|
||||||
--no train exists with layout accepted by both provide and request stations
|
--no train exists with layout accepted by both provide and request stations
|
||||||
local correctness = 0
|
local correctness = 0
|
||||||
local closest_to_correct_p_station = nil
|
local closest_to_correct_p_station = nil
|
||||||
|
|
||||||
local slot_threshold
|
|
||||||
if is_fluid then
|
|
||||||
slot_threshold = r_threshold
|
|
||||||
elseif r_station.is_stack then
|
|
||||||
slot_threshold = r_threshold
|
|
||||||
r_threshold = r_threshold*get_stack_size(map_data, item_name)
|
|
||||||
else
|
|
||||||
slot_threshold = ceil(r_threshold/get_stack_size(map_data, item_name))
|
|
||||||
end
|
|
||||||
|
|
||||||
---@type uint?
|
---@type uint?
|
||||||
local p_station_i = nil
|
local p_station_i = nil
|
||||||
local best_train_id = nil
|
local best_train_id = nil
|
||||||
@@ -349,7 +342,7 @@ local function tick_dispatch(map_data, mod_settings)
|
|||||||
---@type uint
|
---@type uint
|
||||||
local j = 1
|
local j = 1
|
||||||
while j <= #p_stations do
|
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_to_r_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, effective_threshold, slot_threshold
|
||||||
|
|
||||||
local p_station_id = p_stations[j]
|
local p_station_id = p_stations[j]
|
||||||
local p_station = stations[p_station_id]
|
local p_station = stations[p_station_id]
|
||||||
@@ -369,7 +362,13 @@ local function tick_dispatch(map_data, mod_settings)
|
|||||||
if override_threshold and p_station.is_stack and not is_fluid then
|
if override_threshold and p_station.is_stack and not is_fluid then
|
||||||
override_threshold = override_threshold*get_stack_size(map_data, item_name)
|
override_threshold = override_threshold*get_stack_size(map_data, item_name)
|
||||||
end
|
end
|
||||||
if effective_count < (override_threshold or r_threshold) then
|
if override_threshold and override_threshold <= r_threshold then
|
||||||
|
effective_threshold = override_threshold
|
||||||
|
else
|
||||||
|
effective_threshold = r_threshold
|
||||||
|
end
|
||||||
|
|
||||||
|
if effective_count < effective_threshold then
|
||||||
--this p station should have serviced the current r station, lock it so it can't serve any others
|
--this p station should have serviced the current r station, lock it so it can't serve any others
|
||||||
--this will lock stations even when the r station manages to find a p station, this not a problem because all stations will be unlocked before it could be an issue
|
--this will lock stations even when the r station manages to find a p station, this not a problem because all stations will be unlocked before it could be an issue
|
||||||
table_remove(p_stations, j)
|
table_remove(p_stations, j)
|
||||||
@@ -392,6 +391,13 @@ local function tick_dispatch(map_data, mod_settings)
|
|||||||
if p_prior == best_p_prior and best_p_to_r_dist > best_dist then
|
if p_prior == best_p_prior and best_p_to_r_dist > best_dist then
|
||||||
goto p_continue
|
goto p_continue
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if is_fluid then
|
||||||
|
slot_threshold = effective_threshold
|
||||||
|
else
|
||||||
|
slot_threshold = ceil(effective_threshold/get_stack_size(map_data, item_name))
|
||||||
|
end
|
||||||
|
|
||||||
if correctness < 1 then
|
if correctness < 1 then
|
||||||
correctness = 1
|
correctness = 1
|
||||||
closest_to_correct_p_station = p_station
|
closest_to_correct_p_station = p_station
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ data:extend({
|
|||||||
name = "cybersyn-manager-enabled",
|
name = "cybersyn-manager-enabled",
|
||||||
order = "aa",
|
order = "aa",
|
||||||
setting_type = "startup",
|
setting_type = "startup",
|
||||||
default_value = true,
|
default_value = false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type = "int-setting",
|
type = "int-setting",
|
||||||
|
|||||||
Reference in New Issue
Block a user