mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-16 23:30:41 +09:00
Handle create_character failures in inventory sync (#975)
ensure_character asserted on player.create_character() returning false without any context (#912). The most likely trigger is the player being physically inside a space platform hub (or otherwise stuck in remote view) on the destination server: the character in the hub is destroyed while downloading and the god controller ends up on the platform surface where a character can not be created. - Explicitly exit remote view and move the god controller off platform surfaces before create_character; restore_position re-enters the platform - Include controller/surface/connection state in the error message - On deserialization failure treat the player as a temporary inventory (sync = false) so the incomplete state is not uploaded over synced data - Release the acquisition on leave when nothing is uploaded so the player is not left "busy" on other instances Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b5a0d43c96
commit
1c5210c210
2 files changed
+49
-4
No files matched your search
@@ -314,15 +314,20 @@ function inventory_sync.sync_player(acquire_response)
|
||||
end
|
||||
|
||||
function inventory_sync.finish_download(player, finished_record)
|
||||
local script_data = get_script_data()
|
||||
script_data.finished_downloads[player.name] = nil
|
||||
local player_record = script_data.players[player.name]
|
||||
|
||||
local status, result = xpcall(inventory_sync.deserialize_player, debug.traceback, player, finished_record)
|
||||
if not status then
|
||||
log("ERROR: Deserializing player " .. player.name .. " failed: " .. result)
|
||||
player.print("ERROR: Deserializing player data failed: " .. result)
|
||||
-- Treat this as a temporary inventory so the incomplete state is not uploaded over the synced data
|
||||
player_record.dirty = true
|
||||
player_record.sync = false
|
||||
return
|
||||
end
|
||||
local script_data = get_script_data()
|
||||
script_data.finished_downloads[player.name] = nil
|
||||
|
||||
local player_record = script_data.players[player.name]
|
||||
player_record.dirty = true
|
||||
player_record.sync = true
|
||||
player_record.generation = finished_record.generation
|
||||
@@ -380,6 +385,8 @@ inventory_sync.events[defines.events.on_pre_player_left_game] = function(event)
|
||||
end
|
||||
|
||||
if not player_record.dirty or not player_record.sync then
|
||||
-- Nothing to upload, release the acquisition so other instances are not blocked
|
||||
clusterio_api.send_json("inventory_sync_release", { player_name = player.name })
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
Reference in new issue
Block a user