Set default values for mod settings on export

Add missing mod settings set to their default values to a mod pack when
performing a data export based on the settings prototypes that were
extracted from the game. This mirrors the behaviour of Factorio when new
setting prototypes are added by a mod.
This commit is contained in:
Hornwitser committed 2023-02-02 00:28:58 +01:00
1 parent 39ed098a64
commit ddc548f590
3 files changed
+133

No files matched your search

+6
View File
@@ -220,12 +220,17 @@ async function uploadExport(req, res) {
];
let assets = {};
let settingPrototypes = {};
for (let filePath of exportFiles) {
let file = zip.file(filePath);
if (!file) {
continue;
}
if (filePath === "export/settings.json") {
settingPrototypes = JSON.parse(await file.async("text"));
}
let { name, ext } = path.posix.parse(filePath);
let hash = await libHash.hashStream(file.nodeStream());
assets[name] = `${name}.${hash}${ext}`;
@@ -233,6 +238,7 @@ async function uploadExport(req, res) {
}
modPack.exportManifest = new libData.ExportManifest({ assets });
modPack.fillDefaultSettings(settingPrototypes, logger);
res.app.locals.master.modPackUpdated(modPack);
res.sendStatus(200);