Invalid contentpackage content types don't crash the game

This commit is contained in:
Joonas Rikkonen
2018-02-25 17:46:04 +02:00
parent 9e2966e9cb
commit 9df0f0a275

View File

@@ -82,7 +82,12 @@ namespace Barotrauma
foreach (XElement subElement in doc.Root.Elements())
{
ContentType type = (ContentType)Enum.Parse(typeof(ContentType), subElement.Name.ToString(), true);
ContentType type;
if (!Enum.TryParse(subElement.Name.ToString(), true, out type))
{
DebugConsole.ThrowError("Error in content package \""+name+"\" - \""+subElement.Name.ToString()+"\" is not a valid content type.");
continue;
}
files.Add(new ContentFile(subElement.GetAttributeString("file", ""), type));
}
}