From 3894234578d586f8fa2addeddb84877bca5a3e5c Mon Sep 17 00:00:00 2001 From: DeltaNedas Date: Sat, 19 Sep 2020 09:54:09 +0100 Subject: [PATCH 1/8] more info in crash reports --- core/src/mindustry/core/Version.java | 8 ++++++++ core/src/mindustry/net/CrashSender.java | 19 ++++++++++++++----- .../mindustry/ui/fragments/MenuFragment.java | 3 +-- 3 files changed, 23 insertions(+), 7 deletions(-) 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); From c324cf2c6615f7e424a664cf9f8b00dacbc6168c Mon Sep 17 00:00:00 2001 From: DeltaNedas Date: Sat, 19 Sep 2020 09:56:05 +0100 Subject: [PATCH 2/8] h --- core/src/mindustry/net/CrashSender.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/mindustry/net/CrashSender.java b/core/src/mindustry/net/CrashSender.java index 748fa8d592..4e61b91b2d 100644 --- a/core/src/mindustry/net/CrashSender.java +++ b/core/src/mindustry/net/CrashSender.java @@ -27,7 +27,7 @@ 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" + + "Version: " + Version.combined() + "\n" + mods.list().size + " Mods: " + mods.list().toString(", ", mod -> mod.name) + "\n\n" + error; } From 435ef23eedc21ccff378ce9388efe69417dcb480 Mon Sep 17 00:00:00 2001 From: DeltaNedas <39013340+DeltaNedas@users.noreply.github.com> Date: Sat, 19 Sep 2020 09:50:02 +0000 Subject: [PATCH 3/8] Update CrashSender.java --- core/src/mindustry/net/CrashSender.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/src/mindustry/net/CrashSender.java b/core/src/mindustry/net/CrashSender.java index 4e61b91b2d..4a26bb9ee5 100644 --- a/core/src/mindustry/net/CrashSender.java +++ b/core/src/mindustry/net/CrashSender.java @@ -25,9 +25,11 @@ 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" + String report = "Oh no, Mindustry crashed!\n"; + if(mods.list().size == 0){ + report += "Please report this at https://github.com/Anuken/Mindustry/issues/new?labels=bug&template=bug_report.md\n\n"; + } + return report + "Version: " + Version.combined() + "\n" + mods.list().size + " Mods: " + mods.list().toString(", ", mod -> mod.name) + "\n\n" + error; } From 632322a2bcd798cb9b984f427c964dc75cdf2158 Mon Sep 17 00:00:00 2001 From: DeltaNedas Date: Sun, 20 Sep 2020 20:25:57 +0100 Subject: [PATCH 4/8] add even more info to crash logs --- core/src/mindustry/net/CrashSender.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/src/mindustry/net/CrashSender.java b/core/src/mindustry/net/CrashSender.java index 4a26bb9ee5..ac32460733 100644 --- a/core/src/mindustry/net/CrashSender.java +++ b/core/src/mindustry/net/CrashSender.java @@ -29,7 +29,10 @@ public class CrashSender{ if(mods.list().size == 0){ report += "Please report this at https://github.com/Anuken/Mindustry/issues/new?labels=bug&template=bug_report.md\n\n"; } - return report + "Version: " + Version.combined() + "\n" + return report + "Version: " + Version.combined() + (net.headless ? " (Server)" : "") + "\n" + + "OS: " + System.getProperty("os.name") + "x" + (OS.is64Bit ? "64" : "32") + "\n" + + "Java Version: " + System.getProperty("java.version") + "\n" + + "Java Architecture: " + System.getProperty("sun.arch.data.model") + "\n" + mods.list().size + " Mods: " + mods.list().toString(", ", mod -> mod.name) + "\n\n" + error; } @@ -141,7 +144,7 @@ public class CrashSender{ boolean[] sent = {false}; Log.info("Sending crash report."); - //post to crash report URL, exit code indicates success + //post to crash report URL, exit code indicates send success httpPost(Vars.crashReportURL, value.toJson(OutputType.json), r -> { Log.info("Crash sent successfully."); sent[0] = true; From f9a70b1190d278f34246b3a9e78d924d62a5d1e4 Mon Sep 17 00:00:00 2001 From: DeltaNedas Date: Sun, 20 Sep 2020 20:35:44 +0100 Subject: [PATCH 5/8] typo --- core/src/mindustry/net/CrashSender.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/mindustry/net/CrashSender.java b/core/src/mindustry/net/CrashSender.java index ac32460733..daa98a331e 100644 --- a/core/src/mindustry/net/CrashSender.java +++ b/core/src/mindustry/net/CrashSender.java @@ -29,7 +29,7 @@ public class CrashSender{ if(mods.list().size == 0){ report += "Please report this at https://github.com/Anuken/Mindustry/issues/new?labels=bug&template=bug_report.md\n\n"; } - return report + "Version: " + Version.combined() + (net.headless ? " (Server)" : "") + "\n" + return report + "Version: " + Version.combined() + (Vars.headless ? " (Server)" : "") + "\n" + "OS: " + System.getProperty("os.name") + "x" + (OS.is64Bit ? "64" : "32") + "\n" + "Java Version: " + System.getProperty("java.version") + "\n" + "Java Architecture: " + System.getProperty("sun.arch.data.model") + "\n" From 8b354e73344e4617680749d3899a2bba76774f3c Mon Sep 17 00:00:00 2001 From: DeltaNedas <39013340+DeltaNedas@users.noreply.github.com> Date: Tue, 22 Sep 2020 06:13:51 +0000 Subject: [PATCH 6/8] Update core/src/mindustry/net/CrashSender.java Co-authored-by: Anuken --- core/src/mindustry/net/CrashSender.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/mindustry/net/CrashSender.java b/core/src/mindustry/net/CrashSender.java index daa98a331e..9d51b4979e 100644 --- a/core/src/mindustry/net/CrashSender.java +++ b/core/src/mindustry/net/CrashSender.java @@ -30,7 +30,7 @@ public class CrashSender{ report += "Please report this at https://github.com/Anuken/Mindustry/issues/new?labels=bug&template=bug_report.md\n\n"; } return report + "Version: " + Version.combined() + (Vars.headless ? " (Server)" : "") + "\n" - + "OS: " + System.getProperty("os.name") + "x" + (OS.is64Bit ? "64" : "32") + "\n" + + "OS: " + System.getProperty("os.name") + " x" + (OS.is64Bit ? "64" : "32") + "\n" + "Java Version: " + System.getProperty("java.version") + "\n" + "Java Architecture: " + System.getProperty("sun.arch.data.model") + "\n" + mods.list().size + " Mods: " + mods.list().toString(", ", mod -> mod.name) From c7cfb290eb6d55791d993ca6795feb0bf69565e4 Mon Sep 17 00:00:00 2001 From: DeltaNedas <39013340+DeltaNedas@users.noreply.github.com> Date: Tue, 22 Sep 2020 06:15:43 +0000 Subject: [PATCH 7/8] version for mods --- core/src/mindustry/net/CrashSender.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/mindustry/net/CrashSender.java b/core/src/mindustry/net/CrashSender.java index 9d51b4979e..c86ead0973 100644 --- a/core/src/mindustry/net/CrashSender.java +++ b/core/src/mindustry/net/CrashSender.java @@ -33,7 +33,7 @@ public class CrashSender{ + "OS: " + System.getProperty("os.name") + " x" + (OS.is64Bit ? "64" : "32") + "\n" + "Java Version: " + System.getProperty("java.version") + "\n" + "Java Architecture: " + System.getProperty("sun.arch.data.model") + "\n" - + mods.list().size + " Mods: " + mods.list().toString(", ", mod -> mod.name) + + mods.list().size + " Mods: " + mods.list().toString(", ", mod -> mod.name + ":" + mod.meta.version) + "\n\n" + error; } From 472d408bbc9243efc7f8dac8645bc7d0dd6ce9b4 Mon Sep 17 00:00:00 2001 From: DeltaNedas <39013340+DeltaNedas@users.noreply.github.com> Date: Tue, 22 Sep 2020 06:16:40 +0000 Subject: [PATCH 8/8] crash send error code --- core/src/mindustry/net/CrashSender.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/mindustry/net/CrashSender.java b/core/src/mindustry/net/CrashSender.java index c86ead0973..2d31c25ca8 100644 --- a/core/src/mindustry/net/CrashSender.java +++ b/core/src/mindustry/net/CrashSender.java @@ -148,11 +148,11 @@ public class CrashSender{ httpPost(Vars.crashReportURL, value.toJson(OutputType.json), r -> { Log.info("Crash sent successfully."); sent[0] = true; - System.exit(0); + System.exit(1); }, t -> { t.printStackTrace(); sent[0] = true; - System.exit(1); + System.exit(-1); }); //sleep until report is sent