Commit 360bfea5 authored by mercury233's avatar mercury233

rename debug mode to safe mode

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