Fix Voip causing crashes
This commit is contained in:
@@ -9,7 +9,7 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
private readonly ServerPeer netServer;
|
||||
private readonly List<VoipQueue> queues;
|
||||
private readonly Dictionary<VoipQueue,DateTime> lastSendTime;
|
||||
private readonly Dictionary<VoipQueue, DateTime> lastSendTime;
|
||||
|
||||
public VoipServer(ServerPeer server)
|
||||
{
|
||||
@@ -59,7 +59,7 @@ namespace Barotrauma.Networking
|
||||
msg.WriteByte((byte)queue.QueueID);
|
||||
msg.WriteRangedSingle(distanceFactor, 0.0f, 1.0f, 8);
|
||||
queue.Write(msg);
|
||||
|
||||
|
||||
netServer.Send(msg, recipient.Connection, DeliveryMethod.Unreliable);
|
||||
}
|
||||
}
|
||||
@@ -67,10 +67,10 @@ namespace Barotrauma.Networking
|
||||
|
||||
private static bool CanReceive(Client sender, Client recipient, out float distanceFactor)
|
||||
{
|
||||
if (Screen.Selected != GameMain.GameScreen)
|
||||
if (Screen.Selected != GameMain.GameScreen)
|
||||
{
|
||||
distanceFactor = 0.0f;
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
distanceFactor = 0.0f;
|
||||
@@ -98,12 +98,22 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
var canUse = GameMain.LuaCs.Hook.Call<bool?>("canUseVoiceRadio", new object[] { sender, recipient });
|
||||
|
||||
if (canUse != null)
|
||||
if (canUse != null)
|
||||
{
|
||||
return canUse.Value;
|
||||
}
|
||||
|
||||
if (recipientRadio.CanReceive(senderRadio)) { return true; }
|
||||
if (recipientSpectating)
|
||||
{
|
||||
if (recipient.SpectatePos == null) { return true; }
|
||||
distanceFactor = MathHelper.Clamp(Vector2.Distance(sender.Character.WorldPosition, recipient.SpectatePos.Value) / senderRadio.Range, 0.0f, 1.0f);
|
||||
return distanceFactor < 1.0f;
|
||||
}
|
||||
else if (recipientRadio != null && recipientRadio.CanReceive(senderRadio))
|
||||
{
|
||||
distanceFactor = MathHelper.Clamp(Vector2.Distance(sender.Character.WorldPosition, recipient.Character.WorldPosition) / senderRadio.Range, 0.0f, 1.0f);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
float range = GameMain.LuaCs.Hook.Call<float?>("changeLocalVoiceRange", sender, recipient) ?? 1.0f;
|
||||
|
||||
Reference in New Issue
Block a user