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
|
while fluid_capacity > 0 do
|
||||||
local do_inc = false
|
local do_inc = false
|
||||||
if fluid.type == "fluid" then
|
if fluid.type == "fluid" then
|
||||||
local i = #signals + 1
|
|
||||||
if fluid_count > fluid_capacity then
|
if fluid_count > fluid_capacity then
|
||||||
if comb 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
|
end
|
||||||
fluid_capacity = 0
|
fluid_capacity = 0
|
||||||
fluid_count = fluid_count - fluid_capacity
|
fluid_count = fluid_count - fluid_capacity
|
||||||
else
|
else
|
||||||
if comb then
|
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
|
end
|
||||||
fluid_capacity = fluid_capacity - fluid_count
|
fluid_capacity = fluid_capacity - fluid_count
|
||||||
do_inc = true
|
fluid_i = fluid_i + 1
|
||||||
|
if fluid_i <= #manifest then
|
||||||
|
fluid = manifest[fluid_i]
|
||||||
|
fluid_count = fluid.count
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
break
|
||||||
else
|
else
|
||||||
do_inc = true
|
|
||||||
end
|
|
||||||
if do_inc then
|
|
||||||
fluid_i = fluid_i + 1
|
fluid_i = fluid_i + 1
|
||||||
if fluid_i <= #manifest then
|
if fluid_i <= #manifest then
|
||||||
fluid = manifest[fluid_i]
|
fluid = manifest[fluid_i]
|
||||||
fluid_count = fluid.count
|
fluid_count = fluid.count
|
||||||
else
|
|
||||||
break
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -214,7 +213,7 @@ end
|
|||||||
---@param station Station
|
---@param station Station
|
||||||
---@param train Train
|
---@param train Train
|
||||||
function set_r_wagon_combs(map_data, station, 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 carriages = train.entity.carriages
|
||||||
|
|
||||||
local is_reversed = get_train_direction(station.entity_stop, train.entity)
|
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
|
||||||
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 map_data MapData
|
||||||
---@param station Station
|
---@param station Station
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ local function on_failed_delivery(map_data, train)
|
|||||||
remove_manifest(map_data, station, train.manifest, 1)
|
remove_manifest(map_data, station, train.manifest, 1)
|
||||||
if train.status == STATUS_P then
|
if train.status == STATUS_P then
|
||||||
set_combinator_output(map_data, station.entity_comb1, nil)
|
set_combinator_output(map_data, station.entity_comb1, nil)
|
||||||
--TODO: remove wagon_comb manifest output
|
unset_wagon_combs(map_data, station)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local is_r_delivery_made = train.status == STATUS_R_TO_D
|
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)
|
remove_manifest(map_data, station, train.manifest, -1)
|
||||||
if train.status == STATUS_R then
|
if train.status == STATUS_R then
|
||||||
set_combinator_output(map_data, station.entity_comb1, nil)
|
set_combinator_output(map_data, station.entity_comb1, nil)
|
||||||
--TODO: remove wagon_comb manifest output
|
unset_wagon_combs(map_data, station)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
train.r_station_id = 0
|
train.r_station_id = 0
|
||||||
@@ -103,7 +103,6 @@ end
|
|||||||
local function search_for_station_combinator(map_data, stop, comb_operation, comb_forbidden)
|
local function search_for_station_combinator(map_data, stop, comb_operation, comb_forbidden)
|
||||||
local pos_x = stop.position.x
|
local pos_x = stop.position.x
|
||||||
local pos_y = stop.position.y
|
local pos_y = stop.position.y
|
||||||
--TODO: fix search area
|
|
||||||
local search_area = {
|
local search_area = {
|
||||||
{pos_x - 2, pos_y - 2},
|
{pos_x - 2, pos_y - 2},
|
||||||
{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_x = comb.position.x
|
||||||
local pos_y = comb.position.y
|
local pos_y = comb.position.y
|
||||||
|
|
||||||
--TODO: fix search area
|
|
||||||
local search_area
|
local search_area
|
||||||
if comb.direction == defines.direction.north or comb.direction == defines.direction.south then
|
if comb.direction == defines.direction.north or comb.direction == defines.direction.south then
|
||||||
search_area = {
|
search_area = {
|
||||||
@@ -308,7 +306,6 @@ local function on_stop_built(map_data, stop)
|
|||||||
local pos_x = stop.position.x
|
local pos_x = stop.position.x
|
||||||
local pos_y = stop.position.y
|
local pos_y = stop.position.y
|
||||||
|
|
||||||
--TODO: fix search area
|
|
||||||
local search_area = {
|
local search_area = {
|
||||||
{pos_x - 2, pos_y - 2},
|
{pos_x - 2, pos_y - 2},
|
||||||
{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_x = stop.position.x
|
||||||
local pos_y = stop.position.y
|
local pos_y = stop.position.y
|
||||||
|
|
||||||
--TODO: fix search area
|
|
||||||
local search_area = {
|
local search_area = {
|
||||||
{pos_x - 2, pos_y - 2},
|
{pos_x - 2, pos_y - 2},
|
||||||
{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]
|
local station = map_data.stations[train.p_station_id]
|
||||||
remove_manifest(map_data, station, train.manifest, 1)
|
remove_manifest(map_data, station, train.manifest, 1)
|
||||||
set_combinator_output(map_data, station.entity_comb1, nil)
|
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
|
elseif train.status == STATUS_R then
|
||||||
train.status = STATUS_R_TO_D
|
train.status = STATUS_R_TO_D
|
||||||
local station = map_data.stations[train.r_station_id]
|
local station = map_data.stations[train.r_station_id]
|
||||||
remove_manifest(map_data, station, train.manifest, -1)
|
remove_manifest(map_data, station, train.manifest, -1)
|
||||||
set_combinator_output(map_data, station.entity_comb1, nil)
|
set_combinator_output(map_data, station.entity_comb1, nil)
|
||||||
--TODO: remove wagon_comb manifest output
|
unset_wagon_combs(map_data, station)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -535,7 +531,6 @@ end
|
|||||||
local function on_train_modified(map_data, pre_train_id, train_entity)
|
local function on_train_modified(map_data, pre_train_id, train_entity)
|
||||||
local train = map_data.trains[pre_train_id]
|
local train = map_data.trains[pre_train_id]
|
||||||
if train then
|
if train then
|
||||||
|
|
||||||
if train.manifest then
|
if train.manifest then
|
||||||
on_failed_delivery(map_data, train)
|
on_failed_delivery(map_data, train)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user