Unstable 0.17.7.0
This commit is contained in:
@@ -108,7 +108,7 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!Permissions.HasFlag(permission)) Permissions |= permission;
|
||||
if (!Permissions.HasFlag(permission)) { Permissions |= permission; }
|
||||
}
|
||||
|
||||
public void RemovePermission(ClientPermissions permission)
|
||||
@@ -117,7 +117,7 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (Permissions.HasFlag(permission)) Permissions &= ~permission;
|
||||
if (Permissions.HasFlag(permission)) { Permissions &= ~permission; }
|
||||
}
|
||||
|
||||
public bool HasPermission(ClientPermissions permission)
|
||||
|
||||
@@ -51,6 +51,17 @@ namespace Barotrauma.Networking
|
||||
set;
|
||||
}
|
||||
|
||||
public DateTime LastOffsetAckTime
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public void RecordOffsetAckTime()
|
||||
{
|
||||
LastOffsetAckTime = DateTime.Now;
|
||||
}
|
||||
|
||||
public float BytesPerSecond
|
||||
{
|
||||
get;
|
||||
@@ -91,6 +102,8 @@ namespace Barotrauma.Networking
|
||||
Connection = connection;
|
||||
|
||||
Status = FileTransferStatus.NotStarted;
|
||||
|
||||
LastOffsetAckTime = DateTime.Now - new TimeSpan(days: 0, hours: 0, minutes: 5, seconds: 0);
|
||||
}
|
||||
|
||||
public void OpenStream()
|
||||
@@ -214,11 +227,11 @@ namespace Barotrauma.Networking
|
||||
fileName != existingTransfer.FileName)
|
||||
{
|
||||
GameMain.Client.CancelFileTransfer(transferId);
|
||||
DebugConsole.ThrowError("File transfer error: file transfer initiated with an ID that's already in use");
|
||||
DebugConsole.AddWarning("File transfer error: file transfer initiated with an ID that's already in use");
|
||||
}
|
||||
else //resend acknowledgement packet
|
||||
{
|
||||
GameMain.Client.UpdateFileTransfer(transferId, existingTransfer.Received, existingTransfer.LastSeen);
|
||||
GameMain.Client.UpdateFileTransfer(existingTransfer, existingTransfer.Received, existingTransfer.LastSeen);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -285,7 +298,7 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
activeTransfers.Add(newTransfer);
|
||||
|
||||
GameMain.Client.UpdateFileTransfer(transferId, 0, 0); //send acknowledgement packet
|
||||
GameMain.Client.UpdateFileTransfer(newTransfer, 0, 0); //send acknowledgement packet
|
||||
}
|
||||
break;
|
||||
case (byte)FileTransferMessageType.TransferOnSameMachine:
|
||||
@@ -333,7 +346,7 @@ namespace Barotrauma.Networking
|
||||
if (!finishedTransfers.Any(t => t.transferId == transferId))
|
||||
{
|
||||
GameMain.Client.CancelFileTransfer(transferId);
|
||||
DebugConsole.ThrowError("File transfer error: received data without a transfer initiation message");
|
||||
DebugConsole.AddWarning("File transfer error: received data without a transfer initiation message");
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -344,7 +357,7 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
activeTransfer.LastSeen = Math.Max(offset, activeTransfer.LastSeen);
|
||||
DebugConsole.Log($"Received {bytesToRead} bytes of the file {activeTransfer.FileName} (ignoring: offset {offset}, waiting for {activeTransfer.Received})");
|
||||
GameMain.Client.UpdateFileTransfer(activeTransfer.ID, activeTransfer.Received, activeTransfer.LastSeen);
|
||||
GameMain.Client.UpdateFileTransfer(activeTransfer, activeTransfer.Received, activeTransfer.LastSeen);
|
||||
return;
|
||||
}
|
||||
activeTransfer.LastSeen = offset;
|
||||
@@ -375,7 +388,7 @@ namespace Barotrauma.Networking
|
||||
return;
|
||||
}
|
||||
|
||||
GameMain.Client.UpdateFileTransfer(activeTransfer.ID, activeTransfer.Received, activeTransfer.LastSeen, reliable: activeTransfer.Status == FileTransferStatus.Finished);
|
||||
GameMain.Client.UpdateFileTransfer(activeTransfer, activeTransfer.Received, activeTransfer.LastSeen, reliable: activeTransfer.Status == FileTransferStatus.Finished);
|
||||
if (activeTransfer.Status == FileTransferStatus.Finished)
|
||||
{
|
||||
activeTransfer.Dispose();
|
||||
|
||||
@@ -1947,7 +1947,6 @@ namespace Barotrauma.Networking
|
||||
existingClient.Character = null;
|
||||
existingClient.Karma = tc.Karma;
|
||||
existingClient.Muted = tc.Muted;
|
||||
existingClient.HasPermissions = tc.HasPermissions;
|
||||
existingClient.InGame = tc.InGame;
|
||||
existingClient.IsOwner = tc.IsOwner;
|
||||
existingClient.AllowKicking = tc.AllowKicking;
|
||||
@@ -2493,12 +2492,18 @@ namespace Barotrauma.Networking
|
||||
CancelFileTransfer(transfer.ID);
|
||||
}
|
||||
|
||||
public void UpdateFileTransfer(int id, int expecting, int lastSeen, bool reliable = false)
|
||||
public void UpdateFileTransfer(FileReceiver.FileTransferIn transfer, int expecting, int lastSeen, bool reliable = false)
|
||||
{
|
||||
if (!reliable && (DateTime.Now - transfer.LastOffsetAckTime).TotalSeconds < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
transfer.RecordOffsetAckTime();
|
||||
|
||||
IWriteMessage msg = new WriteOnlyMessage();
|
||||
msg.Write((byte)ClientPacketHeader.FILE_REQUEST);
|
||||
msg.Write((byte)FileTransferMessageType.Data);
|
||||
msg.Write((byte)id);
|
||||
msg.Write((byte)transfer.ID);
|
||||
msg.Write(expecting);
|
||||
msg.Write(lastSeen);
|
||||
clientPeer.Send(msg, reliable ? DeliveryMethod.Reliable : DeliveryMethod.Unreliable);
|
||||
@@ -2784,7 +2789,9 @@ namespace Barotrauma.Networking
|
||||
|
||||
public void ShowSubmarineChangeVoteInterface(Client starter, SubmarineInfo info, VoteType type, float timeOut)
|
||||
{
|
||||
if (info == null || votingInterface != null) { return; }
|
||||
if (info == null) { return; }
|
||||
if (votingInterface != null && votingInterface.VoteRunning) { return; }
|
||||
votingInterface?.Remove();
|
||||
votingInterface = VotingInterface.CreateSubmarineVotingInterface(starter, info, type, timeOut);
|
||||
}
|
||||
#endregion
|
||||
@@ -2792,12 +2799,13 @@ namespace Barotrauma.Networking
|
||||
#region Money Transfer Voting
|
||||
public void ShowMoneyTransferVoteInterface(Client starter, Client from, int amount, Client to, float timeOut)
|
||||
{
|
||||
if (votingInterface != null) { return; }
|
||||
if (votingInterface != null && votingInterface.VoteRunning) { return; }
|
||||
if (from == null && to == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Tried to initiate a vote for transferring from null to null!");
|
||||
return;
|
||||
}
|
||||
votingInterface?.Remove();
|
||||
votingInterface = VotingInterface.CreateMoneyTransferVotingInterface(starter, from, to, amount, timeOut);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -78,24 +78,6 @@ namespace Barotrauma.Networking
|
||||
get;
|
||||
private set;
|
||||
} = new List<ulong>();
|
||||
|
||||
public bool ContentPackagesMatch()
|
||||
{
|
||||
//make sure we have all the packages the server requires
|
||||
if (ContentPackageHashes.Count != ContentPackageWorkshopIds.Count) { return false; }
|
||||
for (int i = 0; i < ContentPackageWorkshopIds.Count; i++)
|
||||
{
|
||||
string hash = ContentPackageHashes[i];
|
||||
UInt64 id = ContentPackageWorkshopIds[i];
|
||||
if (!GameMain.ServerListScreen.ContentPackagesByHash.ContainsKey(hash))
|
||||
{
|
||||
if (GameMain.ServerListScreen.ContentPackagesByWorkshopId.ContainsKey(id)) { return false; }
|
||||
if (id == 0) { return false; }
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void CreatePreviewWindow(GUIFrame frame)
|
||||
{
|
||||
@@ -105,7 +87,8 @@ namespace Barotrauma.Networking
|
||||
|
||||
var title = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), frame.RectTransform), ServerName, font: GUIStyle.LargeFont)
|
||||
{
|
||||
ToolTip = ServerName
|
||||
ToolTip = ServerName,
|
||||
CanBeFocused = false
|
||||
};
|
||||
title.Text = ToolBox.LimitString(title.Text, title.Font, (int)(title.Rect.Width * 0.85f));
|
||||
|
||||
@@ -130,7 +113,11 @@ namespace Barotrauma.Networking
|
||||
};
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), frame.RectTransform),
|
||||
TextManager.AddPunctuation(':', TextManager.Get("ServerListVersion"), string.IsNullOrEmpty(GameVersion) ? TextManager.Get("Unknown") : GameVersion));
|
||||
TextManager.AddPunctuation(':', TextManager.Get("ServerListVersion"),
|
||||
string.IsNullOrEmpty(GameVersion) ? TextManager.Get("Unknown") : GameVersion))
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
|
||||
bool hidePlaystyleBanner = !PlayStyle.HasValue;
|
||||
if (!hidePlaystyleBanner)
|
||||
@@ -141,15 +128,23 @@ namespace Barotrauma.Networking
|
||||
var playStyleBanner = new GUIImage(new RectTransform(new Point(frame.Rect.Width, (int)(frame.Rect.Width / playStyleBannerAspectRatio)), frame.RectTransform),
|
||||
playStyleBannerSprite, null, true);
|
||||
|
||||
var playStyleName = new GUITextBlock(new RectTransform(new Vector2(0.15f, 0.0f), playStyleBanner.RectTransform) { RelativeOffset = new Vector2(0.0f, 0.06f) },
|
||||
TextManager.AddPunctuation(':', TextManager.Get("serverplaystyle"), TextManager.Get("servertag."+ playStyle)), textColor: Color.White,
|
||||
font: GUIStyle.SmallFont, textAlignment: Alignment.Center,
|
||||
var playStyleName = new GUITextBlock(
|
||||
new RectTransform(new Vector2(0.15f, 0.0f), playStyleBanner.RectTransform)
|
||||
{ RelativeOffset = new Vector2(0.0f, 0.06f) },
|
||||
TextManager.AddPunctuation(':', TextManager.Get("serverplaystyle"),
|
||||
TextManager.Get("servertag." + playStyle)), textColor: Color.White,
|
||||
font: GUIStyle.SmallFont, textAlignment: Alignment.Center,
|
||||
color: ServerListScreen.PlayStyleColors[(int)playStyle], style: "GUISlopedHeader");
|
||||
playStyleName.RectTransform.NonScaledSize = (playStyleName.Font.MeasureString(playStyleName.Text) + new Vector2(20, 5) * GUI.Scale).ToPoint();
|
||||
playStyleName.RectTransform.IsFixedSize = true;
|
||||
}
|
||||
|
||||
var serverType = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), frame.RectTransform),
|
||||
TextManager.Get((OwnerID != 0 || LobbyID != 0) ? "SteamP2PServer" : "DedicatedServer"), textAlignment: Alignment.TopLeft);
|
||||
TextManager.Get((OwnerID != 0 || LobbyID != 0) ? "SteamP2PServer" : "DedicatedServer"),
|
||||
textAlignment: Alignment.TopLeft)
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
serverType.RectTransform.MinSize = new Point(0, (int)(serverType.Rect.Height * 1.5f));
|
||||
|
||||
var content = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.6f), frame.RectTransform))
|
||||
@@ -270,7 +265,11 @@ namespace Barotrauma.Networking
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), content.RectTransform),
|
||||
TextManager.Get("ServerListContentPackages"), textAlignment: Alignment.Center, font: GUIStyle.SubHeadingFont);
|
||||
|
||||
var contentPackageList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.3f), frame.RectTransform)) { ScrollBarVisible = true };
|
||||
var contentPackageList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.3f), frame.RectTransform))
|
||||
{
|
||||
ScrollBarVisible = true,
|
||||
OnSelected = (component, o) => false
|
||||
};
|
||||
if (ContentPackageNames.Count == 0)
|
||||
{
|
||||
new GUITextBlock(new RectTransform(Vector2.One, contentPackageList.Content.RectTransform), TextManager.Get("Unknown"), textAlignment: Alignment.Center)
|
||||
@@ -282,28 +281,30 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
for (int i = 0; i < ContentPackageNames.Count; i++)
|
||||
{
|
||||
var packageText = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.15f), contentPackageList.Content.RectTransform) { MinSize = new Point(0, 15) },
|
||||
var packageText = new GUITickBox(
|
||||
new RectTransform(new Vector2(1.0f, 0.15f), contentPackageList.Content.RectTransform)
|
||||
{ MinSize = new Point(0, 15) },
|
||||
ContentPackageNames[i])
|
||||
{
|
||||
CanBeFocused = false
|
||||
Enabled = false
|
||||
};
|
||||
packageText.Box.Enabled = true;
|
||||
packageText.TextBlock.Enabled = true;
|
||||
if (i < ContentPackageHashes.Count)
|
||||
{
|
||||
if (ContentPackageManager.AllPackages.Any(contentPackage => contentPackage.Hash.StringRepresentation == ContentPackageHashes[i]))
|
||||
{
|
||||
packageText.TextColor = GUIStyle.Green;
|
||||
packageText.Selected = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
//workshop download link found
|
||||
if (i < ContentPackageWorkshopIds.Count && ContentPackageWorkshopIds[i] != 0)
|
||||
else if (i < ContentPackageWorkshopIds.Count && ContentPackageWorkshopIds[i] != 0)
|
||||
{
|
||||
packageText.TextColor = GUIStyle.Yellow;
|
||||
packageText.ToolTip = TextManager.GetWithVariable("ServerListIncompatibleContentPackageWorkshopAvailable", "[contentpackage]", ContentPackageNames[i]);
|
||||
}
|
||||
else //no package or workshop download link found, tough luck
|
||||
else //no package or workshop download link found (TODO: update text to say that they could be downloaded through the server)
|
||||
{
|
||||
packageText.TextColor = GUIStyle.Red;
|
||||
packageText.TextColor = GameMain.VanillaContent.NameMatches(ContentPackageNames[i]) ? GUIStyle.Red : GUIStyle.Yellow;
|
||||
packageText.ToolTip = TextManager.GetWithVariables("ServerListIncompatibleContentPackage",
|
||||
("[contentpackage]", ContentPackageNames[i]), ("[hash]", ContentPackageHashes[i]));
|
||||
}
|
||||
@@ -342,7 +343,7 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
if (ContentPackageNames.Count > 0)
|
||||
{
|
||||
tags.Add(ContentPackageNames.Count > 1 || ContentPackageNames[0] != GameMain.VanillaContent?.Name ? "modded.true" : "modded.false");
|
||||
tags.Add(ContentPackageNames.Count > 1 || !GameMain.VanillaContent.NameMatches(ContentPackageNames[0]) ? "modded.true" : "modded.false");
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user