Unstable 1.1.14.0
This commit is contained in:
@@ -1,18 +1,67 @@
|
||||
namespace Barotrauma.Steam
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Barotrauma.Networking;
|
||||
|
||||
namespace Barotrauma.Steam
|
||||
{
|
||||
static partial class SteamManager
|
||||
{
|
||||
private static Steamworks.AuthTicket currentTicket = null;
|
||||
public static Steamworks.AuthTicket GetAuthSessionTicket()
|
||||
private static Option<Steamworks.AuthTicket> currentMultiplayerTicket = Option.None;
|
||||
public static Option<Steamworks.AuthTicket> GetAuthSessionTicketForMultiplayer(Endpoint remoteHostEndpoint)
|
||||
{
|
||||
if (!IsInitialized)
|
||||
{
|
||||
return null;
|
||||
return Option.None;
|
||||
}
|
||||
|
||||
currentTicket?.Cancel();
|
||||
currentTicket = Steamworks.SteamUser.GetAuthSessionTicket();
|
||||
return currentTicket;
|
||||
if (currentMultiplayerTicket.TryUnwrap(out var ticketToCancel))
|
||||
{
|
||||
ticketToCancel.Cancel();
|
||||
}
|
||||
currentMultiplayerTicket = Option.None;
|
||||
|
||||
var netIdentity = remoteHostEndpoint switch
|
||||
{
|
||||
LidgrenEndpoint { Address: LidgrenAddress { NetAddress: var ipAddr }, Port: var ipPort }
|
||||
=> (Steamworks.Data.NetIdentity)Steamworks.Data.NetAddress.From(ipAddr, (ushort)ipPort),
|
||||
SteamP2PEndpoint { SteamId: var steamId }
|
||||
=> (Steamworks.Data.NetIdentity)(Steamworks.SteamId)steamId.Value,
|
||||
_
|
||||
=> throw new ArgumentOutOfRangeException(nameof(remoteHostEndpoint))
|
||||
};
|
||||
var newTicket = Steamworks.SteamUser.GetAuthSessionTicket(netIdentity);
|
||||
|
||||
currentMultiplayerTicket = newTicket != null
|
||||
? Option.Some(newTicket)
|
||||
: Option.None;
|
||||
|
||||
return currentMultiplayerTicket;
|
||||
}
|
||||
|
||||
private const string GameAnalyticsConsentIdentity = "BarotraumaGameAnalyticsConsent";
|
||||
|
||||
private static Option<Steamworks.AuthTicketForWebApi> currentGameAnalyticsConsentTicket = Option.None;
|
||||
public static async Task<Option<Steamworks.AuthTicketForWebApi>> GetAuthTicketForGameAnalyticsConsent()
|
||||
{
|
||||
if (!IsInitialized)
|
||||
{
|
||||
return Option.None;
|
||||
}
|
||||
|
||||
if (currentGameAnalyticsConsentTicket.TryUnwrap(out var ticketToCancel))
|
||||
{
|
||||
ticketToCancel.Cancel();
|
||||
}
|
||||
currentGameAnalyticsConsentTicket = Option.None;
|
||||
|
||||
var newTicket = await Steamworks.SteamUser.GetAuthTicketForWebApi(identity: GameAnalyticsConsentIdentity);
|
||||
|
||||
currentGameAnalyticsConsentTicket = newTicket != null
|
||||
? Option.Some(newTicket)
|
||||
: Option.None;
|
||||
|
||||
return currentGameAnalyticsConsentTicket;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -613,7 +613,8 @@ namespace Barotrauma.Steam
|
||||
|
||||
public static async Task CopyDirectory(string fileListDir, string modName, string from, string to, ShouldCorrectPaths shouldCorrectPaths)
|
||||
{
|
||||
from = Path.GetFullPath(from); to = Path.GetFullPath(to);
|
||||
from = Path.GetFullPath(from);
|
||||
to = Path.GetFullPath(to);
|
||||
Directory.CreateDirectory(to);
|
||||
|
||||
string convertFromTo(string from)
|
||||
@@ -623,10 +624,16 @@ namespace Barotrauma.Steam
|
||||
string[] subDirs = Directory.GetDirectories(from);
|
||||
foreach (var file in files)
|
||||
{
|
||||
//ignore hidden files
|
||||
if (Path.GetFileName(file).StartsWith('.')) { continue; }
|
||||
await CopyFile(fileListDir, modName, file, convertFromTo(file), shouldCorrectPaths);
|
||||
}
|
||||
|
||||
foreach (var dir in subDirs) { await CopyDirectory(fileListDir, modName, dir, convertFromTo(dir), shouldCorrectPaths); }
|
||||
foreach (var dir in subDirs)
|
||||
{
|
||||
if (Path.GetFileName(dir) is { } dirName && dirName.StartsWith('.')) { continue; }
|
||||
await CopyDirectory(fileListDir, modName, dir, convertFromTo(dir), shouldCorrectPaths);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user