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:
bbassieandClaude Opus 5.5 committed 2026-10-17 15:36:40 +00:00
1 parent ad779a8799
commit 0504fe15ed
6 files changed
+96 -30

No files matched your search

+26 -2
View File
@@ -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