From bad86a5ff237e92a2778edb14bb6ba97b9c43ba4 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Wed, 29 Sep 2021 01:30:44 +0200 Subject: [PATCH] Fix inventory_sync uploading editor mode The serialization and deserialization of editor mode is not supported by the current code, and while the download correctly checked for the player being in editor mode, the upload did not check for the player being in editor mode causing players in editor mode to break. Fix by adding check in upload_inventory. --- plugins/inventory_sync/module/upload_inventory.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plugins/inventory_sync/module/upload_inventory.lua b/plugins/inventory_sync/module/upload_inventory.lua index d1c4cf23..5ab6051e 100644 --- a/plugins/inventory_sync/module/upload_inventory.lua +++ b/plugins/inventory_sync/module/upload_inventory.lua @@ -3,6 +3,18 @@ local serialize = require("modules/inventory_sync/serialize") local save_crafts = require("modules/inventory_sync/save_crafts") local function upload_inventory(player, player_record) + -- Editor mode is not supported. + if player.controller_type == defines.controllers.editor then + player.toggle_map_editor() + end + + if player.controller_type == defines.controllers.editor then + log("ERROR: Inventory sync failed to upload, unable to switch " .. player.name .. " out of editor mode") + player.print("ERROR: Inventory sync failed to upload, unable to switch out of editor mode") + global.inventory_sync.active_uploads[player.name] = nil + return + end + local serialized_player = serialize.serialize_player(player) serialized_player.generation = player_record.generation