Commit 360bfea5 authored by mercury233's avatar mercury233

rename debug mode to safe mode

parent 62286326
...@@ -261,15 +261,10 @@ namespace WindBot.Game ...@@ -261,15 +261,10 @@ namespace WindBot.Game
{ {
int player = packet.ReadInt16(); int player = packet.ReadInt16();
string message = packet.ReadUnicode(256); string message = packet.ReadUnicode(256);
if (!Program.DebugMode) string myName = _room.Position == 0 ? _room.Names[0] : _room.Names[1];
{ string otherName = _room.Position == 0 ? _room.Names[1] : _room.Names[0];
string myName = _room.Position == 0 ? _room.Names[0] : _room.Names[1]; if (player < 4)
string otherName = _room.Position == 0 ? _room.Names[1] : _room.Names[0]; Logger.DebugWriteLine(otherName + " say to " + myName + ": " + message);
if (player < 4)
Logger.WriteLine(otherName + " say to " + myName + ": " + message);
//else
// Logger.WriteLine(myName + " System or Watch : " + message);
}
} }
private void OnErrorMsg(BinaryReader packet) private void OnErrorMsg(BinaryReader packet)
......
...@@ -10,8 +10,9 @@ namespace WindBot ...@@ -10,8 +10,9 @@ namespace WindBot
} }
public static void DebugWriteLine(string message) public static void DebugWriteLine(string message)
{ {
if (Program.DebugMode) #if DEBUG
Console.WriteLine("[" + DateTime.Now.ToString("yy-MM-dd HH:mm:ss") + "] " + message); Console.WriteLine("[" + DateTime.Now.ToString("yy-MM-dd HH:mm:ss") + "] " + message);
#endif
} }
public static void WriteErrorLine(string message) public static void WriteErrorLine(string message)
{ {
......
...@@ -11,10 +11,11 @@ namespace WindBot ...@@ -11,10 +11,11 @@ namespace WindBot
{ {
public class Program public class Program
{ {
// in safe mode, all errors will be catched instead of causing the program to crash.
#if DEBUG #if DEBUG
public static bool DebugMode = true; public static bool SafeMode = false;
#else #else
public static bool DebugMode = false; public static bool SafeMode = true;
#endif #endif
internal static Random Rand; internal static Random Rand;
...@@ -122,7 +123,7 @@ namespace WindBot ...@@ -122,7 +123,7 @@ namespace WindBot
Thread workThread = new Thread(new ParameterizedThreadStart(Run)); Thread workThread = new Thread(new ParameterizedThreadStart(Run));
workThread.Start(Info); workThread.Start(Info);
} }
catch (Exception ex) when (!DebugMode) catch (Exception ex) when (SafeMode)
{ {
Logger.WriteErrorLine("Start Thread Error: " + ex); Logger.WriteErrorLine("Start Thread Error: " + ex);
} }
...@@ -130,7 +131,7 @@ namespace WindBot ...@@ -130,7 +131,7 @@ namespace WindBot
ctx.Response.Close(); ctx.Response.Close();
} }
} }
catch (Exception ex) when (!DebugMode) catch (Exception ex) when (SafeMode)
{ {
Logger.WriteErrorLine("Parse Http Request Error: " + ex); Logger.WriteErrorLine("Parse Http Request Error: " + ex);
} }
...@@ -153,14 +154,14 @@ namespace WindBot ...@@ -153,14 +154,14 @@ namespace WindBot
client.Tick(); client.Tick();
Thread.Sleep(30); Thread.Sleep(30);
} }
catch (Exception ex) when (!DebugMode) catch (Exception ex) when (SafeMode)
{ {
Logger.WriteErrorLine("Tick Error: " + ex); Logger.WriteErrorLine("Tick Error: " + ex);
} }
} }
Logger.DebugWriteLine(client.Username + " end."); Logger.DebugWriteLine(client.Username + " end.");
} }
catch (Exception ex) when (!DebugMode) catch (Exception ex) when (SafeMode)
{ {
Logger.WriteErrorLine("Run Error: " + ex); Logger.WriteErrorLine("Run Error: " + ex);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment