From f9a97222151f165778737fd9165a5468c7fe5fc0 Mon Sep 17 00:00:00 2001 From: joshricker Date: Mon, 18 Feb 2019 03:26:11 -0600 Subject: [PATCH 1/2] Remove command length. Remove command length for better compatible with large mod packs. --- sharedPlugins/clusterioMod/index.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/sharedPlugins/clusterioMod/index.js b/sharedPlugins/clusterioMod/index.js index 4377c842..240bc2ba 100644 --- a/sharedPlugins/clusterioMod/index.js +++ b/sharedPlugins/clusterioMod/index.js @@ -185,11 +185,6 @@ module.exports = class remoteCommands { for(let i=0;i320) // Factorio max packet size is 508 - { - that.messageInterface("/silent-command remote.call('clusterio', 'runcode', '"+cmd.slice(0, -1)+"}"+ " for k, item in pairs(t) do GiveItemsToStorage(k, item) end')"); - cmd="local t={"; - } } if (!(cmd==="local t={")){ that.messageInterface("/silent-command remote.call('clusterio', 'runcode', '"+cmd.slice(0, -1)+"}"+ " for k, item in pairs(t) do GiveItemsToStorage(k, item) end')"); @@ -222,12 +217,6 @@ module.exports = class remoteCommands { for (let key in inventoryFrame) { cmd+='["'+key+'"]='+inventoryFrame[key]+","; - if(first && cmd.length>300 || !first && cmd.length > 320) // Factorio max packet size is 508 - { - that.messageInterface("/silent-command remote.call('clusterio', 'runcode', '"+(first ? 'global.ticksSinceMasterPinged=0 ':'')+cmd.slice(0, -1)+"}"+ " for name,count in pairs(s) do global.invdata[name]=count end')"); - cmd="local s={"; - first = false; - } } if (!(cmd==="local s={")){ that.messageInterface("/silent-command remote.call('clusterio', 'runcode', '"+(first ? 'global.ticksSinceMasterPinged=0 ':'')+cmd.slice(0, -1)+"}"+ " for name,count in pairs(s) do global.invdata[name]=count end')"); From 103409b0cdaa0441e6761984b27ad6f485b289e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Vest=C3=B8l?= Date: Mon, 18 Feb 2019 19:49:49 +0100 Subject: [PATCH 2/2] Added setting disableFairItemDistribution to disable dole division factor --- config.json.dist | 1 + master.js | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/config.json.dist b/config.json.dist index 6c6a7943..3ca02906 100644 --- a/config.json.dist +++ b/config.json.dist @@ -47,6 +47,7 @@ "entriesPerSecond": 0.01666666667 }, "logItemTransfers": false, + "disableFairItemDistribution": false, "uploadModsToMaster": true, "msBetweenCommands": 10, "allowRemoteCommandExecution": true, diff --git a/master.js b/master.js index 17b73b6f..ea764a90 100644 --- a/master.js +++ b/master.js @@ -566,6 +566,27 @@ app.post("/api/remove", authenticate.middleware, function(req, res) { console.log('failure could not find ' + object.name); } res.send({name:object.name, count:0}); + } else if(config.disableFairItemDistribution){ + let numberToRemove = Math.min(Math.abs(Number(object.count)),Number(item)); + db.items.removeItem({count: numberToRemove, name: object.name}); + res.send({count: numberToRemove, name: object.name}); + + // track statistics and do graphing things + prometheusImportGauge.labels(object.instanceID, object.name).inc(Number(numberToRemove) || 0); + let sentItemStatistics = sentItemStatisticsBySlaveID[object.instanceID]; + if(sentItemStatistics === undefined){ + sentItemStatistics = new averagedTimeSeries({ + maxEntries: config.itemStats.maxEntries, + entriesPerSecond: config.itemStats.entriesPerSecond, + mergeMode: "add", + }, console.log); + } + sentItemStatistics.add({ + key:object.name, + value:numberToRemove, + }); + //console.log(sentItemStatistics.data) + sentItemStatisticsBySlaveID[object.instanceID] = sentItemStatistics; } else { const originalCount = Number(object.count) || 0; object.count /= ((_doleDivisionFactor[object.name]||0)+doleDivisionRetardation)/doleDivisionRetardation;