(7e0adb991) Fixed legacy items failing to load if a sub is saved with a language other than English and the language then changed to something else.

This commit is contained in:
Joonas Rikkonen
2019-06-04 15:29:55 +03:00
parent ebd916e95c
commit bce99f2e6f
17 changed files with 89 additions and 82 deletions
@@ -145,6 +145,11 @@ namespace Barotrauma
private List<XElement> fabricationRecipeElements = new List<XElement>();
/// <summary>
/// Original, non-translated name as defined in the xml
/// </summary>
public readonly string OriginalName;
public string ConfigFile
{
get { return configFile; }
@@ -440,7 +445,7 @@ namespace Barotrauma
configFile = filePath;
ConfigElement = element;
string nonTranslatedName = element.GetAttributeString("name", "");
OriginalName = element.GetAttributeString("name", "");
identifier = element.GetAttributeString("identifier", "");
//nameidentifier can be used to make multiple items use the same names and descriptions
@@ -448,11 +453,11 @@ namespace Barotrauma
if (string.IsNullOrEmpty(nameIdentifier))
{
name = TextManager.Get("EntityName." + identifier, true) ?? nonTranslatedName;
name = TextManager.Get("EntityName." + identifier, true) ?? OriginalName;
}
else
{
name = TextManager.Get("EntityName." + nameIdentifier, true) ?? nonTranslatedName;
name = TextManager.Get("EntityName." + nameIdentifier, true) ?? OriginalName;
}
if (name == "") { DebugConsole.ThrowError("Unnamed item in " + filePath + "!"); }
@@ -462,7 +467,7 @@ namespace Barotrauma
Aliases = new HashSet<string>
(element.GetAttributeStringArray("aliases", null, convertToLowerInvariant: true) ??
element.GetAttributeStringArray("Aliases", new string[0], convertToLowerInvariant: true));
Aliases.Add(nonTranslatedName.ToLowerInvariant());
Aliases.Add(OriginalName.ToLowerInvariant());
if (!Enum.TryParse(element.GetAttributeString("category", "Misc"), true, out MapEntityCategory category))
{