mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-17 23:33:12 +09:00
Default to the newest Base Game pack on new clusters (#1216)
A new cluster gets the default mod packs but controller.default_mod_pack_id stays null, so the first Create save or Start fails with "Default mod pack not set on controller". When seeding the packs, also point the default at the newest Base Game pack, unless an admin already set one. Clusters that already have mod packs are left alone. The config is written with the mod packs on the next autosave or shutdown. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
09d79d775f
commit
c2c7edf1b7
3 files changed
+44
No files matched your search
@@ -93,6 +93,43 @@ describe("controller/src/Controller", function() {
|
||||
assert(loaded.modPacks.size > 0, "default mod packs were not added");
|
||||
await fs.access(modsDirectory);
|
||||
});
|
||||
it("should default to the newest Base Game pack on a new cluster", async function() {
|
||||
const config = new ControllerConfig("controller", {
|
||||
"controller.version": controllerVersion,
|
||||
"controller.database_directory": path.join(dir, "database"),
|
||||
"controller.mods_directory": path.join(dir, "mods"),
|
||||
});
|
||||
|
||||
const loaded = await Controller.fromConfig(config, [], {});
|
||||
const id = config.get("controller.default_mod_pack_id");
|
||||
assert.equal(loaded.modPacks.get(id).name, "Base Game 2.1");
|
||||
});
|
||||
it("should keep a set default mod pack when seeding mod packs", async function() {
|
||||
const config = new ControllerConfig("controller", {
|
||||
"controller.version": controllerVersion,
|
||||
"controller.database_directory": path.join(dir, "database"),
|
||||
"controller.mods_directory": path.join(dir, "mods"),
|
||||
"controller.default_mod_pack_id": 42,
|
||||
});
|
||||
|
||||
await Controller.fromConfig(config, [], {});
|
||||
assert.equal(config.get("controller.default_mod_pack_id"), 42);
|
||||
});
|
||||
it("should not set a default mod pack when mod packs exist", async function() {
|
||||
const databaseDirectory = path.join(dir, "database");
|
||||
await fs.mkdir(databaseDirectory);
|
||||
await fs.writeFile(path.join(databaseDirectory, "mod-packs.json"), JSON.stringify([
|
||||
new ModPack().toJSON(),
|
||||
]));
|
||||
const config = new ControllerConfig("controller", {
|
||||
"controller.version": controllerVersion,
|
||||
"controller.database_directory": databaseDirectory,
|
||||
"controller.mods_directory": path.join(dir, "mods"),
|
||||
});
|
||||
|
||||
await Controller.fromConfig(config, [], {});
|
||||
assert.equal(config.get("controller.default_mod_pack_id"), null);
|
||||
});
|
||||
it("should start and stop with an existing database", async function() {
|
||||
this.timeout(10000);
|
||||
const databaseDirectory = path.join(dir, "database");
|
||||
|
||||
Reference in new issue
Block a user