Unstable 0.17.7.0

This commit is contained in:
Markus Isberg
2022-04-08 00:34:17 +09:00
parent 95764d1fa8
commit 164d72ae3a
82 changed files with 852 additions and 385 deletions
@@ -11,8 +11,8 @@ namespace Barotrauma
public static Success<T, TError> Success(T value)
=> new Success<T, TError>(value);
public static Failure<T, TError> Failure(TError error)
=> new Failure<T, TError>(error);
public static Failure<T, TError> Failure(TError error, string? stackTrace)
=> new Failure<T, TError>(error, stackTrace);
}
public sealed class Success<T, TError> : Result<T, TError>
@@ -33,11 +33,15 @@ namespace Barotrauma
where TError: notnull
{
public readonly TError Error;
public readonly string? StackTrace;
public override bool IsSuccess => false;
public Failure(TError error)
public Failure(TError error, string? stackTrace)
{
Error = error;
StackTrace = stackTrace;
}
}
}
@@ -4,6 +4,7 @@ using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using Barotrauma.Networking;
namespace Barotrauma.IO
{
@@ -23,9 +24,15 @@ namespace Barotrauma.IO
public static bool CanWrite(string path, bool isDirectory)
{
path = System.IO.Path.GetFullPath(path).CleanUpPath();
string localModsDir = System.IO.Path.GetFullPath(ContentPackage.LocalModsDir).CleanUpPath();
string workshopModsDir = System.IO.Path.GetFullPath(ContentPackage.WorkshopModsDir).CleanUpPath();
string getFullPath(string p)
=> System.IO.Path.GetFullPath(p).CleanUpPath();
path = getFullPath(path);
string localModsDir = getFullPath(ContentPackage.LocalModsDir);
string workshopModsDir = getFullPath(ContentPackage.WorkshopModsDir);
#if CLIENT
string tempDownloadDir = getFullPath(ModReceiver.DownloadFolder);
#endif
if (!isDirectory)
{
@@ -34,8 +41,15 @@ namespace Barotrauma.IO
{
return false;
}
if (!path.StartsWith(workshopModsDir, StringComparison.OrdinalIgnoreCase)
&& !path.StartsWith(localModsDir, StringComparison.OrdinalIgnoreCase)
bool pathStartsWith(string prefix)
=> path.StartsWith(prefix, StringComparison.OrdinalIgnoreCase);
if (!pathStartsWith(workshopModsDir)
&& !pathStartsWith(localModsDir)
#if CLIENT
&& !pathStartsWith(tempDownloadDir)
#endif
&& (extension == ".dll" || extension == ".exe" || extension == ".json"))
{
return false;
@@ -13,7 +13,7 @@ using System.Text.RegularExpressions;
namespace Barotrauma
{
partial class SaveUtil
static class SaveUtil
{
private static readonly string LegacySaveFolder = Path.Combine("Data", "Saves");
private static readonly string LegacyMultiplayerSaveFolder = Path.Combine(LegacySaveFolder, "Multiplayer");