mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-04 15:27:19 +07:00
Compile fixes
This commit is contained in:
@ -18,7 +18,6 @@ import io.anuke.arc.util.*;
|
||||
import io.anuke.arc.util.serialization.*;
|
||||
import io.anuke.mindustry.game.Saves.*;
|
||||
import io.anuke.mindustry.io.*;
|
||||
import io.anuke.mindustry.mod.*;
|
||||
import io.anuke.mindustry.ui.dialogs.*;
|
||||
|
||||
import java.io.*;
|
||||
@ -144,7 +143,7 @@ public class AndroidLauncher extends AndroidApplication{
|
||||
useImmersiveMode = true;
|
||||
depth = 0;
|
||||
hideStatusBar = true;
|
||||
errorHandler = ModCrashHandler::handle;
|
||||
//errorHandler = ModCrashHandler::handle;
|
||||
}});
|
||||
checkFiles(getIntent());
|
||||
}
|
||||
|
@ -115,8 +115,8 @@ public class ContentLoader{
|
||||
try{
|
||||
callable.get(content);
|
||||
}catch(Throwable e){
|
||||
if(content.mod != null){
|
||||
mods.handleError(new ModLoadException(content, e), content.mod);
|
||||
if(content.minfo.mod != null){
|
||||
mods.handleContentError(content, e);
|
||||
}else{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@ -180,7 +180,7 @@ public class ContentLoader{
|
||||
throw new IllegalArgumentException("Two content objects cannot have the same name! (issue: '" + content.name + "')");
|
||||
}
|
||||
if(currentMod != null){
|
||||
content.mod = currentMod;
|
||||
content.minfo.mod = currentMod;
|
||||
}
|
||||
contentNameMap[content.getContentType().ordinal()].put(content.name, content);
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
package io.anuke.mindustry.ctype;
|
||||
|
||||
import io.anuke.arc.files.*;
|
||||
import io.anuke.arc.util.ArcAnnotate.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.mod.*;
|
||||
import io.anuke.mindustry.mod.Mods.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
|
||||
|
||||
@ -10,7 +11,7 @@ import io.anuke.mindustry.type.*;
|
||||
public abstract class Content implements Comparable<Content>{
|
||||
public final short id;
|
||||
/** Info on which mod this content was loaded from. */
|
||||
public @Nullable ModContentInfo minfo;
|
||||
public @NonNull ModContentInfo minfo = new ModContentInfo();
|
||||
|
||||
|
||||
public Content(){
|
||||
@ -37,7 +38,7 @@ public abstract class Content implements Comparable<Content>{
|
||||
|
||||
/** @return whether an error ocurred during mod loading. */
|
||||
public boolean hasErrored(){
|
||||
return minfo != null && minfo.error != null;
|
||||
return minfo.error != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -49,4 +50,13 @@ public abstract class Content implements Comparable<Content>{
|
||||
public String toString(){
|
||||
return getContentType().name() + "#" + id;
|
||||
}
|
||||
|
||||
public static class ModContentInfo{
|
||||
/** The mod that loaded this piece of content. */
|
||||
public @Nullable LoadedMod mod;
|
||||
/** File that this content was loaded from. */
|
||||
public @Nullable FileHandle sourceFile;
|
||||
/** The error that occurred during loading, if applicable. Null if no error occurred. */
|
||||
public @Nullable String error;
|
||||
}
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ public class ContentParser{
|
||||
|
||||
TechNode parnode = TechTree.all.find(t -> t.block == parent);
|
||||
if(parnode == null){
|
||||
throw new ModLoadException("Block '" + parent.name + "' isn't in the tech tree, but '" + block.name + "' requires it to be researched.", block);
|
||||
throw new IllegalArgumentException("Block '" + parent.name + "' isn't in the tech tree, but '" + block.name + "' requires it to be researched.");
|
||||
}
|
||||
if(!parnode.children.contains(baseNode)){
|
||||
parnode.children.add(baseNode);
|
||||
@ -386,21 +386,18 @@ public class ContentParser{
|
||||
}
|
||||
}
|
||||
|
||||
public void finishParsing(){
|
||||
reads.each(c -> {
|
||||
try{
|
||||
c.run();
|
||||
}catch(Throwable t){
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
private void attempt(Runnable run){
|
||||
try{
|
||||
reads.each(Runnable::run);
|
||||
postreads.each(Runnable::run);
|
||||
}catch(Exception e){
|
||||
Vars.mods.handleError(new ModLoadException("Error occurred parsing content: " + currentContent, currentContent, e), currentMod);
|
||||
run.run();
|
||||
}catch(Throwable t){
|
||||
//don't overwrite double errors
|
||||
markError(currentContent, t);
|
||||
}
|
||||
}
|
||||
|
||||
public void finishParsing(){
|
||||
reads.each(this::attempt);
|
||||
postreads.each(this::attempt);
|
||||
reads.clear();
|
||||
postreads.clear();
|
||||
toBeParsed.clear();
|
||||
@ -433,7 +430,6 @@ public class ContentParser{
|
||||
currentMod = mod;
|
||||
boolean located = locate(type, name) != null;
|
||||
Content c = parsers.get(type).parse(mod.name, name, value);
|
||||
c.minfo = new ModContentInfo();
|
||||
c.minfo.sourceFile = file;
|
||||
toBeParsed.add(c);
|
||||
|
||||
@ -444,15 +440,17 @@ public class ContentParser{
|
||||
}
|
||||
|
||||
public void markError(Content content, LoadedMod mod, FileHandle file, Throwable error){
|
||||
if(content.minfo == null){
|
||||
content.minfo = new ModContentInfo();
|
||||
}
|
||||
|
||||
content.minfo.mod = mod;
|
||||
content.minfo.sourceFile = file;
|
||||
content.minfo.error = Strings.parseException(error, true);
|
||||
}
|
||||
|
||||
public void markError(Content content, Throwable error){
|
||||
if(content.minfo != null && !content.hasErrored()){
|
||||
markError(content, content.minfo.mod, content.minfo.sourceFile, error);
|
||||
}
|
||||
}
|
||||
|
||||
private <T extends MappableContent> T locate(ContentType type, String name){
|
||||
T first = Vars.content.getByName(type, name); //try vanilla replacement
|
||||
return first != null ? first : Vars.content.getByName(type, currentMod.name + "-" + name);
|
||||
|
@ -1,14 +0,0 @@
|
||||
package io.anuke.mindustry.mod;
|
||||
|
||||
import io.anuke.arc.files.*;
|
||||
import io.anuke.arc.util.ArcAnnotate.*;
|
||||
import io.anuke.mindustry.mod.Mods.*;
|
||||
|
||||
public class ModContentInfo{
|
||||
/** The mod that loaded this piece of content. */
|
||||
public @Nullable LoadedMod mod;
|
||||
/** File that this content was loaded from. */
|
||||
public FileHandle sourceFile;
|
||||
/** The error that occurred during loading, if applicable. Null if no error occurred. */
|
||||
public @Nullable String error;
|
||||
}
|
@ -1,19 +1,9 @@
|
||||
package io.anuke.mindustry.mod;
|
||||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.scene.ui.layout.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.mod.Mods.*;
|
||||
import io.anuke.mindustry.ui.*;
|
||||
|
||||
public class ModCrashHandler{
|
||||
|
||||
public static void handle(Throwable t){
|
||||
/*
|
||||
Array<Throwable> list = Strings.getCauses(t);
|
||||
Throwable modCause = list.find(e -> e instanceof ModLoadException);
|
||||
|
||||
@ -62,6 +52,6 @@ public class ModCrashHandler{
|
||||
});
|
||||
}else{
|
||||
throw new RuntimeException(t);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ public class Mods implements Loadable{
|
||||
//generate new icons
|
||||
for(Array<Content> arr : content.getContentMap()){
|
||||
arr.each(c -> {
|
||||
if(c instanceof UnlockableContent && c.minfo != null && c.minfo.mod != null){
|
||||
if(c instanceof UnlockableContent && c.minfo.mod != null){
|
||||
UnlockableContent u = (UnlockableContent)c;
|
||||
u.createIcons(packer);
|
||||
}
|
||||
@ -465,12 +465,16 @@ public class Mods implements Loadable{
|
||||
//make sure mod content is in proper order
|
||||
runs.sort();
|
||||
for(LoadRun l : runs){
|
||||
Content current = content.getLastAdded();
|
||||
try{
|
||||
//this binds the content but does not load it entirely
|
||||
Content loaded = parser.parse(l.mod, l.file.nameWithoutExtension(), l.file.readString("UTF-8"), l.file, l.type);
|
||||
Log.debug("[{0}] Loaded '{1}'.", l.mod.meta.name, (loaded instanceof UnlockableContent ? ((UnlockableContent)loaded).localizedName : loaded));
|
||||
}catch(Throwable e){
|
||||
throw new RuntimeException("Failed to parse content file '" + l.file + "' for mod '" + l.mod.meta.name + "'.", e);
|
||||
if(current != content.getLastAdded() && content.getLastAdded() != null){
|
||||
parser.markError(content.getLastAdded(), l.mod, l.file, e);
|
||||
}
|
||||
//throw new RuntimeException("Failed to parse content file '" + l.file + "' for mod '" + l.mod.meta.name + "'.", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -478,6 +482,10 @@ public class Mods implements Loadable{
|
||||
parser.finishParsing();
|
||||
}
|
||||
|
||||
public void handleContentError(Content content, Throwable error){
|
||||
parser.markError(content, error);
|
||||
}
|
||||
|
||||
/** @return all loaded mods. */
|
||||
public Array<LoadedMod> all(){
|
||||
return loaded;
|
||||
|
@ -172,8 +172,8 @@ public class Zone extends UnlockableContent{
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
if(generator instanceof MapGenerator && mod != null){
|
||||
((MapGenerator)generator).removePrefix(mod.name);
|
||||
if(generator instanceof MapGenerator && minfo.mod != null){
|
||||
((MapGenerator)generator).removePrefix(minfo.mod.name);
|
||||
}
|
||||
|
||||
generator.init(loadout);
|
||||
|
@ -10,7 +10,6 @@ import io.anuke.arc.util.io.*;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.game.Saves.*;
|
||||
import io.anuke.mindustry.io.*;
|
||||
import io.anuke.mindustry.mod.*;
|
||||
import io.anuke.mindustry.ui.*;
|
||||
import org.robovm.apple.coregraphics.*;
|
||||
import org.robovm.apple.foundation.*;
|
||||
@ -153,7 +152,7 @@ public class IOSLauncher extends IOSApplication.Delegate{
|
||||
UINavigationController.attemptRotationToDeviceOrientation();
|
||||
}
|
||||
}, new IOSApplicationConfiguration(){{
|
||||
errorHandler = ModCrashHandler::handle;
|
||||
//errorHandler = ModCrashHandler::handle;
|
||||
}});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user