diff --git a/Subsurface/Barotrauma.csproj b/Subsurface/Barotrauma.csproj index f8a142aa3..5025b8910 100644 --- a/Subsurface/Barotrauma.csproj +++ b/Subsurface/Barotrauma.csproj @@ -692,9 +692,6 @@ PreserveNewest - - PreserveNewest - PreserveNewest @@ -873,6 +870,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/Subsurface/Barotrauma.csproj.user b/Subsurface/Barotrauma.csproj.user index df35fcf91..1782abafa 100644 --- a/Subsurface/Barotrauma.csproj.user +++ b/Subsurface/Barotrauma.csproj.user @@ -9,7 +9,7 @@ en-US false - ProjectFiles + ShowAllFiles diff --git a/Subsurface/Content/Characters/Mantis/mantis.xml b/Subsurface/Content/Characters/Mantis/mantis.xml index e8657ac5b..f7dbf3fb7 100644 --- a/Subsurface/Content/Characters/Mantis/mantis.xml +++ b/Subsurface/Content/Characters/Mantis/mantis.xml @@ -1,5 +1,5 @@  - + diff --git a/Subsurface/Content/Orders.xml b/Subsurface/Content/Orders.xml index 6f7450632..225e02a97 100644 --- a/Subsurface/Content/Orders.xml +++ b/Subsurface/Content/Orders.xml @@ -1,27 +1,27 @@  - + - + - + - + - + - + \ No newline at end of file diff --git a/Subsurface/Content/UI/orderSymbols.png b/Subsurface/Content/UI/orderSymbols.png deleted file mode 100644 index 60b8a7267..000000000 Binary files a/Subsurface/Content/UI/orderSymbols.png and /dev/null differ diff --git a/Subsurface/Content/UI/uiIcons.png b/Subsurface/Content/UI/uiIcons.png new file mode 100644 index 000000000..f3e87c5c7 Binary files /dev/null and b/Subsurface/Content/UI/uiIcons.png differ diff --git a/Subsurface/Source/Characters/Animation/HumanoidAnimController.cs b/Subsurface/Source/Characters/Animation/HumanoidAnimController.cs index 03f755a6a..e4f3ef309 100644 --- a/Subsurface/Source/Characters/Animation/HumanoidAnimController.cs +++ b/Subsurface/Source/Characters/Animation/HumanoidAnimController.cs @@ -909,9 +909,8 @@ namespace Barotrauma Vector2 shoulderPos = limbJoints[2].WorldAnchorA; Vector2 transformedHoldPos = shoulderPos; - if (itemPos == Vector2.Zero || Anim == Animation.Climbing) + if (itemPos == Vector2.Zero || Anim == Animation.Climbing || (leftHand.Disabled && rightHand.Disabled)) { - if (character.SelectedItems[1] == item) { transformedHoldPos = leftHand.pullJoint.WorldAnchorA - transformedHandlePos[1]; diff --git a/Subsurface/Source/Characters/Animation/Ragdoll.cs b/Subsurface/Source/Characters/Animation/Ragdoll.cs index 5a80bcb92..9db051c04 100644 --- a/Subsurface/Source/Characters/Animation/Ragdoll.cs +++ b/Subsurface/Source/Characters/Animation/Ragdoll.cs @@ -815,25 +815,35 @@ namespace Barotrauma { if (inWater) { - if (character is AICharacter) + if (targetMovement.LengthSquared() > 0.01f) { correctionMovement = - Vector2.Lerp(targetMovement, Vector2.Normalize(diff) * MathHelper.Clamp(dist * 8.0f, 0.1f, 8.0f), 0.5f); + Vector2.Lerp(targetMovement, Vector2.Normalize(diff) * MathHelper.Clamp(dist * 5.0f, 0.1f, 5.0f), 0.2f); } else { - foreach (Limb limb in Limbs) - { - //if (limb.body.TargetPosition == Vector2.Zero) continue; + refLimb.body.LinearVelocity = Vector2.Lerp( + refLimb.LinearVelocity, + Vector2.Normalize(diff) * MathHelper.Clamp(dist, 0.0f, 5.0f), + 0.2f); - limb.body.SetTransform(limb.SimPosition + Vector2.Normalize(diff) * 0.1f, limb.Rotation); - } + //foreach (Limb limb in Limbs) + //{ + // //if (limb.body.TargetPosition == Vector2.Zero) continue; + // // Vector2.Lerp(limb.LinearVelocity, Vector2.Normalize(diff) * MathHelper.Clamp(dist, 0.0f, 1.0f)) + // limb.body.LinearVelocity = Vector2.Lerp( + // limb.LinearVelocity, + // Vector2.Normalize(diff) * MathHelper.Clamp(dist, 0.0f, 5.0f), + // 0.2f); + + // //limb.body.TargetVelocity .SetTransform(limb.SimPosition + Vector2.Normalize(diff) * 0.1f, limb.Rotation); + //} } } else { //clamp the magnitude of the correction movement between 0.5f - 5.0f - Vector2 newCorrectionMovement = Vector2.Normalize(diff) * MathHelper.Clamp(dist * 5.0f, 0.5f, 5.0f); + Vector2 newCorrectionMovement = Vector2.Normalize(diff) * MathHelper.Clamp(dist*2.0f, 0.5f, 5.0f); //heading in the right direction -> use the ''normal'' movement if it's faster than correctionMovement //i.e. the character is close to the targetposition but the character is still running diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs index 9db3d668a..d43e7c342 100644 --- a/Subsurface/Source/Characters/Character.cs +++ b/Subsurface/Source/Characters/Character.cs @@ -965,7 +965,7 @@ namespace Barotrauma key.DequeueHeld(); } - networkUpdateSent = true; + networkUpdateSent = false; } if (needsAir) diff --git a/Subsurface/Source/GUI/GUI.cs b/Subsurface/Source/GUI/GUI.cs index b5e750d23..63570b380 100644 --- a/Subsurface/Source/GUI/GUI.cs +++ b/Subsurface/Source/GUI/GUI.cs @@ -43,6 +43,18 @@ namespace Barotrauma public static Color ScreenOverlayColor; + private static Sprite submarineIcon, arrow; + + public static Sprite SubmarineIcon + { + get { return submarineIcon; } + } + + public static Sprite Arrow + { + get { return arrow; } + } + public static void Init(ContentManager content) { GUI.Font = ToolBox.TryLoadFont("SpriteFont1", content); @@ -72,6 +84,12 @@ namespace Barotrauma t = new Texture2D(graphicsDevice, 1, 1); t.SetData(new Color[] { Color.White });// fill the texture with white + submarineIcon = new Sprite("Content/UI/uiIcons.png", new Rectangle(0, 192, 64, 64), null); + submarineIcon.Origin = submarineIcon.size / 2; + + arrow = new Sprite("Content/UI/uiIcons.png", new Rectangle(80, 240, 16, 16), null); + arrow.Origin = arrow.size / 2; + Style = new GUIStyle("Content/UI/style.xml"); } diff --git a/Subsurface/Source/Items/Components/Holdable/Holdable.cs b/Subsurface/Source/Items/Components/Holdable/Holdable.cs index c640e3f69..cef636e57 100644 --- a/Subsurface/Source/Items/Components/Holdable/Holdable.cs +++ b/Subsurface/Source/Items/Components/Holdable/Holdable.cs @@ -252,7 +252,7 @@ namespace Barotrauma.Items.Components item.Submarine = picker.Submarine; - if (picker.SelectedConstruction != null && picker.SelectedConstruction.GetComponent() != null) return; + //if (picker.SelectedConstruction != null && picker.SelectedConstruction.GetComponent() != null) return; //item.sprite.Depth = picker.AnimController.GetLimb(LimbType.RightHand).sprite.Depth + 0.01f; diff --git a/Subsurface/Source/Items/Components/Machines/Controller.cs b/Subsurface/Source/Items/Components/Machines/Controller.cs index c9d9a6442..dc8f4afb9 100644 --- a/Subsurface/Source/Items/Components/Machines/Controller.cs +++ b/Subsurface/Source/Items/Components/Machines/Controller.cs @@ -210,6 +210,8 @@ namespace Barotrauma.Items.Components limb.pullJoint.Enabled = false; } + if (character.SelectedConstruction == this.item) character.SelectedConstruction = null; + character.AnimController.Anim = AnimController.Animation.None; } @@ -225,9 +227,6 @@ namespace Barotrauma.Items.Components IsActive = false; CancelUsing(character); character = null; - } - else - { return false; } } diff --git a/Subsurface/Source/Networking/FileStreamReceiver.cs b/Subsurface/Source/Networking/FileStreamReceiver.cs index 2fc14244b..52dedefc2 100644 --- a/Subsurface/Source/Networking/FileStreamReceiver.cs +++ b/Subsurface/Source/Networking/FileStreamReceiver.cs @@ -2,6 +2,7 @@ using System; using System.IO; using System.Text.RegularExpressions; +using System.Xml; using System.Xml.Linq; namespace Barotrauma.Networking @@ -259,15 +260,26 @@ namespace Barotrauma.Networking try { - stream.Position = 0; - var doc = XDocument.Load(stream); + stream.Position = 0; + + XmlReaderSettings settings = new XmlReaderSettings(); + settings.DtdProcessing = DtdProcessing.Prohibit; + settings.IgnoreProcessingInstructions = true; + + using (var reader = XmlReader.Create(stream, settings)) + { + while (reader.Read()) + { + + } + } } catch { stream.Close(); stream.Dispose(); - ErrorMessage = "Failed to parse submarine file ''"+file+"''!"; + ErrorMessage = "Parsing file ''"+file+"'' failed! The file may not be a valid submarine file."; return false; } diff --git a/Subsurface/Source/Networking/GameServer.cs b/Subsurface/Source/Networking/GameServer.cs index f6e6b2826..3b34a030f 100644 --- a/Subsurface/Source/Networking/GameServer.cs +++ b/Subsurface/Source/Networking/GameServer.cs @@ -846,6 +846,14 @@ 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); return true; @@ -855,13 +863,6 @@ namespace Barotrauma.Networking { GUIMessageBox.CloseAll(); - 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); - yield return CoroutineStatus.Success; - } - AssignJobs(); roundStartSeed = DateTime.Now.Millisecond; diff --git a/Subsurface/Source/Networking/GameServerSettings.cs b/Subsurface/Source/Networking/GameServerSettings.cs index 778717b80..efa8d83c8 100644 --- a/Subsurface/Source/Networking/GameServerSettings.cs +++ b/Subsurface/Source/Networking/GameServerSettings.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; +using System.Xml; using System.Xml.Linq; namespace Barotrauma.Networking @@ -96,29 +97,25 @@ namespace Barotrauma.Networking private void SaveSettings() { - XDocument doc = new XDocument(new XElement("serversettings")); - - doc.Root.Add - ( - new XAttribute("AllowSpectating", allowSpectating), - new XAttribute("RandomizeSeed", randomizeSeed), - new XAttribute("EndRoundAtLevelEnd", endRoundAtLevelEnd), - new XAttribute("AllowFileTransfers", allowFileTransfers), + XmlWriterSettings settings = new XmlWriterSettings(); + settings.Indent = true; + settings.NewLineOnAttributes = true; - new XAttribute("SaveServerLogs", saveServerLogs), - new XAttribute("LinesPerLogFile", log.LinesPerFile), - - new XAttribute("SubSelection", subSelectionMode), - new XAttribute("ModeSelection", modeSelectionMode) - ); - - try + using (var writer = XmlWriter.Create(SettingsFile, settings)) { - doc.Save(SettingsFile); - } - catch (Exception e) - { - DebugConsole.ThrowError("Saving server settings failed", e); + writer.WriteStartElement("serversettings"); + writer.WriteAttributeString("AllowSpectating", allowSpectating.ToString()); + writer.WriteAttributeString("RandomizeSeed", randomizeSeed.ToString()); + + writer.WriteAttributeString("EndRoundAtLevelEnd", endRoundAtLevelEnd.ToString()); + writer.WriteAttributeString("AllowFileTransfers", allowFileTransfers.ToString()); + writer.WriteAttributeString("MaxFileTransferDuration", ((int)FileStreamSender.MaxTransferDuration.TotalSeconds).ToString()); + writer.WriteAttributeString("SaveServerLogs", saveServerLogs.ToString()); + writer.WriteAttributeString("LinesPerLogFile", log.LinesPerFile.ToString()); + writer.WriteAttributeString("SubSelection", subSelectionMode.ToString()); + writer.WriteAttributeString("ModeSelection", modeSelectionMode.ToString()); + + writer.Flush(); } } @@ -152,17 +149,58 @@ namespace Barotrauma.Networking modeSelectionMode = SelectionMode.Manual; Enum.TryParse(ToolBox.GetAttributeString(doc.Root, "ModeSelection", "Manual"), out modeSelectionMode); + + FileStreamSender.MaxTransferDuration = new TimeSpan(0,0,ToolBox.GetAttributeInt(doc.Root, "MaxFileTransferDuration", 150)); } private void CreateSettingsFrame() { settingsFrame = new GUIFrame(new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.Black * 0.5f); + GUIFrame innerFrame = new GUIFrame(new Rectangle(0, 0, 400, 400), null, Alignment.Center, GUI.Style, settingsFrame); + innerFrame.Padding = new Vector4(20.0f, 20.0f, 20.0f, 20.0f); - new GUITextBlock(new Rectangle(0, -15, 0, 20), "Server settings", GUI.Style, innerFrame, GUI.LargeFont); + new GUITextBlock(new Rectangle(0, -5, 0, 20), "Server settings", GUI.Style, innerFrame, GUI.LargeFont); - var randomizeLevelBox = new GUITickBox(new Rectangle(0, 30, 20, 20), "Randomize level seed between rounds", Alignment.Left, innerFrame); + int y = 40; + + var endBox = new GUITickBox(new Rectangle(0, y, 20, 20), "End round when destination reached", Alignment.Left, innerFrame); + endBox.Selected = endRoundAtLevelEnd; + endBox.OnSelected = (GUITickBox) => { endRoundAtLevelEnd = GUITickBox.Selected; return true; }; + + + y += 30; + var endVoteBox = new GUITickBox(new Rectangle(0, y, 20, 20), "End round by voting", Alignment.Left, innerFrame); + endVoteBox.Selected = Voting.AllowEndVoting; + endVoteBox.OnSelected = (GUITickBox) => + { + Voting.AllowEndVoting = !Voting.AllowEndVoting; + GameMain.Server.UpdateVoteStatus(); + return true; + }; + + var votesRequiredText = new GUITextBlock(new Rectangle(20, y+20, 20, 20), "Votes required: 50 %", GUI.Style, innerFrame, GUI.SmallFont); + + var votesRequiredSlider = new GUIScrollBar(new Rectangle(150, y+22, 100, 10), GUI.Style, 0.1f, innerFrame); + votesRequiredSlider.UserData = votesRequiredText; + 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; + }; + 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) => { @@ -170,37 +208,23 @@ namespace Barotrauma.Networking return true; }; - var endBox = new GUITickBox(new Rectangle(0, 60, 20, 20), "End round when destination reached", Alignment.Left, innerFrame); - endBox.Selected = endRoundAtLevelEnd; - endBox.OnSelected = (GUITickBox) => { endRoundAtLevelEnd = GUITickBox.Selected; return true; }; - var endVoteBox = new GUITickBox(new Rectangle(0, 90, 20, 20), "End round by voting", Alignment.Left, innerFrame); - endVoteBox.Selected = Voting.AllowEndVoting; - endVoteBox.OnSelected = (GUITickBox) => + y += 40; + + var shareSubsBox = new GUITickBox(new Rectangle(0, y, 20, 20), "Share submarine files with players", Alignment.Left, innerFrame); + shareSubsBox.Selected = allowFileTransfers; + shareSubsBox.OnSelected = (GUITickBox) => { - Voting.AllowEndVoting = !Voting.AllowEndVoting; - GameMain.Server.UpdateVoteStatus(); - return true; - }; - - var votesRequiredText = new GUITextBlock(new Rectangle(20, 110, 20, 20), "Votes required: 50 %", GUI.Style, innerFrame, GUI.SmallFont); - - var votesRequiredSlider = new GUIScrollBar(new Rectangle(150,115, 100, 10), GUI.Style, 0.1f, innerFrame); - votesRequiredSlider.UserData = votesRequiredText; - 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) + " %"; + allowFileTransfers = GUITickBox.Selected; return true; }; - votesRequiredSlider.OnMoved(votesRequiredSlider, votesRequiredSlider.BarScroll); - new GUITextBlock(new Rectangle(0, 95+50, 100, 20), "Submarine selection:", GUI.Style, innerFrame); - var selectionFrame = new GUIFrame(new Rectangle(0, 120 + 50, 300, 20), null, innerFrame); + + y += 40; + + + new GUITextBlock(new Rectangle(0, y, 100, 20), "Submarine selection:", GUI.Style, innerFrame); + var selectionFrame = new GUIFrame(new Rectangle(0, y+20, 300, 20), null, innerFrame); for (int i = 0; i<3; i++) { var selectionTick = new GUITickBox(new Rectangle(i * 100, 0, 20, 20), ((SelectionMode)i).ToString(), Alignment.Left, selectionFrame); @@ -209,8 +233,10 @@ namespace Barotrauma.Networking selectionTick.UserData = (SelectionMode)i; } - new GUITextBlock(new Rectangle(0, 145 + 50, 100, 20), "Mode selection:", GUI.Style, innerFrame); - selectionFrame = new GUIFrame(new Rectangle(0, 170 + 50, 300, 20), null, innerFrame); + y += 45; + + new GUITextBlock(new Rectangle(0, y, 100, 20), "Mode selection:", GUI.Style, innerFrame); + selectionFrame = new GUIFrame(new Rectangle(0, y+20, 300, 20), null, innerFrame); for (int i = 0; i<3; i++) { var selectionTick = new GUITickBox(new Rectangle(i*100, 0, 20, 20), ((SelectionMode)i).ToString(), Alignment.Left, selectionFrame); @@ -219,7 +245,9 @@ namespace Barotrauma.Networking selectionTick.UserData = (SelectionMode)i; } - var allowSpecBox = new GUITickBox(new Rectangle(0, 210 + 50, 20, 20), "Allow spectating", Alignment.Left, innerFrame); + y += 60; + + var allowSpecBox = new GUITickBox(new Rectangle(0, y, 20, 20), "Allow spectating", Alignment.Left, innerFrame); allowSpecBox.Selected = allowSpectating; allowSpecBox.OnSelected = (GUITickBox) => { @@ -227,7 +255,9 @@ namespace Barotrauma.Networking return true; }; - var saveLogsBox = new GUITickBox(new Rectangle(0, 240 + 50, 20, 20), "Save server logs", Alignment.Left, innerFrame); + y += 30; + + var saveLogsBox = new GUITickBox(new Rectangle(0, y, 20, 20), "Save server logs", Alignment.Left, innerFrame); saveLogsBox.Selected = saveServerLogs; saveLogsBox.OnSelected = (GUITickBox) => { diff --git a/Subsurface/Source/Screens/GameScreen.cs b/Subsurface/Source/Screens/GameScreen.cs index 1f3b4da72..478f2971f 100644 --- a/Subsurface/Source/Screens/GameScreen.cs +++ b/Subsurface/Source/Screens/GameScreen.cs @@ -177,7 +177,7 @@ namespace Barotrauma //{ // cam.TargetPos = Character.Controlled.WorldPosition; //} - + cam.UpdateTransform(); DrawMap(graphics, spriteBatch); @@ -200,6 +200,8 @@ namespace Barotrauma if (GameMain.GameSession != null) GameMain.GameSession.Draw(spriteBatch); + if (Character.Controlled == null && Submarine.Loaded != null) DrawSubmarineIndicator(spriteBatch, Submarine.Loaded); + GUI.Draw((float)deltaTime, spriteBatch, cam); if (!PlayerInput.LeftButtonHeld()) Inventory.draggingItem = null; @@ -348,5 +350,25 @@ namespace Barotrauma GameMain.LightManager.DrawLOS(graphics, spriteBatch, cam); } + + private void DrawSubmarineIndicator(SpriteBatch spriteBatch, Submarine submarine) + { + Vector2 subDiff = submarine.WorldPosition - cam.Position; + + if (Math.Abs(subDiff.X) > cam.WorldView.Width || Math.Abs(subDiff.Y) > cam.WorldView.Height) + { + Vector2 normalizedSubDiff = Vector2.Normalize(subDiff); + + Vector2 iconPos = + cam.WorldToScreen(cam.Position) + + new Vector2(normalizedSubDiff.X * GameMain.GraphicsWidth * 0.4f, -normalizedSubDiff.Y * GameMain.GraphicsHeight * 0.4f); + + GUI.SubmarineIcon.Draw(spriteBatch, iconPos, Color.LightBlue * 0.5f); + + Vector2 arrowOffset = normalizedSubDiff * GUI.SubmarineIcon.size.X * 0.7f; + arrowOffset.Y = -arrowOffset.Y; + GUI.Arrow.Draw(spriteBatch, iconPos + arrowOffset, Color.LightBlue * 0.5f, MathUtils.VectorToAngle(arrowOffset) + MathHelper.PiOver2); + } + } } } diff --git a/Subsurface/Source/Screens/NetLobbyScreen.cs b/Subsurface/Source/Screens/NetLobbyScreen.cs index bf26560a3..e5ba845ef 100644 --- a/Subsurface/Source/Screens/NetLobbyScreen.cs +++ b/Subsurface/Source/Screens/NetLobbyScreen.cs @@ -440,8 +440,6 @@ namespace Barotrauma UpdateJobPreferences(jobList); - //UpdatePreviewPlayer(Game1.Client.CharacterInfo); - UpdatePreviewPlayer(characterInfo); } } @@ -510,7 +508,6 @@ namespace Barotrauma { valueChanged = true; - var hash = (obj as Submarine).MD5Hash; //hash will be null if opening the sub file failed -> don't select the sub diff --git a/Subsurface_Solution.v12.suo b/Subsurface_Solution.v12.suo index a1f5ff7d2..9461ffab3 100644 Binary files a/Subsurface_Solution.v12.suo and b/Subsurface_Solution.v12.suo differ