mirror of
https://github.com/Xevion/project-cybersyn.git
synced 2025-12-10 12:08:12 -06:00
fixed interface
This commit is contained in:
@@ -29,28 +29,31 @@ end
|
|||||||
---@param train Train
|
---@param train Train
|
||||||
function on_failed_delivery(map_data, train_id, train)
|
function on_failed_delivery(map_data, train_id, train)
|
||||||
--NOTE: must either change this train's status or remove it after this call
|
--NOTE: must either change this train's status or remove it after this call
|
||||||
|
local p_station_id = train.p_station_id
|
||||||
|
local r_station_id = train.r_station_id
|
||||||
|
local manifest = train.manifest
|
||||||
local is_p_in_progress = train.status == STATUS_D_TO_P or train.status == STATUS_P
|
local is_p_in_progress = train.status == STATUS_D_TO_P or train.status == STATUS_P
|
||||||
local is_r_in_progress = is_p_in_progress or train.status == STATUS_P_TO_R or train.status == STATUS_R
|
local is_r_in_progress = is_p_in_progress or train.status == STATUS_P_TO_R or train.status == STATUS_R
|
||||||
if is_p_in_progress then
|
if is_p_in_progress then
|
||||||
local station = map_data.stations[train.p_station_id]
|
local station = map_data.stations[p_station_id]
|
||||||
remove_manifest(map_data, station, train.manifest, 1)
|
remove_manifest(map_data, station, manifest, 1)
|
||||||
if train.status == STATUS_P then
|
if train.status == STATUS_P then
|
||||||
set_comb1(map_data, station, nil)
|
set_comb1(map_data, station, nil)
|
||||||
unset_wagon_combs(map_data, station)
|
unset_wagon_combs(map_data, station)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if is_r_in_progress then
|
if is_r_in_progress then
|
||||||
local station = map_data.stations[train.r_station_id]
|
local station = map_data.stations[r_station_id]
|
||||||
remove_manifest(map_data, station, train.manifest, -1)
|
remove_manifest(map_data, station, manifest, -1)
|
||||||
if train.status == STATUS_R then
|
if train.status == STATUS_R then
|
||||||
set_comb1(map_data, station, nil)
|
set_comb1(map_data, station, nil)
|
||||||
unset_wagon_combs(map_data, station)
|
unset_wagon_combs(map_data, station)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
interface_raise_train_failed_delivery(train_id, is_p_in_progress, is_r_in_progress)
|
|
||||||
train.r_station_id = 0
|
train.r_station_id = 0
|
||||||
train.p_station_id = 0
|
train.p_station_id = 0
|
||||||
train.manifest = nil
|
train.manifest = nil
|
||||||
|
interface_raise_train_failed_delivery(train_id, is_p_in_progress, p_station_id, is_r_in_progress, r_station_id, manifest)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ function interface_raise_train_dispatched(train_id)
|
|||||||
end
|
end
|
||||||
---@param train_id uint
|
---@param train_id uint
|
||||||
function interface_raise_train_dispatch_failed(train_id)
|
function interface_raise_train_dispatch_failed(train_id)
|
||||||
|
--this event is rare, it can only occur when a train is bypassing the depot and can't find a path to the provide station, that train is marked as unavailable but not dispatched
|
||||||
if on_train_dispatch_failed then
|
if on_train_dispatch_failed then
|
||||||
raise_event(on_train_dispatch_failed, {
|
raise_event(on_train_dispatch_failed, {
|
||||||
train_id = train_id,
|
train_id = train_id,
|
||||||
@@ -136,13 +137,19 @@ function interface_raise_train_dispatch_failed(train_id)
|
|||||||
end
|
end
|
||||||
---@param train_id uint
|
---@param train_id uint
|
||||||
---@param was_p_in_progress boolean
|
---@param was_p_in_progress boolean
|
||||||
|
---@param p_station_id uint
|
||||||
---@param was_r_in_progress boolean
|
---@param was_r_in_progress boolean
|
||||||
function interface_raise_train_failed_delivery(train_id, was_p_in_progress, was_r_in_progress)
|
---@param r_station_id uint
|
||||||
|
---@param manifest Manifest
|
||||||
|
function interface_raise_train_failed_delivery(train_id, was_p_in_progress, p_station_id, was_r_in_progress, r_station_id, manifest)
|
||||||
if on_train_failed_delivery then
|
if on_train_failed_delivery then
|
||||||
raise_event(on_train_failed_delivery, {
|
raise_event(on_train_failed_delivery, {
|
||||||
train_id = train_id,
|
train_id = train_id,
|
||||||
was_p_in_progress = was_p_in_progress,
|
was_p_in_progress = was_p_in_progress,
|
||||||
|
p_station_id = p_station_id,
|
||||||
was_r_in_progress = was_r_in_progress,
|
was_r_in_progress = was_r_in_progress,
|
||||||
|
r_station_id = r_station_id,
|
||||||
|
manifest = manifest,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user