From d84832296ce77dde653916e8a629abb53ec6d329 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Sat, 18 May 2019 17:28:18 +0300 Subject: [PATCH] (cd17ab725) Cleanup. --- .../Source/GUI/GUITextBlock.cs | 7 +-- .../Source/Items/Components/ItemLabel.cs | 3 +- .../Source/Networking/GameServer.cs | 12 ++--- .../Source/Characters/AI/HumanAIController.cs | 10 +++- .../AI/Objectives/AIObjectiveGoTo.cs | 2 +- .../Source/Characters/AI/PathFinder.cs | 4 +- .../BarotraumaShared/Source/GameSettings.cs | 48 +++++++++++++++++++ 7 files changed, 65 insertions(+), 21 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUITextBlock.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUITextBlock.cs index 5192c5a0f..bf80ea025 100644 --- a/Barotrauma/BarotraumaClient/Source/GUI/GUITextBlock.cs +++ b/Barotrauma/BarotraumaClient/Source/GUI/GUITextBlock.cs @@ -331,11 +331,8 @@ namespace Barotrauma if (!string.IsNullOrEmpty(text)) { Vector2 pos = rect.Location.ToVector2() + textPos + TextOffset; - if (RoundToNearestPixel) - { - pos.X = (int)pos.X; - pos.Y = (int)pos.Y; - } + pos.X = (int)pos.X; + pos.Y = (int)pos.Y; Font.DrawString(spriteBatch, Wrap ? wrappedText : text, diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/ItemLabel.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/ItemLabel.cs index c837950c7..512abe647 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/Components/ItemLabel.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/Components/ItemLabel.cs @@ -105,8 +105,7 @@ namespace Barotrauma.Items.Components textBlock = new GUITextBlock(new RectTransform(item.Rect.Size), "", textColor: textColor, font: GUI.UnscaledSmallFont, textAlignment: Alignment.Center, wrap: true, style: null) { - TextDepth = item.SpriteDepth - 0.00001f, - RoundToNearestPixel = false, + TextDepth = item.SpriteDepth - 0.0001f, TextScale = TextScale }; } diff --git a/Barotrauma/BarotraumaServer/Source/Networking/GameServer.cs b/Barotrauma/BarotraumaServer/Source/Networking/GameServer.cs index b4cdb82cc..5ee4d596f 100644 --- a/Barotrauma/BarotraumaServer/Source/Networking/GameServer.cs +++ b/Barotrauma/BarotraumaServer/Source/Networking/GameServer.cs @@ -2408,10 +2408,7 @@ namespace Barotrauma.Networking if (senderCharacter != null && client.Character != null && !client.Character.IsDead) { - if (senderCharacter != client.Character) - { - modifiedMessage = ChatMessage.ApplyDistanceEffect(message, (ChatMessageType)type, senderCharacter, client.Character); - } + modifiedMessage = ChatMessage.ApplyDistanceEffect(message, (ChatMessageType)type, senderCharacter, client.Character); //too far to hear the msg -> don't send if (string.IsNullOrWhiteSpace(modifiedMessage)) continue; @@ -2460,16 +2457,13 @@ namespace Barotrauma.Networking if (message.Sender != null && client.Character != null && !client.Character.IsDead) { - if (message.Sender != client.Character) - { - modifiedMessage = ChatMessage.ApplyDistanceEffect(message.Text, messageType, message.Sender, client.Character); - } + modifiedMessage = ChatMessage.ApplyDistanceEffect(message.Text, messageType, message.Sender, client.Character); //too far to hear the msg -> don't send if (string.IsNullOrWhiteSpace(modifiedMessage)) continue; } - SendDirectChatMessage(new OrderChatMessage(message.Order, message.OrderOption, message.TargetEntity, message.TargetCharacter, message.Sender), client); + SendDirectChatMessage(message, client); } string myReceivedMessage = message.Text; diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs index 83962b19c..dd5c808d9 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs @@ -85,12 +85,18 @@ namespace Barotrauma if (Character.Submarine != null || SelectedAiTarget?.Entity?.Submarine != null) { - if (steeringManager != insideSteering) insideSteering.Reset(); + if (steeringManager != insideSteering) + { + insideSteering.Reset(); + } steeringManager = insideSteering; } else { - if (steeringManager != outsideSteering) outsideSteering.Reset(); + if (steeringManager != outsideSteering) + { + outsideSteering.Reset(); + } steeringManager = outsideSteering; } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveGoTo.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveGoTo.cs index 7fe272a64..9e0a92f58 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveGoTo.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveGoTo.cs @@ -117,7 +117,7 @@ namespace Barotrauma // Take the sub position into account in the sim pos if (character.Submarine == null && Target.Submarine != null) { - currTargetSimPos += Target.Submarine.SimPosition; + //currTargetSimPos += Target.Submarine.SimPosition; } else if (character.Submarine != null && Target.Submarine == null) { diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/PathFinder.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/PathFinder.cs index 45adac1ec..604a260ae 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/PathFinder.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/PathFinder.cs @@ -165,8 +165,8 @@ namespace Barotrauma { Vector2 nodePos = node.Position; - float xDiff = System.Math.Abs(start.X - nodePos.X); - float yDiff = System.Math.Abs(start.Y - nodePos.Y); + float xDiff = Math.Abs(start.X - nodePos.X); + float yDiff = Math.Abs(start.Y - nodePos.Y); if (yDiff > 1.0f && node.Waypoint.Ladders == null && node.Waypoint.Stairs == null) { diff --git a/Barotrauma/BarotraumaShared/Source/GameSettings.cs b/Barotrauma/BarotraumaShared/Source/GameSettings.cs index d6722b111..64b8a8358 100644 --- a/Barotrauma/BarotraumaShared/Source/GameSettings.cs +++ b/Barotrauma/BarotraumaShared/Source/GameSettings.cs @@ -821,6 +821,54 @@ namespace Barotrauma VoiceSetting = voiceSetting; } } + if (!SelectedContentPackages.Any()) + { + var availablePackage = ContentPackage.List.FirstOrDefault(cp => cp.IsCompatible() && cp.CorePackage); + if (availablePackage != null) + { + SelectedContentPackages.Add(availablePackage); + } + } + + //save to get rid of the invalid selected packages in the config file + if (missingPackagePaths.Count > 0 || incompatiblePackages.Count > 0) { SaveNewPlayerConfig(); } + } + #endregion + + #region Save DefaultConfig + private void SaveNewDefaultConfig() + { + XDocument doc = new XDocument(); + + if (doc.Root == null) + { + doc.Add(new XElement("config")); + } + + doc.Root.Add( + new XAttribute("language", TextManager.Language), + new XAttribute("masterserverurl", MasterServerUrl), + new XAttribute("autocheckupdates", AutoCheckUpdates), + new XAttribute("musicvolume", musicVolume), + new XAttribute("soundvolume", soundVolume), + new XAttribute("voicechatvolume", voiceChatVolume), + new XAttribute("verboselogging", VerboseLogging), + new XAttribute("savedebugconsolelogs", SaveDebugConsoleLogs), + new XAttribute("enablesplashscreen", EnableSplashScreen), + new XAttribute("usesteammatchmaking", useSteamMatchmaking), + new XAttribute("quickstartsub", QuickStartSubmarineName), + new XAttribute("requiresteamauthentication", requireSteamAuthentication), + new XAttribute("aimassistamount", aimAssistAmount)); + + if (!ShowUserStatisticsPrompt) + { + doc.Root.Add(new XAttribute("senduserstatistics", sendUserStatistics)); + } + + if (WasGameUpdated) + { + doc.Root.Add(new XAttribute("wasgameupdated", true)); + } useSteamMatchmaking = doc.Root.GetAttributeBool("usesteammatchmaking", useSteamMatchmaking); requireSteamAuthentication = doc.Root.GetAttributeBool("requiresteamauthentication", requireSteamAuthentication);