diff --git a/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Holdable/IdCard.cs b/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Holdable/IdCard.cs index cc05194e2..23083323d 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Holdable/IdCard.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Holdable/IdCard.cs @@ -56,10 +56,9 @@ namespace Barotrauma.Items.Components ContentXElement spriteElement = limbElement.GetChildElement("sprite"); if (spriteElement == null) { continue; } - string spritePath = spriteElement.GetAttribute("texture").Value; - - spritePath = characterInfo.ReplaceVars(spritePath); + ContentPath contentPath = spriteElement.GetAttributeContentPath("texture"); + string spritePath = characterInfo.ReplaceVars(contentPath.Value); string fileName = Path.GetFileNameWithoutExtension(spritePath); //go through the files in the directory to find a matching sprite diff --git a/Barotrauma/BarotraumaClient/ClientSource/Map/Submarine.cs b/Barotrauma/BarotraumaClient/ClientSource/Map/Submarine.cs index d6d47fdf7..eff30e678 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/Map/Submarine.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/Map/Submarine.cs @@ -40,7 +40,7 @@ namespace Barotrauma visibleSubs.Clear(); foreach (Submarine sub in Loaded) { - if (sub.WorldPosition.Y < Level.MaxEntityDepth) { continue; } + if (Level.Loaded != null && sub.WorldPosition.Y < Level.MaxEntityDepth) { continue; } int margin = 500; Rectangle worldBorders = new Rectangle( diff --git a/Barotrauma/BarotraumaClient/ClientSource/Screens/CampaignUI.cs b/Barotrauma/BarotraumaClient/ClientSource/Screens/CampaignUI.cs index 3a64bf0b7..81973be7f 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/Screens/CampaignUI.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/Screens/CampaignUI.cs @@ -807,7 +807,7 @@ namespace Barotrauma float balanceContainerWidth = GameMain.IsSingleplayer ? 1 : 1 / 3f; var rt = new RectTransform(new Vector2(balanceContainerWidth, 1.0f), parent.RectTransform) { - MaxSize = new Point(120, int.MaxValue) + MaxSize = new Point(GUI.IntScale(GUI.AdjustForTextScale(120)), int.MaxValue) }; var balanceContainer = new GUILayoutGroup(rt, childAnchor: Anchor.TopRight) { diff --git a/Barotrauma/BarotraumaClient/ClientSource/Steam/WorkshopMenu/Mutable/MutableWorkshopMenu.cs b/Barotrauma/BarotraumaClient/ClientSource/Steam/WorkshopMenu/Mutable/MutableWorkshopMenu.cs index 429ce9e19..49632af2b 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/Steam/WorkshopMenu/Mutable/MutableWorkshopMenu.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/Steam/WorkshopMenu/Mutable/MutableWorkshopMenu.cs @@ -73,11 +73,11 @@ namespace Barotrauma.Steam { if (!SteamManager.IsInitialized) { return; } - uint numSubscribedMods = Steamworks.SteamUGC.NumSubscribedItems; + uint numSubscribedMods = SteamManager.GetNumSubscribedItems(); if (numSubscribedMods == memSubscribedModCount) { return; } memSubscribedModCount = numSubscribedMods; - var subscribedIds = Steamworks.SteamUGC.GetSubscribedItems().ToHashSet(); + var subscribedIds = SteamManager.GetSubscribedItems().ToHashSet(); var installedIds = ContentPackageManager.WorkshopPackages.Select(p => p.SteamWorkshopId).ToHashSet(); foreach (var id in subscribedIds.Where(id2 => !installedIds.Contains(id2))) { diff --git a/Barotrauma/BarotraumaClient/LinuxClient.csproj b/Barotrauma/BarotraumaClient/LinuxClient.csproj index 1a43498c0..feb824001 100644 --- a/Barotrauma/BarotraumaClient/LinuxClient.csproj +++ b/Barotrauma/BarotraumaClient/LinuxClient.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma - 0.17.14.0 + 0.17.15.0 Copyright © FakeFish 2018-2022 AnyCPU;x64 Barotrauma diff --git a/Barotrauma/BarotraumaClient/MacClient.csproj b/Barotrauma/BarotraumaClient/MacClient.csproj index dc20efccf..c0b1d5d63 100644 --- a/Barotrauma/BarotraumaClient/MacClient.csproj +++ b/Barotrauma/BarotraumaClient/MacClient.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma - 0.17.14.0 + 0.17.15.0 Copyright © FakeFish 2018-2022 AnyCPU;x64 Barotrauma diff --git a/Barotrauma/BarotraumaClient/WindowsClient.csproj b/Barotrauma/BarotraumaClient/WindowsClient.csproj index 3dd67f325..870cafa2d 100644 --- a/Barotrauma/BarotraumaClient/WindowsClient.csproj +++ b/Barotrauma/BarotraumaClient/WindowsClient.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma - 0.17.14.0 + 0.17.15.0 Copyright © FakeFish 2018-2022 AnyCPU;x64 Barotrauma diff --git a/Barotrauma/BarotraumaServer/LinuxServer.csproj b/Barotrauma/BarotraumaServer/LinuxServer.csproj index 9a566afcb..f494058e0 100644 --- a/Barotrauma/BarotraumaServer/LinuxServer.csproj +++ b/Barotrauma/BarotraumaServer/LinuxServer.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma Dedicated Server - 0.17.14.0 + 0.17.15.0 Copyright © FakeFish 2018-2022 AnyCPU;x64 DedicatedServer diff --git a/Barotrauma/BarotraumaServer/MacServer.csproj b/Barotrauma/BarotraumaServer/MacServer.csproj index 229732195..e3385b582 100644 --- a/Barotrauma/BarotraumaServer/MacServer.csproj +++ b/Barotrauma/BarotraumaServer/MacServer.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma Dedicated Server - 0.17.14.0 + 0.17.15.0 Copyright © FakeFish 2018-2022 AnyCPU;x64 DedicatedServer diff --git a/Barotrauma/BarotraumaServer/WindowsServer.csproj b/Barotrauma/BarotraumaServer/WindowsServer.csproj index 291a754c2..54c93dda6 100644 --- a/Barotrauma/BarotraumaServer/WindowsServer.csproj +++ b/Barotrauma/BarotraumaServer/WindowsServer.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma Dedicated Server - 0.17.14.0 + 0.17.15.0 Copyright © FakeFish 2018-2022 AnyCPU;x64 DedicatedServer diff --git a/Barotrauma/BarotraumaShared/SharedSource/Characters/AI/NPCConversation.cs b/Barotrauma/BarotraumaShared/SharedSource/Characters/AI/NPCConversation.cs index 53cec3b04..594ba9045 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Characters/AI/NPCConversation.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Characters/AI/NPCConversation.cs @@ -57,8 +57,6 @@ namespace Barotrauma private readonly int speakerIndex; private readonly ImmutableHashSet allowedSpeakerTags; private readonly bool requireNextLine; - // used primarily for team1 characters interacting with escorted personnel (TODO: not used anywhere) - private readonly bool requireSight; public NPCConversation(XElement element) { @@ -75,7 +73,6 @@ namespace Barotrauma Responses = element.Elements().Select(s => new NPCConversation(s)).ToImmutableArray(); requireNextLine = element.GetAttributeBool("requirenextline", false); - requireSight = element.GetAttributeBool("requiresight", false); } private static List GetCurrentFlags(Character speaker) @@ -162,23 +159,38 @@ namespace Barotrauma return currentFlags; } - private static List previousConversations = new List(); + private static readonly List previousConversations = new List(); - public static List> CreateRandom(List availableSpeakers) + public static List<(Character speaker, string line)> CreateRandom(List availableSpeakers) { Dictionary assignedSpeakers = new Dictionary(); - List> lines = new List>(); + List<(Character speaker, string line)> lines = new List<(Character speaker, string line)>(); + + var language = GameSettings.CurrentConfig.Language; + if (language != TextManager.DefaultLanguage && !NPCConversationCollection.Collections.ContainsKey(language)) + { + DebugConsole.AddWarning($"Could not find NPC conversations for the language \"{language}\". Using \"{TextManager.DefaultLanguage}\" instead.."); + language = TextManager.DefaultLanguage; + } CreateConversation(availableSpeakers, assignedSpeakers, null, lines, - availableConversations: NPCConversationCollection.Collections[GameSettings.CurrentConfig.Language].SelectMany(cc => cc.Conversations).ToList()); + availableConversations: NPCConversationCollection.Collections[language].SelectMany(cc => cc.Conversations).ToList()); return lines; } - public static List> CreateRandom(List availableSpeakers, IEnumerable requiredFlags) + public static List<(Character speaker, string line)> CreateRandom(List availableSpeakers, IEnumerable requiredFlags) { Dictionary assignedSpeakers = new Dictionary(); - List> lines = new List>(); - var availableConversations = NPCConversationCollection.Collections[GameSettings.CurrentConfig.Language] + List<(Character speaker, string line)> lines = new List<(Character speaker, string line)>(); + + var language = GameSettings.CurrentConfig.Language; + if (language != TextManager.DefaultLanguage && !NPCConversationCollection.Collections.ContainsKey(language)) + { + DebugConsole.AddWarning($"Could not find NPC conversations for the language \"{language}\". Using \"{TextManager.DefaultLanguage}\" instead.."); + language = TextManager.DefaultLanguage; + } + + var availableConversations = NPCConversationCollection.Collections[language] .SelectMany(cc => cc.Conversations.Where(c => requiredFlags.All(f => c.Flags.Contains(f)))).ToList(); if (availableConversations.Count > 0) { @@ -191,7 +203,7 @@ namespace Barotrauma List availableSpeakers, Dictionary assignedSpeakers, NPCConversation baseConversation, - IList> lineList, + IList<(Character speaker, string line)> lineList, IList availableConversations, bool ignoreFlags = false) { @@ -271,7 +283,7 @@ namespace Barotrauma previousConversations.Insert(0, selectedConversation); if (previousConversations.Count > MaxPreviousConversations) previousConversations.RemoveAt(MaxPreviousConversations); } - lineList.Add(new Pair(speaker, selectedConversation.Line)); + lineList.Add((speaker, selectedConversation.Line)); CreateConversation(availableSpeakers, assignedSpeakers, selectedConversation, lineList, availableConversations); } diff --git a/Barotrauma/BarotraumaShared/SharedSource/Characters/Character.cs b/Barotrauma/BarotraumaShared/SharedSource/Characters/Character.cs index 20f6f24dd..736e50d2c 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Characters/Character.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Characters/Character.cs @@ -2729,12 +2729,15 @@ namespace Barotrauma if (!Enabled) { return; } - if (Level.Loaded != null && WorldPosition.Y < Level.MaxEntityDepth || - (Submarine != null && Submarine.WorldPosition.Y < Level.MaxEntityDepth)) + if (Level.Loaded != null) { - Enabled = false; - Kill(CauseOfDeathType.Pressure, null); - return; + if (WorldPosition.Y < Level.MaxEntityDepth || + (Submarine != null && Submarine.WorldPosition.Y < Level.MaxEntityDepth)) + { + Enabled = false; + Kill(CauseOfDeathType.Pressure, null); + return; + } } ApplyStatusEffects(ActionType.Always, deltaTime); diff --git a/Barotrauma/BarotraumaShared/SharedSource/Characters/NPCPersonalityTrait.cs b/Barotrauma/BarotraumaShared/SharedSource/Characters/NPCPersonalityTrait.cs index e12965df7..292b58fc6 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Characters/NPCPersonalityTrait.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Characters/NPCPersonalityTrait.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; using System.Xml.Linq; namespace Barotrauma @@ -12,7 +11,7 @@ namespace Barotrauma public readonly List AllowedDialogTags; - private float commonness; + private readonly float commonness; public float Commonness { get { return commonness; } @@ -20,12 +19,22 @@ namespace Barotrauma public static IEnumerable GetAll(LanguageIdentifier language) { + if (language != TextManager.DefaultLanguage && !NPCConversationCollection.Collections.ContainsKey(language)) + { + DebugConsole.AddWarning($"Could not find NPC personality traits for the language \"{language}\". Using \"{TextManager.DefaultLanguage}\" instead.."); + language = TextManager.DefaultLanguage; + } return NPCConversationCollection.Collections[language] .SelectMany(cc => cc.PersonalityTraits.Values); } public static NPCPersonalityTrait Get(LanguageIdentifier language, Identifier traitName) { + if (language != TextManager.DefaultLanguage && !NPCConversationCollection.Collections.ContainsKey(language)) + { + DebugConsole.AddWarning($"Could not find NPC personality traits for the language \"{language}\". Using \"{TextManager.DefaultLanguage}\" instead.."); + language = TextManager.DefaultLanguage; + } return NPCConversationCollection.Collections[language] .FirstOrDefault(cc => cc.PersonalityTraits.ContainsKey(traitName)) .PersonalityTraits[traitName]; diff --git a/Barotrauma/BarotraumaShared/SharedSource/GameSession/CrewManager.cs b/Barotrauma/BarotraumaShared/SharedSource/GameSession/CrewManager.cs index 6b4cc9fd5..6bf837b8b 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/GameSession/CrewManager.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/GameSession/CrewManager.cs @@ -13,7 +13,7 @@ namespace Barotrauma const float ConversationIntervalMax = 180.0f; const float ConversationIntervalMultiplierMultiplayer = 5.0f; private float conversationTimer, conversationLineTimer; - private readonly List> pendingConversationLines = new List>(); + private readonly List<(Character speaker, string line)> pendingConversationLines = new List<(Character speaker, string line)>(); public const int MaxCrewSize = 16; @@ -339,7 +339,7 @@ namespace Barotrauma #region Dialog - public void AddConversation(List> conversationLines) + public void AddConversation(List<(Character speaker, string line)> conversationLines) { if (conversationLines == null || conversationLines.Count == 0) { return; } pendingConversationLines.AddRange(conversationLines); @@ -428,16 +428,16 @@ namespace Barotrauma if (conversationLineTimer <= 0.0f) { //speaker of the next line can't speak, interrupt the conversation - if (pendingConversationLines[0].First.SpeechImpediment >= 100.0f) + if (pendingConversationLines[0].speaker.SpeechImpediment >= 100.0f) { pendingConversationLines.Clear(); return; } - pendingConversationLines[0].First.Speak(pendingConversationLines[0].Second, null); + pendingConversationLines[0].speaker.Speak(pendingConversationLines[0].line, null); if (pendingConversationLines.Count > 1) { - conversationLineTimer = MathHelper.Clamp(pendingConversationLines[0].Second.Length * 0.1f, 1.0f, 5.0f); + conversationLineTimer = MathHelper.Clamp(pendingConversationLines[0].line.Length * 0.1f, 1.0f, 5.0f); } pendingConversationLines.RemoveAt(0); } diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/Item.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/Item.cs index 693b8c7ce..03f8e5d48 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Items/Item.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Items/Item.cs @@ -1789,7 +1789,7 @@ namespace Barotrauma if (Math.Abs(body.LinearVelocity.X) > 0.01f || Math.Abs(body.LinearVelocity.Y) > 0.01f || transformDirty) { UpdateTransform(); - if (CurrentHull == null && body.SimPosition.Y < ConvertUnits.ToSimUnits(Level.MaxEntityDepth)) + if (CurrentHull == null && Level.Loaded != null && body.SimPosition.Y < ConvertUnits.ToSimUnits(Level.MaxEntityDepth)) { Spawner?.AddItemToRemoveQueue(this); return; diff --git a/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/Level.cs b/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/Level.cs index efc2b8ea2..763fb0324 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/Level.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/Level.cs @@ -8,10 +8,7 @@ using Microsoft.Xna.Framework; using System; using System.Collections.Generic; using System.Diagnostics; -using System.Globalization; using System.Linq; -using System.Xml.Linq; -using Barotrauma.IO; using Voronoi2; namespace Barotrauma @@ -25,7 +22,7 @@ namespace Barotrauma } //all entities are disabled after they reach this depth - public const int MaxEntityDepth = -300000; + public const int MaxEntityDepth = -1000000; public const float ShaftHeight = 1000.0f; /// /// The level generator won't try to adjust the width of the main path above this limit. diff --git a/Barotrauma/BarotraumaShared/SharedSource/Steam/SteamManager.cs b/Barotrauma/BarotraumaShared/SharedSource/Steam/SteamManager.cs index a3f7cb201..ca1a02271 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Steam/SteamManager.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Steam/SteamManager.cs @@ -1,3 +1,4 @@ +using Steamworks.Data; using System; using System.Collections.Generic; using System.Linq; @@ -74,6 +75,24 @@ namespace Barotrauma.Steam return Steamworks.SteamClient.Name; } + public static uint GetNumSubscribedItems() + { + if (!IsInitialized || !Steamworks.SteamClient.IsValid) + { + return 0; + } + return Steamworks.SteamUGC.NumSubscribedItems; + } + + public static PublishedFileId[] GetSubscribedItems() + { + if (!IsInitialized || !Steamworks.SteamClient.IsValid) + { + return new PublishedFileId[0]; + } + return Steamworks.SteamUGC.GetSubscribedItems(); + } + public static bool UnlockAchievement(string achievementIdentifier) => UnlockAchievement(achievementIdentifier.ToIdentifier()); diff --git a/Barotrauma/BarotraumaShared/SharedSource/Text/RichString.cs b/Barotrauma/BarotraumaShared/SharedSource/Text/RichString.cs index 67cb2fbf0..7a710827c 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Text/RichString.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Text/RichString.cs @@ -80,7 +80,7 @@ namespace Barotrauma #if DEBUG if (!lStr.IsNullOrEmpty() && lStr.Contains("‖")) { - if (Debugger.IsAttached) { Debugger.Break(); } + //if (Debugger.IsAttached) { Debugger.Break(); } } #endif return Plain(lStr ?? string.Empty); diff --git a/Barotrauma/BarotraumaShared/changelog.txt b/Barotrauma/BarotraumaShared/changelog.txt index 10715e447..37b6f8943 100644 --- a/Barotrauma/BarotraumaShared/changelog.txt +++ b/Barotrauma/BarotraumaShared/changelog.txt @@ -1,3 +1,12 @@ +--------------------------------------------------------------------------------------------------------- +v0.17.15.0 +--------------------------------------------------------------------------------------------------------- + +Fixes: +- Fixed crashing if a custom language doesn't configure NPC personality traits or conversations. +- Fixed crashing when you try to disguise as someone else when using a mod that overrides the vanilla human config. +- Fixed characters getting instakilled if you dive too deep in the sub editor test mode. + --------------------------------------------------------------------------------------------------------- v0.17.14.0 ---------------------------------------------------------------------------------------------------------