Some more logging to help diagnose #278, a potential workaround to remove items/characters that Entity.RemoveAll failed to remove for some reason.

This commit is contained in:
Joonas Rikkonen
2018-04-20 16:50:10 +03:00
parent 395ca3c5c2
commit 177f31d538
3 changed files with 47 additions and 2 deletions
@@ -133,6 +133,51 @@ namespace Barotrauma
DebugConsole.ThrowError(" - " + e.ToString() + "(ID " + e.id + ")");
}
}
if (Item.ItemList.Count > 0)
{
DebugConsole.ThrowError("Some items were not removed in Entity.RemoveAll:");
foreach (Item item in Item.ItemList)
{
DebugConsole.ThrowError(" - " + item.Name + "(ID " + item.id + ")");
}
var items = new List<Item>(Item.ItemList);
foreach (Item item in items)
{
try
{
item.Remove();
}
catch (Exception exception)
{
DebugConsole.ThrowError("Error while removing entity \"" + item.ToString() + "\"", exception);
}
}
Item.ItemList.Clear();
}
if (Character.CharacterList.Count > 0)
{
DebugConsole.ThrowError("Some characters were not removed in Entity.RemoveAll:");
foreach (Character character in Character.CharacterList)
{
DebugConsole.ThrowError(" - " + character.Name + "(ID " + character.id + ")");
}
var characters = new List<Character>(Character.CharacterList);
foreach (Character character in characters)
{
try
{
character.Remove();
}
catch (Exception exception)
{
DebugConsole.ThrowError("Error while removing entity \"" + character.ToString() + "\"", exception);
}
}
Character.CharacterList.Clear();
}
dictionary.Clear();
}