Unstable 0.17.1.0

This commit is contained in:
Markus Isberg
2022-03-17 01:25:04 +09:00
parent 3974067915
commit 6d410cc1b7
302 changed files with 5878 additions and 3317 deletions
@@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Xml.Linq;
@@ -63,7 +64,7 @@ namespace Barotrauma
public static Result<ContentFile, string> CreateFromXElement(ContentPackage contentPackage, XElement element)
{
Result<ContentFile, string> fail(string error)
static Result<ContentFile, string> fail(string error)
=> Result<ContentFile, string>.Failure(error);
Identifier elemName = element.NameAsIdentifier();
@@ -73,13 +74,16 @@ namespace Barotrauma
{
return fail($"Invalid content type \"{elemName}\"");
}
if (filePath is null)
{
return fail($"No content path defined for file of type \"{elemName}\"");
}
try
{
if (!File.Exists(filePath.FullPath))
{
return fail($"Failed to load file \"{filePath}\" of type \"{elemName}\": file not found.");
}
var file = type.CreateInstance(contentPackage, filePath);
return file is null
? throw new Exception($"Content type is not implemented correctly")
@@ -1,4 +1,3 @@
using System;
using System.Linq;
using System.Xml.Linq;
@@ -54,8 +54,10 @@ namespace Barotrauma
public int Index => ContentPackageManager.EnabledPackages.IndexOf(this);
#warning TODO: remove this, unless we truly believe that determining "multiplayer-incompatible content" is something we should do
public readonly bool HasMultiplayerIncompatibleContent;
/// <summary>
/// Does the content package include some content that needs to match between all players in multiplayer.
/// </summary>
public readonly bool HasMultiplayerSyncedContent;
protected ContentPackage(XDocument doc, string path)
{
@@ -93,7 +95,7 @@ namespace Barotrauma
.Select(f => f.Error)
.ToImmutableArray();
HasMultiplayerIncompatibleContent = Files.Any(f => !f.NotSyncedInMultiplayer);
HasMultiplayerSyncedContent = Files.Any(f => !f.NotSyncedInMultiplayer);
Hash = CalculateHash();
var expectedHash = rootElement.GetAttributeString("expectedhash", "");
@@ -392,6 +392,10 @@ namespace Barotrauma
public static void LoadVanillaFileList()
{
VanillaCorePackage = new CorePackage(XDocument.Load(VanillaFileList), VanillaFileList);
foreach (string error in VanillaCorePackage.Errors)
{
DebugConsole.ThrowError(error);
}
}
public static IEnumerable<LoadProgress> Init()
@@ -101,23 +101,27 @@ namespace Barotrauma
}
private static bool StringEquality(string? a, string? b)
=> (a.IsNullOrEmpty() && b.IsNullOrEmpty()) ||
string.Equals(Path.GetFullPath(a.CleanUpPathCrossPlatform(false) ?? ""),
Path.GetFullPath(b.CleanUpPathCrossPlatform(false) ?? ""),
StringComparison.OrdinalIgnoreCase);
{
if (a.IsNullOrEmpty() || b.IsNullOrEmpty())
{
return a.IsNullOrEmpty() == b.IsNullOrEmpty();
}
return string.Equals(Path.GetFullPath(a.CleanUpPathCrossPlatform(false) ?? ""),
Path.GetFullPath(b.CleanUpPathCrossPlatform(false) ?? ""), StringComparison.OrdinalIgnoreCase);
}
public static bool operator==(ContentPath a, ContentPath b)
=> StringEquality(a.Value, b.Value);
=> StringEquality(a?.Value, b?.Value);
public static bool operator!=(ContentPath a, ContentPath b) => !(a == b);
public static bool operator==(ContentPath a, string? b)
=> StringEquality(a.Value, b);
=> StringEquality(a?.Value, b);
public static bool operator!=(ContentPath a, string? b) => !(a == b);
public static bool operator==(string? a, ContentPath b)
=> StringEquality(a, b.Value);
=> StringEquality(a, b?.Value);
public static bool operator!=(string? a, ContentPath b) => !(a == b);