mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-15 23: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
@@ -1,6 +1,6 @@
|
||||
import type { ControllerPluginContext, InstanceRecord } from "@clusterio/controller";
|
||||
import type { IpcPlayerData } from "./messages.js";
|
||||
import { enabledComponents, mergePlayerData } from "./components.js";
|
||||
import { mergePlayerData } from "./components.js";
|
||||
|
||||
import fs from "node:fs/promises";
|
||||
import path from "path";
|
||||
@@ -138,8 +138,7 @@ export default async function(context: ControllerPluginContext) {
|
||||
|
||||
controller.handle(msg.UploadRequest, async (request: msg.UploadRequest) => {
|
||||
let { instanceId, playerName, playerData } = request;
|
||||
let instanceConfig = controller.instances.get(instanceId)!.config;
|
||||
let instanceName = instanceConfig.get("instance.name");
|
||||
let instanceName = controller.instances.get(instanceId)!.config.get("instance.name");
|
||||
let store = true;
|
||||
let acquisitionRecord = acquiredPlayers.get(playerName);
|
||||
if (!acquisitionRecord) {
|
||||
@@ -167,9 +166,7 @@ export default async function(context: ControllerPluginContext) {
|
||||
|
||||
if (store) {
|
||||
logger.verbose(`Received player data for ${playerName} from ${instanceName}`);
|
||||
playerDatastore.set(
|
||||
playerName, mergePlayerData(oldPlayerData, playerData, enabledComponents(instanceConfig))
|
||||
);
|
||||
playerDatastore.set(playerName, mergePlayerData(oldPlayerData, playerData));
|
||||
playerDatastoreDirty = true;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user