diff --git a/VoiceCraft.Maui/VoiceCraft/VoiceCraftClient.cs b/VoiceCraft.Maui/VoiceCraft/VoiceCraftClient.cs index 71edce7a..c9189e25 100644 --- a/VoiceCraft.Maui/VoiceCraft/VoiceCraftClient.cs +++ b/VoiceCraft.Maui/VoiceCraft/VoiceCraftClient.cs @@ -345,7 +345,6 @@ private void VoiceCraftSocketJoinChannel(Core.Packets.VoiceCraft.JoinChannel dat { if(Channels.TryGetValue(data.ChannelId, out var channel) && channel != JoinedChannel) { - ClearParticipants(); JoinedChannel = channel; OnChannelJoined?.Invoke(channel); } diff --git a/VoiceCraft.Server/Data/VoiceCraftParticipant.cs b/VoiceCraft.Server/Data/VoiceCraftParticipant.cs index dcd542ef..5f78b523 100644 --- a/VoiceCraft.Server/Data/VoiceCraftParticipant.cs +++ b/VoiceCraft.Server/Data/VoiceCraftParticipant.cs @@ -35,6 +35,8 @@ public static short GenerateKey() public enum ParticipantBitmask : ushort { + All = ushort.MaxValue, // 1111 1111 1111 1111 + None = 0, // 0000 0000 0000 0000 DeathEnabled = 1, // 0000 0000 0000 0001 ProximityEnabled = 2, // 0000 0000 0000 0010 WaterEffectEnabled = 4, // 0000 0000 0000 0100 diff --git a/VoiceCraft.Server/VoiceCraftServer.cs b/VoiceCraft.Server/VoiceCraftServer.cs index 2d10ea2f..7d6edb51 100644 --- a/VoiceCraft.Server/VoiceCraftServer.cs +++ b/VoiceCraft.Server/VoiceCraftServer.cs @@ -143,7 +143,7 @@ public void MoveParticipantToChannel(NetPeer peer, VoiceCraftParticipant client, if (client.Channel == channel) return; //Client is already in the channel, do nothing. - //Tell the client to leave the previous channel/reset if hidden. + //Tell the client to leave the previous channel/reset even if the channel is hidden. peer.AddToSendBuffer(new Core.Packets.VoiceCraft.LeaveChannel()); //Tell the other clients that the participant has left the channel. @@ -488,9 +488,8 @@ private void OnClientAudio(Core.Packets.VoiceCraft.ClientAudio data, NetPeer pee (((x.Value.ChecksBitmask >> 6) & (client.ChecksBitmask >> 11)) != 0) ); //Get Participants - for (ushort i = 0; i < list.Count(); i++) + foreach(var participant in list) { - var participant = list.ElementAt(i); var volume = ((participant.Value.ChecksBitmask | client.ChecksBitmask) & (ushort)ParticipantBitmask.ProximityEnabled) != 0 ? 1.0f - Math.Clamp(Vector3.Distance(participant.Value.Position, client.Position) / proximityDistance, 0.0f, 1.0f) : 1.0f; var echo = ((participant.Value.ChecksBitmask | client.ChecksBitmask) & (ushort)ParticipantBitmask.EchoEffectEnabled) != 0 && voiceEffects ? Math.Max(participant.Value.CaveDensity, client.CaveDensity) * (1.0f - volume) : 0.0f; var muffled = ((participant.Value.ChecksBitmask | client.ChecksBitmask) & (ushort)ParticipantBitmask.WaterEffectEnabled) != 0 && voiceEffects && (participant.Value.InWater || client.InWater);