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.
This commit is contained in:
Hornwitser committed 2021-10-01 01:52:18 +02:00
1 parent 034ca4c250
commit bad86a5ff2
1 file changed
+12
@@ -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