From 96baf62c39b78a04bbd548c54414d46b7aaacf17 Mon Sep 17 00:00:00 2001 From: mamoniot Date: Fri, 23 Dec 2022 20:48:20 -0500 Subject: [PATCH] improved SE compat --- TODO | 1 - cybersyn/changelog.txt | 2 ++ cybersyn/info.json | 2 +- cybersyn/scripts/global.lua | 4 ---- cybersyn/scripts/main.lua | 4 +--- cybersyn/scripts/migrations.lua | 1 + 6 files changed, 5 insertions(+), 9 deletions(-) diff --git a/TODO b/TODO index aa08128..01dcfc5 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,4 @@ bugs: - fix crash in submitted massively modded world check for bugs in new player's submitted world find se bug https://mods.factorio.com/mod/cybersyn/discussion/639d1ea26f00ecfa7b048da0 https://mods.factorio.com/mod/cybersyn/discussion/63a52e54be4341bccc0446f8 diff --git a/cybersyn/changelog.txt b/cybersyn/changelog.txt index d012120..e260049 100644 --- a/cybersyn/changelog.txt +++ b/cybersyn/changelog.txt @@ -12,6 +12,8 @@ Date: 2022-12-23 - Made several alerts persistent - Fixed bug with depot priority not working - Fixed a memory leak relating to train layouts + - Fixed a rare crash when building stations + - Slightly improved compat with SE thanks to a bugfix in 0.6.94 --------------------------------------------------------------------------------------------------- Version: 1.1.7 Date: 2022-12-17 diff --git a/cybersyn/info.json b/cybersyn/info.json index c3f06d2..aff5c6b 100644 --- a/cybersyn/info.json +++ b/cybersyn/info.json @@ -8,7 +8,7 @@ "dependencies": [ "base", "flib >= 0.6.0", - "? space-exploration >= 0.6.90", + "? space-exploration >= 0.6.94", "? miniloader", "? nullius", "? pypostprocessing" diff --git a/cybersyn/scripts/global.lua b/cybersyn/scripts/global.lua index a267061..5ddba18 100644 --- a/cybersyn/scripts/global.lua +++ b/cybersyn/scripts/global.lua @@ -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 diff --git a/cybersyn/scripts/main.lua b/cybersyn/scripts/main.lua index 1456ee7..8a4f804 100644 --- a/cybersyn/scripts/main.lua +++ b/cybersyn/scripts/main.lua @@ -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 diff --git a/cybersyn/scripts/migrations.lua b/cybersyn/scripts/migrations.lua index 737448d..27bd7b3 100644 --- a/cybersyn/scripts/migrations.lua +++ b/cybersyn/scripts/migrations.lua @@ -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)