Put try{} catch{} around Console.WriteLine, fixes crashing on WINE when run without terminal

This commit is contained in:
UnknownShadow200 2017-10-08 20:59:24 +11:00
parent d04e257e57
commit 955891467b
7 changed files with 12 additions and 33 deletions

View file

@ -84,13 +84,7 @@ namespace ClassicalSharp.Network.Protocols {
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() {

View file

@ -165,20 +165,9 @@ namespace ClassicalSharp.Network.Protocols {
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() {

View file

@ -101,11 +101,11 @@ namespace ClassicalSharp {
}
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) {

View file

@ -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 @@ namespace Launcher.Patcher {
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);

View file

@ -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 @@ namespace Launcher.Patcher {
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]);

View file

@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
using ClassicalSharp;
namespace Launcher.Web {
@ -87,8 +88,6 @@ namespace Launcher.Web {
}
}
protected static void Log(string text) {
Console.WriteLine(text);
}
protected static void Log(string text) { Utils.LogDebug(text); }
}
}

View file

@ -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 { }
}
}
}