Permalink
Browse files

Put try{} catch{} around Console.WriteLine, fixes crashing on WINE wh…

…en run without terminal
  • Loading branch information...
UnknownShadow200 committed Oct 8, 2017
1 parent d04e257 commit 955891467bbc1cb24048ca08cdda597d022bee46
@@ -84,13 +84,7 @@ public sealed class CPEProtocol : IProtocol {
WriteCustomBlockSupportLevel(1);
net.SendPacket();
game.UseCPEBlocks = true;
if (supportLevel == 1) {
game.Events.RaiseBlockPermissionsChanged();
} else {
Utils.LogDebug("Server's block support level is {0}, this client only supports level 1.", supportLevel);
Utils.LogDebug("You won't be able to see or use blocks from levels above level 1");
}
game.Events.RaiseBlockPermissionsChanged();
}
void HandleHoldThis() {
@@ -165,20 +165,9 @@ public sealed class ClassicProtocol : IProtocol {
int y = reader.ReadUInt16();
int z = reader.ReadUInt16();
byte block = reader.ReadUInt8();
#if DEBUG_BLOCKS
if (game.World.IsNotLoaded) {
Utils.LogDebug("Server tried to update a block while still sending us the map!");
} else if (!game.World.IsValidPos(x, y, z)) {
Utils.LogDebug("Server tried to update a block at an invalid position!");
} else {
game.UpdateBlock(x, y, z, block);
}
#else
if (game.World.blocks != null && game.World.IsValidPos(x, y, z)) {
game.UpdateBlock(x, y, z, block);
}
#endif
}
void HandleAddEntity() {
@@ -101,11 +101,11 @@ public static partial class Utils {
}
public static void LogDebug(string text) {
Console.WriteLine(text);
try { Console.WriteLine(text); } catch { }
}
public static void LogDebug(string text, params object[] args) {
Console.WriteLine(String.Format(text, args));
try { Console.WriteLine(String.Format(text, args)); } catch { }
}
public static int AccumulateWheelDelta(ref float accmulator, float delta) {
@@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using ClassicalSharp;
using ClassicalSharp.Network;
namespace Launcher.Patcher {
@@ -94,7 +95,7 @@ public sealed class ResourceFetcher {
Request item;
if (downloader.TryGetItem(identifier, out item)) {
FilesToDownload.RemoveAt(0);
Console.WriteLine("got resource " + identifier);
Utils.LogDebug("got resource " + identifier);
if (item.Data == null) {
setStatus("&cFailed to download " + identifier);
@@ -1,6 +1,7 @@
// ClassicalSharp copyright 2014-2016 UnknownShadow200 | Licensed under MIT
using System;
using System.IO;
using ClassicalSharp;
using ClassicalSharp.Network;
using SharpWave;
using SharpWave.Codecs.Vorbis;
@@ -40,7 +41,7 @@ public sealed class SoundPatcher {
Request item;
if (fetcher.downloader.TryGetItem(identifiers[i], out item)) {
fetcher.FilesToDownload.RemoveAt(0);
Console.WriteLine("got sound " + identifiers[i]);
Utils.LogDebug("got sound " + identifiers[i]);
if (item.Data == null) {
setStatus("&cFailed to download " + identifiers[i]);
@@ -4,6 +4,7 @@
using System.IO;
using System.Net;
using System.Text;
using ClassicalSharp;
namespace Launcher.Web {
@@ -87,8 +88,6 @@ public abstract class IWebTask {
}
}
protected static void Log(string text) {
Console.WriteLine(text);
}
protected static void Log(string text) { Utils.LogDebug(text); }
}
}
View
@@ -6,17 +6,12 @@ namespace OpenTK {
public static class Debug {
public static void Print(string text) {
try {
Console.WriteLine(text);
} catch (Exception) {
} // raised by Mono sometimes when trying to write to console from the finalizer thread.
try { Console.WriteLine(text); } catch { }
// raised by Mono sometimes when trying to write to console from the finalizer thread.
}
public static void Print(string text, params object[] args) {
try {
Console.WriteLine(text, args);
} catch (Exception) {
}
try { Console.WriteLine(text, args); } catch { }
}
}
}

0 comments on commit 9558914

Please sign in to comment.