mirror of
https://github.com/Xevion/project-cybersyn.git
synced 2025-12-08 12:08:09 -06:00
fixes to wagon combs
This commit is contained in:
@@ -175,30 +175,29 @@ function set_p_wagon_combs(map_data, station, train)
|
||||
while fluid_capacity > 0 do
|
||||
local do_inc = false
|
||||
if fluid.type == "fluid" then
|
||||
local i = #signals + 1
|
||||
if fluid_count > fluid_capacity then
|
||||
if comb then
|
||||
signals[i] = {index = i, signal = {type = fluid.type, name = fluid.name}, count = fluid_capacity}
|
||||
signals[1] = {index = 1, signal = {type = fluid.type, name = fluid.name}, count = fluid_capacity}
|
||||
end
|
||||
fluid_capacity = 0
|
||||
fluid_count = fluid_count - fluid_capacity
|
||||
else
|
||||
if comb then
|
||||
signals[i] = {index = i, signal = {type = fluid.type, name = fluid.name}, count = item_count}
|
||||
signals[1] = {index = 1, signal = {type = fluid.type, name = fluid.name}, count = item_count}
|
||||
end
|
||||
fluid_capacity = fluid_capacity - fluid_count
|
||||
do_inc = true
|
||||
end
|
||||
else
|
||||
do_inc = true
|
||||
end
|
||||
if do_inc then
|
||||
fluid_i = fluid_i + 1
|
||||
if fluid_i <= #manifest then
|
||||
fluid = manifest[fluid_i]
|
||||
fluid_count = fluid.count
|
||||
else
|
||||
end
|
||||
end
|
||||
break
|
||||
else
|
||||
fluid_i = fluid_i + 1
|
||||
if fluid_i <= #manifest then
|
||||
fluid = manifest[fluid_i]
|
||||
fluid_count = fluid.count
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -214,7 +213,7 @@ end
|
||||
---@param station Station
|
||||
---@param train Train
|
||||
function set_r_wagon_combs(map_data, station, train)
|
||||
if not station.wagon_combs or not next(station.wagon_combs) then return end
|
||||
if not station.wagon_combs then return end
|
||||
local carriages = train.entity.carriages
|
||||
|
||||
local is_reversed = get_train_direction(station.entity_stop, train.entity)
|
||||
@@ -256,6 +255,23 @@ function set_r_wagon_combs(map_data, station, train)
|
||||
end
|
||||
end
|
||||
|
||||
---@param map_data MapData
|
||||
---@param station Station
|
||||
function unset_wagon_combs(map_data, station)
|
||||
if not station.wagon_combs then return end
|
||||
|
||||
for i, comb in pairs(station.wagon_combs) do
|
||||
if comb.valid then
|
||||
set_combinator_output(map_data, comb, nil)
|
||||
else
|
||||
station.wagon_combs[i] = nil
|
||||
end
|
||||
end
|
||||
if next(station.wagon_combs) == nil then
|
||||
station.wagon_combs = nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
---@param map_data MapData
|
||||
---@param station Station
|
||||
|
||||
@@ -11,7 +11,7 @@ local function on_failed_delivery(map_data, train)
|
||||
remove_manifest(map_data, station, train.manifest, 1)
|
||||
if train.status == STATUS_P then
|
||||
set_combinator_output(map_data, station.entity_comb1, nil)
|
||||
--TODO: remove wagon_comb manifest output
|
||||
unset_wagon_combs(map_data, station)
|
||||
end
|
||||
end
|
||||
local is_r_delivery_made = train.status == STATUS_R_TO_D
|
||||
@@ -20,7 +20,7 @@ local function on_failed_delivery(map_data, train)
|
||||
remove_manifest(map_data, station, train.manifest, -1)
|
||||
if train.status == STATUS_R then
|
||||
set_combinator_output(map_data, station.entity_comb1, nil)
|
||||
--TODO: remove wagon_comb manifest output
|
||||
unset_wagon_combs(map_data, station)
|
||||
end
|
||||
end
|
||||
train.r_station_id = 0
|
||||
@@ -103,7 +103,6 @@ end
|
||||
local function search_for_station_combinator(map_data, stop, comb_operation, comb_forbidden)
|
||||
local pos_x = stop.position.x
|
||||
local pos_y = stop.position.y
|
||||
--TODO: fix search area
|
||||
local search_area = {
|
||||
{pos_x - 2, pos_y - 2},
|
||||
{pos_x + 2, pos_y + 2}
|
||||
@@ -128,7 +127,6 @@ local function on_combinator_built(map_data, comb)
|
||||
local pos_x = comb.position.x
|
||||
local pos_y = comb.position.y
|
||||
|
||||
--TODO: fix search area
|
||||
local search_area
|
||||
if comb.direction == defines.direction.north or comb.direction == defines.direction.south then
|
||||
search_area = {
|
||||
@@ -308,7 +306,6 @@ local function on_stop_built(map_data, stop)
|
||||
local pos_x = stop.position.x
|
||||
local pos_y = stop.position.y
|
||||
|
||||
--TODO: fix search area
|
||||
local search_area = {
|
||||
{pos_x - 2, pos_y - 2},
|
||||
{pos_x + 2, pos_y + 2}
|
||||
@@ -344,7 +341,6 @@ local function on_stop_broken(map_data, stop)
|
||||
local pos_x = stop.position.x
|
||||
local pos_y = stop.position.y
|
||||
|
||||
--TODO: fix search area
|
||||
local search_area = {
|
||||
{pos_x - 2, pos_y - 2},
|
||||
{pos_x + 2, pos_y + 2}
|
||||
@@ -506,13 +502,13 @@ local function on_train_leaves_station(map_data, train)
|
||||
local station = map_data.stations[train.p_station_id]
|
||||
remove_manifest(map_data, station, train.manifest, 1)
|
||||
set_combinator_output(map_data, station.entity_comb1, nil)
|
||||
--TODO: remove wagon_comb manifest output
|
||||
unset_wagon_combs(map_data, station)
|
||||
elseif train.status == STATUS_R then
|
||||
train.status = STATUS_R_TO_D
|
||||
local station = map_data.stations[train.r_station_id]
|
||||
remove_manifest(map_data, station, train.manifest, -1)
|
||||
set_combinator_output(map_data, station.entity_comb1, nil)
|
||||
--TODO: remove wagon_comb manifest output
|
||||
unset_wagon_combs(map_data, station)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -535,7 +531,6 @@ end
|
||||
local function on_train_modified(map_data, pre_train_id, train_entity)
|
||||
local train = map_data.trains[pre_train_id]
|
||||
if train then
|
||||
|
||||
if train.manifest then
|
||||
on_failed_delivery(map_data, train)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user