mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-12 23:04:52 +09:00
Restore recipe notifications a prefetched copy would leave cleared
A prefetched copy is sent without the save's list of cleared recipes, so its delta had only add, and a recipe cleared on the destination but not in the stored list stayed cleared where a download would give it its notification back. Without a current list the instance now sends the whole stored list marked full, and the save gives the recipes it has cleared that aren't in it their notification back, as a download's remove does. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
fe416da26c
commit
ca7caedfbe
3 files changed
+40
-10
No files matched your search
@@ -895,6 +895,7 @@ end
|
||||
--- @class CraftingNotificationDelta
|
||||
--- @field add string[]? Recipes cleared elsewhere that still have a notification here
|
||||
--- @field remove string[]? Recipes with a notification elsewhere that are cleared here
|
||||
--- @field full boolean? add is the whole stored list, sent without this save's (a prefetched copy)
|
||||
|
||||
--- @param player LuaPlayer
|
||||
--- @param serialized string Encoded delta against the state sent with the download request
|
||||
@@ -929,6 +930,23 @@ function serialize.deserialize_crafting_notifications(player, serialized)
|
||||
end
|
||||
end
|
||||
|
||||
-- A full delta has no remove: recipes cleared here that aren't in add get their notification back, as remove does
|
||||
if delta.full then
|
||||
local stored = {}
|
||||
for _, recipe_name in pairs(delta.add or {}) do
|
||||
stored[recipe_name] = true
|
||||
end
|
||||
local notified = {}
|
||||
for _, recipe in pairs(player.get_recipe_notifications()) do
|
||||
notified[recipe.name] = true
|
||||
end
|
||||
for recipe_name in pairs(enabled) do
|
||||
if not stored[recipe_name] and not notified[recipe_name] then
|
||||
player.add_recipe_notification(recipe_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return next(failed) and failed or nil
|
||||
end
|
||||
|
||||
|
||||
Reference in new issue
Block a user