(6eeea9b7c) v0.9.10.0.0
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using Barotrauma.IO;
|
||||
using System.IO.Pipes;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
@@ -18,8 +18,8 @@ namespace Barotrauma.Networking
|
||||
|
||||
public static void Start(ProcessStartInfo processInfo)
|
||||
{
|
||||
writePipe = new AnonymousPipeServerStream(PipeDirection.Out, HandleInheritability.Inheritable);
|
||||
readPipe = new AnonymousPipeServerStream(PipeDirection.In, HandleInheritability.Inheritable);
|
||||
writePipe = new AnonymousPipeServerStream(PipeDirection.Out, System.IO.HandleInheritability.Inheritable);
|
||||
readPipe = new AnonymousPipeServerStream(PipeDirection.In, System.IO.HandleInheritability.Inheritable);
|
||||
|
||||
writeStream = writePipe; readStream = readPipe;
|
||||
|
||||
@@ -38,6 +38,13 @@ namespace Barotrauma.Networking
|
||||
localHandlesDisposed = true;
|
||||
}
|
||||
|
||||
public static void ClosePipes()
|
||||
{
|
||||
writePipe?.Close();
|
||||
readPipe?.Close();
|
||||
shutDown = true;
|
||||
}
|
||||
|
||||
public static void ShutDown()
|
||||
{
|
||||
Process?.Kill(); Process = null;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Barotrauma.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Xml;
|
||||
@@ -100,7 +100,7 @@ namespace Barotrauma.Networking
|
||||
WriteStream = null;
|
||||
}
|
||||
|
||||
WriteStream = new FileStream(FilePath, FileMode.Create, FileAccess.Write, FileShare.None);
|
||||
WriteStream = File.Open(FilePath, System.IO.FileMode.Create, System.IO.FileAccess.Write);
|
||||
TimeStarted = Environment.TickCount;
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
newTransfer.OpenStream();
|
||||
}
|
||||
catch (IOException e)
|
||||
catch (System.IO.IOException e)
|
||||
{
|
||||
if (i < maxRetries)
|
||||
{
|
||||
@@ -422,7 +422,7 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(fileName) ||
|
||||
fileName.IndexOfAny(Path.GetInvalidFileNameChars()) > -1)
|
||||
fileName.IndexOfAny(Path.GetInvalidFileNameChars().ToArray()) > -1)
|
||||
{
|
||||
errorMessage = "Illegal characters in file name ''" + fileName + "''";
|
||||
return false;
|
||||
@@ -455,7 +455,7 @@ namespace Barotrauma.Networking
|
||||
switch (fileTransfer.FileType)
|
||||
{
|
||||
case FileTransferType.Submarine:
|
||||
Stream stream;
|
||||
System.IO.Stream stream;
|
||||
try
|
||||
{
|
||||
stream = SaveUtil.DecompressFiletoStream(fileTransfer.FilePath);
|
||||
|
||||
@@ -3,7 +3,7 @@ using Barotrauma.Steam;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Barotrauma.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -52,7 +52,7 @@ namespace Barotrauma.Networking
|
||||
public GUITickBox EndVoteTickBox;
|
||||
private GUIComponent buttonContainer;
|
||||
|
||||
private NetStats netStats;
|
||||
public readonly NetStats NetStats;
|
||||
|
||||
protected GUITickBox cameraFollowsSub;
|
||||
|
||||
@@ -169,9 +169,9 @@ namespace Barotrauma.Networking
|
||||
|
||||
allowReconnect = true;
|
||||
|
||||
netStats = new NetStats();
|
||||
NetStats = new NetStats();
|
||||
|
||||
inGameHUD = new GUIFrame(new RectTransform(Vector2.One, GUI.Canvas), style: null)
|
||||
inGameHUD = new GUIFrame(new RectTransform(GUI.Canvas.RelativeSize, GUI.Canvas), style: null)
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
@@ -569,14 +569,7 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
}
|
||||
|
||||
/*TODO: reimplement
|
||||
if (ShowNetStats && client?.ServerConnection != null)
|
||||
{
|
||||
netStats.AddValue(NetStats.NetStatType.ReceivedBytes, client.ServerConnection.Statistics.ReceivedBytes);
|
||||
netStats.AddValue(NetStats.NetStatType.SentBytes, client.ServerConnection.Statistics.SentBytes);
|
||||
netStats.AddValue(NetStats.NetStatType.ResentMessages, client.ServerConnection.Statistics.ResentMessages);
|
||||
netStats.Update(deltaTime);
|
||||
}*/
|
||||
NetStats.Update(deltaTime);
|
||||
|
||||
UpdateHUD(deltaTime);
|
||||
|
||||
@@ -781,7 +774,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
if (readyToStart && !CoroutineManager.IsCoroutineRunning("WaitForStartRound"))
|
||||
{
|
||||
CoroutineManager.StartCoroutine(GameMain.NetLobbyScreen.WaitForStartRound(startButton: null, allowCancel: false), "WaitForStartRound");
|
||||
CoroutineManager.StartCoroutine(GameMain.NetLobbyScreen.WaitForStartRound(startButton: null), "WaitForStartRound");
|
||||
}
|
||||
break;
|
||||
case ServerPacketHeader.STARTGAME:
|
||||
@@ -1455,6 +1448,15 @@ namespace Barotrauma.Networking
|
||||
|
||||
var teamID = i == 0 ? Character.TeamType.Team1 : Character.TeamType.Team2;
|
||||
Submarine.MainSubs[i].TeamID = teamID;
|
||||
foreach (Item item in Item.ItemList)
|
||||
{
|
||||
if (item.Submarine == null) { continue; }
|
||||
if (item.Submarine != Submarine.MainSubs[i] && !Submarine.MainSubs[i].DockedTo.Contains(item.Submarine)) { continue; }
|
||||
foreach (WifiComponent wifiComponent in item.GetComponents<WifiComponent>())
|
||||
{
|
||||
wifiComponent.TeamID = Submarine.MainSubs[i].TeamID;
|
||||
}
|
||||
}
|
||||
foreach (Submarine sub in Submarine.MainSubs[i].DockedTo)
|
||||
{
|
||||
sub.TeamID = teamID;
|
||||
@@ -1891,8 +1893,8 @@ namespace Barotrauma.Networking
|
||||
|
||||
DebugConsole.ThrowError("Writing object data to \"crashreport_object.bin\", please send this file to us at http://github.com/Regalis11/Barotrauma/issues");
|
||||
|
||||
using (FileStream fl = File.Open("crashreport_object.bin", FileMode.Create))
|
||||
using (BinaryWriter sw = new BinaryWriter(fl))
|
||||
using (FileStream fl = File.Open("crashreport_object.bin", System.IO.FileMode.Create))
|
||||
using (System.IO.BinaryWriter sw = new System.IO.BinaryWriter(fl))
|
||||
{
|
||||
sw.Write(inc.Buffer, (int)(prevBytePos - prevByteLength), (int)(prevByteLength));
|
||||
}
|
||||
@@ -2759,15 +2761,15 @@ namespace Barotrauma.Networking
|
||||
|
||||
if (!ShowNetStats) return;
|
||||
|
||||
netStats.Draw(spriteBatch, new Rectangle(300, 10, 300, 150));
|
||||
NetStats.Draw(spriteBatch, new Rectangle(300, 10, 300, 150));
|
||||
|
||||
/* TODO: reimplement
|
||||
int width = 200, height = 300;
|
||||
int x = GameMain.GraphicsWidth - width, y = (int)(GameMain.GraphicsHeight * 0.3f);
|
||||
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(x, y, width, height), Color.Black * 0.7f, true);
|
||||
GUI.Font.DrawString(spriteBatch, "Network statistics:", new Vector2(x + 10, y + 10), Color.White);
|
||||
|
||||
/* TODO: reimplement
|
||||
if (client.ServerConnection != null)
|
||||
{
|
||||
GUI.Font.DrawString(spriteBatch, "Ping: " + (int)(client.ServerConnection.AverageRoundtripTime * 1000.0f) + " ms", new Vector2(x + 10, y + 25), Color.White);
|
||||
|
||||
@@ -14,10 +14,10 @@ namespace Barotrauma.Networking
|
||||
ResentMessages = 2
|
||||
}
|
||||
|
||||
private Graph[] graphs;
|
||||
private readonly Graph[] graphs;
|
||||
|
||||
private float[] totalValue;
|
||||
private float[] lastValue;
|
||||
private readonly float[] totalValue;
|
||||
private readonly float[] lastValue;
|
||||
|
||||
const float UpdateInterval = 0.1f;
|
||||
float updateTimer;
|
||||
@@ -37,9 +37,7 @@ namespace Barotrauma.Networking
|
||||
public void AddValue(NetStatType statType, float value)
|
||||
{
|
||||
float valueChange = value - lastValue[(int)statType];
|
||||
|
||||
totalValue[(int)statType] += valueChange;
|
||||
|
||||
lastValue[(int)statType] = value;
|
||||
}
|
||||
|
||||
@@ -51,7 +49,6 @@ namespace Barotrauma.Networking
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
|
||||
graphs[i].Update(totalValue[i] / UpdateInterval);
|
||||
totalValue[i] = 0.0f;
|
||||
}
|
||||
@@ -64,23 +61,22 @@ namespace Barotrauma.Networking
|
||||
GUI.DrawRectangle(spriteBatch, rect, Color.Black * 0.4f, true);
|
||||
|
||||
graphs[(int)NetStatType.ReceivedBytes].Draw(spriteBatch, rect, null, 0.0f, Color.Cyan);
|
||||
|
||||
graphs[(int)NetStatType.SentBytes].Draw(spriteBatch, rect, null, 0.0f, GUI.Style.Orange);
|
||||
|
||||
graphs[(int)NetStatType.ResentMessages].Draw(spriteBatch, rect, null, 0.0f, GUI.Style.Red);
|
||||
if (graphs[(int)NetStatType.ResentMessages].Average() > 0)
|
||||
{
|
||||
graphs[(int)NetStatType.ResentMessages].Draw(spriteBatch, rect, null, 0.0f, GUI.Style.Red);
|
||||
GUI.SmallFont.DrawString(spriteBatch, "Peak resent: " + graphs[(int)NetStatType.ResentMessages].LargestValue() + " messages/s",
|
||||
new Vector2(rect.Right + 10, rect.Y + 50), GUI.Style.Red);
|
||||
}
|
||||
|
||||
GUI.SmallFont.DrawString(spriteBatch,
|
||||
"Peak received: " + MathUtils.GetBytesReadable((int)graphs[(int)NetStatType.ReceivedBytes].LargestValue()) + "/s " +
|
||||
"Avg received: " + MathUtils.GetBytesReadable((int)graphs[(int)NetStatType.ReceivedBytes].Average()) + "/s",
|
||||
new Vector2(rect.Right + 10, rect.Y + 10), Color.Cyan);
|
||||
|
||||
|
||||
GUI.SmallFont.DrawString(spriteBatch, "Peak sent: " + MathUtils.GetBytesReadable((int)graphs[(int)NetStatType.SentBytes].LargestValue()) + "/s " +
|
||||
"Avg sent: " + MathUtils.GetBytesReadable((int)graphs[(int)NetStatType.SentBytes].Average()) + "/s",
|
||||
new Vector2(rect.Right + 10, rect.Y + 30), GUI.Style.Orange);
|
||||
|
||||
GUI.SmallFont.DrawString(spriteBatch, "Peak resent: " + graphs[(int)NetStatType.ResentMessages].LargestValue() + " messages/s",
|
||||
new Vector2(rect.Right + 10, rect.Y + 50), GUI.Style.Red);
|
||||
#if DEBUG
|
||||
/*int y = 10;
|
||||
|
||||
|
||||
+3
@@ -97,6 +97,9 @@ namespace Barotrauma.Networking
|
||||
incomingLidgrenMessages.Clear();
|
||||
netClient.ReadMessages(incomingLidgrenMessages);
|
||||
|
||||
GameMain.Client?.NetStats?.AddValue(NetStats.NetStatType.ReceivedBytes, netClient.Statistics.ReceivedBytes);
|
||||
GameMain.Client?.NetStats?.AddValue(NetStats.NetStatType.SentBytes, netClient.Statistics.SentBytes);
|
||||
|
||||
foreach (NetIncomingMessage inc in incomingLidgrenMessages)
|
||||
{
|
||||
if (inc.SenderConnection != (ServerConnection as LidgrenConnection).NetConnection) { continue; }
|
||||
|
||||
+17
-4
@@ -18,6 +18,8 @@ namespace Barotrauma.Networking
|
||||
private double timeout;
|
||||
private double heartbeatTimer;
|
||||
|
||||
private long sentBytes, receivedBytes;
|
||||
|
||||
private List<IReadMessage> incomingInitializationMessages;
|
||||
private List<IReadMessage> incomingDataMessages;
|
||||
|
||||
@@ -63,6 +65,7 @@ namespace Barotrauma.Networking
|
||||
outMsg.Write((byte)ConnectionInitialization.ConnectionStarted);
|
||||
|
||||
Steamworks.SteamNetworking.SendP2PPacket(hostSteamId, outMsg.Buffer, outMsg.LengthBytes, 0, Steamworks.P2PSend.Reliable);
|
||||
sentBytes += outMsg.LengthBytes;
|
||||
|
||||
initializationStep = ConnectionInitialization.SteamTicketAndVersion;
|
||||
|
||||
@@ -99,11 +102,11 @@ namespace Barotrauma.Networking
|
||||
if (isConnectionInitializationStep)
|
||||
{
|
||||
ulong low = Lidgren.Network.NetBitWriter.ReadUInt32(data, 32, 8);
|
||||
ulong high = Lidgren.Network.NetBitWriter.ReadUInt32(data, 32, 8+32);
|
||||
ulong high = Lidgren.Network.NetBitWriter.ReadUInt32(data, 32, 8 + 32);
|
||||
ulong lobbyId = low + (high << 32);
|
||||
|
||||
Steam.SteamManager.JoinLobby(lobbyId, false);
|
||||
IReadMessage inc = new ReadOnlyMessage(data, false, 1+8, dataLength - 9, ServerConnection);
|
||||
IReadMessage inc = new ReadOnlyMessage(data, false, 1 + 8, dataLength - 9, ServerConnection);
|
||||
if (initializationStep != ConnectionInitialization.Success)
|
||||
{
|
||||
incomingInitializationMessages.Add(inc);
|
||||
@@ -137,16 +140,20 @@ namespace Barotrauma.Networking
|
||||
timeout -= deltaTime;
|
||||
heartbeatTimer -= deltaTime;
|
||||
|
||||
for (int i=0;i<100;i++)
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
if (!Steamworks.SteamNetworking.IsP2PPacketAvailable()) { break; }
|
||||
var packet = Steamworks.SteamNetworking.ReadP2PPacket();
|
||||
if (packet.HasValue)
|
||||
{
|
||||
OnP2PData(packet?.SteamId ?? 0, packet?.Data, packet?.Data.Length ?? 0, 0);
|
||||
receivedBytes += packet?.Data.Length ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
GameMain.Client?.NetStats?.AddValue(NetStats.NetStatType.ReceivedBytes, receivedBytes);
|
||||
GameMain.Client?.NetStats?.AddValue(NetStats.NetStatType.SentBytes, sentBytes);
|
||||
|
||||
if (heartbeatTimer < 0.0)
|
||||
{
|
||||
IWriteMessage outMsg = new WriteOnlyMessage();
|
||||
@@ -154,6 +161,7 @@ namespace Barotrauma.Networking
|
||||
outMsg.Write((byte)PacketHeader.IsHeartbeatMessage);
|
||||
|
||||
Steamworks.SteamNetworking.SendP2PPacket(hostSteamId, outMsg.Buffer, outMsg.LengthBytes, 0, Steamworks.P2PSend.Unreliable);
|
||||
sentBytes += outMsg.LengthBytes;
|
||||
|
||||
heartbeatTimer = 5.0;
|
||||
}
|
||||
@@ -227,6 +235,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
heartbeatTimer = 5.0;
|
||||
Steamworks.SteamNetworking.SendP2PPacket(hostSteamId, outMsg.Buffer, outMsg.LengthBytes, 0, Steamworks.P2PSend.Reliable);
|
||||
sentBytes += outMsg.LengthBytes;
|
||||
break;
|
||||
case ConnectionInitialization.ContentPackageOrder:
|
||||
if (initializationStep == ConnectionInitialization.SteamTicketAndVersion ||
|
||||
@@ -254,7 +263,7 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
|
||||
Steamworks.SteamNetworking.SendP2PPacket(hostSteamId, outMsg.Buffer, outMsg.LengthBytes, 0, Steamworks.P2PSend.Reliable);
|
||||
|
||||
sentBytes += outMsg.LengthBytes;
|
||||
break;
|
||||
case ConnectionInitialization.Password:
|
||||
if (initializationStep == ConnectionInitialization.SteamTicketAndVersion) { initializationStep = ConnectionInitialization.Password; }
|
||||
@@ -334,6 +343,7 @@ namespace Barotrauma.Networking
|
||||
private void Send(byte[] buf, int length, Steamworks.P2PSend sendType)
|
||||
{
|
||||
bool successSend = Steamworks.SteamNetworking.SendP2PPacket(hostSteamId, buf, length + 4, 0, sendType);
|
||||
sentBytes += length + 4;
|
||||
if (!successSend)
|
||||
{
|
||||
if (sendType != Steamworks.P2PSend.Reliable)
|
||||
@@ -341,6 +351,7 @@ namespace Barotrauma.Networking
|
||||
DebugConsole.Log("WARNING: message couldn't be sent unreliably, forcing reliable send (" + length.ToString() + " bytes)");
|
||||
sendType = Steamworks.P2PSend.Reliable;
|
||||
successSend = Steamworks.SteamNetworking.SendP2PPacket(hostSteamId, buf, length + 4, 0, sendType);
|
||||
sentBytes += length + 4;
|
||||
}
|
||||
if (!successSend)
|
||||
{
|
||||
@@ -364,6 +375,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
heartbeatTimer = 5.0;
|
||||
Steamworks.SteamNetworking.SendP2PPacket(hostSteamId, outMsg.Buffer, outMsg.LengthBytes, 0, Steamworks.P2PSend.Reliable);
|
||||
sentBytes += outMsg.LengthBytes;
|
||||
}
|
||||
|
||||
public override void Close(string msg = null)
|
||||
@@ -380,6 +392,7 @@ namespace Barotrauma.Networking
|
||||
outMsg.Write(msg ?? "Disconnected");
|
||||
|
||||
Steamworks.SteamNetworking.SendP2PPacket(hostSteamId, outMsg.Buffer, outMsg.LengthBytes, 0, Steamworks.P2PSend.Reliable);
|
||||
sentBytes += outMsg.LengthBytes;
|
||||
|
||||
Thread.Sleep(100);
|
||||
|
||||
|
||||
+12
-6
@@ -13,7 +13,9 @@ namespace Barotrauma.Networking
|
||||
private bool isActive;
|
||||
|
||||
private ConnectionInitialization initializationStep;
|
||||
private UInt64 selfSteamID;
|
||||
private readonly UInt64 selfSteamID;
|
||||
|
||||
private long sentBytes, receivedBytes;
|
||||
|
||||
class RemotePeer
|
||||
{
|
||||
@@ -204,22 +206,24 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=0;i<100;i++)
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
if (!Steamworks.SteamNetworking.IsP2PPacketAvailable()) { break; }
|
||||
var packet = Steamworks.SteamNetworking.ReadP2PPacket();
|
||||
if (packet.HasValue)
|
||||
{
|
||||
OnP2PData(packet?.SteamId ?? 0, packet?.Data, packet?.Data.Length ?? 0, 0);
|
||||
receivedBytes += packet?.Data.Length ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
GameMain.Client?.NetStats?.AddValue(NetStats.NetStatType.ReceivedBytes, receivedBytes);
|
||||
GameMain.Client?.NetStats?.AddValue(NetStats.NetStatType.SentBytes, sentBytes);
|
||||
|
||||
while (ChildServerRelay.Read(out byte[] incBuf))
|
||||
{
|
||||
ChildServerRelay.DisposeLocalHandles();
|
||||
|
||||
IReadMessage inc = new ReadOnlyMessage(incBuf, false, 0, incBuf.Length, ServerConnection);
|
||||
|
||||
HandleDataMessage(inc);
|
||||
}
|
||||
}
|
||||
@@ -295,6 +299,7 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
|
||||
bool successSend = Steamworks.SteamNetworking.SendP2PPacket(recipientSteamId, p2pData, p2pData.Length, 0, sendType);
|
||||
sentBytes += p2pData.Length;
|
||||
|
||||
if (!successSend)
|
||||
{
|
||||
@@ -303,6 +308,7 @@ namespace Barotrauma.Networking
|
||||
DebugConsole.Log("WARNING: message couldn't be sent unreliably, forcing reliable send (" + p2pData.Length.ToString() + " bytes)");
|
||||
sendType = Steamworks.P2PSend.Reliable;
|
||||
successSend = Steamworks.SteamNetworking.SendP2PPacket(recipientSteamId, p2pData, p2pData.Length, 0, sendType);
|
||||
sentBytes += p2pData.Length;
|
||||
}
|
||||
if (!successSend)
|
||||
{
|
||||
@@ -336,7 +342,6 @@ namespace Barotrauma.Networking
|
||||
byte[] msgToSend = (byte[])outMsg.Buffer.Clone();
|
||||
Array.Resize(ref msgToSend, outMsg.LengthBytes);
|
||||
ChildServerRelay.Write(msgToSend);
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
@@ -369,6 +374,7 @@ namespace Barotrauma.Networking
|
||||
outMsg.Write(msg);
|
||||
|
||||
Steamworks.SteamNetworking.SendP2PPacket(peer.SteamID, outMsg.Buffer, outMsg.LengthBytes, 0, Steamworks.P2PSend.Reliable);
|
||||
sentBytes += outMsg.LengthBytes;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -405,7 +411,7 @@ namespace Barotrauma.Networking
|
||||
ClosePeerSession(remotePeers[i]);
|
||||
}
|
||||
|
||||
ChildServerRelay.ShutDown();
|
||||
ChildServerRelay.ClosePipes();
|
||||
|
||||
OnDisconnect?.Invoke();
|
||||
|
||||
|
||||
@@ -26,10 +26,13 @@ namespace Barotrauma.Networking
|
||||
|
||||
public void CreateLogFrame()
|
||||
{
|
||||
LogFrame = new GUIButton(new RectTransform(Vector2.One, GUI.Canvas), style: "GUIBackgroundBlocker")
|
||||
LogFrame = new GUIButton(new RectTransform(Vector2.One, GUI.Canvas, Anchor.Center), style: null)
|
||||
{
|
||||
OnClicked = (btn, userdata) => { if (GUI.MouseOn == btn || GUI.MouseOn == btn.TextBlock) LogFrame = null; return true; }
|
||||
};
|
||||
|
||||
new GUIFrame(new RectTransform(GUI.Canvas.RelativeSize, LogFrame.RectTransform, Anchor.Center), style: "GUIBackgroundBlocker");
|
||||
|
||||
new GUIButton(new RectTransform(Vector2.One, LogFrame.RectTransform), "", style: null).OnClicked += (btn, userData) =>
|
||||
{
|
||||
LogFrame = null;
|
||||
|
||||
@@ -266,7 +266,9 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
|
||||
//background frame
|
||||
settingsFrame = new GUIFrame(new RectTransform(Vector2.One, GUI.Canvas), style: null, color: Color.Black * 0.5f);
|
||||
settingsFrame = new GUIFrame(new RectTransform(Vector2.One, GUI.Canvas, Anchor.Center), style: null);
|
||||
new GUIFrame(new RectTransform(GUI.Canvas.RelativeSize, settingsFrame.RectTransform, Anchor.Center), style: "GUIBackgroundBlocker");
|
||||
|
||||
new GUIButton(new RectTransform(Vector2.One, settingsFrame.RectTransform), "", style: null).OnClicked += (btn, userData) =>
|
||||
{
|
||||
if (GUI.MouseOn == btn || GUI.MouseOn == btn.TextBlock) { ToggleSettingsFrame(btn, userData); }
|
||||
|
||||
@@ -2,13 +2,12 @@
|
||||
using RestSharp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Barotrauma.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using RestSharp.Contrib;
|
||||
using System.Xml.Linq;
|
||||
using System.Xml;
|
||||
using Color = Microsoft.Xna.Framework.Color;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
@@ -250,7 +249,8 @@ namespace Barotrauma.Steam
|
||||
}
|
||||
};
|
||||
|
||||
Steamworks.Data.LobbyQuery lobbyQuery = Steamworks.SteamMatchmaking.CreateLobbyQuery().FilterDistanceWorldwide();
|
||||
//TODO: find a better strategy to fetch all lobbies, this is gonna take forever if we actually have 10000 lobbies
|
||||
Steamworks.Data.LobbyQuery lobbyQuery = Steamworks.SteamMatchmaking.CreateLobbyQuery().FilterDistanceWorldwide().WithMaxResults(10000);
|
||||
|
||||
TaskPool.Add(Task.Run(async () =>
|
||||
{
|
||||
@@ -578,7 +578,7 @@ namespace Barotrauma.Steam
|
||||
if (!isInitialized) return;
|
||||
|
||||
var query = new Steamworks.Ugc.Query(Steamworks.UgcType.All)
|
||||
.RankedByTotalUniqueSubscriptions()
|
||||
.RankedByTrend()
|
||||
.WithLongDescription();
|
||||
if (requireTags != null) query.WithTags(requireTags);
|
||||
|
||||
@@ -754,7 +754,7 @@ namespace Barotrauma.Steam
|
||||
|
||||
if (!CheckWorkshopItemEnabled(existingItem))
|
||||
{
|
||||
if (!EnableWorkShopItem(existingItem, false, out string errorMsg))
|
||||
if (!EnableWorkShopItem(existingItem, out string errorMsg))
|
||||
{
|
||||
DebugConsole.NewMessage(errorMsg, Color.Red);
|
||||
new GUIMessageBox(
|
||||
@@ -881,6 +881,10 @@ namespace Barotrauma.Steam
|
||||
DebugConsole.NewMessage("Published workshop item " + item?.Title + " successfully.", Microsoft.Xna.Framework.Color.LightGreen);
|
||||
|
||||
contentPackage.SteamWorkshopUrl = $"http://steamcommunity.com/sharedfiles/filedetails/?source=Facepunch.Steamworks&id={task.Result.FileId.Value}";
|
||||
//NOTE: This sets InstallTime one hour into the future to guarantee
|
||||
//that the published content package won't be autoupdated incorrectly.
|
||||
//Change if it causes issues.
|
||||
contentPackage.InstallTime = DateTime.UtcNow + TimeSpan.FromHours(1);
|
||||
contentPackage.Save(contentPackage.Path);
|
||||
|
||||
SubscribeToWorkshopItem(task.Result.FileId);
|
||||
@@ -892,7 +896,7 @@ namespace Barotrauma.Steam
|
||||
/// <summary>
|
||||
/// Enables a workshop item by moving it to the game folder.
|
||||
/// </summary>
|
||||
public static bool EnableWorkShopItem(Steamworks.Ugc.Item? item, bool allowFileOverwrite, out string errorMsg, bool selectContentPackage = false, bool suppressInstallNotif = false)
|
||||
public static bool EnableWorkShopItem(Steamworks.Ugc.Item? item, out string errorMsg, bool selectContentPackage = false, bool suppressInstallNotif = false)
|
||||
{
|
||||
if (!(item?.IsInstalled ?? false))
|
||||
{
|
||||
@@ -916,7 +920,8 @@ namespace Barotrauma.Steam
|
||||
};
|
||||
string newContentPackagePath = GetWorkshopItemContentPackagePath(contentPackage);
|
||||
|
||||
if (ContentPackage.List.Any(cp => cp.Path.CleanUpPath() == newContentPackagePath.CleanUpPath()))
|
||||
List<ContentPackage> existingPackages = ContentPackage.List.Where(cp => cp.Path.CleanUpPath() == newContentPackagePath.CleanUpPath()).ToList();
|
||||
if (existingPackages.Any())
|
||||
{
|
||||
if (item?.Owner.Id != Steamworks.SteamClient.SteamId)
|
||||
{
|
||||
@@ -952,15 +957,9 @@ namespace Barotrauma.Steam
|
||||
{
|
||||
if (modCopiesInProgress.ContainsKey(item.Value.Id))
|
||||
{
|
||||
if (!modCopiesInProgress[item.Value.Id].IsCompleted &&
|
||||
!modCopiesInProgress[item.Value.Id].IsFaulted &&
|
||||
!modCopiesInProgress[item.Value.Id].IsCanceled)
|
||||
{
|
||||
errorMsg = ""; return true;
|
||||
}
|
||||
modCopiesInProgress.Remove(item.Value.Id);
|
||||
errorMsg = ""; return true;
|
||||
}
|
||||
newTask = CopyWorkShopItemAsync(item, contentPackage, newContentPackagePath, metaDataFilePath, allowFileOverwrite);
|
||||
newTask = CopyWorkShopItemAsync(item, contentPackage, newContentPackagePath, metaDataFilePath);
|
||||
modCopiesInProgress.Add(item.Value.Id, newTask);
|
||||
}
|
||||
|
||||
@@ -968,67 +967,85 @@ namespace Barotrauma.Steam
|
||||
contentPackage,
|
||||
(task, cp) =>
|
||||
{
|
||||
if (task.IsFaulted || task.IsCanceled)
|
||||
try
|
||||
{
|
||||
DebugConsole.ThrowError($"Failed to copy \"{item?.Title}\"", task.Exception);
|
||||
GameMain.SteamWorkshopScreen?.SetReinstallButtonStatus(item, true, GUI.Style.Red);
|
||||
return;
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(task.Result))
|
||||
{
|
||||
DebugConsole.ThrowError($"Failed to copy \"{item?.Title}\": {task.Result}");
|
||||
GameMain.SteamWorkshopScreen?.SetReinstallButtonStatus(item, true, GUI.Style.Red);
|
||||
return;
|
||||
}
|
||||
|
||||
GameMain.Config.SuppressModFolderWatcher = true;
|
||||
|
||||
var newPackage = new ContentPackage(cp.Path, newContentPackagePath)
|
||||
{
|
||||
SteamWorkshopUrl = item?.Url,
|
||||
InstallTime = item?.Updated > item?.Created ? item?.Updated : item?.Created
|
||||
};
|
||||
|
||||
foreach (ContentFile contentFile in newPackage.Files)
|
||||
{
|
||||
contentFile.Path = CorrectContentFilePath(contentFile.Path, cp, true);
|
||||
}
|
||||
|
||||
if (!Directory.Exists(Path.GetDirectoryName(newContentPackagePath)))
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(newContentPackagePath));
|
||||
}
|
||||
newPackage.Save(newContentPackagePath);
|
||||
ContentPackage.List.Add(newPackage);
|
||||
|
||||
if (selectContentPackage)
|
||||
{
|
||||
if (newPackage.CorePackage)
|
||||
if (task.IsFaulted || task.IsCanceled)
|
||||
{
|
||||
GameMain.Config.SelectCorePackage(newPackage);
|
||||
DebugConsole.ThrowError($"Failed to copy \"{item?.Title}\"", task.Exception);
|
||||
GameMain.SteamWorkshopScreen?.SetReinstallButtonStatus(item, true, GUI.Style.Red);
|
||||
return;
|
||||
}
|
||||
else
|
||||
if (!string.IsNullOrWhiteSpace(task.Result))
|
||||
{
|
||||
GameMain.Config.SelectContentPackage(newPackage);
|
||||
DebugConsole.ThrowError($"Failed to copy \"{item?.Title}\": {task.Result}");
|
||||
GameMain.SteamWorkshopScreen?.SetReinstallButtonStatus(item, true, GUI.Style.Red);
|
||||
return;
|
||||
}
|
||||
GameMain.Config.SaveNewPlayerConfig();
|
||||
|
||||
GameMain.Config.WarnIfContentPackageSelectionDirty();
|
||||
GameMain.Config.SuppressModFolderWatcher = true;
|
||||
|
||||
if (newPackage.Files.Any(f => f.Type == ContentType.Submarine))
|
||||
var newPackage = new ContentPackage(cp.Path, newContentPackagePath)
|
||||
{
|
||||
SubmarineInfo.RefreshSavedSubs();
|
||||
SteamWorkshopUrl = item?.Url,
|
||||
InstallTime = item?.Updated > item?.Created ? item?.Updated : item?.Created
|
||||
};
|
||||
|
||||
foreach (ContentFile contentFile in newPackage.Files)
|
||||
{
|
||||
contentFile.Path = CorrectContentFilePath(contentFile.Path, contentFile.Type, cp, true);
|
||||
}
|
||||
|
||||
foreach (ContentFile file in existingPackages.SelectMany(p => p.Files))
|
||||
{
|
||||
string path = CorrectContentFilePath(file.Path, file.Type, cp, true).CleanUpPath();
|
||||
if (newPackage.Files.Any(f => f.Path.CleanUpPath() == path)) { continue; }
|
||||
newPackage.AddFile(path, file.Type);
|
||||
}
|
||||
|
||||
if (!Directory.Exists(Path.GetDirectoryName(newContentPackagePath)))
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(newContentPackagePath));
|
||||
}
|
||||
newPackage.Save(newContentPackagePath);
|
||||
ContentPackage.List.Add(newPackage);
|
||||
|
||||
if (selectContentPackage)
|
||||
{
|
||||
if (newPackage.CorePackage)
|
||||
{
|
||||
GameMain.Config.SelectCorePackage(newPackage);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameMain.Config.SelectContentPackage(newPackage);
|
||||
}
|
||||
GameMain.Config.SaveNewPlayerConfig();
|
||||
|
||||
GameMain.Config.WarnIfContentPackageSelectionDirty();
|
||||
|
||||
if (newPackage.Files.Any(f => f.Type == ContentType.Submarine))
|
||||
{
|
||||
SubmarineInfo.RefreshSavedSubs();
|
||||
}
|
||||
}
|
||||
else if (!suppressInstallNotif)
|
||||
{
|
||||
GameMain.MainMenuScreen?.SetEnableModsNotification(true);
|
||||
}
|
||||
|
||||
GameMain.Config.SuppressModFolderWatcher = false;
|
||||
|
||||
GameMain.SteamWorkshopScreen?.SetReinstallButtonStatus(item, true, GUI.Style.Green);
|
||||
|
||||
}
|
||||
else if (!suppressInstallNotif)
|
||||
catch
|
||||
{
|
||||
GameMain.MainMenuScreen?.SetEnableModsNotification(true);
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
modCopiesInProgress.Remove(item.Value.Id);
|
||||
}
|
||||
|
||||
GameMain.Config.SuppressModFolderWatcher = false;
|
||||
|
||||
GameMain.SteamWorkshopScreen?.SetReinstallButtonStatus(item, true, GUI.Style.Green);
|
||||
|
||||
});
|
||||
|
||||
errorMsg = "";
|
||||
@@ -1039,7 +1056,7 @@ namespace Barotrauma.Steam
|
||||
/// Asynchronously copies a Workshop item into the Mods folder.
|
||||
/// </summary>
|
||||
/// <returns>Returns an empty string on success, otherwise returns an error message.</returns>
|
||||
private async static Task<string> CopyWorkShopItemAsync(Steamworks.Ugc.Item? item, ContentPackage contentPackage, string newContentPackagePath, string metaDataFilePath, bool allowFileOverwrite)
|
||||
private async static Task<string> CopyWorkShopItemAsync(Steamworks.Ugc.Item? item, ContentPackage contentPackage, string newContentPackagePath, string metaDataFilePath)
|
||||
{
|
||||
await Task.Yield();
|
||||
|
||||
@@ -1052,13 +1069,13 @@ namespace Barotrauma.Steam
|
||||
Directory.CreateDirectory(targetPath);
|
||||
File.WriteAllText(copyingPath, "TEMPORARY FILE");
|
||||
|
||||
SaveUtil.CopyFolder(item?.Directory, targetPath, copySubDirs: true, overwriteExisting: item?.Owner.Id != Steamworks.SteamClient.SteamId);
|
||||
SaveUtil.CopyFolder(item?.Directory, targetPath, copySubDirs: true, overwriteExisting: false);
|
||||
|
||||
File.Delete(copyingPath);
|
||||
return "";
|
||||
}
|
||||
|
||||
var allPackageFiles = Directory.GetFiles(item?.Directory, "*", SearchOption.AllDirectories);
|
||||
var allPackageFiles = Directory.GetFiles(item?.Directory, "*", System.IO.SearchOption.AllDirectories);
|
||||
List<string> nonContentFiles = new List<string>();
|
||||
foreach (string file in allPackageFiles)
|
||||
{
|
||||
@@ -1069,27 +1086,24 @@ namespace Barotrauma.Steam
|
||||
nonContentFiles.Add(relativePath);
|
||||
}
|
||||
|
||||
if (!allowFileOverwrite)
|
||||
/*if (File.Exists(newContentPackagePath) && !CheckFileEquality(newContentPackagePath, metaDataFilePath))
|
||||
{
|
||||
if (File.Exists(newContentPackagePath) && !CheckFileEquality(newContentPackagePath, metaDataFilePath))
|
||||
errorMsg = TextManager.GetWithVariables("WorkshopErrorOverwriteOnEnable", new string[2] { "[itemname]", "[filename]" }, new string[2] { item?.Title, newContentPackagePath });
|
||||
DebugConsole.NewMessage(errorMsg, Color.Red);
|
||||
return errorMsg;
|
||||
}
|
||||
|
||||
foreach (ContentFile contentFile in contentPackage.Files)
|
||||
{
|
||||
string sourceFile = Path.Combine(item?.Directory, contentFile.Path);
|
||||
|
||||
if (File.Exists(sourceFile) && File.Exists(contentFile.Path) && !CheckFileEquality(sourceFile, contentFile.Path))
|
||||
{
|
||||
errorMsg = TextManager.GetWithVariables("WorkshopErrorOverwriteOnEnable", new string[2] { "[itemname]", "[filename]" }, new string[2] { item?.Title, newContentPackagePath });
|
||||
errorMsg = TextManager.GetWithVariables("WorkshopErrorOverwriteOnEnable", new string[2] { "[itemname]", "[filename]" }, new string[2] { item?.Title, contentFile.Path });
|
||||
DebugConsole.NewMessage(errorMsg, Color.Red);
|
||||
return errorMsg;
|
||||
}
|
||||
|
||||
foreach (ContentFile contentFile in contentPackage.Files)
|
||||
{
|
||||
string sourceFile = Path.Combine(item?.Directory, contentFile.Path);
|
||||
|
||||
if (File.Exists(sourceFile) && File.Exists(contentFile.Path) && !CheckFileEquality(sourceFile, contentFile.Path))
|
||||
{
|
||||
errorMsg = TextManager.GetWithVariables("WorkshopErrorOverwriteOnEnable", new string[2] { "[itemname]", "[filename]" }, new string[2] { item?.Title, contentFile.Path });
|
||||
DebugConsole.NewMessage(errorMsg, Color.Red);
|
||||
return errorMsg;
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
Directory.CreateDirectory(targetPath);
|
||||
File.WriteAllText(copyingPath, "TEMPORARY FILE");
|
||||
@@ -1107,7 +1121,7 @@ namespace Barotrauma.Steam
|
||||
}
|
||||
}
|
||||
|
||||
contentFile.Path = CorrectContentFilePath(contentFile.Path, contentPackage,
|
||||
contentFile.Path = CorrectContentFilePath(contentFile.Path, contentFile.Type, contentPackage,
|
||||
contentFile.Type != ContentType.Submarine);
|
||||
|
||||
//path not allowed -> the content file must be a reference to an external file (such as some vanilla file outside the Mods folder)
|
||||
@@ -1145,16 +1159,16 @@ namespace Barotrauma.Steam
|
||||
|
||||
//make sure the destination directory exists
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(contentFile.Path));
|
||||
CorrectContentFileCopy(contentPackage, sourceFile, contentFile.Path, overwrite: item?.Owner.Id != Steamworks.SteamClient.SteamId);
|
||||
CorrectContentFileCopy(contentPackage, sourceFile, contentFile.Path, overwrite: false);
|
||||
}
|
||||
|
||||
foreach (string nonContentFile in nonContentFiles)
|
||||
{
|
||||
string sourceFile = Path.Combine(item?.Directory, nonContentFile);
|
||||
if (!File.Exists(sourceFile)) { continue; }
|
||||
string destinationPath = CorrectContentFilePath(nonContentFile, contentPackage, false);
|
||||
string destinationPath = CorrectContentFilePath(nonContentFile, ContentType.None, contentPackage, false);
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(destinationPath));
|
||||
CorrectContentFileCopy(contentPackage, sourceFile, destinationPath, overwrite: item?.Owner.Id != Steamworks.SteamClient.SteamId);
|
||||
CorrectContentFileCopy(contentPackage, sourceFile, destinationPath, overwrite: false);
|
||||
}
|
||||
|
||||
File.Delete(copyingPath);
|
||||
@@ -1271,7 +1285,7 @@ namespace Barotrauma.Steam
|
||||
string metaDataPath = Path.Combine(item?.Directory, MetadataFileName);
|
||||
if (!File.Exists(metaDataPath))
|
||||
{
|
||||
throw new FileNotFoundException("Metadata file for the Workshop item \"" + item?.Title + "\" not found. The file may be corrupted.");
|
||||
throw new System.IO.FileNotFoundException("Metadata file for the Workshop item \"" + item?.Title + "\" not found. The file may be corrupted.");
|
||||
}
|
||||
|
||||
ContentPackage contentPackage = new ContentPackage(metaDataPath);
|
||||
@@ -1294,7 +1308,7 @@ namespace Barotrauma.Steam
|
||||
{
|
||||
metaDataPath = Path.Combine(item?.Directory, MetadataFileName);
|
||||
}
|
||||
catch (ArgumentException e)
|
||||
catch (ArgumentException)
|
||||
{
|
||||
string errorMessage = "Metadata file for the Workshop item \"" + item?.Title +
|
||||
"\" not found. Could not combine path (" + (item?.Directory ?? "directory name empty") + ").";
|
||||
@@ -1354,6 +1368,8 @@ namespace Barotrauma.Steam
|
||||
|
||||
public static async Task<bool> AutoUpdateWorkshopItemsAsync()
|
||||
{
|
||||
await Task.Yield();
|
||||
|
||||
if (!isInitialized) { return false; }
|
||||
|
||||
var query = new Steamworks.Ugc.Query(Steamworks.UgcType.All)
|
||||
@@ -1381,7 +1397,7 @@ namespace Barotrauma.Steam
|
||||
string errorMsg;
|
||||
if (!CheckWorkshopItemEnabled(item))
|
||||
{
|
||||
installedSuccessfully = EnableWorkShopItem(item, true, out errorMsg);
|
||||
installedSuccessfully = EnableWorkShopItem(item, out errorMsg);
|
||||
}
|
||||
else if (!CheckWorkshopItemUpToDate(item))
|
||||
{
|
||||
@@ -1442,10 +1458,12 @@ namespace Barotrauma.Steam
|
||||
{
|
||||
while (updateNotifications.Count > 0)
|
||||
{
|
||||
float width = updateNotifications.Max(notif => GUI.Font.MeasureString(notif).X) * 1.25f;
|
||||
|
||||
int notificationsPerMsgBox = 20;
|
||||
new GUIMessageBox("", string.Join('\n', updateNotifications.Take(notificationsPerMsgBox)),
|
||||
relativeSize: new Microsoft.Xna.Framework.Vector2(0.5f, 0.0f),
|
||||
minSize: new Microsoft.Xna.Framework.Point(600, 0));
|
||||
relativeSize: new Microsoft.Xna.Framework.Vector2(0.25f, 0.0f),
|
||||
minSize: new Microsoft.Xna.Framework.Point((int)width, 0));
|
||||
updateNotifications.RemoveRange(0, Math.Min(notificationsPerMsgBox, updateNotifications.Count));
|
||||
}
|
||||
});
|
||||
@@ -1465,12 +1483,12 @@ namespace Barotrauma.Steam
|
||||
{
|
||||
errorMsg = "";
|
||||
if (!(item?.IsInstalled ?? false)) { return false; }
|
||||
bool reenable = GameMain.Config.SelectedContentPackages.Any(p => !string.IsNullOrEmpty(p.SteamWorkshopUrl) && GetWorkshopItemIDFromUrl(p.SteamWorkshopUrl) == item?.Id);
|
||||
if (item?.Owner.Id != Steamworks.SteamClient.SteamId)
|
||||
{
|
||||
if (!DisableWorkShopItem(item, false, out errorMsg)) { return false; }
|
||||
}
|
||||
if (!EnableWorkShopItem(item, allowFileOverwrite: false, errorMsg: out errorMsg)) { return false; }
|
||||
|
||||
if (!EnableWorkShopItem(item, errorMsg: out errorMsg, selectContentPackage: reenable)) { return false; }
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1495,7 +1513,9 @@ namespace Barotrauma.Steam
|
||||
attr.Name.ToString() == "characterfile") &&
|
||||
attr.Value.CleanUpPath().Contains("/"))
|
||||
{
|
||||
attr.Value = CorrectContentFilePath(attr.Value, package, true);
|
||||
ContentType type = ContentType.None;
|
||||
Enum.TryParse(attr.Name.LocalName, true, out type);
|
||||
attr.Value = CorrectContentFilePath(attr.Value, type, package, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1515,12 +1535,12 @@ namespace Barotrauma.Steam
|
||||
if (doc != null)
|
||||
{
|
||||
CorrectXMLFilePaths(package, doc.Root);
|
||||
using (MemoryStream stream = new MemoryStream())
|
||||
using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
|
||||
{
|
||||
XmlWriterSettings settings = new XmlWriterSettings();
|
||||
System.Xml.XmlWriterSettings settings = new System.Xml.XmlWriterSettings();
|
||||
settings.Indent = true;
|
||||
settings.Encoding = new System.Text.UTF8Encoding(false);
|
||||
using (var xmlWriter = XmlWriter.Create(stream, settings))
|
||||
using (var xmlWriter = System.Xml.XmlWriter.Create(stream, settings))
|
||||
{
|
||||
doc.WriteTo(xmlWriter);
|
||||
xmlWriter.Flush();
|
||||
@@ -1540,15 +1560,24 @@ namespace Barotrauma.Steam
|
||||
}
|
||||
}
|
||||
|
||||
private static string CorrectContentFilePath(string contentFilePath, ContentPackage package, bool checkIfFileExists = false)
|
||||
private static string CorrectContentFilePath(string contentFilePath, ContentType type, ContentPackage package, bool checkIfFileExists = false)
|
||||
{
|
||||
string packageName = Path.GetDirectoryName(GetWorkshopItemContentPackagePath(package));
|
||||
|
||||
contentFilePath = contentFilePath.CleanUpPathCrossPlatform();
|
||||
|
||||
if (checkIfFileExists && File.Exists(contentFilePath))
|
||||
if (checkIfFileExists)
|
||||
{
|
||||
return contentFilePath;
|
||||
bool exists = File.Exists(contentFilePath);
|
||||
if (type == ContentType.Executable ||
|
||||
type == ContentType.ServerExecutable)
|
||||
{
|
||||
exists |= File.Exists(contentFilePath + ".dll");
|
||||
}
|
||||
if (exists)
|
||||
{
|
||||
return contentFilePath;
|
||||
}
|
||||
}
|
||||
|
||||
string[] splitPath = contentFilePath.Split('/');
|
||||
|
||||
@@ -275,14 +275,6 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
}
|
||||
|
||||
public override void Write(IWriteMessage msg)
|
||||
{
|
||||
lock (buffers)
|
||||
{
|
||||
base.Write(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
Instance = null;
|
||||
|
||||
Reference in New Issue
Block a user