mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-14 23:24:52 +09:00
Replace Hotpatch with save patching
Remove Hotpatch and implement a save patcher in its place. The save patcher takes a normal Factorio save and adds modules to it that's loaded by a generated control.lua file. This greatly reduces the difficulty of adding an existing game to Clusterio and using scenario code in plugins. The mechanism for selecting what code to patch into the saves from plugins is temorary and expected to change with #220.
This commit is contained in:
1 parent
079e31cf05
commit
1a035e849e
61 files changed
+575
-2709
No files matched your search
@@ -0,0 +1,31 @@
|
||||
const assert = require("assert").strict;
|
||||
const fs = require("fs-extra");
|
||||
const jszip = require("jszip");
|
||||
const path = require("path");
|
||||
|
||||
const factorio = require("lib/factorio");
|
||||
|
||||
|
||||
// The server integration test is required to run before this one
|
||||
require("./server")
|
||||
|
||||
describe("Integration of lib/factorio/patch", function() {
|
||||
describe("patch()", function() {
|
||||
let savePath = path.join("test", "temp", "integration", "saves", "test.zip");
|
||||
it("should patch a freeplay game", async function() {
|
||||
await factorio.patch(savePath, [{
|
||||
name: "test",
|
||||
files: [{ path: "test.lua", content: "-- test" }]
|
||||
}]);
|
||||
|
||||
let zip = await jszip.loadAsync(await fs.readFile(savePath));
|
||||
let content = await zip.file("test/modules/test.lua").async("string");
|
||||
assert.equal(content, "-- test");
|
||||
});
|
||||
it("should remove old modules in a save", async function() {
|
||||
await factorio.patch(savePath, [{ name: "test", files: [] }]);
|
||||
let zip = await jszip.loadAsync(await fs.readFile(savePath));
|
||||
assert.equal(zip.file("test/modules/test.lua"), null);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user