diff --git a/core/src/mindustry/core/Version.java b/core/src/mindustry/core/Version.java index 08a105d8fb..bef40c5e87 100644 --- a/core/src/mindustry/core/Version.java +++ b/core/src/mindustry/core/Version.java @@ -45,4 +45,12 @@ public class Version{ build = Strings.canParseInt(map.get("build")) ? Integer.parseInt(map.get("build")) : -1; } } + + /** get menu version without colors */ + public static String combined(){ + if(build == -1){ + return "custom build"; + } + return (type.equals("official") ? modifier : type) + " build " + build + (revision == 0 ? "" : "." + revision); + } } diff --git a/core/src/mindustry/net/CrashSender.java b/core/src/mindustry/net/CrashSender.java index 24a82a9e07..748fa8d592 100644 --- a/core/src/mindustry/net/CrashSender.java +++ b/core/src/mindustry/net/CrashSender.java @@ -19,19 +19,28 @@ import java.text.*; import java.util.*; import static arc.Core.*; +import static mindustry.Vars.mods; import static mindustry.Vars.net; public class CrashSender{ + public static String createReport(String error){ + return "Oh no, Mindustry crashed!\n" + + "Please report this at https://github.com/Anuken/Mindustry/issues/new?labels=bug&template=bug_report.md\n\n" + + "Version:" + Version.combined() + "\n" + + mods.list().size + " Mods: " + mods.list().toString(", ", mod -> mod.name) + + "\n\n" + error; + } + public static void log(Throwable exception){ try{ - Core.settings.getDataDirectory().child("crashes").child("crash_" + System.currentTimeMillis() + ".txt").writeString(Strings.neatError(exception)); + Core.settings.getDataDirectory().child("crashes").child("crash_" + System.currentTimeMillis() + ".txt") + .writeString(createReport(Strings.neatError(exception))); }catch(Throwable ignored){ } } public static void send(Throwable exception, Cons writeListener){ - try{ exception.printStackTrace(); @@ -70,7 +79,7 @@ public class CrashSender{ try{ File file = new File(OS.getAppDataDirectoryString(Vars.appName), "crashes/crash-report-" + new SimpleDateFormat("MM_dd_yyyy_HH_mm_ss").format(new Date()) + ".txt"); new Fi(OS.getAppDataDirectoryString(Vars.appName)).child("crashes").mkdirs(); - new Fi(file).writeString(parseException(exception)); + new Fi(file).writeString(createReport(parseException(exception))); writeListener.get(file); }catch(Throwable e){ Log.err("Failed to save local crash report.", e); @@ -130,11 +139,11 @@ public class CrashSender{ boolean[] sent = {false}; Log.info("Sending crash report."); - //post to crash report URL + //post to crash report URL, exit code indicates success httpPost(Vars.crashReportURL, value.toJson(OutputType.json), r -> { Log.info("Crash sent successfully."); sent[0] = true; - System.exit(1); + System.exit(0); }, t -> { t.printStackTrace(); sent[0] = true; diff --git a/core/src/mindustry/ui/fragments/MenuFragment.java b/core/src/mindustry/ui/fragments/MenuFragment.java index 5ec2692d04..45faa9bf10 100644 --- a/core/src/mindustry/ui/fragments/MenuFragment.java +++ b/core/src/mindustry/ui/fragments/MenuFragment.java @@ -73,8 +73,7 @@ public class MenuFragment extends Fragment{ })); } - String versionText = "[#ffffffba]" + ((Version.build == -1) ? "[#fc8140aa]custom build" : (Version.type.equals("official") ? Version.modifier : Version.type) + " build " + Version.build + (Version.revision == 0 ? "" : "." + Version.revision)); - + String versionText = ((Version.build == -1) ? "[#fc8140aa]" : "[#ffffffba]") + Version.combined(); parent.fill((x, y, w, h) -> { TextureRegion logo = Core.atlas.find("logo"); float logoscl = Scl.scl(1);