From c8e54cd5636cac11b2047d1a36beeb522a702c7c Mon Sep 17 00:00:00 2001 From: Danielv123 Date: Wed, 15 May 2024 07:50:36 +0100 Subject: [PATCH] Fix crash loading mutiplayer map in singleplayer Caused by on_player_created not being called when loading a multiplayer map in singleplayer. For further discussion see $622 and https://forums.factorio.com/viewtopic.php?f=7&t=113497 --- plugins/inventory_sync/module/inventory_sync.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/inventory_sync/module/inventory_sync.lua b/plugins/inventory_sync/module/inventory_sync.lua index 96ead28a..d7e8483c 100644 --- a/plugins/inventory_sync/module/inventory_sync.lua +++ b/plugins/inventory_sync/module/inventory_sync.lua @@ -357,8 +357,14 @@ end -- Download inventory from controller inventory_sync.events[defines.events.on_player_joined_game] = function(event) - -- Send acquire request even if an active download is currently in plogress local player = game.get_player(event.player_index) + + -- It's possible Factorio doesn't invoke the on_player_created event when loading a save in single player + if not global.inventory_sync.players[player.name] then + create_player(player, false) + end + + -- Send acquire request even if an active download is currently in plogress inventory_sync.acquire(player, false) -- Clear active upload if it existsi