mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-24 08:23:12 +09:00
research_sync: cluster research queue on the controller
- QueueUpdateEvent, QueueEvent and QueueSyncRequest messages. - The controller keeps one queue (max 7 names) in research_queue.json, saved with the other data. - An update that changes the queue replaces it and is broadcast as QueueEvent; an equal update is ignored. - QueueSyncRequest returns the queue and seeds it from the request when the queue is empty. - A finished technology (completing contribution, advancing FinishedEvent, technology sync) drops its first queue entry without a broadcast. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
43243eab86
commit
e3099e1e05
4 files changed
+265
No files matched your search
@@ -136,3 +136,76 @@ export class SyncTechnologiesRequest {
|
||||
|
||||
static Response = lib.jsonArray(TechnologySync);
|
||||
}
|
||||
|
||||
export class QueueUpdateEvent {
|
||||
declare ["constructor"]: typeof QueueUpdateEvent;
|
||||
static type = "event" as const;
|
||||
static src = "instance" as const;
|
||||
static dst = "controller" as const;
|
||||
static plugin = "research_sync" as const;
|
||||
|
||||
constructor(
|
||||
public queue: string[],
|
||||
public player: string | null,
|
||||
) {
|
||||
}
|
||||
|
||||
static jsonSchema = Type.Object({
|
||||
"queue": Type.Array(Type.String()),
|
||||
"player": Type.Union([Type.String(), Type.Null()]),
|
||||
});
|
||||
|
||||
static fromJSON(json: Static<typeof QueueUpdateEvent.jsonSchema>): QueueUpdateEvent {
|
||||
return new this(json.queue, json.player);
|
||||
}
|
||||
}
|
||||
|
||||
export class QueueEvent {
|
||||
declare ["constructor"]: typeof QueueEvent;
|
||||
static type = "event" as const;
|
||||
static src = "controller" as const;
|
||||
static dst = "instance" as const;
|
||||
static plugin = "research_sync" as const;
|
||||
|
||||
constructor(
|
||||
public queue: string[],
|
||||
public player: string | null,
|
||||
public instance: string,
|
||||
) {
|
||||
}
|
||||
|
||||
static jsonSchema = Type.Object({
|
||||
"queue": Type.Array(Type.String()),
|
||||
"player": Type.Union([Type.String(), Type.Null()]),
|
||||
"instance": Type.String(),
|
||||
});
|
||||
|
||||
static fromJSON(json: Static<typeof QueueEvent.jsonSchema>): QueueEvent {
|
||||
return new this(json.queue, json.player, json.instance);
|
||||
}
|
||||
}
|
||||
|
||||
export class QueueSyncRequest {
|
||||
declare ["constructor"]: typeof QueueSyncRequest;
|
||||
static type = "request" as const;
|
||||
static src = "instance" as const;
|
||||
static dst = "controller" as const;
|
||||
static plugin = "research_sync" as const;
|
||||
|
||||
constructor(
|
||||
public queue: string[] | null,
|
||||
public player: string | null,
|
||||
) {
|
||||
}
|
||||
|
||||
static jsonSchema = Type.Object({
|
||||
"queue": Type.Union([Type.Array(Type.String()), Type.Null()]),
|
||||
"player": Type.Union([Type.String(), Type.Null()]),
|
||||
});
|
||||
|
||||
static fromJSON(json: Static<typeof QueueSyncRequest.jsonSchema>): QueueSyncRequest {
|
||||
return new this(json.queue, json.player);
|
||||
}
|
||||
|
||||
static Response = lib.plainJson(Type.Array(Type.String()));
|
||||
}
|
||||
Reference in new issue
Block a user