Keep the local controller intact when it is not synced

With the controller off, a god or ghost player was still turned into a spectator while downloading, which threw away the local state the sync is meant to leave alone. Only spectate a player without a character when the controller is synced, and skip the ghost round trip when the ghost is the local state.

A ghost on an instance that syncs inventories but not the controller never received the stored character, so after respawning it uploaded an empty one over it. Respawn such a ghost straight away when there is a stored character to give it.

Clear the saved local controller when the player picks a temporary inventory after a failed download, otherwise a later download restores the stale controller over the temporary character. An empty download only gives a character when the controller is synced or the player was spectated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bbassieandClaude Opus 5.5 committed 2026-10-17 15:25:06 +00:00
1 parent 0e559cf000
commit c798b2a33f
5 files changed
+12 -3

No files matched your search

+7 -1
View File
@@ -987,10 +987,16 @@ function serialize.deserialize_player(player, serialized, components, local_cont
local state = local_controller
if restore_controller then
state = { controller = serialized.controller, ticks_to_respawn = serialized.ticks_to_respawn }
elseif state and state.controller == "ghost" and sync_inventories and serialized.character then
-- Respawn now, a ghost would drop the synced character and upload an empty one after respawning
state = { controller = "character" }
end
local target_controller = state and defines.controllers[state.controller]
if state and (player.controller_type ~= target_controller or state.controller == "ghost") then
if state and (
player.controller_type ~= target_controller
or restore_controller and state.controller == "ghost"
) then
if state.controller == "character" then
-- Create a character but do not destroy an existing one
ensure_character(player)