improved SE compat

This commit is contained in:
mamoniot
2022-12-23 20:48:20 -05:00
parent c1d2a3dab9
commit 96baf62c39
6 changed files with 5 additions and 9 deletions

View File

@@ -21,7 +21,6 @@
---@field public economy Economy
---@field public each_refuelers {[uint]: true}
---@field public active_alerts {[uint]: {[1]: LuaTrain, [2]: int}}?
---@field public se_tele_old_id {[string]: uint}
---@class Station
---@field public entity_stop LuaEntity
@@ -150,9 +149,6 @@ function init_global()
global.each_refuelers = {}
IS_SE_PRESENT = remote.interfaces["space-exploration"] ~= nil
if IS_SE_PRESENT then
global.se_tele_old_id = {}
end
end
---@param v string

View File

@@ -695,7 +695,6 @@ local function setup_se_compat()
if not train then return end
--NOTE: IMPORTANT, until se_on_train_teleport_finished_event is called map_data.trains[old_id] will reference an invalid train entity; our events have either been set up to account for this or should be impossible to trigger until teleportation is finished
train.se_is_being_teleported = true
map_data.se_tele_old_id[train_unique_identifier] = old_id
interface_raise_train_teleport_started(old_id)
end)
---@param event {}
@@ -711,8 +710,7 @@ local function setup_se_compat()
--NOTE: event.old_train_id_1 from this event is useless, it's for one of the many transient trains SE spawns while teleporting the old train, only se_on_train_teleport_started_event returns the correct old train id
--NOTE: please SE dev if you read this fix the issue where se_on_train_teleport_finished_event is returning the wrong old train id
local old_id = map_data.se_tele_old_id[train_unique_identifier]
map_data.se_tele_old_id[train_unique_identifier] = nil
local old_id = event.old_train_id_1
local train = map_data.trains[old_id]
if not train then return end

View File

@@ -121,6 +121,7 @@ local migrations_table = {
map_data.tick_data = {}
map_data.each_refuelers = {}
map_data.se_tele_old_id = nil
for k, comb in pairs(map_data.to_comb) do
local control = get_comb_control(comb)