mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-17 23:33:12 +09:00
Add and fix tests
This commit is contained in:
8 files changed
+60
-15
No files matched your search
@@ -620,11 +620,9 @@ export default class Host extends lib.Link {
|
||||
async fetchMods(mods: Iterable<lib.ModRecord>) {
|
||||
// This is better than the previous hard coded names
|
||||
// But it really shouldn't be a hard coded version either
|
||||
const builtinModNames = lib.ModPack.getBuiltinMods("2.0").map(builtinMod => builtinMod.name);
|
||||
const builtinModNames = lib.ModPack.getBuiltinModNames("2.0");
|
||||
const modInfos: Promise<lib.ModInfo>[] = [];
|
||||
for (const mod of mods) {
|
||||
// XXX These mods ship with Factorio, but the list of mods may
|
||||
// change and should not be hardcoded here.
|
||||
if (builtinModNames.includes(mod.name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -103,8 +103,8 @@ async function loadFile(server: FactorioServer, modVersions: Map<string, string>
|
||||
|
||||
let [, mod, filePath] = match;
|
||||
|
||||
const builtinMods = lib.ModPack.getBuiltinMods(server.version!);
|
||||
if (builtinMods.some(builtinMod => builtinMod.name === mod)) {
|
||||
const builtinModNames = ["core", ...lib.ModPack.getBuiltinModNames(server.version!)];
|
||||
if (builtinModNames.includes(mod)) {
|
||||
try {
|
||||
return await fs.readFile(server.dataPath(mod, filePath));
|
||||
} catch (err: any) {
|
||||
@@ -397,15 +397,18 @@ async function exportLocale(
|
||||
}
|
||||
}
|
||||
|
||||
const builtinMods = lib.ModPack.getBuiltinMods(server.version!);
|
||||
for (const builtinMod of builtinMods) {
|
||||
const localeFilePath = server.dataPath(builtinMod.name, "locale", languageCode, `${builtinMod.name}.cfg`);
|
||||
const builtinModNames = [
|
||||
// Filter if on builtin mods so "core" does not need to be specified in modOrder
|
||||
"core", ...lib.ModPack.getBuiltinModNames(server.version!).filter(mod => modOrder.includes(mod)),
|
||||
];
|
||||
for (const builtinModName of builtinModNames) {
|
||||
const localeFilePath = server.dataPath(builtinModName, "locale", languageCode, `${builtinModName}.cfg`);
|
||||
mergeLocale(lib.parse(await fs.readFile(localeFilePath, "utf8")));
|
||||
}
|
||||
|
||||
const builtinModNames = ["export", ...builtinMods.map(builtinMod => builtinMod.name)];
|
||||
const builtinModNamesExport = ["export", ...builtinModNames];
|
||||
for (let mod of modOrder) {
|
||||
if (builtinModNames.includes(mod)) {
|
||||
if (builtinModNamesExport.includes(mod)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -346,9 +346,9 @@ function reorderDependencies(modules: SaveModule[]) {
|
||||
const knownScenarios: Record<string, lib.ModuleInfo> = {
|
||||
// First seen in 0.17.63
|
||||
"4e866186ebe297f1038fd325b09df1a1f5e2fdd1": new lib.ModuleInfo("freeplay", "0.17.63", [], ["scenario"]),
|
||||
// First seen in 1.2.0 (aka 2.0) TODO Uncomment once clusterio lib supports 2.0
|
||||
// First seen in 2.0 TODO Uncomment once clusterio lib supports 2.0
|
||||
// The rest of the code has already been updated to support the new control.lua file for 2.0
|
||||
// "bcbdde18ce4ec16ebfd93bd694cd9b12ef969c9a": new lib.ModuleInfo("freeplay", "1.2.0", [], ["scenario"]),
|
||||
// "bcbdde18ce4ec16ebfd93bd694cd9b12ef969c9a": new lib.ModuleInfo("freeplay", "2.0.0", [], ["scenario"]),
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -391,6 +391,7 @@ export default class ModPack {
|
||||
*/
|
||||
static getBuiltinMods(factorioVersion: string) {
|
||||
let defaultMods: ModRecord[] = [
|
||||
// "core" not included because core cannot be disabled
|
||||
{ name: "base", enabled: true, version: factorioVersion },
|
||||
];
|
||||
|
||||
@@ -405,4 +406,8 @@ export default class ModPack {
|
||||
|
||||
return defaultMods;
|
||||
}
|
||||
|
||||
static getBuiltinModNames(factorioVersion: string) {
|
||||
return this.getBuiltinMods(factorioVersion).map(builtinMod => builtinMod.name);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user