(8cc6af65f) Fixed Character.GetConfigFile searching for the character file from all available content packages, not just the ones that are currently selected. Caused modded character files to affect the game even when the mod is not enabled. An easy way to reproduce the issue was to install BTE but not select it, which caused "damagedsprite not found" errors because the vanilla game would attempt to use the BTE human file (which still has the damagedsprite configured even though the texture has been removed).

This commit is contained in:
Joonas Rikkonen
2019-06-13 11:43:36 +03:00
parent a92e01b6af
commit 122be7783b

View File

@@ -836,13 +836,21 @@ namespace Barotrauma
private static string humanConfigFile;
public static string HumanConfigFile
{
get
get
{
if (string.IsNullOrEmpty(humanConfigFile))
{
humanConfigFile = GetConfigFile("Human");
humanConfigFile = GameMain.Instance.GetFilesOfType(ContentType.Character)?
.FirstOrDefault(c => Path.GetFileName(c).ToLowerInvariant() == "human.xml");
if (humanConfigFile == null)
{
DebugConsole.ThrowError($"Couldn't find a human config file from the selected content packages!");
DebugConsole.ThrowError($"(The config file must end with \"human.xml\")");
return string.Empty;
}
}
return humanConfigFile;
return humanConfigFile;
}
}
@@ -859,6 +867,46 @@ namespace Barotrauma
}
}
/// <summary>
/// Searches for a character config file from all currently selected content packages,
/// or from a specific package if the contentPackage parameter is given.
/// </summary>
public static string GetConfigFile(string speciesName, ContentPackage contentPackage = null)
{
string configFile = null;
if (contentPackage == null)
{
configFile = GameMain.Instance.GetFilesOfType(ContentType.Character)
.FirstOrDefault(c => Path.GetFileName(c).ToLowerInvariant() == $"{speciesName.ToLowerInvariant()}.xml");
}
else
{
configFile = contentPackage.GetFilesOfType(ContentType.Character)?
.FirstOrDefault(c => Path.GetFileName(c).ToLowerInvariant() == $"{speciesName.ToLowerInvariant()}.xml");
}
if (configFile == null)
{
DebugConsole.ThrowError($"Couldn't find a config file for {speciesName} from the selected content packages!");
DebugConsole.ThrowError($"(The config file must end with \"{speciesName}.xml\")");
return string.Empty;
}
return configFile;
}
private static IEnumerable<string> characterConfigFiles;
private static IEnumerable<string> CharacterConfigFiles
{
get
{
if (characterConfigFiles == null)
{
characterConfigFiles = GameMain.Instance.GetFilesOfType(ContentType.Character);
}
return characterConfigFiles;
}
}
public static string GetConfigFile(string speciesName, ContentPackage contentPackage = null)
{
string configFile = null;