From e6b073f8725f846604e287a6b1b04e2850d7a6dc Mon Sep 17 00:00:00 2001 From: Regalis Date: Sun, 22 May 2016 01:39:10 +0300 Subject: [PATCH] - clients see the submarines that the host has instead of their own subs in server lobby - possible to vote for subs the client doesn't have - fixed the "votes required" slider moving when re-opening the server settings - WIP method for sending missing subs to clients before the round starts (atm the clients won't have time to request a sub file that was chosen by voting) --- Subsurface/Source/GUI/GUIScrollBar.cs | 57 ++++++++---- Subsurface/Source/GUI/LoadingScreen.cs | 2 +- Subsurface/Source/GameMain.cs | 1 + Subsurface/Source/GameSession/GameSession.cs | 11 ++- Subsurface/Source/Map/Submarine.cs | 19 ++-- .../Source/Networking/FileStreamReceiver.cs | 10 ++- Subsurface/Source/Networking/GameClient.cs | 29 ++++++- Subsurface/Source/Networking/GameServer.cs | 49 ++++++++--- .../Source/Networking/GameServerSettings.cs | 11 ++- Subsurface/Source/Screens/NetLobbyScreen.cs | 87 ++++++++++++++----- 10 files changed, 202 insertions(+), 74 deletions(-) diff --git a/Subsurface/Source/GUI/GUIScrollBar.cs b/Subsurface/Source/GUI/GUIScrollBar.cs index b83047cbf..fc6f0a0eb 100644 --- a/Subsurface/Source/GUI/GUIScrollBar.cs +++ b/Subsurface/Source/GUI/GUIScrollBar.cs @@ -15,6 +15,8 @@ namespace Barotrauma private float barSize; private float barScroll; + private float step; + private bool enabled; public delegate bool OnMovedHandler(GUIScrollBar scrollBar, float barScroll); @@ -33,29 +35,42 @@ namespace Barotrauma public float BarScroll { - get { return barScroll; } + get { return step == 0.0f ? barScroll : MathUtils.RoundTowardsClosest(barScroll, step); } set { barScroll = MathHelper.Clamp(value, 0.0f, 1.0f); int newX = bar.Rect.X - frame.Rect.X, newY = bar.Rect.Y - frame.Rect.Y; + + float newScroll = step == 0.0f ? barScroll : MathUtils.RoundTowardsClosest(barScroll, step); + if (isHorizontal) { - newX = (int)(barScroll *(frame.Rect.Width - bar.Rect.Width)); - newX = Math.Max(newX, 0); - newX = Math.Min(newX, frame.Rect.Width - bar.Rect.Width); + newX = (int)(newScroll * (frame.Rect.Width - bar.Rect.Width)); + newX = MathHelper.Clamp(newX, 0, frame.Rect.Width - bar.Rect.Width); } else { - newY = (int)(barScroll * (frame.Rect.Height- bar.Rect.Height)); - newY = Math.Max(newY, 0); - newY = Math.Min(newY, frame.Rect.Height - bar.Rect.Height); + newY = (int)(newScroll * (frame.Rect.Height - bar.Rect.Height)); + newY = MathHelper.Clamp(newY, 0, frame.Rect.Height - bar.Rect.Height); } bar.Rect = new Rectangle(newX + frame.Rect.X, newY + frame.Rect.Y, bar.Rect.Width, bar.Rect.Height); } } + public float Step + { + get + { + return step; + } + set + { + step = MathHelper.Clamp(value, 0.0f, 1.0f); + } + } + public float BarSize { get { return barSize; } @@ -158,25 +173,35 @@ namespace Barotrauma //if (barSize == 1.0f) return false; int newX = bar.Rect.X - frame.Rect.X, newY = bar.Rect.Y - frame.Rect.Y; - int moveAmount; + float moveAmount; if (isHorizontal) { - moveAmount = (int)PlayerInput.MouseSpeed.X; - newX = Math.Min(Math.Max(newX + moveAmount, 0), frame.Rect.Width - bar.Rect.Width); + moveAmount = PlayerInput.MouseSpeed.X; + barScroll += moveAmount / (frame.Rect.Width - bar.Rect.Width); + //newX = Math.Min(Math.Max(newX + moveAmount, 0), frame.Rect.Width - bar.Rect.Width); - barScroll = (float)newX / ((float)frame.Rect.Width - (float)bar.Rect.Width); + //barScroll = (float)newX / ((float)frame.Rect.Width - (float)bar.Rect.Width); } else { - moveAmount = (int)PlayerInput.MouseSpeed.Y; - newY = Math.Min(Math.Max(newY+moveAmount, 0), frame.Rect.Height - bar.Rect.Height); + moveAmount = PlayerInput.MouseSpeed.Y; + barScroll += moveAmount / (frame.Rect.Height - bar.Rect.Height); + //newY = Math.Min(Math.Max(newY+moveAmount, 0), frame.Rect.Height - bar.Rect.Height); - barScroll = (float)newY / ((float)frame.Rect.Height - (float)bar.Rect.Height); + //barScroll = (float)newY / ((float)frame.Rect.Height - (float)bar.Rect.Height); } - if (moveAmount != 0 && OnMoved != null) OnMoved(this, barScroll); + if (moveAmount != 0) + { + int asdf = 1; + } - bar.Rect = new Rectangle(newX + frame.Rect.X, newY + frame.Rect.Y, bar.Rect.Width, bar.Rect.Height); + BarScroll = barScroll; + + if (moveAmount != 0 && OnMoved != null) OnMoved(this, BarScroll); + + + //bar.Rect = new Rectangle(newX + frame.Rect.X, newY + frame.Rect.Y, bar.Rect.Width, bar.Rect.Height); } diff --git a/Subsurface/Source/GUI/LoadingScreen.cs b/Subsurface/Source/GUI/LoadingScreen.cs index 0be6371c9..d4ec357a7 100644 --- a/Subsurface/Source/GUI/LoadingScreen.cs +++ b/Subsurface/Source/GUI/LoadingScreen.cs @@ -138,7 +138,7 @@ namespace Barotrauma public IEnumerable DoLoading(IEnumerable loader) { drawn = false; - LoadState = null; + LoadState = null; while (!drawn) { diff --git a/Subsurface/Source/GameMain.cs b/Subsurface/Source/GameMain.cs index ecc7054b7..cd64827ef 100644 --- a/Subsurface/Source/GameMain.cs +++ b/Subsurface/Source/GameMain.cs @@ -355,6 +355,7 @@ namespace Barotrauma { waitForKeyHit = waitKeyHit; titleScreenOpen = true; + TitleScreen.LoadState = null; CoroutineManager.StartCoroutine(TitleScreen.DoLoading(loader)); } diff --git a/Subsurface/Source/GameSession/GameSession.cs b/Subsurface/Source/GameSession/GameSession.cs index 20d2660fd..b16e0d567 100644 --- a/Subsurface/Source/GameSession/GameSession.cs +++ b/Subsurface/Source/GameSession/GameSession.cs @@ -164,10 +164,13 @@ namespace Barotrauma GameMain.LobbyScreen.Select(); } - GUIFrame summaryFrame = shiftSummary.CreateSummaryFrame(endMessage); - GUIMessageBox.MessageBoxes.Enqueue(summaryFrame); - var okButton = new GUIButton(new Rectangle(0, 0, 100, 30), "Ok", Alignment.BottomRight, GUI.Style, summaryFrame.children[0]); - okButton.OnClicked = (GUIButton button, object obj) => { GUIMessageBox.MessageBoxes.Dequeue(); return true; }; + if (shiftSummary!=null) + { + GUIFrame summaryFrame = shiftSummary.CreateSummaryFrame(endMessage); + GUIMessageBox.MessageBoxes.Enqueue(summaryFrame); + var okButton = new GUIButton(new Rectangle(0, 0, 100, 30), "Ok", Alignment.BottomRight, GUI.Style, summaryFrame.children[0]); + okButton.OnClicked = (GUIButton button, object obj) => { GUIMessageBox.MessageBoxes.Dequeue(); return true; }; + } TaskManager.EndShift(); diff --git a/Subsurface/Source/Map/Submarine.cs b/Subsurface/Source/Map/Submarine.cs index 74cf538d3..018bc98bb 100644 --- a/Subsurface/Source/Map/Submarine.cs +++ b/Subsurface/Source/Map/Submarine.cs @@ -187,7 +187,7 @@ namespace Barotrauma //constructors & generation ---------------------------------------------------- - public Submarine(string filePath, string hash = "") : base(null) + public Submarine(string filePath, string hash = "", bool tryLoad = true) : base(null) { this.filePath = filePath; try @@ -196,7 +196,7 @@ namespace Barotrauma } catch (Exception e) { - DebugConsole.ThrowError("Error loading map " + filePath + "!", e); + DebugConsole.ThrowError("Error loading submarine " + filePath + "!", e); } if (hash != "") @@ -204,17 +204,22 @@ namespace Barotrauma this.hash = new Md5Hash(hash); } - XDocument doc = OpenDoc(filePath); - - if (doc != null && doc.Root != null) + if (tryLoad) { - Description = ToolBox.GetAttributeString(doc.Root, "description", ""); + XDocument doc = OpenDoc(filePath); + + if (doc != null && doc.Root != null) + { + Description = ToolBox.GetAttributeString(doc.Root, "description", ""); + } } + ID = ushort.MaxValue; base.Remove(); } + //drawing ---------------------------------------------------- public static void Draw(SpriteBatch spriteBatch, bool editing = false) @@ -607,7 +612,7 @@ namespace Barotrauma SavedSubmarines.Add(new Submarine(path)); } - if (GameMain.NetLobbyScreen!=null) GameMain.NetLobbyScreen.UpdateSubList(); + //if (GameMain.NetLobbyScreen!=null) GameMain.NetLobbyScreen.UpdateSubList(Submarine.SavedSubmarines); } private XDocument OpenDoc(string file) diff --git a/Subsurface/Source/Networking/FileStreamReceiver.cs b/Subsurface/Source/Networking/FileStreamReceiver.cs index 52dedefc2..9d1852414 100644 --- a/Subsurface/Source/Networking/FileStreamReceiver.cs +++ b/Subsurface/Source/Networking/FileStreamReceiver.cs @@ -29,6 +29,12 @@ namespace Barotrauma.Networking get; private set; } + + public string FilePath + { + get; + private set; + } public ulong FileSize { @@ -190,7 +196,9 @@ namespace Barotrauma.Networking return; } - writeStream = new FileStream(Path.Combine(downloadFolder, FileName), FileMode.Create, FileAccess.Write, FileShare.None); + FilePath = Path.Combine(downloadFolder, FileName); + + writeStream = new FileStream(FilePath, FileMode.Create, FileAccess.Write, FileShare.None); timeStarted = Environment.TickCount; Status = FileTransferStatus.NotStarted; diff --git a/Subsurface/Source/Networking/GameClient.cs b/Subsurface/Source/Networking/GameClient.cs index 19ce65df5..c1ad086d7 100644 --- a/Subsurface/Source/Networking/GameClient.cs +++ b/Subsurface/Source/Networking/GameClient.cs @@ -257,8 +257,8 @@ namespace Barotrauma.Networking GameMain.NetLobbyScreen.ClearPlayers(); //add the names of other connected clients to the lobby screen - int existingClients = inc.ReadInt32(); - for (int i = 1; i <= existingClients; i++) + int clientCount = inc.ReadByte(); + for (int i = 0; i < clientCount; i++) { Client otherClient = new Client(inc.ReadString(), inc.ReadByte()); @@ -266,6 +266,17 @@ namespace Barotrauma.Networking otherClients.Add(otherClient); } + List submarines = new List(); + int subCount = inc.ReadByte(); + for (int i = 0; i < subCount; i++ ) + { + string subName = inc.ReadString(); + string subHash = inc.ReadString(); + + submarines.Add(new Submarine(Path.Combine(Submarine.SavePath, subName), subHash, false)); + } + GameMain.NetLobbyScreen.UpdateSubList(submarines); + //add the name of own client to the lobby screen GameMain.NetLobbyScreen.AddPlayer(name); @@ -342,7 +353,10 @@ namespace Barotrauma.Networking { if (Screen.Selected != GameMain.GameScreen) { + List subList = GameMain.NetLobbyScreen.GetSubList(); + GameMain.NetLobbyScreen = new NetLobbyScreen(); + GameMain.NetLobbyScreen.UpdateSubList(subList); GameMain.NetLobbyScreen.Select(); } connected = true; @@ -819,7 +833,16 @@ namespace Barotrauma.Networking switch (receiver.FileType) { case FileTransferMessageType.Submarine: - Submarine.Preload(); + var textBlock = GameMain.NetLobbyScreen.SubList.children.Find(c => (c.UserData as Submarine).Name+".sub" == receiver.FileName); + if (textBlock != null) + { + Submarine.SavedSubmarines.RemoveAll(s => s.Name + ".sub" == receiver.FileName); + + (textBlock as GUITextBlock).TextColor = Color.White; + var newSub = new Submarine(receiver.FilePath); + Submarine.SavedSubmarines.Add(newSub); + textBlock.UserData = newSub; + } break; } } diff --git a/Subsurface/Source/Networking/GameServer.cs b/Subsurface/Source/Networking/GameServer.cs index 777c1ad98..66bed8f45 100644 --- a/Subsurface/Source/Networking/GameServer.cs +++ b/Subsurface/Source/Networking/GameServer.cs @@ -300,7 +300,7 @@ namespace Barotrauma.Networking else if (autoRestart && Screen.Selected == GameMain.NetLobbyScreen && ConnectedClients.Count>0) { AutoRestartTimer -= deltaTime; - if (AutoRestartTimer < 0.0f) + if (AutoRestartTimer < 0.0f && GameMain.NetLobbyScreen.StartButton.Enabled) { StartGameClicked(null,null); } @@ -437,11 +437,11 @@ namespace Barotrauma.Networking outmsg.Write((byte)PacketTypes.LoggedIn); outmsg.Write(sender.ID); outmsg.Write(gameStarted); - outmsg.Write(gameStarted && sender.Character!=null); + outmsg.Write(gameStarted && sender.Character != null); outmsg.Write(allowSpectating); //notify the client about other clients already logged in - outmsg.Write((characterInfo == null) ? ConnectedClients.Count - 1 : ConnectedClients.Count); + outmsg.Write((byte)((characterInfo == null) ? ConnectedClients.Count - 1 : ConnectedClients.Count)); foreach (Client c in ConnectedClients) { if (c.Connection == inc.SenderConnection) continue; @@ -455,6 +455,14 @@ namespace Barotrauma.Networking outmsg.Write(-1); } + var subs = GameMain.NetLobbyScreen.GetSubList(); + outmsg.Write((byte)subs.Count); + foreach (Submarine sub in subs) + { + outmsg.Write(sub.Name); + outmsg.Write(sub.MD5Hash.Hash); + } + server.SendMessage(outmsg, inc.SenderConnection, NetDeliveryMethod.ReliableUnordered, 0); //notify other clients about the new client @@ -854,21 +862,37 @@ namespace Barotrauma.Networking return false; } - - if (ConnectedClients.Any(c => c.FileStreamSender != null && c.FileStreamSender.FilePath == selectedSub.FilePath)) - { - new GUIMessageBox("Couldn't start a round", - "Can't start a round while sending the selected submarine to clients. Cancel the transfers or wait for them to finish before starting.", 400, 400); - return false; - } - - GameMain.ShowLoading(StartGame(selectedSub, selectedMode), false); + CoroutineManager.StartCoroutine(WaitForPlayersReady(selectedSub, selectedMode), "WaitForPlayersReady"); return true; } + private IEnumerable WaitForPlayersReady(Submarine selectedSub, GameModePreset selectedMode) + { + GameMain.NetLobbyScreen.StartButton.Enabled = false; + + if (Voting.AllowSubVoting) yield return new WaitForSeconds(1.0f); + + while (ConnectedClients.Any(c => c.FileStreamSender != null && c.FileStreamSender.FilePath == selectedSub.FilePath)) + { + if (GUIMessageBox.MessageBoxes.Peek() == null) + { + new GUIMessageBox("File transfer in progress", + "The round will be started after the submarine file has been sent to all players.", 400, 400); + } + + yield return new WaitForSeconds(0.1f); + } + + GameMain.ShowLoading(StartGame(selectedSub, selectedMode), false); + + yield return CoroutineStatus.Success; + } + private IEnumerable StartGame(Submarine selectedSub, GameModePreset selectedMode) { + GameMain.NetLobbyScreen.StartButton.Enabled = false; + GUIMessageBox.CloseAll(); AssignJobs(); @@ -965,6 +989,7 @@ namespace Barotrauma.Networking AddChatMessage("Press TAB to chat. Use ''r;'' to talk through the radio.", ChatMessageType.Server); } + GameMain.NetLobbyScreen.StartButton.Enabled = true; yield return CoroutineStatus.Success; } diff --git a/Subsurface/Source/Networking/GameServerSettings.cs b/Subsurface/Source/Networking/GameServerSettings.cs index 5723ee376..764de02c0 100644 --- a/Subsurface/Source/Networking/GameServerSettings.cs +++ b/Subsurface/Source/Networking/GameServerSettings.cs @@ -146,9 +146,11 @@ namespace Barotrauma.Networking subSelectionMode = SelectionMode.Manual; Enum.TryParse(ToolBox.GetAttributeString(doc.Root, "SubSelection", "Manual"), out subSelectionMode); + Voting.AllowSubVoting = subSelectionMode == SelectionMode.Vote; modeSelectionMode = SelectionMode.Manual; Enum.TryParse(ToolBox.GetAttributeString(doc.Root, "ModeSelection", "Manual"), out modeSelectionMode); + Voting.AllowModeVoting = modeSelectionMode == SelectionMode.Vote; FileStreamSender.MaxTransferDuration = new TimeSpan(0,0,ToolBox.GetAttributeInt(doc.Root, "MaxFileTransferDuration", 150)); } @@ -184,12 +186,12 @@ namespace Barotrauma.Networking var votesRequiredSlider = new GUIScrollBar(new Rectangle(150, y+22, 100, 10), GUI.Style, 0.1f, innerFrame); votesRequiredSlider.UserData = votesRequiredText; + votesRequiredSlider.Step = 0.2f; votesRequiredSlider.BarScroll = (EndVoteRequiredRatio - 0.5f) * 2.0f; votesRequiredSlider.OnMoved = (GUIScrollBar scrollBar, float barScroll) => { GUITextBlock voteText = scrollBar.UserData as GUITextBlock; - scrollBar.BarScroll = MathUtils.Round(barScroll, 0.2f); EndVoteRequiredRatio = barScroll / 2.0f + 0.5f; voteText.Text = "Votes required: " + (int)MathUtils.Round(EndVoteRequiredRatio * 100.0f, 10.0f) + " %"; return true; @@ -197,9 +199,7 @@ namespace Barotrauma.Networking votesRequiredSlider.OnMoved(votesRequiredSlider, votesRequiredSlider.BarScroll); y += 40; - - - + var randomizeLevelBox = new GUITickBox(new Rectangle(0, y, 20, 20), "Randomize level seed between rounds", Alignment.Left, innerFrame); randomizeLevelBox.Selected = randomizeSeed; randomizeLevelBox.OnSelected = (GUITickBox) => @@ -207,8 +207,7 @@ namespace Barotrauma.Networking randomizeSeed = GUITickBox.Selected; return true; }; - - + y += 40; var shareSubsBox = new GUITickBox(new Rectangle(0, y, 20, 20), "Share submarine files with players", Alignment.Left, innerFrame); diff --git a/Subsurface/Source/Screens/NetLobbyScreen.cs b/Subsurface/Source/Screens/NetLobbyScreen.cs index def01fde3..db8b14a99 100644 --- a/Subsurface/Source/Screens/NetLobbyScreen.cs +++ b/Subsurface/Source/Screens/NetLobbyScreen.cs @@ -63,6 +63,12 @@ namespace Barotrauma get { return playerList; } } + public GUIButton StartButton + { + get; + private set; + } + public GUIFrame InfoFrame { get { return infoFrame; } @@ -200,7 +206,7 @@ namespace Barotrauma voteText.UserData = "subvotes"; voteText.Visible = false; - UpdateSubList(); + //UpdateSubList(Submarine.SavedSubmarines); columnX += columnWidth + 20; @@ -340,7 +346,7 @@ namespace Barotrauma ServerName = (GameMain.Server==null) ? "Server" : GameMain.Server.Name; - infoFrame.RemoveChild(infoFrame.children.Find(c => c.UserData as string == "startButton")); + infoFrame.RemoveChild(StartButton); infoFrame.RemoveChild(infoFrame.children.Find(c => c.UserData as string == "settingsButton")); infoFrame.RemoveChild(infoFrame.children.Find(c => c.UserData as string == "spectateButton")); @@ -348,6 +354,8 @@ namespace Barotrauma if (IsServer && GameMain.Server != null) { + UpdateSubList(Submarine.SavedSubmarines); + modeList.OnSelected = VotableClicked; modeList.OnSelected = SelectMode; subList.OnSelected = VotableClicked; @@ -359,9 +367,8 @@ namespace Barotrauma missionTypeButtons[0].OnClicked = ToggleMissionType; missionTypeButtons[1].OnClicked = ToggleMissionType; - GUIButton startButton = new GUIButton(new Rectangle(0, 0, 80, 30), "Start", Alignment.BottomRight, GUI.Style, infoFrame); - startButton.OnClicked = GameMain.Server.StartGameClicked; - startButton.UserData = "startButton"; + StartButton = new GUIButton(new Rectangle(0, 0, 80, 30), "Start", Alignment.BottomRight, GUI.Style, infoFrame); + StartButton.OnClicked = GameMain.Server.StartGameClicked; GUIButton settingsButton = new GUIButton(new Rectangle(-100, 0, 80, 30), "Settings", Alignment.BottomRight, GUI.Style, infoFrame); settingsButton.OnClicked = GameMain.Server.ToggleSettingsFrame; @@ -562,7 +569,17 @@ namespace Barotrauma if (GameMain.Server != null) GameMain.Server.TraitorsEnabled = enabled; (traitorProbabilityText as GUITextBlock).Text = enabled.ToString(); + } + public List GetSubList() + { + List subs = new List(); + foreach (GUIComponent component in subList.children) + { + if (component.UserData is Submarine) subs.Add((Submarine)component.UserData); + } + + return subs; } private bool SelectSub(GUIComponent component, object obj) @@ -583,30 +600,47 @@ namespace Barotrauma return true; } - public void UpdateSubList() + public void UpdateSubList(List submarines) { if (subList == null) return; subList.ClearChildren(); - if (Submarine.SavedSubmarines.Count == 0) + if (submarines.Count == 0) { - DebugConsole.ThrowError("No saved submarines found!"); + DebugConsole.ThrowError("No submarines found!"); } - foreach (Submarine sub in Submarine.SavedSubmarines) + foreach (Submarine sub in submarines) { - new GUITextBlock( - new Rectangle(0, 0, 0, 25), sub.Name, GUI.Style, - Alignment.Left, Alignment.Left, subList) - { - Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f), - ToolTip = sub.Description, - UserData = sub - }; + AddSubmarine(sub); } } + public void AddSubmarine(Submarine sub) + { + var subTextBlock = new GUITextBlock( + new Rectangle(0, 0, 0, 25), sub.Name, GUI.Style, + Alignment.Left, Alignment.Left, subList) + { + Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f), + ToolTip = sub.Description, + UserData = sub + }; + + var matchingSub = Submarine.SavedSubmarines.Find(s => s.Name == sub.Name); + if (matchingSub == null) + { + subTextBlock.TextColor = Color.Gray; + subTextBlock.ToolTip = "Submarine not found in your submarine folder"; + } + else if (matchingSub.MD5Hash.Hash != sub.MD5Hash.Hash) + { + subTextBlock.TextColor = Color.LightGray; + subTextBlock.ToolTip = "Your version of the submarine doesn't match the servers version"; + } + } + public bool VotableClicked(GUIComponent component, object userData) { if (GameMain.Client == null) return false; @@ -993,6 +1027,12 @@ namespace Barotrauma //already downloading the selected sub file if (GameMain.Client.ActiveFileTransferName == subName+".sub") return false; + var matchingListSub = subList.children.Find(c => c.UserData != null && (c.UserData as Submarine).Name == subName); + if (matchingListSub!=null) + { + subList.Select(subList.children.IndexOf(matchingListSub), true); + } + Submarine sub = Submarine.SavedSubmarines.Find(m => m.Name == subName); if (sub == null || sub.MD5Hash.Hash != md5Hash) { @@ -1012,7 +1052,7 @@ namespace Barotrauma + "Server's MD5 hash: " + md5Hash + ". "; } - string downloadMsg = GameMain.Client.ActiveFileTransferName == "" ? + string downloadMsg = string.IsNullOrEmpty(GameMain.Client.ActiveFileTransferName) ? "Do you want to download the file from the server host?" : "Do you want to download the file and cancel downloading ''" + GameMain.Client.ActiveFileTransferName + "''?"; @@ -1029,23 +1069,22 @@ namespace Barotrauma return false; } - subList.Select(sub, true); return true; } public void WriteData(NetOutgoingMessage msg) { - Submarine selectedMap = subList.SelectedData as Submarine; + Submarine selectedSub = subList.SelectedData as Submarine; - if (selectedMap==null) + if (selectedSub==null) { msg.Write(" "); msg.Write(" "); } else { - msg.Write(Path.GetFileName(selectedMap.Name)); - msg.Write(selectedMap.MD5Hash.Hash); + msg.Write(Path.GetFileName(selectedSub.Name)); + msg.Write(selectedSub.MD5Hash.Hash); } msg.Write(ServerName); @@ -1113,7 +1152,7 @@ namespace Barotrauma catch (Exception e) { - DebugConsole.ThrowError("Failed to read lobby update message"); + DebugConsole.ThrowError("Failed to read lobby update message ("+e.Message+")"); return; }