mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-19 23:33:13 +09:00
Remove one research queue entry per level a technology sync unlocks
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
ed1e4ee3cb
commit
f7c78d9f74
2 files changed
+29
-6
No files matched your search
@@ -86,9 +86,13 @@ export default async function(context: ControllerPluginContext) {
|
||||
return controller.instances.get(src.id)?.config.get("instance.name") ?? String(src.id);
|
||||
}
|
||||
|
||||
function removeFinished(name: string) {
|
||||
let index = queue.indexOf(name);
|
||||
if (index !== -1) {
|
||||
// Removes one entry per level that finished
|
||||
function removeFinished(name: string, levels = 1) {
|
||||
for (let i = 0; i < levels; i++) {
|
||||
let index = queue.indexOf(name);
|
||||
if (index === -1) {
|
||||
return;
|
||||
}
|
||||
queue.splice(index, 1);
|
||||
queueDirty = true;
|
||||
}
|
||||
@@ -198,7 +202,8 @@ export default async function(context: ControllerPluginContext) {
|
||||
progressToBroadcast.add(name);
|
||||
} else if (researched || baseLevel(name) !== level) {
|
||||
controller.sendTo("allInstances", new FinishedEvent(name, level));
|
||||
removeFinished(name);
|
||||
// One queue entry per level unlocked
|
||||
removeFinished(name, Math.max(level - Number(!researched) - baseLevel(name) + 1, 1));
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -208,9 +213,10 @@ export default async function(context: ControllerPluginContext) {
|
||||
|
||||
if (tech.level < level || researched) {
|
||||
// Send update if the unlocked level is greater
|
||||
if (level - Number(!researched) > tech.level - Number(!tech.researched)) {
|
||||
let unlocked = level - Number(!researched) - (tech.level - Number(!tech.researched));
|
||||
if (unlocked > 0) {
|
||||
controller.sendTo("allInstances", new FinishedEvent(name, level - Number(!researched)));
|
||||
removeFinished(name);
|
||||
removeFinished(name, unlocked);
|
||||
}
|
||||
tech.level = level;
|
||||
tech.progress = progress;
|
||||
|
||||
Reference in new issue
Block a user