mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-16 23:30:41 +09:00
6 files changed
+24
-6
No files matched your search
+1
-1
@@ -370,7 +370,7 @@ class Control extends link.Link {
|
||||
try {
|
||||
await link.messages.prepareDisconnect.send(this);
|
||||
} catch (err) {
|
||||
if (!(err instanceof SessionLost)) {
|
||||
if (!(err instanceof errors.SessionLost)) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -351,6 +351,7 @@ class WebSocketClientConnector extends WebSocketBaseConnector {
|
||||
this._sessionToken = data.session_token;
|
||||
this._heartbeatInterval = data.heartbeat_interval;
|
||||
this.startHeartbeat();
|
||||
this._startedReconnect = null;
|
||||
this._connected = true;
|
||||
this.emit("connected");
|
||||
|
||||
@@ -363,6 +364,7 @@ class WebSocketClientConnector extends WebSocketBaseConnector {
|
||||
for (let message of this._sendBuffer) {
|
||||
this._socket.send(JSON.stringify(message));
|
||||
}
|
||||
this._startedReconnect = null;
|
||||
this._connected = true;
|
||||
this.emit("connected");
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -197,7 +197,7 @@ function research_sync.research_technology(name, level)
|
||||
tech.researched = true
|
||||
|
||||
if tech.name:find("-%d+$") then
|
||||
game.print {"", "Researched ", {"technology-name." .. tech.name:gsub("-%d+$", "")}, level}
|
||||
game.print {"", "Researched ", {"technology-name." .. tech.name:gsub("-%d+$", "")}, " ", level}
|
||||
else
|
||||
game.print {"", "Researched ", {"technology-name." .. tech.name}}
|
||||
end
|
||||
|
||||
@@ -94,6 +94,7 @@ let _doleDivisionFactor = {};
|
||||
function doleDivider({
|
||||
object,
|
||||
items,
|
||||
logItemTransfers,
|
||||
}){
|
||||
let itemCount = items.getItemCount(object.name);
|
||||
const doleDivisionRetardation = 10; //lower rates will equal more dramatic swings
|
||||
@@ -102,7 +103,7 @@ function doleDivider({
|
||||
const originalCount = Number(object.count) || 0;
|
||||
object.count /= ((_doleDivisionFactor[object.name]||0)+doleDivisionRetardation)/doleDivisionRetardation;
|
||||
object.count = Math.round(object.count);
|
||||
if (itemCount > 40) {
|
||||
if (logItemTransfers) {
|
||||
console.info(`Serving ${object.count}/${originalCount} ${object.name} from ${itemCount} ${object.name} with dole division factor ${(_doleDivisionFactor[object.name]||0)} (real=${((_doleDivisionFactor[object.name]||0)+doleDivisionRetardation)/doleDivisionRetardation}), item is ${itemCount > object.count?'stocked':'short'}.`);
|
||||
}
|
||||
|
||||
|
||||
@@ -139,6 +139,7 @@ class MasterPlugin extends plugin.BaseMasterPlugin {
|
||||
let count = dole.doleDivider({
|
||||
object: { name: item[0], count: item[1], instanceId, instanceName},
|
||||
items: this.items,
|
||||
logItemTransfers: this.master.config.get("subspace_storage.log_item_transfers"),
|
||||
});
|
||||
if (count > 0) {
|
||||
itemsRemoved.push([item[0], count]);
|
||||
|
||||
Reference in new issue
Block a user