mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-13 15:14:52 +09:00
Merge uploads by the components they were serialized with
The controller merged uploads using the uploading instance's current config. An upload serialized under different settings, for example one sent from the save right after an admin turned on sync_inventories and restarted the instance, was then merged as if it held a character and wiped the stored one. Uploads now carry the components they were serialized with, the controller merges by those and drops the key before storing. The scenario keeps the components a player's synced session started with and serializes their upload with them, so changing the options while a player is online takes effect the next time they join. A player whose session lacks a component that is now synced downloads again even if the generation matches. Downloads snapshot the components when they start, so a change during a download can't mix two sets. A failed acquire unsyncs the player again regardless of the inventories setting, as before this branch. The god and dead player inventories move from the inventories component to the controller one, matching what the scenario syncs, which removes the special case in mergePlayerData. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8487c6d923
commit
b0e07ea73b
11 files changed
+150
-58
No files matched your search
@@ -730,6 +730,7 @@ end
|
||||
--- @field shortcuts table<string, boolean>?
|
||||
--- @field game_view_settings table<string, boolean>?
|
||||
--- @field ticks_to_respawn number?
|
||||
--- @field components SyncComponents Components this was serialized with
|
||||
--- @field character table<string, any>?
|
||||
--- @field inventories table<string, table>?
|
||||
--- @field hotbar table<string, string>?
|
||||
@@ -795,6 +796,23 @@ local function syncs(components, name)
|
||||
end
|
||||
serialize.syncs = syncs
|
||||
|
||||
local component_names = {
|
||||
"controller", "force", "appearance", "inventories", "logistics", "quick_bar", "settings", "recipe_notifications",
|
||||
}
|
||||
|
||||
--- True if a component synced in new_components was not synced in old_components
|
||||
--- @param old_components SyncComponents
|
||||
--- @param new_components SyncComponents
|
||||
--- @return boolean
|
||||
function serialize.newly_synced(old_components, new_components)
|
||||
for _, name in ipairs(component_names) do
|
||||
if syncs(new_components, name) and not syncs(old_components, name) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
--- @param player LuaPlayer
|
||||
--- @param failed_deserialization FailedDeserializationPlayerData
|
||||
--- @param components SyncComponents
|
||||
@@ -808,6 +826,7 @@ function serialize.serialize_player(player, failed_deserialization, components)
|
||||
local serialized = {
|
||||
generation = 0, -- Gets replaced later
|
||||
name = player.name,
|
||||
components = components,
|
||||
}
|
||||
|
||||
if sync_controller then
|
||||
|
||||
Reference in new issue
Block a user