Sending error messages during EntityEvent writing/reading and entity removal to GameAnalytics
This commit is contained in:
+3
-3
@@ -191,10 +191,10 @@ namespace Barotrauma.Networking
|
|||||||
if (GameSettings.VerboseLogging)
|
if (GameSettings.VerboseLogging)
|
||||||
{
|
{
|
||||||
DebugConsole.ThrowError("Failed to read event for entity \"" + entity.ToString() + "\"!", e);
|
DebugConsole.ThrowError("Failed to read event for entity \"" + entity.ToString() + "\"!", e);
|
||||||
GameAnalyticsManager.AddErrorEventOnce("ClientEntityEventManager.Read:ReadFailed" + entity.ToString(),
|
|
||||||
GameAnalyticsSDK.Net.EGAErrorSeverity.Error,
|
|
||||||
"Failed to read event for entity \"" + entity.ToString() + "\"!\n" + e.StackTrace);
|
|
||||||
}
|
}
|
||||||
|
GameAnalyticsManager.AddErrorEventOnce("ClientEntityEventManager.Read:ReadFailed" + entity.ToString(),
|
||||||
|
GameAnalyticsSDK.Net.EGAErrorSeverity.Error,
|
||||||
|
"Failed to read event for entity \"" + entity.ToString() + "\"!\n" + e.StackTrace);
|
||||||
msg.Position = msgPosition + msgLength * 8;
|
msg.Position = msgPosition + msgLength * 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
@@ -126,22 +127,27 @@ namespace Barotrauma
|
|||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
DebugConsole.ThrowError("Error while removing entity \"" + e.ToString() + "\"", exception);
|
DebugConsole.ThrowError("Error while removing entity \"" + e.ToString() + "\"", exception);
|
||||||
|
GameAnalyticsManager.AddErrorEventOnce(
|
||||||
|
"Entity.RemoveAll:Exception" + e.ToString(),
|
||||||
|
GameAnalyticsSDK.Net.EGAErrorSeverity.Error,
|
||||||
|
"Error while removing entity \"" + e.ToString() + "\"" + exception.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
StringBuilder errorMsg = new StringBuilder();
|
||||||
if (dictionary.Count > 0)
|
if (dictionary.Count > 0)
|
||||||
{
|
{
|
||||||
DebugConsole.ThrowError("Some entities were not removed in Entity.RemoveAll:");
|
errorMsg.AppendLine("Some entities were not removed in Entity.RemoveAll:");
|
||||||
foreach (Entity e in dictionary.Values)
|
foreach (Entity e in dictionary.Values)
|
||||||
{
|
{
|
||||||
DebugConsole.ThrowError(" - " + e.ToString() + "(ID " + e.id + ")");
|
errorMsg.AppendLine(" - " + e.ToString() + "(ID " + e.id + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Item.ItemList.Count > 0)
|
if (Item.ItemList.Count > 0)
|
||||||
{
|
{
|
||||||
DebugConsole.ThrowError("Some items were not removed in Entity.RemoveAll:");
|
errorMsg.AppendLine("Some items were not removed in Entity.RemoveAll:");
|
||||||
foreach (Item item in Item.ItemList)
|
foreach (Item item in Item.ItemList)
|
||||||
{
|
{
|
||||||
DebugConsole.ThrowError(" - " + item.Name + "(ID " + item.id + ")");
|
errorMsg.AppendLine(" - " + item.Name + "(ID " + item.id + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
var items = new List<Item>(Item.ItemList);
|
var items = new List<Item>(Item.ItemList);
|
||||||
@@ -153,17 +159,17 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
DebugConsole.ThrowError("Error while removing entity \"" + item.ToString() + "\"", exception);
|
DebugConsole.ThrowError("Error while removing item \"" + item.ToString() + "\"", exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Item.ItemList.Clear();
|
Item.ItemList.Clear();
|
||||||
}
|
}
|
||||||
if (Character.CharacterList.Count > 0)
|
if (Character.CharacterList.Count > 0)
|
||||||
{
|
{
|
||||||
DebugConsole.ThrowError("Some characters were not removed in Entity.RemoveAll:");
|
errorMsg.AppendLine("Some characters were not removed in Entity.RemoveAll:");
|
||||||
foreach (Character character in Character.CharacterList)
|
foreach (Character character in Character.CharacterList)
|
||||||
{
|
{
|
||||||
DebugConsole.ThrowError(" - " + character.Name + "(ID " + character.id + ")");
|
errorMsg.AppendLine(" - " + character.Name + "(ID " + character.id + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
var characters = new List<Character>(Character.CharacterList);
|
var characters = new List<Character>(Character.CharacterList);
|
||||||
@@ -175,26 +181,42 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
DebugConsole.ThrowError("Error while removing entity \"" + character.ToString() + "\"", exception);
|
DebugConsole.ThrowError("Error while removing character \"" + character.ToString() + "\"", exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Character.CharacterList.Clear();
|
Character.CharacterList.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(errorMsg.ToString()))
|
||||||
|
{
|
||||||
|
foreach (string errorLine in errorMsg.ToString().Split('\n'))
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError(errorLine);
|
||||||
|
}
|
||||||
|
GameAnalyticsManager.AddErrorEventOnce("Entity.RemoveAll", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
dictionary.Clear();
|
dictionary.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Remove()
|
public virtual void Remove()
|
||||||
{
|
{
|
||||||
DebugConsole.Log("Removing entity " + this.ToString() + " (" + ID + ") from entity dictionary.");
|
DebugConsole.Log("Removing entity " + ToString() + " (" + ID + ") from entity dictionary.");
|
||||||
Entity existingEntity;
|
if (!dictionary.TryGetValue(ID, out Entity existingEntity))
|
||||||
if (!dictionary.TryGetValue(ID, out existingEntity))
|
|
||||||
{
|
{
|
||||||
DebugConsole.Log("Entity " + this.ToString() + " (" + ID + ") not present in entity dictionary.");
|
DebugConsole.Log("Entity " + ToString() + " (" + ID + ") not present in entity dictionary.");
|
||||||
|
GameAnalyticsManager.AddErrorEventOnce(
|
||||||
|
"Entity.Remove:EntityNotFound" + ID,
|
||||||
|
GameAnalyticsSDK.Net.EGAErrorSeverity.Error,
|
||||||
|
"Entity " + ToString() + " (" + ID + ") not present in entity dictionary.\n" + Environment.StackTrace);
|
||||||
}
|
}
|
||||||
else if (existingEntity != this)
|
else if (existingEntity != this)
|
||||||
{
|
{
|
||||||
DebugConsole.Log("Entity ID mismatch in entity dictionary. Entity " + existingEntity + " had the ID " + ID);
|
DebugConsole.Log("Entity ID mismatch in entity dictionary. Entity " + existingEntity + " had the ID " + ID + " (expecting " + ToString() + ")");
|
||||||
|
GameAnalyticsManager.AddErrorEventOnce("Entity.Remove:EntityMismatch" + ID,
|
||||||
|
GameAnalyticsSDK.Net.EGAErrorSeverity.Error,
|
||||||
|
"Entity ID mismatch in entity dictionary. Entity " + existingEntity + " had the ID " + ID + " (expecting " + ToString() + ")");
|
||||||
|
|
||||||
foreach (var keyValuePair in dictionary.Where(kvp => kvp.Value == this).ToList())
|
foreach (var keyValuePair in dictionary.Where(kvp => kvp.Value == this).ToList())
|
||||||
{
|
{
|
||||||
dictionary.Remove(keyValuePair.Key);
|
dictionary.Remove(keyValuePair.Key);
|
||||||
|
|||||||
+5
-1
@@ -135,10 +135,14 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
string entityName = bufferedEvent.TargetEntity == null ? "null" : bufferedEvent.TargetEntity.ToString();
|
||||||
if (GameSettings.VerboseLogging)
|
if (GameSettings.VerboseLogging)
|
||||||
{
|
{
|
||||||
DebugConsole.ThrowError("Failed to read event for entity \"" + bufferedEvent.TargetEntity.ToString() + "\"!", e);
|
DebugConsole.ThrowError("Failed to read server event for entity \"" + entityName + "\"!", e);
|
||||||
}
|
}
|
||||||
|
GameAnalyticsManager.AddErrorEventOnce("ServerEntityEventManager.Read:ReadFailed" + entityName,
|
||||||
|
GameAnalyticsSDK.Net.EGAErrorSeverity.Error,
|
||||||
|
"Failed to read server event for entity \"" + entityName + "\"!\n" + e.StackTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
bufferedEvent.IsProcessed = true;
|
bufferedEvent.IsProcessed = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user