Browse Source

bug #1817: Fixed an issue causing mods to load in the incorrect order for more complex depeondsOn trees

tags/v0.10.0^2
Shaun 2 years ago
parent
commit
27bd042a3b
1 changed files with 11 additions and 15 deletions
  1. +11
    -15
      src/server/misc/mods.js

+ 11
- 15
src/server/misc/mods.js View File

@@ -22,26 +22,22 @@ module.exports = {
};
});

//Reorder mods so that mods that depend on others load later
loadList = loadList.sort((a, b) => {
const { id: idA, mod: { dependsOn: depA = [] } } = a;
const { id: idB, mod: { dependsOn: depB = [] } } = b;
while (loadList.length) {
for (const m of loadList) {
const { id, folderName, mod } = m;
const { dependsOn = [] } = mod;

if (depB.includes(idA) || !depA.length)
return -1;
else if (depA.includes(idB) || !depB.length)
return 1;
const wait = dependsOn.some(d => loadList.some(l => l.id === d));

return 0;
});
if (wait)
continue;

//Initialize mods
for (const m of loadList) {
const { folderName, mod } = m;
await this.onGetMod(folderName, mod);

await this.onGetMod(folderName, mod);
this.mods.push(mod);

this.mods.push(mod);
loadList.spliceWhere(l => l.id === id);
}
}
},



Loading…
Cancel
Save