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