From f4b2300d9b6cd304b3f86999b734677db696cfd2 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Sat, 26 Oct 2019 16:53:27 +0200 Subject: [PATCH 1/6] Port disable uploading of mods to master by default Set uploadModsToMaster to false in config.json.dist. This feature is not necessary as the integrated mod portal in Factorio provides a better method to synchronize mods. This is a port of 3c5b108. --- CHANGELOG.md | 8 ++++++++ config.json.dist | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28fb75b2..aca225d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,6 +63,14 @@ Version 2.0.0 add in a remote interface. +Version 1.2.3 +------------- + +- Disabled uploading mods to the master server by default as this is mostly + just a waste of bandwidth with the mod portal being integrated into the + game now. + + Version 1.2.2 ------------- diff --git a/config.json.dist b/config.json.dist index 6fda38cd..88025449 100644 --- a/config.json.dist +++ b/config.json.dist @@ -50,7 +50,7 @@ "__comment6.5": "When the master is undersupplied, we have 3 different modes to 'fairly' distribute items. First to ask gets all, dole division using weird formula or experimental neural net tries to make stuff as fair as possible. Feel free to play around.", "disableFairItemDistribution": false, "useNeuralNetDoleDivider": true, - "uploadModsToMaster": true, + "uploadModsToMaster": false, "msBetweenCommands": 10, "allowRemoteCommandExecution": true, "enableCrossServerShout": true, From 7359f9075e4a73a420c8a9ef5151bc0958c1dd6d Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Sat, 26 Oct 2019 17:37:24 +0200 Subject: [PATCH 2/6] Port increase limit of Json payloads to master server The default limit of 100kb to JSON payloads of bodyParser can be exceeded when running modded games with researchSync. Increase the limit to 10mb as a bandaid to fix this issue. This is a port of 25eb5e5. --- CHANGELOG.md | 2 ++ master.js | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aca225d7..64d8b5d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -69,6 +69,8 @@ Version 1.2.3 - Disabled uploading mods to the master server by default as this is mostly just a waste of bandwidth with the mod portal being integrated into the game now. +- Fixed researchSync breaking with heavily modded games due to the tech tree + exceeding the default 100kb limit on JSON payloads. Version 1.2.2 diff --git a/master.js b/master.js index a154a6d9..81d02ed8 100644 --- a/master.js +++ b/master.js @@ -47,7 +47,9 @@ const fileUpload = require('express-fileupload'); var app = express(); app.use(cookieParser()); -app.use(bodyParser.json()); +app.use(bodyParser.json({ + limit: '10mb', +})); app.use(bodyParser.urlencoded({ parameterLimit: 100000, limit: '10mb', From 7c79ea44b6d9689667aabda8d3c12be5a2660272 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Sat, 9 Nov 2019 17:15:36 +0100 Subject: [PATCH 3/6] Port fix inventoryImports command Fix the inventory imports command trying to count up the removed quick bar slots as well as using player_main instead of character_main. Add warning that the lua commands file containing the unminified vesion of the command has not been kept up to date. There are multiple changes that has been done previously so these have already diverged. This is a port of 10414eb. --- CHANGELOG.md | 2 ++ sharedPlugins/inventoryImports/interfacingFunctions.js | 5 ++++- sharedPlugins/inventoryImports/lua commands.lua | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64d8b5d2..c01c5a74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -71,6 +71,8 @@ Version 1.2.3 game now. - Fixed researchSync breaking with heavily modded games due to the tech tree exceeding the default 100kb limit on JSON payloads. +- Fixed the command inventoryImport sends referencing player instead of + character, and trying to count the non-existant quick bar slots. Version 1.2.2 diff --git a/sharedPlugins/inventoryImports/interfacingFunctions.js b/sharedPlugins/inventoryImports/interfacingFunctions.js index 9ea57750..c8493c67 100644 --- a/sharedPlugins/inventoryImports/interfacingFunctions.js +++ b/sharedPlugins/inventoryImports/interfacingFunctions.js @@ -136,7 +136,10 @@ function pollInventories(outputFile){ //console.log("/silent-command "+'local a=game.players["Danielv123"].get_inventory(defines.inventory.player_main).get_contents()local b=game.players["Danielv123"].get_quickbar().get_contents()local c={}for d=1,game.players["Danielv123"].force.character_logistic_slot_count do c[d]=game.players["Danielv123"].character.get_request_slot(d)end;local e="{inventory:{"for f,g in pairs(a)do e=e.."['+"'"+'"..f.."'+"'"+']:"..g..","end;for f,g in pairs(b)do e=e.."['+"'"+'"..f.."'+"'"+']:"..g..","end;e=e.."},requestSlots:{"for f,g in pairs(c)do e=e.."['+"'"+'"..g["name"].."'+"'"+']:"..g["count"]..", "end;e=e.."}}"game.write_file("'+pluginConfig.scriptOutputFileSubscription+'",e)') // console.log("/silent-command "+'local a="{"for b,c in pairs(game.players)do local d=game.players[b].get_inventory(defines.inventory.player_main).get_contents()local e=game.players[b].get_quickbar().get_contents()local f={}for g=1,game.players[b].force.character_logistic_slot_count do f[g]=game.players[b].character.get_request_slot(g)end;a=a..b..":{inventory:{"for h,i in pairs(d)do a=a.."['+"'"+'"..h.."'+"'"+']:"..i..","end;for h,i in pairs(e)do a=a.."['+"'"+'"..h.."'+"'"+']:"..i..","end;a=a.."},requestSlots:{"for h,i in pairs(f)do a=a.."['+"'"+'"..i["name"].."'+"'"+']:"..i["count"]..", "end;a=a.."}},"end;a=a.."}"game.write_file("'+pluginConfig.scriptOutputFileSubscription+'",a)') //return "/silent-command "+'local a="{"for b,c in pairs(game.players)do if c.connected then local d=game.players[b].get_inventory(defines.inventory.player_main).get_contents()local e=game.players[b].get_quickbar().get_contents()local f={}for g=1,game.players[b].force.character_logistic_slot_count do f[g]=game.players[b].character.get_request_slot(g)end;a=a..b..":{inventory:{"for h,i in pairs(d)do a=a.."['+"'"+'"..h.."'+"'"+']:"..i..","end;for h,i in pairs(e)do a=a.."['+"'"+'"..h.."'+"'"+']:"..i..","end;a=a.."},requestSlots:{"for h,i in pairs(f)do a=a.."['+"'"+'"..i["name"].."'+"'"+']:"..i["count"]..", "end;a=a.."}},"end end;a=a.."}"game.write_file("'+outputFile+'",a)' - return '/silent-command '+'local a='+"'"+'{"players":{'+"'"+'local b=false;for c,d in pairs(game.players)do if d.connected and d.character then if b then a=a..'+"'"+','+"'"+'else b=true end;local e=game.players[c].get_inventory(defines.inventory.player_main).get_contents()local f=game.players[c].get_quickbar().get_contents()local g={}local z={}for j,k in pairs(e)do if z[j] ~= nil then z[j] = z[j] + k else z[j] = k end end for j,k in pairs(f)do if z[j] ~= nil then z[j] = z[j] + k else z[j] = k end end for h=1,game.players[c].force.character_logistic_slot_count do g[h]=game.players[c].character.get_request_slot(h)end;a=a..'+"'"+'"'+"'"+'..c..'+"'"+'":{"inventory":{'+"'"+'local i=false;for j,k in pairs(z)do if i then a=a..'+"'"+','+"'"+'else i=true end;a=a..'+"'"+'"'+"'"+'..j..'+"'"+'":'+"'"+'..k end;a=a..'+"'"+'},"requestSlots":{'+"'"+'i=false;for j,k in pairs(g)do if i then a=a..'+"'"+','+"'"+'else i=true end;a=a..'+"'"+'"'+"'"+'..k['+"'"+'name'+"'"+']..'+"'"+'":'+"'"+'..k['+"'"+'count'+"'"+']end;a=a..'+"'"+'}}'+"'"+'end end;a=a.."}}"game.write_file("'+outputFile+'",a,true,0)' + //return '/silent-command '+'local a='+"'"+'{"players":{'+"'"+'local b=false;for c,d in pairs(game.players)do if d.connected and d.character then if b then a=a..'+"'"+','+"'"+'else b=true end;local e=game.players[c].get_inventory(defines.inventory.player_main).get_contents()local f=game.players[c].get_quickbar().get_contents()local g={}local z={}for j,k in pairs(e)do if z[j] ~= nil then z[j] = z[j] + k else z[j] = k end end for j,k in pairs(f)do if z[j] ~= nil then z[j] = z[j] + k else z[j] = k end end for h=1,game.players[c].force.character_logistic_slot_count do g[h]=game.players[c].character.get_request_slot(h)end;a=a..'+"'"+'"'+"'"+'..c..'+"'"+'":{"inventory":{'+"'"+'local i=false;for j,k in pairs(z)do if i then a=a..'+"'"+','+"'"+'else i=true end;a=a..'+"'"+'"'+"'"+'..j..'+"'"+'":'+"'"+'..k end;a=a..'+"'"+'},"requestSlots":{'+"'"+'i=false;for j,k in pairs(g)do if i then a=a..'+"'"+','+"'"+'else i=true end;a=a..'+"'"+'"'+"'"+'..k['+"'"+'name'+"'"+']..'+"'"+'":'+"'"+'..k['+"'"+'count'+"'"+']end;a=a..'+"'"+'}}'+"'"+'end end;a=a.."}}"game.write_file("'+outputFile+'",a,true,0)' + + // Warning: This command is not in sync with lua commands.lua + return `/silent-command local a='{"players":{'local b=false;for c,d in pairs(game.players)do if d.connected and d.character then if b then a=a..','else b=true end;local e=game.players[c].get_inventory(defines.inventory.character_main).get_contents()local g={}for h=1,game.players[c].force.character_logistic_slot_count do g[h]=game.players[c].character.get_request_slot(h)end;a=a..'"'..c..'":{"inventory":{'local i=false;for j,k in pairs(e)do if i then a=a..','else i=true end;a=a..'"'..j..'":'..k end;a=a..'},"requestSlots":{'i=false;for j,k in pairs(g)do if i then a=a..','else i=true end;a=a..'"'..k['name']..'":'..k['count']end;a=a..'}}'end end;a=a.."}}"game.write_file("${outputFile}",a,true,0)` /* needle.post(config.masterURL+'/api/editSlaveMeta', {instanceID: config.unique, password: config.clientPassword, meta: {UPS:UPS}}, function(err, resp) { // success? diff --git a/sharedPlugins/inventoryImports/lua commands.lua b/sharedPlugins/inventoryImports/lua commands.lua index 431740de..298adcff 100644 --- a/sharedPlugins/inventoryImports/lua commands.lua +++ b/sharedPlugins/inventoryImports/lua commands.lua @@ -1,3 +1,4 @@ +-- WARNING: The commands in this file is not in sync with interfacingFunctions.js -- Lua cheatsheet /c game.write_file("test.txt",serpent.block(game.players["Danielv123"].get_quickbar().get_contents())) From 31ab3a09f636bed8a41c5c02828a9f61d81d88ae Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Sat, 9 Nov 2019 17:18:57 +0100 Subject: [PATCH 4/6] Port add fileReadDelay to inventoryImports config Fix the inventoryImports client side code never receiving the script output by specifying fileReadDelay and thereby getting the old behaviour. This broke with the introduction of the tail mode script output mode which requires a newline to be written at the end of the output. This is a port of d810b56. --- CHANGELOG.md | 2 ++ sharedPlugins/inventoryImports/config.js | 1 + 2 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c01c5a74..eaf77e27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -73,6 +73,8 @@ Version 1.2.3 exceeding the default 100kb limit on JSON payloads. - Fixed the command inventoryImport sends referencing player instead of character, and trying to count the non-existant quick bar slots. +- Fixed inventoryImport never receiving the script output after the default + mode for reading script output changed to tail mode. Version 1.2.2 diff --git a/sharedPlugins/inventoryImports/config.js b/sharedPlugins/inventoryImports/config.js index 9b2258cf..758d2b9d 100644 --- a/sharedPlugins/inventoryImports/config.js +++ b/sharedPlugins/inventoryImports/config.js @@ -17,4 +17,5 @@ module.exports = { description: "Clusterio plugin to fill character logistic slots with master imports", // We'll send everything in this file to your stdin. Beware. scriptOutputFileSubscription: "inventoryImports.txt", + fileReadDelay: 100, } \ No newline at end of file From 35f3f4f02bbb8396c649348fc99f2310bc21b9bc Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Mon, 11 Nov 2019 23:47:19 +0100 Subject: [PATCH 5/6] Add changelog entry from 1.2.3 Add the fixed Hotpatch changelog entry from 1.2.3. --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index eaf77e27..5bc31311 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -75,6 +75,10 @@ Version 1.2.3 character, and trying to count the non-existant quick bar slots. - Fixed inventoryImport never receiving the script output after the default mode for reading script output changed to tail mode. +- Fixed desync caused by the mods and loaded mods arrays in Hotpatch getting + out of sync when plugins update their scenario mod code. To fix existing + games you will need copy lib/scenarios/Hotpatch/hotpatch/mod-tools.lua + over the existing mod-tools.lua in the save's hotpatch folder. Version 1.2.2 From 707f06be762e0018e812031b0fb062203a12d83b Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Thu, 14 Nov 2019 18:29:02 +0100 Subject: [PATCH 6/6] Port update Windows install instructions Remove the reference to the out of repo Windows install script and list updated commands to install Clusterio stable in the readme itself. This is a port of e1771ec. --- CHANGELOG.md | 1 + README.md | 43 +++++++++++++++++++++++++++++++------------ 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5bc31311..2fa3e217 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -79,6 +79,7 @@ Version 1.2.3 out of sync when plugins update their scenario mod code. To fix existing games you will need copy lib/scenarios/Hotpatch/hotpatch/mod-tools.lua over the existing mod-tools.lua in the save's hotpatch folder. +- Updated the Windows install instructions. Version 1.2.2 diff --git a/README.md b/README.md index 09797799..549b63bb 100644 --- a/README.md +++ b/README.md @@ -189,28 +189,47 @@ reboot when you are done, then proceed to the next steps. *reboots matter* **Master** -1. download and run https://puu.sh/toFHl/01eebbb333.bat +1. Open PowerShell or Command prompt in the directory you want to install to and run the following commands. -2. Copy config.json.dist to config.json + git clone -b 1.2.x https://github.com/clusterio/factorioClusterio + cd factorioClusterio + npm install --only=production + copy config.json.dist config.json -3. Follow the instructions in the bat file -3. Some of the instructions are outdated. If you get stuck somewhere, look at the Ubuntu section. +2. Obtain Factorio by either of these two methods: -4. Run `node client manage shared mods add clusterio` + - Via the stand alone version on from their website -5. type `node master` to start the server + 1. Download the MS Windows (64-bit zip package) from https://www.factorio.com/download + + 2. Open the zip file and drag the folder called "Factorio_0.17.x" into the factorioClusterio folder + + 3. Rename the folder to "factorio" + + - Via steam installation + + 1. Locate the game files by right clicking the game in steam, selecting properties, then Local Files, then Browse local files. + + 2. Go to the parent folder of the folder that Steam opened and copy the Factorio folder into the factorioClusterio folder + + 3. Rename the folder to "factorio" + + +3. Open `config.json` with a text editor and configure as desired. + +4. Run `node master` to generate the athentication token into secret-api-token.txt + +5. Run `node master` again to start the master server. **Server Host** -1. download and run https://puu.sh/toFHl/01eebbb333.bat +1. Do step 1 and 2 of the Master section above *OR* use the same folder that was created in that section. -2. Copy config.json.dist to config.json +2. Open `config.json` with a text editor and configure as desired. You will need to set masterAuthToken to string found in secret-api-token.txt on the master server. -3. Follow the instructions given. +3. Optionally run the command `node client manage shared mods add clusterio` to add the clusterio mod (needed for item teleports.) -3.5 Some of the instructions are outdated. If you get stuck somewhere, look at the Ubuntu section. - -4. Type `node client start [instancename]` to create a new instance. +4. Run `node client start [instancename]` to create a new instance. Repeat it again to start the instance. To connect to a master server running on a remote machine, open config.json with your favourite text editor (notepad++). You can also set it up to use the official server browser.