mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-17 23:33:12 +09:00
Merge pull request #1188 from bbassie/fix/research-queue-message
Print only what changed in the research queue chat line
This commit is contained in:
1 parent
7cf9cf8d3e
commit
bd9c4a5fea
7 files changed
+209
-28
No files matched your search
@@ -8,6 +8,7 @@ import {
|
||||
SyncTechnologiesRequest,
|
||||
QueueUpdateEvent,
|
||||
QueueEvent,
|
||||
QueueChange,
|
||||
QueueSyncRequest,
|
||||
} from "./messages.js";
|
||||
|
||||
@@ -22,6 +23,7 @@ type IpcFinished = {
|
||||
level: number,
|
||||
};
|
||||
type IpcQueue = { queue: unknown, player?: string };
|
||||
type ApplyQueue = { queue: string[], instance?: string, player?: string, changes?: QueueChange[] };
|
||||
|
||||
export default async function(context: InstancePluginContext) {
|
||||
const { instance, host, logger, plugin } = context;
|
||||
@@ -49,7 +51,7 @@ export default async function(context: InstancePluginContext) {
|
||||
return Array.isArray(v) ? v : [];
|
||||
}
|
||||
|
||||
async function applyQueue(data: { queue: string[], instance?: string, player?: string }) {
|
||||
async function applyQueue(data: ApplyQueue) {
|
||||
await sendOrderedRcon(`/sc research_sync.apply_queue("${lib.escapeString(JSON.stringify(data))}")`, true);
|
||||
}
|
||||
|
||||
@@ -177,13 +179,16 @@ export default async function(context: InstancePluginContext) {
|
||||
if (!syncStarted || !["starting", "running"].includes(instance.status)) {
|
||||
return;
|
||||
}
|
||||
let data: { queue: string[], instance?: string, player?: string } = { queue: event.queue };
|
||||
let data: ApplyQueue = { queue: event.queue };
|
||||
if (event.instance !== null) {
|
||||
data.instance = event.instance;
|
||||
}
|
||||
if (event.player !== null) {
|
||||
data.player = event.player;
|
||||
}
|
||||
if (event.changes?.length) {
|
||||
data.changes = event.changes;
|
||||
}
|
||||
queueEventsApplied += 1;
|
||||
await applyQueue(data);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user