diff --git a/Barotrauma/BarotraumaClient/ClientSource/GameMain.cs b/Barotrauma/BarotraumaClient/ClientSource/GameMain.cs index ebe52c9fe..38c159d25 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/GameMain.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/GameMain.cs @@ -458,7 +458,10 @@ namespace Barotrauma Eos.EosAccount.LoginPlatformSpecific(); - initialLoadingThread = new Thread(Load); + initialLoadingThread = new Thread(Load) + { + Name = "Load" + }; initialLoadingThread.Start(); } diff --git a/Barotrauma/BarotraumaClient/ClientSource/Items/Components/ItemComponent.cs b/Barotrauma/BarotraumaClient/ClientSource/Items/Components/ItemComponent.cs index 8f01d40f2..cfd3d453b 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/Items/Components/ItemComponent.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/Items/Components/ItemComponent.cs @@ -265,6 +265,7 @@ namespace Barotrauma.Items.Components float gainDiff = targetGain - loopingSoundChannel.Gain; loopingSoundChannel.Gain += Math.Abs(gainDiff) < 0.1f ? gainDiff : Math.Sign(gainDiff) * 0.1f; loopingSoundChannel.Position = new Vector3(item.WorldPosition, 0.0f); + loopingSound.RoundSound.LastStreamSeekPos = loopingSoundChannel.StreamSeekPos; } for (int i = 0; i < playingOneshotSoundChannels.Count; i++) { @@ -409,6 +410,10 @@ namespace Barotrauma.Items.Components loopingSoundChannel.Near = loopingSound.Range * 0.4f; loopingSoundChannel.Far = loopingSound.Range; } + if (loopingSound.RoundSound.Stream) + { + loopingSoundChannel.StreamSeekPos = loopingSound.RoundSound.LastStreamSeekPos; + } } } else diff --git a/Barotrauma/BarotraumaClient/ClientSource/Map/RoundSound.cs b/Barotrauma/BarotraumaClient/ClientSource/Map/RoundSound.cs index 61ca17006..4511aaec9 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/Map/RoundSound.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/Map/RoundSound.cs @@ -16,6 +16,8 @@ namespace Barotrauma public readonly bool Stream; public readonly bool IgnoreMuffling; + public int LastStreamSeekPos; + public readonly bool MuteBackgroundMusic; public readonly string? Filename; diff --git a/Barotrauma/BarotraumaClient/ClientSource/StatusEffects/StatusEffect.cs b/Barotrauma/BarotraumaClient/ClientSource/StatusEffects/StatusEffect.cs index fa75a9b59..fb7f0738e 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/StatusEffects/StatusEffect.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/StatusEffects/StatusEffect.cs @@ -152,6 +152,8 @@ namespace Barotrauma private bool ignoreMuffling; + private RoundSound lastPlayingSound; + private void PlaySound(Entity entity, Hull hull, Vector2 worldPosition) { if (sounds.Count == 0) { return; } @@ -204,6 +206,7 @@ namespace Barotrauma else { soundChannel.Position = new Vector3(worldPosition, 0.0f); + if (lastPlayingSound != null && lastPlayingSound.Stream) { lastPlayingSound.LastStreamSeekPos = soundChannel.StreamSeekPos; } } KeepLoopingSoundAlive(soundChannel); @@ -248,6 +251,11 @@ namespace Barotrauma ignoreMuffling = selectedSound.IgnoreMuffling; if (soundChannel != null) { + if (soundChannel.IsStream && lastPlayingSound == selectedSound) + { + soundChannel.StreamSeekPos = lastPlayingSound.LastStreamSeekPos; + } + lastPlayingSound = selectedSound; soundChannel.Looping = loopSound; KeepLoopingSoundAlive(soundChannel); } diff --git a/Barotrauma/BarotraumaClient/LinuxClient.csproj b/Barotrauma/BarotraumaClient/LinuxClient.csproj index f3a101296..14dd9e549 100644 --- a/Barotrauma/BarotraumaClient/LinuxClient.csproj +++ b/Barotrauma/BarotraumaClient/LinuxClient.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma - 1.9.7.0 + 1.9.8.0 Copyright © FakeFish 2018-2024 AnyCPU;x64 Barotrauma diff --git a/Barotrauma/BarotraumaClient/MacClient.csproj b/Barotrauma/BarotraumaClient/MacClient.csproj index 8843b53ed..ebf575985 100644 --- a/Barotrauma/BarotraumaClient/MacClient.csproj +++ b/Barotrauma/BarotraumaClient/MacClient.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma - 1.9.7.0 + 1.9.8.0 Copyright © FakeFish 2018-2024 AnyCPU;x64 Barotrauma diff --git a/Barotrauma/BarotraumaClient/WindowsClient.csproj b/Barotrauma/BarotraumaClient/WindowsClient.csproj index ad2687830..7787e4d7c 100644 --- a/Barotrauma/BarotraumaClient/WindowsClient.csproj +++ b/Barotrauma/BarotraumaClient/WindowsClient.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma - 1.9.7.0 + 1.9.8.0 Copyright © FakeFish 2018-2024 AnyCPU;x64 Barotrauma diff --git a/Barotrauma/BarotraumaServer/LinuxServer.csproj b/Barotrauma/BarotraumaServer/LinuxServer.csproj index 0f2afa293..9d39aaae1 100644 --- a/Barotrauma/BarotraumaServer/LinuxServer.csproj +++ b/Barotrauma/BarotraumaServer/LinuxServer.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma Dedicated Server - 1.9.7.0 + 1.9.8.0 Copyright © FakeFish 2018-2023 AnyCPU;x64 DedicatedServer diff --git a/Barotrauma/BarotraumaServer/MacServer.csproj b/Barotrauma/BarotraumaServer/MacServer.csproj index fcff91b4c..e36baf22a 100644 --- a/Barotrauma/BarotraumaServer/MacServer.csproj +++ b/Barotrauma/BarotraumaServer/MacServer.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma Dedicated Server - 1.9.7.0 + 1.9.8.0 Copyright © FakeFish 2018-2023 AnyCPU;x64 DedicatedServer diff --git a/Barotrauma/BarotraumaServer/WindowsServer.csproj b/Barotrauma/BarotraumaServer/WindowsServer.csproj index 6c594e9ba..32e783019 100644 --- a/Barotrauma/BarotraumaServer/WindowsServer.csproj +++ b/Barotrauma/BarotraumaServer/WindowsServer.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma Dedicated Server - 1.9.7.0 + 1.9.8.0 Copyright © FakeFish 2018-2023 AnyCPU;x64 DedicatedServer diff --git a/Barotrauma/BarotraumaShared/LocalMods/[DebugOnlyTest]RegEx Timeout Test/RegEx Timeout Test.sub b/Barotrauma/BarotraumaShared/LocalMods/[DebugOnlyTest]RegEx Timeout Test/RegEx Timeout Test.sub new file mode 100644 index 000000000..fc53217ee Binary files /dev/null and b/Barotrauma/BarotraumaShared/LocalMods/[DebugOnlyTest]RegEx Timeout Test/RegEx Timeout Test.sub differ diff --git a/Barotrauma/BarotraumaShared/LocalMods/[DebugOnlyTest]RegEx Timeout Test/filelist.xml b/Barotrauma/BarotraumaShared/LocalMods/[DebugOnlyTest]RegEx Timeout Test/filelist.xml new file mode 100644 index 000000000..ad117a2da --- /dev/null +++ b/Barotrauma/BarotraumaShared/LocalMods/[DebugOnlyTest]RegEx Timeout Test/filelist.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Barotrauma/BarotraumaShared/SharedSource/GameAnalytics/GameAnalyticsConsent.cs b/Barotrauma/BarotraumaShared/SharedSource/GameAnalytics/GameAnalyticsConsent.cs index fe540c172..4e4e4bba4 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/GameAnalytics/GameAnalyticsConsent.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/GameAnalytics/GameAnalyticsConsent.cs @@ -282,6 +282,8 @@ namespace Barotrauma private static async Task RequestAnswerFromRemoteDatabase() { + await Task.Yield(); + static void error(string reason, Exception? exception) { DebugConsole.ThrowError($"Error in {nameof(GameAnalyticsManager)}.{nameof(RequestAnswerFromRemoteDatabase)}: {reason}", exception); diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Signal/RegExFindComponent.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Signal/RegExFindComponent.cs index a78255abd..d6cb27531 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Signal/RegExFindComponent.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Signal/RegExFindComponent.cs @@ -1,11 +1,25 @@ using System; +using System.Diagnostics; using System.Text.RegularExpressions; namespace Barotrauma.Items.Components { class RegExFindComponent : ItemComponent { - private static readonly TimeSpan timeout = TimeSpan.FromMilliseconds(1); + /// + /// The timeout should be a lot shorter (used to be 1 ms), but there seems to be an issue in .NET 8 + /// that sometimes causes the evaluation to randomly take a significant amount of time + /// (an expression that normally takes 20 ticks might sometimes take several milliseconds every few minutes). + /// So let's use a relatively long timeout instead, and measure the actual time the expression took ourselves. + /// + private static readonly TimeSpan timeout = TimeSpan.FromMilliseconds(50); + + private static readonly TimeSpan shortTimeout = TimeSpan.FromMilliseconds(1); + + private readonly Stopwatch stopwatch = new Stopwatch(); + private bool timedOut; + private int timeOutsInARow; + const int MaxTimeOutsInARow = 3; private string expression; @@ -19,6 +33,7 @@ namespace Barotrauma.Items.Components private bool nonContinuousOutputSent; + private int maxOutputLength; [Editable, Serialize(200, IsPropertySaveable.No, description: "The maximum length of the output string. Warning: Large values can lead to large memory usage or networking issues.")] public int MaxOutputLength @@ -80,7 +95,7 @@ namespace Barotrauma.Items.Components return; } //reactivate the component, in case some faulty/malicious expression caused it to time out and deactivate itself - IsActive = true; + timedOut = false; } } @@ -93,6 +108,12 @@ namespace Barotrauma.Items.Components public override void Update(float deltaTime, Camera cam) { + if (timedOut) + { + item.SendSignal("TIMEOUT", "signal_out"); + return; + } + if (string.IsNullOrWhiteSpace(expression) || regex == null) { return; } if (!ContinuousOutput && nonContinuousOutputSent) { return; } @@ -100,7 +121,26 @@ namespace Barotrauma.Items.Components { try { + stopwatch.Restart(); Match match = regex.Match(receivedSignal); + stopwatch.Stop(); + + //workaround to regex timeout issues in .NET 8, see comment on the timeout variable + if (stopwatch.Elapsed > shortTimeout) + { + timeOutsInARow++; + //if the regex times out just once every now and then, it's a symptom of the .NET 8 bug, + //if multiple times in a row, it's most likely a performance-intensive/malicious expression we should react to + if (timeOutsInARow >= MaxTimeOutsInARow) + { + throw new RegexMatchTimeoutException(); + } + } + else + { + timeOutsInARow = 0; + } + previousResult = match.Success; previousGroups = UseCaptureGroup && previousResult ? match.Groups : null; previousReceivedSignal = receivedSignal; @@ -109,9 +149,7 @@ namespace Barotrauma.Items.Components { if (e is RegexMatchTimeoutException) { - item.SendSignal("TIMEOUT", "signal_out"); - //deactivate the component if the expression caused it to time out - IsActive = false; + timedOut = true; } else { diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/Item.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/Item.cs index 330948972..7fe35e286 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Items/Item.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Items/Item.cs @@ -2333,7 +2333,6 @@ namespace Barotrauma private void SendPendingNetworkUpdatesInternal() { - DebugConsole.NewMessage($"Sending status event for item {Name}", Color.Gray); CreateStatusEvent(loadingRound: false); lastSentCondition = condition; sendConditionUpdateTimer = NetConfig.ItemConditionUpdateInterval; diff --git a/Barotrauma/BarotraumaShared/SharedSource/StatusEffects/DelayedEffect.cs b/Barotrauma/BarotraumaShared/SharedSource/StatusEffects/DelayedEffect.cs index 5a72a36cb..9c9be6e95 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/StatusEffects/DelayedEffect.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/StatusEffects/DelayedEffect.cs @@ -113,6 +113,7 @@ namespace Barotrauma public override void Apply(ActionType type, float deltaTime, Entity entity, IReadOnlyList targets, Vector2? worldPosition = null) { if (this.type != type) { return; } + if (Disabled) { return; } if (ShouldWaitForInterval(entity, deltaTime)) { return; } if (!HasRequiredItems(entity)) { return; } if (delayType == DelayTypes.ReachCursor && Character.Controlled == null) { return; } diff --git a/Barotrauma/BarotraumaShared/SharedSource/StatusEffects/StatusEffect.cs b/Barotrauma/BarotraumaShared/SharedSource/StatusEffects/StatusEffect.cs index c62d2fe39..6777e0a04 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/StatusEffects/StatusEffect.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/StatusEffects/StatusEffect.cs @@ -853,6 +853,9 @@ namespace Barotrauma } } + /// + /// Disabled effects will no longer be executed. Used to make oneshot effects only execute once. + /// public bool Disabled { get; private set; } public static StatusEffect Load(ContentXElement element, string parentDebugName) diff --git a/Barotrauma/BarotraumaShared/changelog.txt b/Barotrauma/BarotraumaShared/changelog.txt index 93a55aa61..f6878cdb4 100644 --- a/Barotrauma/BarotraumaShared/changelog.txt +++ b/Barotrauma/BarotraumaShared/changelog.txt @@ -1,4 +1,16 @@ ------------------------------------------------------------------------------------------------------------------------------------------------- +v1.9.8.0 +------------------------------------------------------------------------------------------------------------------------------------------------- + +- Fixed RegEx components occasionally timing out for no apparent reason (even if the expression isn't particularly performance-intensive). Seemed to have been caused by RegEx changes in .NET 8. +- Fixed the game sometimes freezing for a long time at a specific point during the loading screen. Only affected some players: the issue had to do with the game failing to connect to a server to check whether the player has given their consent collect gameplay analytics. +- Fixed streamed sounds always starting from the beginning when they're re-played. Particularly noticeable in the night club modules, when the music always starts from the beginning if you step outside the range of the sounds. +- Fixed distance attenuation and positioning not working on the music played by jukeboxes and bar speakers (meaning they'd play at full volume regardless of your distance to the speakers). + +Modding: +- Fixed oneshot delayed effects (which should only ever trigger once) still continuing to run some of the logic after the first trigger, causing an unnecessary performance hit. Did not seem to affect any vanilla items. + +------------------------------------------------------------------------------------------------------------------------------------------------- v1.9.7.0 ------------------------------------------------------------------------------------------------------------------------------------------------- @@ -10,7 +22,7 @@ Modding: - Fixed conditional's TargetSelf property not working on melee weapons. ------------------------------------------------------------------------------------------------------------------------------------------------- -v1.9.6.0 +v1.9.6.0 (Summer Update 2025) ------------------------------------------------------------------------------------------------------------------------------------------------- Changes and additions: @@ -159,7 +171,7 @@ v1.8.7.0 - Fixed normal outpost events triggering in outpost that have been abandoned because of Jovian Radiation. ------------------------------------------------------------------------------------------------------------------------------------------------- -v1.8.6.2 +v1.8.6.2 (Calm Before the Storm) ------------------------------------------------------------------------------------------------------------------------------------------------- - Fixed some icons still scaling incorrectly (e.g. location icons on the campaign map, device icons on the status monitor). @@ -579,7 +591,7 @@ Modding: - Fixed outpost generation parameters that reference non-existent NPC prefabs causing a crash during outpost generation. ------------------------------------------------------------------------------------------------------------------------------------------------- -v1.6.17.0 +v1.6.17.0 (Unto the Breach) ------------------------------------------------------------------------------------------------------------------------------------------------- - Fixed water currents stopping subs entirely (regardless of the size of the sub or the current). @@ -1086,7 +1098,7 @@ v1.4.5.0 - Fixed combat diving suit being slower than intended when using an underwater scooter. ------------------------------------------------------------------------------------------------------------------------------------------------- -v1.4.4.1 +v1.4.4.1 (Blood in the Water) ------------------------------------------------------------------------------------------------------------------------------------------------- - Fixed welding objective completing automatically in the basic tutorial due to the reduced flooding rates. @@ -1545,7 +1557,7 @@ v1.1.18.1 - Fixed opening the "load game" menu crashing the game if you have any corrupted/unloadable saves in the save folder. In multiplayer, this would just prevent opening the campaign setup menu without any error messages. ------------------------------------------------------------------------------------------------------------------------------------------------- -v1.1.18.0 +v1.1.18.0 (Treacherous Tides) ------------------------------------------------------------------------------------------------------------------------------------------------- - Updated translations. @@ -2247,7 +2259,7 @@ v1.0.8.0 - Fixed healing your crewmates causing your karma to decrease. --------------------------------------------------------------------------------------------------------- -v1.0.7.0 +v1.0.7.0 --------------------------------------------------------------------------------------------------------- - Fixed mechanic tutorial getting stuck at the point where you need to weld a leak. @@ -2330,7 +2342,7 @@ v1.0.1.0 - Fixed ready checks not working. --------------------------------------------------------------------------------------------------------- -v1.0.0.0 +v1.0.0.0 (Full Release) --------------------------------------------------------------------------------------------------------- Faction overhaul: @@ -2471,7 +2483,6 @@ v0.21.6.0 - Minor localization fixes. - Fixed some occasional crashes in the character editor. - --------------------------------------------------------------------------------------------------------- v0.21.5.0 --------------------------------------------------------------------------------------------------------- @@ -2958,7 +2969,7 @@ v0.19.8.0 - Fixed "completed initialization before receiving content package order" error when trying to reconnect to a SteamP2P server. --------------------------------------------------------------------------------------------------------- -v0.19.7.0 +v0.19.7.0 (Hoist the Sails) --------------------------------------------------------------------------------------------------------- Changes and additions: @@ -3339,7 +3350,7 @@ v0.18.9.0 - Backwards compatibility: readded some mission events we'd removed since the previous update. --------------------------------------------------------------------------------------------------------- -v0.18.8.0 +v0.18.8.0 (3rd Anniversary Update) --------------------------------------------------------------------------------------------------------- Balancing: @@ -3629,7 +3640,7 @@ Fixes: - Fixed occasional mission mismatch errors in multiplayer when there's a hunting grounds or beacon mission in the level. --------------------------------------------------------------------------------------------------------- -v0.17.10.0 +v0.17.10.0 (Urban Expanses) --------------------------------------------------------------------------------------------------------- Changes and additions: @@ -3873,7 +3884,7 @@ v0.16.6.1 - Fixed some of Spineling's spikes getting hidden for 30 seconds instead of 15. --------------------------------------------------------------------------------------------------------- -v0.16.6.0 +v0.16.6.0 (Rising Tide) --------------------------------------------------------------------------------------------------------- Changes and additions: @@ -4523,7 +4534,7 @@ v0.15.10.0 - Fixed harpoon rope sometimes being drawn when it's already snapped. --------------------------------------------------------------------------------------------------------- -v0.15.9.0 +v0.15.9.0 (Among the Ancients) --------------------------------------------------------------------------------------------------------- Alien ruin overhaul: @@ -4855,7 +4866,7 @@ Modding: - Fixed crashing when trying to create a thalamus when there's no wreck AI configs available in the selected content packages. --------------------------------------------------------------------------------------------------------- -v0.14.4.0 +v0.14.4.0 (Thunder Under the Ice) --------------------------------------------------------------------------------------------------------- Changes: @@ -5045,7 +5056,7 @@ Modding: - Fixed crashing if a mod's version number is incorrectly formatted in filelist.xml. --------------------------------------------------------------------------------------------------------- -v0.13.0.11 +v0.13.0.11 (Embrace the Abyss) --------------------------------------------------------------------------------------------------------- Campaign changes: @@ -5334,7 +5345,7 @@ v0.12.0.1 - Fixed ancient weapon being sometimes unable to damage ruin walls. --------------------------------------------------------------------------------------------------------- -v0.12.0.0 +v0.12.0.0 (Cave Update) --------------------------------------------------------------------------------------------------------- Cave improvements: @@ -5600,7 +5611,7 @@ v0.11.0.8 - Fixed dancing coilguns. --------------------------------------------------------------------------------------------------------- -v0.11.0.7 +v0.11.0.7 (Uncharted Depths) --------------------------------------------------------------------------------------------------------- Environment overhaul: @@ -5808,7 +5819,7 @@ v0.10.6.1 - Test changing the assignment logic for maintenance/operate orders: if the player doesn't specify the target character, use the bot who already is following the same order. The intention is to make it easier to change the target item of the order. The draw back is that ordering multiple bots to man the turrets now requires an extra step: specify the target character. --------------------------------------------------------------------------------------------------------- -v0.10.6.0 +v0.10.6.0 (Halloween 2020: Creepy Creature Feature) --------------------------------------------------------------------------------------------------------- Changes and additions: @@ -6300,7 +6311,7 @@ v0.10.1.0 - Fixed initial campaign cinematic being shown to clients who join mid-campaign. --------------------------------------------------------------------------------------------------------- -v0.10.0.0 +v0.10.0.0 (New Frontiers) --------------------------------------------------------------------------------------------------------- Improved campaign mode: @@ -6369,7 +6380,7 @@ Bugfixes: - Fixed a bug where a waypoint lost all the references when it was selected and the user pressed over an UI element, like the save button. --------------------------------------------------------------------------------------------------------- -v0.9.10.0 +v0.9.10.0 (Moloch-sized Update) --------------------------------------------------------------------------------------------------------- Additions and changes: