mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-11 23:04:52 +09:00
Handle contributions to the next level of a technology
Fix research_sync sending out contribution events for the previous level of a researched technology and sending finished events for the wrong level when synchronizing technologies. Both of these issues are related to failing to accunt for the unlocked level being one less than the level stored when the researched property is false.
This commit is contained in:
1 parent
b6585e6364
commit
f4ca8366e2
1 file changed
+17
-3
@@ -67,6 +67,17 @@ class MasterPlugin extends plugin.BaseMasterPlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle contributon to the next level of a researched technology
|
||||
if (tech.level === level - 1 && tech.researched) {
|
||||
tech.researched = false;
|
||||
tech.level = level;
|
||||
}
|
||||
|
||||
// Ignore contributions to higher levels
|
||||
if (tech.level < level) {
|
||||
return;
|
||||
}
|
||||
|
||||
let newProgress = tech.progress + contribution;
|
||||
if (newProgress < 1) {
|
||||
tech.progress = newProgress;
|
||||
@@ -125,12 +136,15 @@ class MasterPlugin extends plugin.BaseMasterPlugin {
|
||||
}
|
||||
|
||||
if (tech.level < level || researched) {
|
||||
// Send update if the unlocked level is greater
|
||||
if (level - !researched > tech.level - !tech.researched) {
|
||||
for (let slaveConnection of this.master.slaveConnections.values()) {
|
||||
this.info.messages.finished.send(slaveConnection, { name, level: level - !researched });
|
||||
}
|
||||
}
|
||||
tech.level = level;
|
||||
tech.progress = progress;
|
||||
tech.researched = researched;
|
||||
for (let slaveConnection of this.master.slaveConnections.values()) {
|
||||
this.info.messages.finished.send(slaveConnection, { name, level });
|
||||
}
|
||||
|
||||
if (progress) {
|
||||
this.progressToBroadcast.add(name);
|
||||
|
||||
Reference in new issue
Block a user