Improved crash logs; source mod of crashes now included in report
This commit is contained in:
@@ -1252,6 +1252,7 @@ public class Mods implements Loadable{
|
||||
if(name != null) name = Strings.stripColors(name);
|
||||
if(displayName != null) displayName = Strings.stripColors(displayName);
|
||||
if(displayName == null) displayName = name;
|
||||
if(version == null) version = "0";
|
||||
if(author != null) author = Strings.stripColors(author);
|
||||
if(description != null) description = Strings.stripColors(description);
|
||||
if(subtitle != null) subtitle = Strings.stripColors(subtitle).replace("\n", "");
|
||||
|
||||
@@ -10,7 +10,6 @@ import rhino.*;
|
||||
import rhino.module.*;
|
||||
import rhino.module.provider.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
import java.util.regex.*;
|
||||
@@ -85,7 +84,7 @@ public class Scripts implements Disposable{
|
||||
|
||||
public void run(LoadedMod mod, Fi file){
|
||||
currentMod = mod;
|
||||
run(file.readString(), file.name(), true);
|
||||
run(file.readString(), mod.name + "/" + file.name(), true);
|
||||
currentMod = null;
|
||||
}
|
||||
|
||||
@@ -95,15 +94,10 @@ public class Scripts implements Disposable{
|
||||
//inject script info into file
|
||||
context.evaluateString(scope, "modName = \"" + currentMod.name + "\"\nscriptName = \"" + file + "\"", "initscript.js", 1);
|
||||
}
|
||||
context.evaluateString(scope,
|
||||
wrap ? "(function(){'use strict';\n" + script + "\n})();" : script,
|
||||
file, 0);
|
||||
context.evaluateString(scope, wrap ? "(function(){'use strict';\n" + script + "\n})();" : script, file, 0);
|
||||
return true;
|
||||
}catch(Throwable t){
|
||||
if(currentMod != null){
|
||||
file = currentMod.name + "/" + file;
|
||||
}
|
||||
log(LogLevel.err, file, "" + getError(t, true));
|
||||
log(LogLevel.err, file, getError(t, true));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -123,10 +117,10 @@ public class Scripts implements Disposable{
|
||||
@Override
|
||||
public ModuleSource loadSource(String moduleId, Scriptable paths, Object validator) throws URISyntaxException{
|
||||
if(currentMod == null) return null;
|
||||
return loadSource(moduleId, currentMod.root.child("scripts"), validator);
|
||||
return loadSource(currentMod, moduleId, currentMod.root.child("scripts"), validator);
|
||||
}
|
||||
|
||||
private ModuleSource loadSource(String moduleId, Fi root, Object validator) throws URISyntaxException{
|
||||
private ModuleSource loadSource(LoadedMod sourceMod, String moduleId, Fi root, Object validator) throws URISyntaxException{
|
||||
Matcher matched = directory.matcher(moduleId);
|
||||
if(matched.find()){
|
||||
LoadedMod required = Vars.mods.locateMod(matched.group(1));
|
||||
@@ -134,18 +128,16 @@ public class Scripts implements Disposable{
|
||||
if(required == null){ // Mod not found, treat it as a folder
|
||||
Fi dir = root.child(matched.group(1));
|
||||
if(!dir.exists()) return null; // Mod and folder not found
|
||||
return loadSource(script, dir, validator);
|
||||
return loadSource(sourceMod, script, dir, validator);
|
||||
}
|
||||
|
||||
currentMod = required;
|
||||
return loadSource(script, required.root.child("scripts"), validator);
|
||||
return loadSource(sourceMod, script, required.root.child("scripts"), validator);
|
||||
}
|
||||
|
||||
Fi module = root.child(moduleId + ".js");
|
||||
if(!module.exists() || module.isDirectory()) return null;
|
||||
return new ModuleSource(
|
||||
new InputStreamReader(new ByteArrayInputStream((module.readString()).getBytes())),
|
||||
new URI(moduleId), root.file().toURI(), validator);
|
||||
return new ModuleSource(module.reader(Vars.bufferSize), new URI(sourceMod.name + "/" + moduleId + ".js"), root.file().toURI(), validator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user