From f088b1b460551ffcfe7bdee82b056020af950451 Mon Sep 17 00:00:00 2001 From: Lex Manos Date: Mon, 25 May 2015 13:34:04 -0700 Subject: [PATCH 1/3] Attempt to disable the new splash screen if there are errors detected finishing up. Print a slightly more helpful error message. (cherry picked from commit e3211eec0469dc6717943010d584207b7abdb1e0) Conflicts: fml/src/main/java/cpw/mods/fml/client/SplashProgress.java --- .../cpw/mods/fml/client/SplashProgress.java | 68 +++++++++++++++++-- .../fml/common/EnhancedRuntimeException.java | 8 +-- 2 files changed, 68 insertions(+), 8 deletions(-) diff --git a/fml/src/main/java/cpw/mods/fml/client/SplashProgress.java b/fml/src/main/java/cpw/mods/fml/client/SplashProgress.java index d52154d0f..cf1c07b8e 100644 --- a/fml/src/main/java/cpw/mods/fml/client/SplashProgress.java +++ b/fml/src/main/java/cpw/mods/fml/client/SplashProgress.java @@ -9,6 +9,8 @@ import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; +import java.io.PrintStream; +import java.io.PrintWriter; import java.lang.Thread.UncaughtExceptionHandler; import java.nio.IntBuffer; import java.util.Iterator; @@ -41,6 +43,7 @@ import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.SharedDrawable; import org.lwjgl.util.glu.GLU; +import cpw.mods.fml.common.EnhancedRuntimeException; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.ICrashCallable; @@ -176,7 +179,12 @@ public class SplashProgress return "GL info"; } }); - CrashReport report = CrashReport.makeCrashReport(new Throwable(), "Loading screen debug info"); + CrashReport report = CrashReport.makeCrashReport(new Throwable() + { + @Override public String getMessage(){ return "This is just a prompt for computer specs to be printed. THIS IS NOT A ERROR"; } + @Override public void printStackTrace(final PrintWriter s){ s.println(getMessage()); } + @Override public void printStackTrace(final PrintStream s) { s.println(getMessage()); } + }, "Loading screen debug info"); System.out.println(report.getCompleteReport()); try @@ -272,8 +280,8 @@ public class SplashProgress // forge logo setColor(backgroundColor); - float fw = (float)forgeTexture.getWidth() / 2; - float fh = (float)forgeTexture.getHeight() / 2; + float fw = (float)forgeTexture.getWidth() / 2 / 2; + float fh = (float)forgeTexture.getHeight() / 2 / 2; if(rotate) { float sh = Math.max(fw, fh); @@ -494,10 +502,62 @@ public class SplashProgress catch (Exception e) { e.printStackTrace(); - throw new RuntimeException(e); + if (disableSplash()) + { + throw new EnhancedRuntimeException(e) + { + @Override + protected void printStackTrace(WrappedPrintStream stream) + { + stream.println("SplashProgress has detected a error loading Minecraft."); + stream.println("This can sometimes be caused by bad video drivers."); + stream.println("We have automatically disabeled the new Splash Screen in config/splash.properties."); + stream.println("Try reloading minecraft before reporting any errors."); + } + }; + } + else + { + throw new EnhancedRuntimeException(e) + { + @Override + protected void printStackTrace(WrappedPrintStream stream) + { + stream.println("SplashProgress has detected a error loading Minecraft."); + stream.println("This can sometimes be caused by bad video drivers."); + stream.println("Please try disabeling the new Splash Screen in config/splash.properties."); + stream.println("After doing so, try reloading minecraft before reporting any errors."); + } + }; + } } } + private static boolean disableSplash() + { + File configFile = new File(Minecraft.getMinecraft().mcDataDir, "config/splash.properties"); + FileReader r = null; + enabled = false; + config.setProperty("enabled", "false"); + + FileWriter w = null; + try + { + w = new FileWriter(configFile); + config.store(w, "Splash screen properties"); + } + catch(IOException e) + { + FMLLog.log(Level.ERROR, e, "Could not save the splash.properties file"); + return false; + } + finally + { + IOUtils.closeQuietly(w); + } + return true; + } + private static IResourcePack createResourcePack(File file) { if(file.isDirectory()) diff --git a/fml/src/main/java/cpw/mods/fml/common/EnhancedRuntimeException.java b/fml/src/main/java/cpw/mods/fml/common/EnhancedRuntimeException.java index 894b7f35a..c761d36a1 100644 --- a/fml/src/main/java/cpw/mods/fml/common/EnhancedRuntimeException.java +++ b/fml/src/main/java/cpw/mods/fml/common/EnhancedRuntimeException.java @@ -44,7 +44,7 @@ public abstract class EnhancedRuntimeException extends RuntimeException this.printStackTrace(new WrappedPrintStream() { @Override - void println(String line) + public void println(String line) { buf.append(line).append('\n'); } @@ -60,7 +60,7 @@ public abstract class EnhancedRuntimeException extends RuntimeException printStackTrace(new WrappedPrintStream() { @Override - void println(String line) + public void println(String line) { s.println(line); } @@ -72,7 +72,7 @@ public abstract class EnhancedRuntimeException extends RuntimeException printStackTrace(new WrappedPrintStream() { @Override - void println(String line) + public void println(String line) { s.println(line); } @@ -84,6 +84,6 @@ public abstract class EnhancedRuntimeException extends RuntimeException public static abstract class WrappedPrintStream { - abstract void println(String line); + public abstract void println(String line); } } From e6eeb031080c819781fe468dd155d4b8973d40ca Mon Sep 17 00:00:00 2001 From: Lex Manos Date: Mon, 25 May 2015 14:32:35 -0700 Subject: [PATCH 2/3] Finish loading screen before going fullscreen. Closes MinecraftForge/FML#662 (cherry picked from commit 19d7e16fa6a28c5665de1ed6e50d8699e865bff2) Conflicts: fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch --- .../net/minecraft/client/Minecraft.java.patch | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch b/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch index 64fd52fa6..c5e5abb79 100644 --- a/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch +++ b/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch @@ -79,7 +79,7 @@ this.field_71417_B = new MouseHelper(); this.func_71361_d("Pre startup"); GL11.glEnable(GL11.GL_TEXTURE_2D); -@@ -524,27 +535,35 @@ +@@ -524,30 +535,39 @@ GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_MODELVIEW); this.func_71361_d("Startup"); @@ -117,14 +117,10 @@ this.field_152354_ay = null; this.field_71461_s = new LoadingScreenRenderer(this); -@@ -553,6 +572,7 @@ - this.func_71352_k(); - } - + FMLClientHandler.instance().onInitializationComplete(); - try + if (this.field_71474_y.field_74353_u && !this.field_71431_Q) { - Display.setVSyncEnabled(this.field_71474_y.field_74352_v); + this.func_71352_k(); @@ -970,9 +990,11 @@ if (!this.field_71454_w) From f8cb411df1510379fa34b32ec649d7d49ccf8003 Mon Sep 17 00:00:00 2001 From: cpw Date: Tue, 2 Jun 2015 07:24:26 -0400 Subject: [PATCH 3/3] So we can't print a lot of unicode in the splash screen, so restrict to a hard subset we know we CAN print, closes #1910 --- .../main/java/cpw/mods/fml/client/FMLClientHandler.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fml/src/main/java/cpw/mods/fml/client/FMLClientHandler.java b/fml/src/main/java/cpw/mods/fml/client/FMLClientHandler.java index 73dc9a694..b61887b2d 100644 --- a/fml/src/main/java/cpw/mods/fml/client/FMLClientHandler.java +++ b/fml/src/main/java/cpw/mods/fml/client/FMLClientHandler.java @@ -69,6 +69,7 @@ import org.lwjgl.LWJGLUtil; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.Display; +import com.google.common.base.CharMatcher; import com.google.common.base.Strings; import com.google.common.base.Throwables; import com.google.common.collect.BiMap; @@ -1011,10 +1012,12 @@ public class FMLClientHandler implements IFMLSidedHandler Display.processMessages(); SplashProgress.mutex.release(); } - + // From FontRenderer.renderCharAtPos + private static final String ALLOWED_CHARS = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000"; @Override public String stripSpecialChars(String message) { - return StringUtils.stripControlCodes(message); + // We can't handle many unicode points in the splash renderer + return CharMatcher.anyOf(ALLOWED_CHARS).retainFrom(StringUtils.stripControlCodes(message)); } }