-try-catch blocks for GUIComponents fixedChildren lists

-player name and IP address in debug messages
-crash logs now output up to 15 messages
This commit is contained in:
juanjp600
2017-03-03 15:14:18 -03:00
parent e059a08688
commit ee16f0708b
3 changed files with 29 additions and 13 deletions
+16
View File
@@ -29,12 +29,20 @@ namespace Barotrauma
if (ComponentsToUpdate.Contains(this)) return; if (ComponentsToUpdate.Contains(this)) return;
ComponentsToUpdate.Add(this); ComponentsToUpdate.Add(this);
try
{
List<GUIComponent> fixedChildren = new List<GUIComponent>(children); List<GUIComponent> fixedChildren = new List<GUIComponent>(children);
foreach (GUIComponent c in fixedChildren) foreach (GUIComponent c in fixedChildren)
{ {
c.AddToGUIUpdateList(); c.AddToGUIUpdateList();
} }
} }
catch (Exception e)
{
DebugConsole.NewMessage("Error in AddToGUIUPdateList! GUIComponent runtime type: "+this.GetType().ToString()+"; children count: "+children.Count.ToString(),Color.Red);
throw e;
}
}
public static void ClearUpdateList() public static void ClearUpdateList()
{ {
@@ -372,6 +380,8 @@ namespace Barotrauma
}*/ }*/
try
{
//use a fixed list since children can change their order in the main children list //use a fixed list since children can change their order in the main children list
//TODO: maybe find a more efficient way of handling changes in list order //TODO: maybe find a more efficient way of handling changes in list order
List<GUIComponent> fixedChildren = new List<GUIComponent>(children); List<GUIComponent> fixedChildren = new List<GUIComponent>(children);
@@ -381,6 +391,12 @@ namespace Barotrauma
c.Update(deltaTime); c.Update(deltaTime);
} }
} }
catch (Exception e)
{
DebugConsole.NewMessage("Error in Update! GUIComponent runtime type: " + this.GetType().ToString() + "; children count: " + children.Count.ToString(), Color.Red);
throw e;
}
}
protected virtual void UpdateDimensions(GUIComponent parent = null) protected virtual void UpdateDimensions(GUIComponent parent = null)
{ {
@@ -87,8 +87,6 @@ namespace Barotrauma.Networking
return; return;
} }
DebugConsole.NewMessage("New player has joined the server", Color.White);
byte userID; byte userID;
string version = "", packageName = "", packageHash = "", name = ""; string version = "", packageName = "", packageHash = "", name = "";
try try
@@ -106,6 +104,8 @@ namespace Barotrauma.Networking
return; return;
} }
DebugConsole.NewMessage("New player has joined the server (" + name + ", " + inc.SenderConnection.RemoteEndPoint.Address.ToString() + ")", Color.White);
#if !DEBUG #if !DEBUG
if (string.IsNullOrWhiteSpace(name)) if (string.IsNullOrWhiteSpace(name))
{ {
+1 -1
View File
@@ -157,7 +157,7 @@ namespace Barotrauma
sb.AppendLine("\n"); sb.AppendLine("\n");
sb.AppendLine("Last debug messages:"); sb.AppendLine("Last debug messages:");
for (int i = DebugConsole.Messages.Count - 1; i > 0 && i > DebugConsole.Messages.Count - 10; i-- ) for (int i = DebugConsole.Messages.Count - 1; i > 0 && i > DebugConsole.Messages.Count - 15; i-- )
{ {
sb.AppendLine(" "+DebugConsole.Messages[i].Time+" - "+DebugConsole.Messages[i].Text); sb.AppendLine(" "+DebugConsole.Messages[i].Time+" - "+DebugConsole.Messages[i].Text);
} }