Fixed getMac and launching instance with no mods

This commit is contained in:
Danielv123 committed 2018-04-02 12:14:06 +02:00
1 parent cbee07e451
commit cd4887e5cf
2 files changed
+18 -15

No files matched your search

+10 -9
View File
@@ -605,9 +605,9 @@ function instanceManagement() {
} }
} }
if(global.mac){ if(global.mac){
getMac(callback);
} else {
callback(undefined, global.mac); callback(undefined, global.mac);
} else {
getMac(callback);
} }
},1000)}); },1000)});
} }
@@ -892,7 +892,7 @@ function instanceManagement() {
// returns [{modName:string,hash:string}, ... ] // returns [{modName:string,hash:string}, ... ]
function hashMods(instanceName, callback) { function hashMods(instanceName, callback) {
if(!callback) { if(!callback) {
throw "ERROR in function hashMods NO CALLBACK" throw new Error("ERROR in function hashMods NO CALLBACK");
} }
function callback2(hash, modName){ function callback2(hash, modName){
hashedMods[hashedMods.length] = { hashedMods[hashedMods.length] = {
@@ -900,22 +900,23 @@ function hashMods(instanceName, callback) {
hash: hash, hash: hash,
} }
// check if this callback has ran once for each mod // check if this callback has ran once for each mod
if(hashedMods.length == /*mods.length*/ + instanceMods.length) { if(hashedMods.length == instanceMods.length) {
callback(hashedMods); callback(hashedMods);
} }
//console.log(modname); //console.log(modname);
} }
let hashedMods = []; let hashedMods = [];
var i = 0;
/*let mods = fs.readdirSync("./sharedMods/")*/ /*let mods = fs.readdirSync("./sharedMods/")*/
let instanceMods = fs.readdirSync("./instances/"+instanceName+"/mods/"); let instanceMods = fs.readdirSync("./instances/"+instanceName+"/mods/");
if(instanceMods.length == 0){
for(o=0;o<instanceMods.length;o++) { callback({}); // there are no mods installed, return an empty object
}
for(let o=0;o<instanceMods.length;o++) {
if(path.extname(instanceMods[o]) != ".zip") { if(path.extname(instanceMods[o]) != ".zip") {
instanceMods.splice(instanceMods.indexOf(instanceMods[o]), 1); // remove element from array instanceMods.splice(instanceMods.indexOf(instanceMods[o]), 1); // remove element from array, we can't hash unzipped mods
} }
} }
for(i=0; i<instanceMods.length; i++){ for(let i=0; i<instanceMods.length; i++){
let path = "./instances/"+instanceName+"/mods/"+instanceMods[i]; let path = "./instances/"+instanceName+"/mods/"+instanceMods[i];
let name = instanceMods[i]; let name = instanceMods[i];
let options = { let options = {
+8 -6
View File
@@ -19,12 +19,14 @@ setTimeout(function() {
// detect if remoteMap mod is installed, if it is we want to show the link for it // detect if remoteMap mod is installed, if it is we want to show the link for it
let hasRemoteMap = false; let hasRemoteMap = false;
slaveData[key].mods.forEach(mod => { if(slaveData[key].mods){ // not all instances have mods apparently
console.log(mod.modName); slaveData[key].mods.forEach(mod => {
if(mod.modName.includes("remoteMap")){ console.log(mod.modName);
hasRemoteMap = true; // we are still doing the logic on the outside, in case there are multiple instances of remoteMap installed.... if(mod.modName.includes("remoteMap")){
} hasRemoteMap = true; // we are still doing the logic on the outside, in case there are multiple instances of remoteMap installed....
}); }
});
}
if(hasRemoteMap){ if(hasRemoteMap){
HTML += "<a href='/remoteMap?instanceID="+slaveData[key].unique+"'>Remote map</a>" HTML += "<a href='/remoteMap?instanceID="+slaveData[key].unique+"'>Remote map</a>"
} }