From f313f8aaf47a8df3d1369f0aeeeed1a6affe1a16 Mon Sep 17 00:00:00 2001 From: teascade Date: Fri, 7 Aug 2020 21:12:18 +0300 Subject: [PATCH] Add except field for Send(un)reliable to all --- Assets/Scripts/Net/Instances/Server.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/Net/Instances/Server.cs b/Assets/Scripts/Net/Instances/Server.cs index 6a0b004..9614c22 100644 --- a/Assets/Scripts/Net/Instances/Server.cs +++ b/Assets/Scripts/Net/Instances/Server.cs @@ -67,7 +67,7 @@ namespace NeonTea.Quakeball.Net.Instances { spawn = new SpawnPckt(); spawn.PlayerId = conn.uid; spawn.Location = obj.transform.position; - SendReliableToAll(spawn); + SendReliableToAll(spawn, except: spawn.PlayerId); } } else if (packet is PlayerUpdatePckt) { PlayerUpdatePckt updatePckt = (PlayerUpdatePckt)packet; @@ -78,14 +78,20 @@ namespace NeonTea.Quakeball.Net.Instances { } } - public void SendReliableToAll(Packet packet) { + public void SendReliableToAll(Packet packet, ulong except = ulong.MaxValue) { foreach (NetPlayer p in Players.Values) { + if (p.Id == ulong.MaxValue || p.Id == except) { + continue; + } Peer.SendReliable(p.Id, packet); } } - public void SendUnreliableToAll(Packet packet) { + public void SendUnreliableToAll(Packet packet, ulong except = ulong.MaxValue) { foreach (NetPlayer p in Players.Values) { + if (p.Id == ulong.MaxValue || p.Id == except) { + continue; + } Peer.SendUnreliable(p.Id, packet); } }