mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-13 23:14:53 +09:00
Send only recipe notification changes on inventory download
Lua includes its current cleared recipe list in the download request. The instance plugin diffs it against the stored list and sends back the names to add and remove instead of the full list. Lua rebuilds the full list from the snapshot kept in the download record and runs the existing deserializer, so the end state is unchanged. Also stop the serializer from appending to the stored failed recipe list in place, which grew the list on every upload without a download in between. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
7987a5d925
commit
0d6beeba47
6 files changed
+210
-10
No files matched your search
@@ -111,6 +111,13 @@ function inventory_sync.deserialize_player(player, finished_record)
|
||||
-- Deserialize downloaded player data
|
||||
local serialized_player = compat.json_to_table(finished_record.data)
|
||||
assert(type(serialized_player) == "table", "wrong type for serialized_player")
|
||||
if serialized_player.recipe_notifications_delta then
|
||||
serialized_player.recipe_notifications = serialize.apply_crafting_notification_delta(
|
||||
assert(finished_record.recipe_notifications, "recipe notification delta without snapshot"),
|
||||
serialized_player.recipe_notifications_delta
|
||||
)
|
||||
serialized_player.recipe_notifications_delta = nil
|
||||
end
|
||||
script_data.failed_deserialization[player.name] = serialize.deserialize_player(player, serialized_player)
|
||||
|
||||
-- Restore player position and driving state
|
||||
@@ -441,8 +448,14 @@ function inventory_sync.initiate_inventory_download(player, player_record, gener
|
||||
local script_data = get_script_data()
|
||||
script_data.active_downloads[player.name] = record
|
||||
|
||||
-- The plugin only sends back what differs from the current notification state
|
||||
record.recipe_notifications = serialize.crafting_notification_snapshot(
|
||||
player, script_data.failed_deserialization[player.name]
|
||||
)
|
||||
|
||||
clusterio_api.send_json("inventory_sync_download", {
|
||||
player_name = player.name
|
||||
player_name = player.name,
|
||||
recipe_notifications = record.recipe_notifications,
|
||||
})
|
||||
|
||||
-- If this is a synced player turn them into a spectator while the
|
||||
|
||||
Reference in new issue
Block a user