Sync personal roboport and movement bonus toggles in inventory_sync

The toggle state of the personal roboport and equipment movement bonus
shortcuts lives on the player and was not part of the serialized player
data, so it reset when switching instances.

Closes #898

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
bbassieandClaude Fable 5.1 committed 2026-09-05 22:13:12 +00:00
1 parent e09e1c5f80
commit 75ac8bb491
2 files changed
+36

No files matched your search

+1
View File
@@ -12,6 +12,7 @@ export type IpcPlayerData = {
force: string,
cheat_mode: boolean,
flashlight: boolean,
shortcuts?: Record<string, boolean>,
ticks_to_respawn?: number,
character?: any,
inventories?: any,
@@ -592,6 +592,7 @@ end
--- @field force string
--- @field cheat_mode boolean
--- @field flashlight boolean
--- @field shortcuts table<string, boolean>?
--- @field ticks_to_respawn number
--- @field character table<string, any>?
--- @field inventories table<string, table>?
@@ -601,6 +602,36 @@ end
--- @field crafting_queue table?
--- @field recipe_notifications string?
--- Toggle shortcuts whose state is stored on the player and not covered by any other synced data
local synced_shortcuts = {
"toggle-personal-roboport",
"toggle-equipment-movement-bonus",
}
--- @param player LuaPlayer
--- @return table<string, boolean>
function serialize.serialize_shortcuts(player)
local shortcut_prototypes = compat.prototypes.shortcut
local shortcuts = {}
for _, name in ipairs(synced_shortcuts) do
if shortcut_prototypes[name] then
shortcuts[name] = player.is_shortcut_toggled(name)
end
end
return shortcuts
end
--- @param player LuaPlayer
--- @param serialized table<string, boolean>
function serialize.deserialize_shortcuts(player, serialized)
local shortcut_prototypes = compat.prototypes.shortcut
for name, toggled in pairs(serialized) do
if shortcut_prototypes[name] then
player.set_shortcut_toggled(name, toggled)
end
end
end
--- @param player LuaPlayer
--- @param failed_deserialization FailedDeserializationPlayerData
--- @return SerializedPlayerData
@@ -616,6 +647,7 @@ function serialize.serialize_player(player, failed_deserialization)
force = player.force.name,
cheat_mode = player.cheat_mode,
flashlight = player.is_flashlight_enabled(),
shortcuts = serialize.serialize_shortcuts(player),
ticks_to_respawn = player.ticks_to_respawn,
}
@@ -790,6 +822,9 @@ function serialize.deserialize_player(player, serialized)
else
player.disable_flashlight()
end
if serialized.shortcuts then
serialize.deserialize_shortcuts(player, serialized.shortcuts)
end
-- Deserialize character
if player.character then