mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-14 07:24:52 +09:00
Let the instance decide the components of a download
The scenario no longer sends its components with the download request. The instance strips the download by its own config and sends the components it used with the first chunk. If they differ from the ones the scenario started the download with, because the config changed in between, the scenario restarts the download. A pending download is now marked with sync_in_progress instead of clearing dirty while spectating, and it is set for every download rather than only when inventories are synced. Uploads are skipped while it is set, so a player who leaves during a download with inventories off no longer uploads their stale state. SyncComponent names the components in the Lua annotations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ad779a8799
commit
0504fe15ed
6 files changed
+96
-30
No files matched your search
@@ -963,21 +963,45 @@ function serialize.deserialize_game_view_settings(player, serialized)
|
||||
end
|
||||
end
|
||||
|
||||
--- @alias SyncComponent
|
||||
--- | "controller"
|
||||
--- | "force"
|
||||
--- | "appearance"
|
||||
--- | "inventories"
|
||||
--- | "logistics"
|
||||
--- | "quick_bar"
|
||||
--- | "settings"
|
||||
--- | "recipe_notifications"
|
||||
|
||||
--- Components which are synced, nil when all of them are
|
||||
--- @alias SyncComponents table<string, boolean>?
|
||||
--- @alias SyncComponents table<SyncComponent, boolean>?
|
||||
|
||||
--- @param components SyncComponents
|
||||
--- @param name string
|
||||
--- @param name SyncComponent
|
||||
--- @return boolean
|
||||
local function syncs(components, name)
|
||||
return components == nil or components[name] == true
|
||||
end
|
||||
serialize.syncs = syncs
|
||||
|
||||
--- @type SyncComponent[]
|
||||
local component_names = {
|
||||
"controller", "force", "appearance", "inventories", "logistics", "quick_bar", "settings", "recipe_notifications",
|
||||
}
|
||||
|
||||
--- True if the same components are synced in both
|
||||
--- @param a SyncComponents
|
||||
--- @param b SyncComponents
|
||||
--- @return boolean
|
||||
function serialize.same_components(a, b)
|
||||
for _, name in ipairs(component_names) do
|
||||
if syncs(a, name) ~= syncs(b, name) then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
--- True if a component synced in new_components was not synced in old_components
|
||||
--- @param old_components SyncComponents
|
||||
--- @param new_components SyncComponents
|
||||
|
||||
Reference in new issue
Block a user