mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-15 15:24:52 +09:00
Merge uploads by the components they were serialized with
The controller merged uploads using the uploading instance's current config. An upload serialized under different settings, for example one sent from the save right after an admin turned on sync_inventories and restarted the instance, was then merged as if it held a character and wiped the stored one. Uploads now carry the components they were serialized with, the controller merges by those and drops the key before storing. The scenario keeps the components a player's synced session started with and serializes their upload with them, so changing the options while a player is online takes effect the next time they join. A player whose session lacks a component that is now synced downloads again even if the generation matches. Downloads snapshot the components when they start, so a change during a download can't mix two sets. A failed acquire unsyncs the player again regardless of the inventories setting, as before this branch. The god and dead player inventories move from the inventories component to the controller one, matching what the scenario syncs, which removes the special case in mergePlayerData. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8487c6d923
commit
b0e07ea73b
11 files changed
+150
-58
No files matched your search
@@ -5,6 +5,7 @@ import path from "node:path";
|
||||
import * as lib from "@clusterio/lib";
|
||||
import * as mock from "../../../test/mock.js";
|
||||
import controllerEntrypoint from "../dist/node/controller.js";
|
||||
import { components as allComponents } from "../dist/node/components.js";
|
||||
import { plugin as info } from "../dist/node/index.js";
|
||||
import { DatabaseStatsRequest, DownloadRequest, UploadRequest } from "../dist/node/messages.js";
|
||||
|
||||
@@ -75,14 +76,15 @@ describe("player_sync controller", function() {
|
||||
.playerData;
|
||||
}
|
||||
|
||||
it("should store the upload as is when everything is synced", async function() {
|
||||
it("should store the upload as is when it has no components", async function() {
|
||||
const playerData = { generation: 2, name: "test", force: "enemy", tag: "uploaded" };
|
||||
assert.deepEqual(await upload(playerData), playerData);
|
||||
});
|
||||
it("should keep stored fields the uploading instance does not sync", async function() {
|
||||
disabled = ["force"];
|
||||
it("should merge by the payload's components and ignore the instance config", async function() {
|
||||
disabled = ["appearance"];
|
||||
const components = Object.fromEntries(Object.keys(allComponents).map(c => [c, c !== "force"]));
|
||||
assert.deepEqual(
|
||||
await upload({ generation: 2, name: "test", tag: "uploaded" }),
|
||||
await upload({ generation: 2, name: "test", tag: "uploaded", components }),
|
||||
{ generation: 2, name: "test", force: "player", tag: "uploaded" },
|
||||
);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user