mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-19 15:33:12 +09:00
Fix export when default mod pack is used
This commit is contained in:
1 parent
8db1b48691
commit
91af66e2db
2 files changed
+14
-9
No files matched your search
@@ -191,6 +191,12 @@ class Instance extends libLink.Link {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mod pack currently running on this instance
|
||||||
|
* @type {module:lib/data.ModPack>}
|
||||||
|
*/
|
||||||
|
this.activeModPack = undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Per player statistics recorded by this instance.
|
* Per player statistics recorded by this instance.
|
||||||
* @type {Map<string, module:lib/PlayerStats>}
|
* @type {Map<string, module:lib/PlayerStats>}
|
||||||
@@ -593,13 +599,13 @@ rcon.print(game.table_to_json(players))`.replace(/\r?\n/g, " ");
|
|||||||
*/
|
*/
|
||||||
async syncMods() {
|
async syncMods() {
|
||||||
const modPackId = this.config.get("factorio.mod_pack");
|
const modPackId = this.config.get("factorio.mod_pack");
|
||||||
let modPack;
|
let response;
|
||||||
if (modPackId === null) {
|
if (modPackId === null) {
|
||||||
modPack = new libData.ModPack();
|
response = await libLink.messages.getDefaultModPack.send(this);
|
||||||
} else {
|
} else {
|
||||||
const response = await libLink.messages.getModPack.send(this, { id: modPackId });
|
response = await libLink.messages.getModPack.send(this, { id: modPackId });
|
||||||
modPack = new libData.ModPack(response.mod_pack);
|
|
||||||
}
|
}
|
||||||
|
this.activeModPack = new libData.ModPack(response.mod_pack);
|
||||||
|
|
||||||
// TODO validate factorioVersion
|
// TODO validate factorioVersion
|
||||||
|
|
||||||
@@ -625,7 +631,7 @@ rcon.print(game.table_to_json(players))`.replace(/\r?\n/g, " ");
|
|||||||
|
|
||||||
// Add mods from mod the pack
|
// Add mods from mod the pack
|
||||||
const modsDir = this._slave.config.get("slave.mods_directory");
|
const modsDir = this._slave.config.get("slave.mods_directory");
|
||||||
for (let mod of modPack.mods.values()) {
|
for (let mod of this.activeModPack.mods.values()) {
|
||||||
const modFile = `${mod.name}_${mod.version}.zip`;
|
const modFile = `${mod.name}_${mod.version}.zip`;
|
||||||
const target = path.join(modsDir, modFile);
|
const target = path.join(modsDir, modFile);
|
||||||
const link = this.path("mods", modFile);
|
const link = this.path("mods", modFile);
|
||||||
@@ -643,11 +649,11 @@ rcon.print(game.table_to_json(players))`.replace(/\r?\n/g, " ");
|
|||||||
|
|
||||||
// Write mod-list.json
|
// Write mod-list.json
|
||||||
await fs.outputFile(this.path("mods", "mod-list.json"), JSON.stringify({
|
await fs.outputFile(this.path("mods", "mod-list.json"), JSON.stringify({
|
||||||
mods: [{ name: "base" }, ...modPack.mods.values()].map(m => ({ name: m.name, enabled: true })),
|
mods: [{ name: "base" }, ...this.activeModPack.mods.values()].map(m => ({ name: m.name, enabled: true })),
|
||||||
}, null, 2));
|
}, null, 2));
|
||||||
|
|
||||||
// Write mod-settings.dat
|
// Write mod-settings.dat
|
||||||
await fs.outputFile(this.path("mods", "mod-settings.dat"), modPack.toModSettingsDat());
|
await fs.outputFile(this.path("mods", "mod-settings.dat"), this.activeModPack.toModSettingsDat());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1064,7 +1070,7 @@ rcon.print(game.table_to_json(players))`.replace(/\r?\n/g, " ");
|
|||||||
let content = await zip.generateAsync({ type: "nodebuffer" });
|
let content = await zip.generateAsync({ type: "nodebuffer" });
|
||||||
let url = new URL(this._slave.config.get("slave.master_url"));
|
let url = new URL(this._slave.config.get("slave.master_url"));
|
||||||
url.pathname += "api/upload-export";
|
url.pathname += "api/upload-export";
|
||||||
url.searchParams.set("mod_pack_id", this.config.get("factorio.mod_pack"));
|
url.searchParams.set("mod_pack_id", this.activeModPack.id);
|
||||||
let response = await phin({
|
let response = await phin({
|
||||||
url, method: "PUT",
|
url, method: "PUT",
|
||||||
data: content,
|
data: content,
|
||||||
|
|||||||
@@ -265,7 +265,6 @@ describe("Integration of Clusterio", function() {
|
|||||||
);
|
);
|
||||||
await execCtl(`instance config set-prop test factorio.settings visibility "'${value}'"`);
|
await execCtl(`instance config set-prop test factorio.settings visibility "'${value}'"`);
|
||||||
await execCtl("instance config set-prop test factorio.settings require_user_verification false");
|
await execCtl("instance config set-prop test factorio.settings require_user_verification false");
|
||||||
await execCtl("instance config set test factorio.mod_pack 12");
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user