Unstable 1.2.1.0

This commit is contained in:
Markus Isberg
2023-11-10 17:45:19 +02:00
parent 2ea58c58a7
commit 8a2e2ea0ae
268 changed files with 4076 additions and 1843 deletions
@@ -50,7 +50,8 @@ namespace Barotrauma
if (identifier.IsEmpty)
{
DebugConsole.ThrowError(
$"No identifier defined for the affliction '{elementName}' in file '{Path}'");
$"No identifier defined for the affliction '{elementName}' in file '{Path}'",
contentPackage: element?.ContentPackage);
return;
}
@@ -60,12 +61,13 @@ namespace Barotrauma
{
DebugConsole.NewMessage(
$"Overriding an affliction or a buff with the identifier '{identifier}' using the file '{Path}'",
Color.Yellow);
Color.MediumPurple);
}
else
{
DebugConsole.ThrowError(
$"Duplicate affliction: '{identifier}' defined in {elementName} of '{Path}'");
$"Duplicate affliction: '{identifier}' defined in {elementName} of '{Path}'",
contentPackage: element?.ContentPackage);
return;
}
}
@@ -17,12 +17,12 @@ namespace Barotrauma
XDocument doc = XMLExtensions.TryLoadXml(Path);
if (doc == null)
{
DebugConsole.ThrowError($"Loading character file failed: {Path}");
DebugConsole.ThrowError($"Loading character file failed: {Path}", contentPackage: ContentPackage);
return;
}
if (CharacterPrefab.Prefabs.AllPrefabs.Any(kvp => kvp.Value.Any(cf => cf?.ContentFile == this)))
{
DebugConsole.ThrowError($"Duplicate path: {Path}");
DebugConsole.ThrowError($"Duplicate path: {Path}", contentPackage: ContentPackage);
return;
}
var mainElement = doc.Root.FromPackage(ContentPackage);
@@ -69,7 +69,8 @@ namespace Barotrauma
}
catch (Exception e)
{
DebugConsole.ThrowError($"Failed to preload a ragdoll file for the character \"{characterPrefab.Name}\"", e);
DebugConsole.ThrowError($"Failed to preload a ragdoll file for the character \"{characterPrefab.Name}\"", e,
contentPackage: characterPrefab.ContentPackage);
return;
}
@@ -76,7 +76,8 @@ namespace Barotrauma
{
DebugConsole.AddWarning(
$"The content type \"TraitorMission\" in content package \"{package.Name}\" is no longer supported." +
$" Traitor missions should be implemented using the scripted event system and the content type TraitorEvents.");
$" Traitor missions should be implemented using the scripted event system and the content type TraitorEvents.",
package);
}
return true;
}
@@ -55,7 +55,7 @@ namespace Barotrauma
}
else
{
DebugConsole.ThrowError($"GenericPrefabFile: Invalid {GetType().Name} element: {parentElement.Name} in {Path}");
DebugConsole.ThrowError($"GenericPrefabFile: Invalid {GetType().Name} element: {parentElement.Name} in {Path}", contentPackage: ContentPackage);
}
}
@@ -2,6 +2,7 @@ using System.Xml.Linq;
namespace Barotrauma
{
[NotSyncedInMultiplayer]
sealed class NPCConversationsFile : ContentFile
{
public NPCConversationsFile(ContentPackage contentPackage, ContentPath path) : base(contentPackage, path) { }
@@ -42,7 +42,8 @@ namespace Barotrauma
}
else
{
DebugConsole.ThrowError($"OrdersFile: Invalid {GetType().Name} element: {parentElement.Name} in {Path}");
DebugConsole.ThrowError($"OrdersFile: Invalid {GetType().Name} element: {parentElement.Name} in {Path}",
contentPackage: parentElement?.ContentPackage);
}
}
@@ -65,7 +65,8 @@ namespace Barotrauma
}
else
{
DebugConsole.ThrowError($"RandomEventsFile: Invalid {GetType().Name} element: {parentElement.Name} in {Path}");
DebugConsole.ThrowError($"RandomEventsFile: Invalid {GetType().Name} element: {parentElement.Name} in {Path}",
contentPackage: parentElement.ContentPackage);
}
}
@@ -4,6 +4,7 @@ using System.Xml.Linq;
namespace Barotrauma
{
[NotSyncedInMultiplayer]
public sealed class TextFile : ContentFile
{
public TextFile(ContentPackage contentPackage, ContentPath path) : base(contentPackage, path) { }
@@ -37,6 +38,13 @@ namespace Barotrauma
if (newHashSet.Count != 0) { TextManager.TextPacks.TryAdd(kvp.Key, newHashSet); }
}
TextManager.IncrementLanguageVersion();
if (!TextManager.TextPacks.ContainsKey(GameSettings.CurrentConfig.Language))
{
DebugConsole.AddWarning($"The language {GameSettings.CurrentConfig.Language} is no longer available. Switching to {TextManager.DefaultLanguage}...");
var config = GameSettings.CurrentConfig;
config.Language = TextManager.DefaultLanguage;
GameSettings.SetCurrentConfig(config);
}
}
public override void Sort()
@@ -283,7 +283,7 @@ namespace Barotrauma
catch (Exception e)
{
var innermost = e.GetInnermost();
DebugConsole.LogError($"Failed to load \"{filesToLoad[i].Path}\": {innermost.Message}\n{innermost.StackTrace}");
DebugConsole.LogError($"Failed to load \"{filesToLoad[i].Path}\": {innermost.Message}\n{innermost.StackTrace}", contentPackage: this);
exception = e;
}
if (exception != null)
@@ -391,7 +391,8 @@ namespace Barotrauma
DebugConsole.AddWarning(
$"The following errors occurred while loading the content package \"{Name}\". The package might not work correctly.\n" +
string.Join('\n', FatalLoadErrors.Select(errorToStr)));
string.Join('\n', FatalLoadErrors.Select(errorToStr)),
this);
static string errorToStr(LoadError error)
=> error.ToString();
@@ -70,7 +70,7 @@ namespace Barotrauma
public Identifier[] GetAttributeIdentifierArray(string key, Identifier[] def, bool trim = true) => Element.GetAttributeIdentifierArray(key, def, trim);
[return: NotNullIfNotNull("def")]
public ImmutableHashSet<Identifier> GetAttributeIdentifierImmutableHashSet(string key, ImmutableHashSet<Identifier>? def, bool trim = true) => Element.GetAttributeIdentifierImmutableHashSet(key, def, trim);
[return: NotNullIfNotNull(parameterName: "def")]
public string? GetAttributeString(string key, string? def) => Element.GetAttributeString(key, def);
public string GetAttributeStringUnrestricted(string key, string def) => Element.GetAttributeStringUnrestricted(key, def);
public string[]? GetAttributeStringArray(string key, string[]? def, bool convertToLowerInvariant = false) => Element.GetAttributeStringArray(key, def, convertToLowerInvariant);
@@ -90,6 +90,7 @@ namespace Barotrauma
public Color? GetAttributeColor(string key) => Element.GetAttributeColor(key);
public Color[]? GetAttributeColorArray(string key, Color[]? def) => Element.GetAttributeColorArray(key, def);
public Rectangle GetAttributeRect(string key, in Rectangle def) => Element.GetAttributeRect(key, def);
public Version GetAttributeVersion(string key, Version def) => Element.GetAttributeVersion(key, def);
public T GetAttributeEnum<T>(string key, in T def) where T : struct, Enum => Element.GetAttributeEnum(key, def);
public (T1, T2) GetAttributeTuple<T1, T2>(string key, in (T1, T2) def) => Element.GetAttributeTuple(key, def);
public (T1, T2)[] GetAttributeTupleArray<T1, T2>(string key, in (T1, T2)[] def) => Element.GetAttributeTupleArray(key, def);