Unstable v0.19.3.0

This commit is contained in:
Juan Pablo Arce
2022-09-02 15:10:56 -03:00
parent 28789616bd
commit 3f2c843247
336 changed files with 7152 additions and 7739 deletions
@@ -4,7 +4,6 @@ using Microsoft.Xna.Framework;
using OpenAL;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
@@ -22,13 +21,13 @@ namespace Barotrauma.Networking
public static IReadOnlyList<string> CaptureDeviceNames =>
Alc.GetStringList(IntPtr.Zero, OpenAL.Alc.CaptureDeviceSpecifier);
private IntPtr captureDevice;
private readonly IntPtr captureDevice;
private Thread captureThread;
private bool capturing;
private OpusEncoder encoder;
private readonly OpusEncoder encoder;
public double LastdB
{
@@ -171,8 +170,8 @@ namespace Barotrauma.Networking
}
IntPtr nativeBuffer;
short[] uncompressedBuffer = new short[VoipConfig.BUFFER_SIZE];
short[] prevUncompressedBuffer = new short[VoipConfig.BUFFER_SIZE];
readonly short[] uncompressedBuffer = new short[VoipConfig.BUFFER_SIZE];
readonly short[] prevUncompressedBuffer = new short[VoipConfig.BUFFER_SIZE];
bool prevCaptured = true;
int captureTimer;
@@ -227,16 +226,20 @@ namespace Barotrauma.Networking
bool allowEnqueue = overrideSound != null;
if (GameMain.WindowActive && SettingsMenu.Instance is null)
{
bool usingActiveMode = PlayerInput.KeyDown(InputType.Voice);
bool usingLocalMode = PlayerInput.KeyDown(InputType.LocalVoice);
bool usingRadioMode = PlayerInput.KeyDown(InputType.RadioVoice);
bool pttDown = (usingActiveMode || usingLocalMode || usingRadioMode) && GUI.KeyboardDispatcher.Subscriber == null;
if (pttDown || captureTimer <= 0)
{
ForceLocal = (usingActiveMode && GameMain.ActiveChatMode == ChatMode.Local) || usingLocalMode;
}
if (GameSettings.CurrentConfig.Audio.VoiceSetting == VoiceMode.Activity)
{
bool pttDown = (usingLocalMode || usingRadioMode) && GUI.KeyboardDispatcher.Subscriber == null;
if (pttDown)
{
ForceLocal = usingLocalMode;
}
//in Activity mode, we default to the active mode UNLESS a specific ptt key is held
else
{
ForceLocal = GameMain.ActiveChatMode == ChatMode.Local;
}
if (dB > GameSettings.CurrentConfig.Audio.NoiseGateThreshold)
{
allowEnqueue = true;
@@ -244,6 +247,13 @@ namespace Barotrauma.Networking
}
else if (GameSettings.CurrentConfig.Audio.VoiceSetting == VoiceMode.PushToTalk)
{
//in push-to-talk mode, InputType.Voice uses the active chat mode
bool usingActiveMode = PlayerInput.KeyDown(InputType.Voice);
bool pttDown = (usingActiveMode || usingLocalMode || usingRadioMode) && GUI.KeyboardDispatcher.Subscriber == null;
if (pttDown || captureTimer <= 0)
{
ForceLocal = (usingActiveMode && GameMain.ActiveChatMode == ChatMode.Local) || usingLocalMode;
}
if (pttDown)
{
allowEnqueue = true;
@@ -72,8 +72,8 @@ namespace Barotrauma.Networking
{
IWriteMessage msg = new WriteOnlyMessage();
msg.Write((byte)ClientPacketHeader.VOICE);
msg.Write((byte)VoipCapture.Instance.QueueID);
msg.WriteByte((byte)ClientPacketHeader.VOICE);
msg.WriteByte((byte)VoipCapture.Instance.QueueID);
VoipCapture.Instance.Write(msg);
netClient.Send(msg, DeliveryMethod.Unreliable);