From e20ef82eb5d72be377213bec69f455edb973a2e8 Mon Sep 17 00:00:00 2001 From: mamoniot Date: Sun, 30 Apr 2023 21:00:50 -0400 Subject: [PATCH 1/5] added check for poisoned migrations --- cybersyn/scripts/migrations.lua | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/cybersyn/scripts/migrations.lua b/cybersyn/scripts/migrations.lua index 94488ac..90ed9df 100644 --- a/cybersyn/scripts/migrations.lua +++ b/cybersyn/scripts/migrations.lua @@ -297,7 +297,7 @@ local migrations_table = { end end, ["1.2.14"] = function() - ---@type MapData + ---@type MapData local map_data = global map_data.manager = { @@ -328,12 +328,21 @@ function on_config_changed(data) global.tick_data = {} global.perf_cache = {} - flib_migration.on_config_changed(data, migrations_table) - - for i, v in pairs(global.manager.players) do - manager_gui.reset_player(i, v) + if global.manager then + for i, v in pairs(global.manager.players) do + manager_gui.reset_player(i, v) + end + else + global.manager = { + players = {}, + } + for i, v in pairs(game.players) do + manager_gui.on_player_created({player_index = i}) + end end + flib_migration.on_config_changed(data, migrations_table) + IS_SE_PRESENT = remote.interfaces["space-exploration"] ~= nil if IS_SE_PRESENT and not global.se_tele_old_id then global.se_tele_old_id = {} From 59eb580eb562d36eeb1659fe3aa4831f99bf2f57 Mon Sep 17 00:00:00 2001 From: mamoniot Date: Mon, 1 May 2023 06:26:20 -0400 Subject: [PATCH 2/5] moved migration logic into manager --- cybersyn/changelog.txt | 1 + cybersyn/info.lua | 2 +- cybersyn/scripts/gui/main.lua | 13 ++++++++++--- cybersyn/scripts/migrations.lua | 13 ------------- 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/cybersyn/changelog.txt b/cybersyn/changelog.txt index b909d26..11e4a85 100644 --- a/cybersyn/changelog.txt +++ b/cybersyn/changelog.txt @@ -4,6 +4,7 @@ Date: 2023-4-30 Bugfixes: - Fixed UPS spikes in Space Exploration related to expensive remote calls into their modding interface. - Fixed missing cybersyn manager translation key. + - Added a fix for a crash related to using the beta branch of cybersyn --------------------------------------------------------------------------------------------------- Version: 1.2.14 Date: 2023-4-30 diff --git a/cybersyn/info.lua b/cybersyn/info.lua index 90cefac..639a3a2 100644 --- a/cybersyn/info.lua +++ b/cybersyn/info.lua @@ -3,4 +3,4 @@ --- It is used in migrations.lua to determine if any migrations need to be run for beta testers. --- It is expected these are only meaningful between releases during beta testing. --- It should be set to nil for any release version. -return 2 +return nil diff --git a/cybersyn/scripts/gui/main.lua b/cybersyn/scripts/gui/main.lua index 277810c..ac3df56 100644 --- a/cybersyn/scripts/gui/main.lua +++ b/cybersyn/scripts/gui/main.lua @@ -50,9 +50,9 @@ function manager_gui.on_lua_shortcut(e) if e.prototype_name == "cybersyn-toggle-gui" or e.input_name == "cybersyn-toggle-gui" or e.element then if e.element then if e.element.name == "manager_window" then - manager.wrapper(e, manager.handle.manager_toggle) + manager.wrapper(e, manager.handle.manager_toggle) end - else + else manager.wrapper(e, manager.handle.manager_toggle) end end @@ -147,7 +147,14 @@ end function manager_gui.on_migration() - init_items(global.manager) + if global.manager then + for i, v in pairs(global.manager.players) do + manager_gui.reset_player(i, v) + end + init_items(global.manager) + else + manager_gui.on_init() + end end function manager_gui.on_init() diff --git a/cybersyn/scripts/migrations.lua b/cybersyn/scripts/migrations.lua index 90ed9df..f004736 100644 --- a/cybersyn/scripts/migrations.lua +++ b/cybersyn/scripts/migrations.lua @@ -328,19 +328,6 @@ function on_config_changed(data) global.tick_data = {} global.perf_cache = {} - if global.manager then - for i, v in pairs(global.manager.players) do - manager_gui.reset_player(i, v) - end - else - global.manager = { - players = {}, - } - for i, v in pairs(game.players) do - manager_gui.on_player_created({player_index = i}) - end - end - flib_migration.on_config_changed(data, migrations_table) IS_SE_PRESENT = remote.interfaces["space-exploration"] ~= nil From f0d8c2e430c9e0d5e733c5fb23f82440643f4985 Mon Sep 17 00:00:00 2001 From: mamoniot Date: Mon, 1 May 2023 06:35:42 -0400 Subject: [PATCH 3/5] added additional fixes to migrations --- cybersyn/scripts/gui/main.lua | 10 +++------- cybersyn/scripts/migrations.lua | 14 ++++++++------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/cybersyn/scripts/gui/main.lua b/cybersyn/scripts/gui/main.lua index ac3df56..7628c42 100644 --- a/cybersyn/scripts/gui/main.lua +++ b/cybersyn/scripts/gui/main.lua @@ -147,14 +147,10 @@ end function manager_gui.on_migration() - if global.manager then - for i, v in pairs(global.manager.players) do - manager_gui.reset_player(i, v) - end - init_items(global.manager) - else - manager_gui.on_init() + for i, v in pairs(global.manager.players) do + manager_gui.reset_player(i, v) end + init_items(global.manager) end function manager_gui.on_init() diff --git a/cybersyn/scripts/migrations.lua b/cybersyn/scripts/migrations.lua index f004736..ce39374 100644 --- a/cybersyn/scripts/migrations.lua +++ b/cybersyn/scripts/migrations.lua @@ -296,15 +296,17 @@ local migrations_table = { end end end, - ["1.2.14"] = function() + ["1.2.15"] = function() ---@type MapData local map_data = global - map_data.manager = { - players = {}, - } - for i, v in pairs(game.players) do - manager_gui.on_player_created({player_index = i}) + if not global.manager then + global.manager = { + players = {}, + } + for i, v in pairs(game.players) do + manager_gui.on_player_created({player_index = i}) + end end for _, e in pairs(map_data.refuelers) do From 7b57ffb276b85fed2d626d4f9eda01e305684adf Mon Sep 17 00:00:00 2001 From: mamoniot Date: Mon, 1 May 2023 06:38:15 -0400 Subject: [PATCH 4/5] improved migrations --- cybersyn/scripts/migrations.lua | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/cybersyn/scripts/migrations.lua b/cybersyn/scripts/migrations.lua index ce39374..51d406a 100644 --- a/cybersyn/scripts/migrations.lua +++ b/cybersyn/scripts/migrations.lua @@ -310,16 +310,22 @@ local migrations_table = { end for _, e in pairs(map_data.refuelers) do - e.network_mask = e.network_flag - e.network_flag = nil + if e.network_flag then + e.network_mask = e.network_flag + e.network_flag = nil + end end for _, e in pairs(map_data.stations) do - e.network_mask = e.network_flag - e.network_flag = nil + if e.network_flag then + e.network_mask = e.network_flag + e.network_flag = nil + end end for _, e in pairs(map_data.trains) do - e.network_mask = e.network_flag - e.network_flag = nil + if e.network_flag then + e.network_mask = e.network_flag + e.network_flag = nil + end end end, } From fc4dad06d920ce669573569b321a2300fe317210 Mon Sep 17 00:00:00 2001 From: mamoniot Date: Mon, 1 May 2023 06:39:25 -0400 Subject: [PATCH 5/5] upped version number --- cybersyn/info.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cybersyn/info.json b/cybersyn/info.json index e1a036f..06ebe55 100644 --- a/cybersyn/info.json +++ b/cybersyn/info.json @@ -1,6 +1,6 @@ { "name": "cybersyn", - "version": "1.2.14", + "version": "1.2.15", "title": "Project Cybersyn", "author": "Mami", "factorio_version": "1.1",