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:
ILLISISandClaude Opus 5.5 committed 2026-10-20 12:23:38 +11:00
1 parent fe416da26c
commit ca7caedfbe
3 files changed
+40 -10

No files matched your search

+14 -5
View File
@@ -54,10 +54,15 @@ describe("player_sync", function() {
await apply(playerData, await encode(["a"]));
assert.deepEqual(await decode(playerData.recipe_notifications), {});
});
it("should add everything without a current list", async function() {
it("should send the whole list marked full without a current list", async function() {
const playerData = { name: "test", recipe_notifications: await encode(["a"]) };
await apply(playerData, undefined);
assert.deepEqual(await decode(playerData.recipe_notifications), { add: ["a"] });
assert.deepEqual(await decode(playerData.recipe_notifications), { add: ["a"], full: true });
});
it("should mark an empty list full without a current list", async function() {
const playerData = { name: "test", recipe_notifications: await encode([]) };
await apply(playerData, undefined);
assert.deepEqual(await decode(playerData.recipe_notifications), { full: true });
});
it("should do nothing without stored notifications", async function() {
const playerData = { name: "test" };
@@ -118,10 +123,12 @@ describe("player_sync", function() {
["/sc player_sync.download_inventory('test',nil,0,0)"]
);
});
it("should send everything as a delta when no snapshot was given", async function() {
it("should send everything as a full delta when no snapshot was given", async function() {
respondWith({ generation: 1, name: "test", recipe_notifications: await encode(["a"]) });
await download({ player_name: "test" });
const expected = { generation: 1, name: "test", recipe_notifications: await encode({ add: ["a"] }) };
const expected = {
generation: 1, name: "test", recipe_notifications: await encode({ add: ["a"], full: true }),
};
assert.deepEqual(instance.server.rconCommands, [downloadCommand(expected)]);
});
it("should send a delta when a snapshot was given", async function() {
@@ -275,7 +282,9 @@ describe("player_sync", function() {
it("should send prefetch_inventory chunks with the generation and the full recipe list", async function() {
await prefetch({ generation: 3, name: "test", recipe_notifications: await encode(["a"]) });
const expected = { generation: 3, name: "test", recipe_notifications: await encode({ add: ["a"] }) };
const expected = {
generation: 3, name: "test", recipe_notifications: await encode({ add: ["a"], full: true }),
};
assert.ok(instance.server.rconCommands.length > 1, "more than one chunk");
assert.deepEqual(instance.server.rconCommands, prefetchCommands(expected));
});