From 08b8e913eb298588d9cfcc0da80c636fa9ea3399 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Fri, 14 Jun 2019 20:44:19 +0300 Subject: [PATCH] (30c3f2268) Fixed server crashing when attempting to send voip from living players to spectators --- .../BarotraumaServer/Source/Networking/Voip/VoipServer.cs | 3 +++ Barotrauma/BarotraumaShared/Source/Networking/ChatMessage.cs | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/Barotrauma/BarotraumaServer/Source/Networking/Voip/VoipServer.cs b/Barotrauma/BarotraumaServer/Source/Networking/Voip/VoipServer.cs index b282901ce..3189ab1bf 100644 --- a/Barotrauma/BarotraumaServer/Source/Networking/Voip/VoipServer.cs +++ b/Barotrauma/BarotraumaServer/Source/Networking/Voip/VoipServer.cs @@ -84,6 +84,9 @@ namespace Barotrauma.Networking //both spectating, no need to do radio/distance checks if (recipientSpectating && senderSpectating) { return true; } + //spectators can hear non-spectators + if (!senderSpectating && recipientSpectating) { return false; } + //sender can't speak if (sender.Character != null && sender.Character.SpeechImpediment >= 100.0f) { return false; } diff --git a/Barotrauma/BarotraumaShared/Source/Networking/ChatMessage.cs b/Barotrauma/BarotraumaShared/Source/Networking/ChatMessage.cs index 609348ce7..b89da7dfc 100644 --- a/Barotrauma/BarotraumaShared/Source/Networking/ChatMessage.cs +++ b/Barotrauma/BarotraumaShared/Source/Networking/ChatMessage.cs @@ -126,6 +126,10 @@ namespace Barotrauma.Networking public static float GetGarbleAmount(Entity listener, Entity sender, float range, float obstructionmult = 2.0f) { + if (listener == null || sender == null) + { + return 0.0f; + } if (listener.WorldPosition == sender.WorldPosition) { return 0.0f; } float dist = Vector2.Distance(listener.WorldPosition, sender.WorldPosition);