mirror of
https://github.com/Xevion/project-cybersyn.git
synced 2025-12-10 14:08:16 -06:00
implemented networks
This commit is contained in:
@@ -247,41 +247,38 @@ local function send_train_between(map_data, r_station_id, p_station_id, train, p
|
||||
local requests = {}
|
||||
local manifest = {}
|
||||
|
||||
local r_signals = get_signals(r_station)
|
||||
local r_signals = r_station.tick_signals
|
||||
if r_signals then
|
||||
for k, v in pairs(r_signals) do
|
||||
---@type string
|
||||
local item_name = v.signal.name
|
||||
local item_count = v.count
|
||||
local item_type = v.signal.type
|
||||
if item_name and item_type and item_type ~= "virtual" then
|
||||
local effective_item_count = item_count + (r_station.deliveries[item_name] or 0)
|
||||
local r_threshold, p_threshold = get_thresholds(map_data, r_station, v.signal)
|
||||
if -effective_item_count >= r_threshold then
|
||||
requests[item_name] = -effective_item_count
|
||||
end
|
||||
--local item_type = v.signal.type
|
||||
local effective_item_count = item_count + (r_station.deliveries[item_name] or 0)
|
||||
local r_threshold, p_threshold = get_thresholds(map_data, r_station, v.signal)
|
||||
if -effective_item_count >= r_threshold then
|
||||
requests[item_name] = -effective_item_count
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local p_signals = get_signals(p_station)
|
||||
local p_signals = p_station.tick_signals
|
||||
if p_signals then
|
||||
for k, v in pairs(p_signals) do
|
||||
local item_name = v.signal.name
|
||||
local item_count = v.count
|
||||
local item_type = v.signal.type
|
||||
if item_name and item_type and item_type ~= "virtual" then
|
||||
local effective_item_count = item_count + (p_station.deliveries[item_name] or 0)
|
||||
local r_threshold, p_threshold = get_thresholds(map_data, p_station, v.signal)
|
||||
if effective_item_count >= p_threshold then
|
||||
local r = requests[item_name]
|
||||
if r then
|
||||
local item = {name = item_name, count = math.min(r, effective_item_count), type = item_type}
|
||||
if item_name == primary_item_name then
|
||||
manifest[#manifest + 1] = manifest[1]
|
||||
manifest[1] = item
|
||||
else
|
||||
manifest[#manifest + 1] = item
|
||||
end
|
||||
local effective_item_count = item_count + (p_station.deliveries[item_name] or 0)
|
||||
local r_threshold, p_threshold = get_thresholds(map_data, p_station, v.signal)
|
||||
if effective_item_count >= p_threshold then
|
||||
local r = requests[item_name]
|
||||
if r then
|
||||
local item = {name = item_name, type = item_type, count = math.min(r, effective_item_count)}
|
||||
if item_name == primary_item_name then
|
||||
manifest[#manifest + 1] = manifest[1]
|
||||
manifest[1] = item
|
||||
else
|
||||
manifest[#manifest + 1] = item
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -390,6 +387,7 @@ function tick(map_data, mod_settings)
|
||||
station.locked_slots = 0
|
||||
station.network_flag = 1
|
||||
local signals = get_signals(station)
|
||||
station.tick_signals = signals
|
||||
if signals then
|
||||
for k, v in pairs(signals) do
|
||||
local item_name = v.signal.name
|
||||
@@ -421,26 +419,24 @@ function tick(map_data, mod_settings)
|
||||
local effective_item_count = item_count + (station.deliveries[item_name] or 0)
|
||||
local r_threshold, p_threshold = get_thresholds(map_data, station, v.signal)
|
||||
|
||||
if item_name then
|
||||
if -effective_item_count >= r_threshold then
|
||||
local item_network_name = item_name + ":" + station.network_name
|
||||
if r_stations_all[item_network_name] == nil then
|
||||
r_stations_all[item_network_name] = {}
|
||||
p_stations_all[item_network_name] = {}
|
||||
all_names[#all_names + 1] = item_network_name
|
||||
all_names[#all_names + 1] = v.signal
|
||||
end
|
||||
table.insert(r_stations_all[item_name], station_id)
|
||||
elseif effective_item_count >= p_threshold then
|
||||
local item_network_name = item_name + ":" + station.network_name
|
||||
if r_stations_all[item_network_name] == nil then
|
||||
r_stations_all[item_network_name] = {}
|
||||
p_stations_all[item_network_name] = {}
|
||||
all_names[#all_names + 1] = item_network_name
|
||||
all_names[#all_names + 1] = v.signal
|
||||
end
|
||||
table.insert(p_stations_all[item_name], station_id)
|
||||
if -effective_item_count >= r_threshold then
|
||||
local item_network_name = item_name + ":" + station.network_name
|
||||
if r_stations_all[item_network_name] == nil then
|
||||
r_stations_all[item_network_name] = {}
|
||||
p_stations_all[item_network_name] = {}
|
||||
all_names[#all_names + 1] = item_network_name
|
||||
all_names[#all_names + 1] = v.signal
|
||||
end
|
||||
table.insert(r_stations_all[item_name], station_id)
|
||||
elseif effective_item_count >= p_threshold then
|
||||
local item_network_name = item_name + ":" + station.network_name
|
||||
if r_stations_all[item_network_name] == nil then
|
||||
r_stations_all[item_network_name] = {}
|
||||
p_stations_all[item_network_name] = {}
|
||||
all_names[#all_names + 1] = item_network_name
|
||||
all_names[#all_names + 1] = v.signal
|
||||
end
|
||||
table.insert(p_stations_all[item_name], station_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -529,4 +525,7 @@ function tick(map_data, mod_settings)
|
||||
end
|
||||
end
|
||||
end
|
||||
for station_id, station in pairs(stations) do
|
||||
station.tick_signals = nil
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user