Fixed IndexOutOfRange exceptions when cloning items with requiredItems that aren't present in the xml, + some more exception handling & error logging

This commit is contained in:
Joonas Rikkonen
2018-09-10 12:06:39 +03:00
parent 2b3c0d103b
commit 57c9e5a731
3 changed files with 26 additions and 4 deletions
@@ -171,7 +171,19 @@ namespace Barotrauma
foreach (MapEntity e in entitiesToClone)
{
Debug.Assert(e != null);
clones.Add(e.Clone());
try
{
clones.Add(e.Clone());
}
catch (Exception ex)
{
DebugConsole.ThrowError("Cloning entity \"" + e.Name + "\" failed.", ex);
GameAnalyticsManager.AddErrorEventOnce(
"MapEntity.Clone:" + e.Name,
GameAnalyticsSDK.Net.EGAErrorSeverity.Error,
"Cloning entity \"" + e.Name + "\" failed (" + ex.Message + ").\n" + ex.StackTrace);
return clones;
}
Debug.Assert(clones.Last() != null);
}