Server and EntityEventManager debug logging can be enabled in release builds by enabling verbose logging, DebugConsole.ThrowError logs stacktraces
This commit is contained in:
@@ -933,8 +933,11 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
public static void ThrowError(string error, Exception e = null)
|
||||
{
|
||||
if (e != null) error += " {" + e.Message + "}";
|
||||
{
|
||||
if (e != null)
|
||||
{
|
||||
error += " {" + e.Message + "}\n" + e.StackTrace;
|
||||
}
|
||||
System.Diagnostics.Debug.WriteLine(error);
|
||||
NewMessage(error, Color.Red);
|
||||
isOpen = true;
|
||||
|
||||
@@ -173,7 +173,7 @@ namespace Barotrauma.Networking
|
||||
fileSender = new FileSender(this);
|
||||
fileSender.OnEnded += FileTransferChanged;
|
||||
fileSender.OnStarted += FileTransferChanged;
|
||||
|
||||
|
||||
server.Start();
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -513,11 +513,10 @@ namespace Barotrauma.Networking
|
||||
|
||||
catch (Exception e)
|
||||
{
|
||||
#if DEBUG
|
||||
DebugConsole.ThrowError("Failed to read incoming message", e);
|
||||
#endif
|
||||
|
||||
continue;
|
||||
if (GameSettings.VerboseLogging)
|
||||
{
|
||||
DebugConsole.ThrowError("Failed to read an incoming message. {" + e + "}\n" + e.StackTrace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -723,28 +722,24 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
c.lastRecvChatMsgID = lastRecvChatMsgID;
|
||||
}
|
||||
#if DEBUG
|
||||
else if (lastRecvChatMsgID != c.lastRecvChatMsgID)
|
||||
else if (lastRecvChatMsgID != c.lastRecvChatMsgID && GameSettings.VerboseLogging)
|
||||
{
|
||||
DebugConsole.ThrowError(
|
||||
"Invalid lastRecvChatMsgID " + lastRecvChatMsgID +
|
||||
" (previous: " + c.lastChatMsgQueueID + ", latest: "+c.lastChatMsgQueueID+")");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (NetIdUtils.IdMoreRecent(lastRecvEntityEventID, c.lastRecvEntityEventID) &&
|
||||
!NetIdUtils.IdMoreRecent(lastRecvEntityEventID, lastEntityEventID))
|
||||
{
|
||||
c.lastRecvEntityEventID = lastRecvEntityEventID;
|
||||
}
|
||||
#if DEBUG
|
||||
else if (lastRecvEntityEventID != c.lastRecvEntityEventID)
|
||||
else if (lastRecvEntityEventID != c.lastRecvEntityEventID && GameSettings.VerboseLogging)
|
||||
{
|
||||
DebugConsole.ThrowError(
|
||||
"Invalid lastRecvEntityEventID " + lastRecvEntityEventID +
|
||||
" (previous: " + c.lastRecvEntityEventID + ", latest: " + lastEntityEventID + ")");
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case ClientNetObject.CHAT_MESSAGE:
|
||||
ChatMessage.ServerRead(inc, c);
|
||||
|
||||
@@ -112,15 +112,20 @@ namespace Barotrauma.Networking
|
||||
unreceivedEntityEventCount = msg.ReadUInt16();
|
||||
firstNewID = msg.ReadUInt16();
|
||||
|
||||
#if DEBUG
|
||||
DebugConsole.NewMessage("received midround syncing msg, unreceived: "+unreceivedEntityEventCount+", first new ID: "+firstNewID, Microsoft.Xna.Framework.Color.Yellow);
|
||||
#endif
|
||||
if (GameSettings.VerboseLogging)
|
||||
{
|
||||
DebugConsole.NewMessage(
|
||||
"received midround syncing msg, unreceived: " + unreceivedEntityEventCount +
|
||||
", first new ID: " + firstNewID, Microsoft.Xna.Framework.Color.Yellow);
|
||||
}
|
||||
}
|
||||
else if (firstNewID != null)
|
||||
{
|
||||
#if DEBUG
|
||||
DebugConsole.NewMessage("midround syncing complete, switching to ID "+ (UInt16)(firstNewID - 1), Microsoft.Xna.Framework.Color.Yellow);
|
||||
#endif
|
||||
if (GameSettings.VerboseLogging)
|
||||
{
|
||||
DebugConsole.NewMessage("midround syncing complete, switching to ID " + (UInt16) (firstNewID - 1),
|
||||
Microsoft.Xna.Framework.Color.Yellow);
|
||||
}
|
||||
|
||||
lastReceivedID = (UInt16)(firstNewID - 1);
|
||||
firstNewID = null;
|
||||
@@ -148,24 +153,33 @@ namespace Barotrauma.Networking
|
||||
//skip the event if we've already received it or if the entity isn't found
|
||||
if (thisEventID != (UInt16)(lastReceivedID + 1) || entity == null)
|
||||
{
|
||||
#if DEBUG
|
||||
if (thisEventID != (UInt16)(lastReceivedID + 1))
|
||||
if (GameSettings.VerboseLogging)
|
||||
{
|
||||
DebugConsole.NewMessage("received msg " + thisEventID + " (waiting for "+ (lastReceivedID+1) + ")", thisEventID<lastReceivedID+1 ? Microsoft.Xna.Framework.Color.Yellow : Microsoft.Xna.Framework.Color.Red);
|
||||
if (thisEventID != (UInt16) (lastReceivedID + 1))
|
||||
{
|
||||
DebugConsole.NewMessage(
|
||||
"received msg " + thisEventID + " (waiting for " + (lastReceivedID + 1) + ")",
|
||||
thisEventID < lastReceivedID + 1
|
||||
? Microsoft.Xna.Framework.Color.Yellow
|
||||
: Microsoft.Xna.Framework.Color.Red);
|
||||
}
|
||||
else if (entity == null)
|
||||
{
|
||||
DebugConsole.NewMessage(
|
||||
"received msg " + thisEventID + ", entity " + entityID + " not found",
|
||||
Microsoft.Xna.Framework.Color.Red);
|
||||
}
|
||||
}
|
||||
else if (entity == null)
|
||||
{
|
||||
DebugConsole.NewMessage("received msg " + thisEventID + ", entity " + entityID + " not found", Microsoft.Xna.Framework.Color.Red);
|
||||
}
|
||||
#endif
|
||||
msg.Position += msgLength * 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
long msgPosition = msg.Position;
|
||||
#if DEBUG
|
||||
DebugConsole.NewMessage("received msg " + thisEventID + " (" + entity.ToString() + ")", Microsoft.Xna.Framework.Color.Green);
|
||||
#endif
|
||||
if (GameSettings.VerboseLogging)
|
||||
{
|
||||
DebugConsole.NewMessage("received msg " + thisEventID + " (" + entity.ToString() + ")",
|
||||
Microsoft.Xna.Framework.Color.Green);
|
||||
}
|
||||
lastReceivedID++;
|
||||
try
|
||||
{
|
||||
@@ -174,9 +188,10 @@ namespace Barotrauma.Networking
|
||||
|
||||
catch (Exception e)
|
||||
{
|
||||
#if DEBUG
|
||||
DebugConsole.ThrowError("Failed to read event for entity \"" + entity.ToString() + "\"!", e);
|
||||
#endif
|
||||
if (GameSettings.VerboseLogging)
|
||||
{
|
||||
DebugConsole.ThrowError("Failed to read event for entity \"" + entity.ToString() + "!", e);
|
||||
}
|
||||
msg.Position = msgPosition + msgLength * 8;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,9 +135,10 @@ namespace Barotrauma.Networking
|
||||
|
||||
catch (Exception e)
|
||||
{
|
||||
#if DEBUG
|
||||
DebugConsole.ThrowError("Failed to read event for entity \"" + bufferedEvent.TargetEntity.ToString() + "\"!", e);
|
||||
#endif
|
||||
if (GameSettings.VerboseLogging)
|
||||
{
|
||||
DebugConsole.ThrowError("Failed to read event for entity \"" + bufferedEvent.TargetEntity.ToString() + "!", e);
|
||||
}
|
||||
}
|
||||
|
||||
bufferedEvent.IsProcessed = true;
|
||||
@@ -326,23 +327,27 @@ namespace Barotrauma.Networking
|
||||
//skip the event if we've already received it or if the entity isn't found
|
||||
if (thisEventID != (UInt16)(sender.lastSentEntityEventID + 1) || entity == null)
|
||||
{
|
||||
#if DEBUG
|
||||
if (thisEventID != (UInt16)(sender.lastSentEntityEventID + 1))
|
||||
if (GameSettings.VerboseLogging)
|
||||
{
|
||||
DebugConsole.NewMessage("received msg " + thisEventID, Microsoft.Xna.Framework.Color.Red);
|
||||
if (thisEventID != (UInt16) (sender.lastSentEntityEventID + 1))
|
||||
{
|
||||
DebugConsole.NewMessage("received msg " + thisEventID, Microsoft.Xna.Framework.Color.Red);
|
||||
}
|
||||
else if (entity == null)
|
||||
{
|
||||
DebugConsole.NewMessage(
|
||||
"received msg " + thisEventID + ", entity " + entityID + " not found",
|
||||
Microsoft.Xna.Framework.Color.Red);
|
||||
}
|
||||
}
|
||||
else if (entity == null)
|
||||
{
|
||||
DebugConsole.NewMessage("received msg " + thisEventID + ", entity " + entityID + " not found", Microsoft.Xna.Framework.Color.Red);
|
||||
}
|
||||
#endif
|
||||
msg.Position += msgLength * 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if DEBUG
|
||||
DebugConsole.NewMessage("received msg " + thisEventID, Microsoft.Xna.Framework.Color.Green);
|
||||
#endif
|
||||
if (GameSettings.VerboseLogging)
|
||||
{
|
||||
DebugConsole.NewMessage("received msg " + thisEventID, Microsoft.Xna.Framework.Color.Green);
|
||||
}
|
||||
|
||||
UInt16 characterStateID = msg.ReadUInt16();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user