Release 1.9.7.0 - Summer Update 2025

This commit is contained in:
Regalis11
2025-06-17 16:38:11 +03:00
parent 22227f13e5
commit ea5a2bc693
297 changed files with 7344 additions and 2421 deletions
@@ -17,11 +17,15 @@ namespace Barotrauma.Sounds
private short[] sampleBuffer = Array.Empty<short>();
private short[] muffleBuffer = Array.Empty<short>();
private readonly double durationSeconds;
public override double? DurationSeconds => durationSeconds;
public OggSound(SoundManager owner, string filename, bool stream, ContentXElement xElement) : base(owner, filename,
stream, true, xElement)
{
var reader = new VorbisReader(Filename);
durationSeconds = reader.TotalTime.TotalSeconds;
ALFormat = reader.Channels == 1 ? Al.FormatMono16 : Al.FormatStereo16;
SampleRate = reader.SampleRate;
@@ -1,8 +1,6 @@
using System;
using OpenAL;
using Barotrauma.IO;
using Microsoft.Xna.Framework;
using Barotrauma.IO;
using System.Xml.Linq;
using System;
namespace Barotrauma.Sounds
{
@@ -24,6 +22,11 @@ namespace Barotrauma.Sounds
public readonly bool StreamsReliably;
/// <summary>
/// Length of the audio in seconds. Null if the length is unknown (e.g. a streaming audio source).
/// </summary>
public abstract double? DurationSeconds { get; }
public bool Loading { get; protected set; }
private readonly SoundManager.SourcePoolIndex sourcePoolIndex = SoundManager.SourcePoolIndex.Default;
@@ -778,34 +778,36 @@ namespace Barotrauma.Sounds
while (!killThread)
{
killThread = true;
for (int i = 0; i < playingChannels.Length; i++)
for (int sourcePoolIndex = 0; sourcePoolIndex < playingChannels.Length; sourcePoolIndex++)
{
lock (playingChannels[i])
lock (playingChannels[sourcePoolIndex])
{
for (int j = 0; j < playingChannels[i].Length; j++)
for (int channelIndex = 0; channelIndex < playingChannels[sourcePoolIndex].Length; channelIndex++)
{
if (playingChannels[i][j] == null) { continue; }
if (playingChannels[i][j].IsStream)
var channel = playingChannels[sourcePoolIndex][channelIndex];
if (channel == null) { continue; }
if (channel.FadingOutAndDisposing)
{
if (playingChannels[i][j].IsPlaying)
killThread = false;
channel.Gain -= 0.1f;
if (channel.Gain <= 0.0f)
{
channel.Dispose();
playingChannels[sourcePoolIndex][channelIndex] = null;
}
}
else if (channel.IsStream)
{
if (channel.IsPlaying)
{
killThread = false;
playingChannels[i][j].UpdateStream();
channel.UpdateStream();
}
else
{
playingChannels[i][j].Dispose();
playingChannels[i][j] = null;
}
}
else if (playingChannels[i][j].FadingOutAndDisposing)
{
killThread = false;
playingChannels[i][j].Gain -= 0.1f;
if (playingChannels[i][j].Gain <= 0.0f)
{
playingChannels[i][j].Dispose();
playingChannels[i][j] = null;
channel.Dispose();
playingChannels[sourcePoolIndex][channelIndex] = null;
}
}
}
@@ -868,10 +868,28 @@ namespace Barotrauma
if (Level.IsLoadedOutpost)
{
// Only return music type for location types which have music tracks defined
var locationType = Level.Loaded.StartLocation?.Type?.Identifier;
if (locationType.HasValue && locationType != Identifier.Empty && musicClips.Any(c => c.Type == locationType))
var locationType = Level.Loaded?.StartLocation?.Type?.Identifier;
var backgroundMusicIdentifier = Level.Loaded?.StartLocation?.Type?.BackgroundMusicLocationType;
if (MatchesTrack(backgroundMusicIdentifier, out Identifier id) ||
MatchesTrack(locationType, out id))
{
return locationType.Value;
return id;
}
bool MatchesTrack(Identifier? identifier, out Identifier idValue)
{
if (identifier.HasValue && identifier.Value != Identifier.Empty)
{
if (musicClips.Any(clip => clip.Type == identifier.Value))
{
idValue = identifier.Value;
return true;
}
}
idValue = Identifier.Empty;
return false;
}
}
}
@@ -1,23 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenAL;
using Barotrauma.Media;
using Microsoft.Xna.Framework;
using System.Runtime.InteropServices;
using System.Threading;
using Barotrauma.Media;
using OpenAL;
using System;
using System.Collections.Generic;
namespace Barotrauma.Sounds
{
class VideoSound : Sound
{
private readonly object mutex;
private Queue<short[]> sampleQueue;
private readonly Queue<short[]> sampleQueue;
private SoundChannel soundChannel;
private Video video;
private readonly Video video;
public override double? DurationSeconds => null;
public VideoSound(SoundManager owner, string filename, int sampleRate, int channelCount, Video vid) : base(owner, filename, true, false)
{
@@ -8,6 +8,8 @@ namespace Barotrauma.Sounds
{
class VoipSound : Sound
{
public override double? DurationSeconds => null;
public override SoundManager.SourcePoolIndex SourcePoolIndex
{
get