Forward player data to the instance a player is switching to

An upload can carry destinationInstanceId. Once the upload is stored,
the controller sends the stored data, the upload merged with its copy,
in a PrefetchEvent to that instance, if it is another running instance
with player_sync enabled. No lock is taken or released. A failed send is
logged and doesn't fail the upload.

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:13 +11:00
1 parent 4128f75328
commit b8c1e89dff
4 files changed
+124 -2

No files matched your search

+26 -1
View File
@@ -29,6 +29,7 @@ export type IpcPlayerData = {
recipe_notifications?: string,
// Components the upload was serialized with, all when missing
components?: Record<string, boolean> | unknown[],
destination_instance_id?: number, // set_destination's instance, on the leave upload only; not player data
}
// Marks tombstones in player_sync.json
@@ -268,6 +269,7 @@ export class UploadRequest {
public instanceId: number,
public playerName: string,
public playerData: IpcPlayerData,
public destinationInstanceId?: number,
) {
}
@@ -275,10 +277,33 @@ export class UploadRequest {
"instanceId": Type.Integer(),
"playerName": Type.String(),
"playerData": jsonPlayerData,
"destinationInstanceId": Type.Optional(Type.Integer()),
});
static fromJSON(json: Static<typeof UploadRequest.jsonSchema>) {
return new this(json.instanceId, json.playerName, json.playerData as IpcPlayerData);
return new this(json.instanceId, json.playerName, json.playerData as IpcPlayerData, json.destinationInstanceId);
}
}
/** The stored data of a player switching to the instance it is sent to, so the join there needs no download */
export class PrefetchEvent {
declare ["constructor"]: typeof PrefetchEvent;
static type = "event" as const;
static src = "controller" as const;
static dst = "instance" as const;
static plugin = "player_sync" as const;
constructor(
public playerData: IpcPlayerData,
) {
}
static jsonSchema = Type.Object({
"playerData": jsonPlayerData,
});
static fromJSON(json: Static<typeof PrefetchEvent.jsonSchema>): PrefetchEvent {
return new this(json.playerData as IpcPlayerData);
}
}