From 6c11cefb993fca501f8ea8bb6a7b7665fb89c80a Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Sun, 6 Dec 2020 17:02:33 +0100 Subject: [PATCH 1/3] Remove resource count limiting Remove the limiting of the resource counts sent to the subspace_storage mod as this has been implemented on the mod side with version 1.99.6. --- plugins/subspace_storage/instance.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/plugins/subspace_storage/instance.js b/plugins/subspace_storage/instance.js index 39a67546..668f0b69 100644 --- a/plugins/subspace_storage/instance.js +++ b/plugins/subspace_storage/instance.js @@ -73,14 +73,6 @@ class InstancePlugin extends libPlugin.BaseInstancePlugin { async updateStorageEventHandler(message, event) { let items = message.data.items; - // XXX this should be done on the lua side - // Ensure counts don't overflow - for (let item of items) { - if (item[1] > 0x7fffffff) { - item[1] = 0x7fffffff; - } - } - // XXX this should be moved to instance/clusterio api items.push(["signal-unixtime", Math.floor(Date.now()/1000)]); From faae6ccf975e840a9870bcd895564d43db38ebf4 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Sun, 6 Dec 2020 17:04:25 +0100 Subject: [PATCH 2/3] Rework mod build system to be multi-version capable Add a variants array which can specify overriden properties of the info.json for building multiple versions of the mod at the same time and fix the additonal_files to allow specifying under what path the file is put. Together these two changes allow setting up the build to do all supported versions at the same time and add specialized code for each version of Factorio supported. --- packages/lib/build_mod.js | 34 +++++++++++++--------- packages/slave/lua/clusterio_lib/info.json | 18 ++++++++---- 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/packages/lib/build_mod.js b/packages/lib/build_mod.js index 6fa8822f..4ea89c51 100644 --- a/packages/lib/build_mod.js +++ b/packages/lib/build_mod.js @@ -13,11 +13,10 @@ async function main() { .scriptName("build") .options({ "clean": { describe: "Remove previous builds", type: "boolean", default: false }, - "build": { describe: "Build mod", type: "boolean", default: true }, + "build": { describe: "Build mod(s)", type: "boolean", default: true }, "pack": { describe: "Pack into zip file", type: "boolean", default: true }, "source-dir": { describe: "Path to mod source files", nargs: 1, type: "string", demandOption: true }, - "output-dir": { describe: "Path to output built mod", nargs: 1, type: "string", default: "dist" }, - "bump-patch": { describe: "Increment patch number of build", type: "boolean", default: false }, + "output-dir": { describe: "Path to output built mod(s)", nargs: 1, type: "string", default: "dist" }, "factorio-version": { describe: "Override factorio_version", type: "string" }, }) .strict() @@ -30,12 +29,6 @@ async function main() { async function build(args) { let info = JSON.parse(await fs.readFile(path.join(args.sourceDir, "info.json"))); - if (args.bumpPatch) { - let [major, minor, patch] = info.version.split("."); - patch = String(Number.parseInt(patch, 10) + 1); - info.version = [major, minor, patch].join("."); - } - if (args.factorioVersion) { info.factorio_version = args.factorioVersion; } @@ -59,6 +52,21 @@ async function build(args) { } } + if (info.variants) { + for (let [variant, variantOverrides] of Object.entries(info.variants)) { + let variantInfo = { + ...info, + ...variantOverrides, + }; + delete variantInfo.variants; + await buildMod(args, variantInfo); + } + } else { + await buildMod(args, info); + } +} + +async function buildMod(args, info) { if (args.build) { await fs.ensureDir(args.outputDir); let modName = `${info.name}_${info.version}`; @@ -78,12 +86,12 @@ async function build(args) { ; await events.once(walker, "end"); - for (let pathParts of info.additional_files || []) { + for (let [fileName, pathParts] of Object.entries(info.additional_files || {})) { let filePath = path.join(args.sourceDir, ...pathParts); if (!await fs.pathExists(filePath)) { throw new Error(`Additional file ${filePath} does not exist`); } - zip.file(path.posix.join(modName, path.basename(filePath)), fs.createReadStream(filePath)); + zip.file(path.posix.join(modName, fileName), fs.createReadStream(filePath)); } delete info.additional_files; @@ -102,9 +110,9 @@ async function build(args) { } console.log(`Building ${modDir}`); await fs.copy(args.sourceDir, modDir); - for (let pathParts of info.additional_files || []) { + for (let [fileName, pathParts] of Object.entries(info.additional_files) || []) { let filePath = path.join(...pathParts); - await fs.copy(filePath, path.join(modDir, path.basename(filePath))); + await fs.copy(filePath, path.join(modDir, fileName)); } delete info.additional_files; diff --git a/packages/slave/lua/clusterio_lib/info.json b/packages/slave/lua/clusterio_lib/info.json index b66e2a2e..64b04a33 100644 --- a/packages/slave/lua/clusterio_lib/info.json +++ b/packages/slave/lua/clusterio_lib/info.json @@ -1,12 +1,20 @@ { "name": "clusterio_lib", - "version": "0.1.1", + "variants": [ + { + "version": "0.1.0", + "factorio_version": "0.17" + }, + { + "version": "0.1.1", + "factorio_version": "0.18" + } + ], "title": "Clusterio Library (Alpha)", "author": "Clusterio Team", "homepage": "https://github.com/clusterio/factorioClusterio", "description": "Library for interfacing with Clusterio. Warning: work in progress alpha.", - "factorio_version": "0.17", - "additional_files": [ - ["..", "..", "modules", "clusterio", "serialize.lua"] - ] + "additional_files": { + "serialize.lua": ["..", "..", "modules", "clusterio", "serialize.lua"] + } } From 30b7fd8767a4ca722827267f6bd455236920f6a4 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Sun, 6 Dec 2020 22:48:47 +0100 Subject: [PATCH 3/3] Add support for Factorio 1.1 Add variant to clusterio_lib supporting 1.1 and update travis config to use the 1.1 compatible version of Subspace Storage. --- .travis.yml | 4 ++-- packages/slave/lua/clusterio_lib/changelog.txt | 4 ++++ packages/slave/lua/clusterio_lib/info.json | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index b75fb52d..9ffbf028 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,8 +7,8 @@ before_install: - npm install -g codecov script: - npx lerna bootstrap --no-ci - - node packages/lib/build_mod --source-dir packages/slave/lua/clusterio_lib --bump-patch --factorio-version 0.18 --output-dir temp/test/sharedMods - - curl -o temp/test/sharedMods/subspace_storage_1.99.1.zip -L https://github.com/clusterio/factorioClusterioMod/releases/download/1.99.1/subspace_storage_1.99.1.zip + - node packages/lib/build_mod --source-dir packages/slave/lua/clusterio_lib --output-dir temp/test/sharedMods + - curl -o temp/test/sharedMods/subspace_storage_1.99.8.zip -L https://github.com/clusterio/factorioClusterioMod/releases/download/1.99.6/subspace_storage_1.99.8.zip - npx lerna run build - npm run-script ci-cover - codecov -f coverage/lcov.info diff --git a/packages/slave/lua/clusterio_lib/changelog.txt b/packages/slave/lua/clusterio_lib/changelog.txt index fdce82ea..e078d229 100644 --- a/packages/slave/lua/clusterio_lib/changelog.txt +++ b/packages/slave/lua/clusterio_lib/changelog.txt @@ -1,4 +1,8 @@ --------------------------------------------------------------------------------------------------- +Version: 0.1.2 + Features: + - Added support for Factorio 1.1. +--------------------------------------------------------------------------------------------------- Version: 0.1.1 Features: - Added support for Factorio 0.18.x diff --git a/packages/slave/lua/clusterio_lib/info.json b/packages/slave/lua/clusterio_lib/info.json index 64b04a33..1633d6e2 100644 --- a/packages/slave/lua/clusterio_lib/info.json +++ b/packages/slave/lua/clusterio_lib/info.json @@ -8,6 +8,10 @@ { "version": "0.1.1", "factorio_version": "0.18" + }, + { + "version": "0.1.2", + "factorio_version": "1.1" } ], "title": "Clusterio Library (Alpha)",