From d2fb33f8b9aa81c73313c94403e71b9d94f2e93a Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Fri, 17 Apr 2020 16:15:34 +0200 Subject: [PATCH 1/5] Fix log spam by subspace_storage plugin Fix log spam when the dole distribution method is used on subspace_storage plugin. This was caused by a bogus if condition being translated into a sensible but wrong one. --- plugins/subspace_storage/dole.js | 3 ++- plugins/subspace_storage/master.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/subspace_storage/dole.js b/plugins/subspace_storage/dole.js index 5a4d9306..f7ed8dc2 100644 --- a/plugins/subspace_storage/dole.js +++ b/plugins/subspace_storage/dole.js @@ -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'}.`); } diff --git a/plugins/subspace_storage/master.js b/plugins/subspace_storage/master.js index 21e44938..64a10a3b 100644 --- a/plugins/subspace_storage/master.js +++ b/plugins/subspace_storage/master.js @@ -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]); From b6585e63644c6b8e9608ca00047fc23e6f3a841d Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Fri, 17 Apr 2020 16:54:42 +0200 Subject: [PATCH 2/5] Fix reconnect giving up too early Fix the reconnect logic giving immediately if a previous reconnection had been made long prior to the connection being dropped again. --- lib/link/connectors.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/link/connectors.js b/lib/link/connectors.js index 2b94c0e5..5a420323 100644 --- a/lib/link/connectors.js +++ b/lib/link/connectors.js @@ -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"); From f4ca8366e2b66660a8cfdfe7cbf26da7439e5fca Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Fri, 17 Apr 2020 17:52:04 +0200 Subject: [PATCH 3/5] 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. --- plugins/research_sync/master.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/plugins/research_sync/master.js b/plugins/research_sync/master.js index 84a00db4..4e141be9 100644 --- a/plugins/research_sync/master.js +++ b/plugins/research_sync/master.js @@ -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); From 3603b16901d3e5e2424b8d96e9f11995f883af67 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Sun, 19 Apr 2020 18:23:37 +0200 Subject: [PATCH 4/5] Fix missing space in researched notification Add space between the technology name and the level in the notification for researched technologies. --- plugins/research_sync/module/sync.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/research_sync/module/sync.lua b/plugins/research_sync/module/sync.lua index f7c88aae..108e0b2d 100644 --- a/plugins/research_sync/module/sync.lua +++ b/plugins/research_sync/module/sync.lua @@ -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 From c601c530445a99104290157e5361cd0f88baaa71 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Sun, 19 Apr 2020 18:24:43 +0200 Subject: [PATCH 5/5] Fix typo in clusterctl.js Fix SessionLost being refered to as a global instead of from the errors module in clusterctl.js. --- clusterctl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clusterctl.js b/clusterctl.js index 6f38905e..d02594db 100644 --- a/clusterctl.js +++ b/clusterctl.js @@ -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; } }