From c1d620bc9cc6e2ba5a4247796e6a6eee63e8d21e Mon Sep 17 00:00:00 2001 From: teascade Date: Sat, 8 Aug 2020 01:37:03 +0300 Subject: [PATCH] Remove handing of Singular Update pckts from Client --- Assets/Scripts/Networking/Instances/Client.cs | 19 +++++++++++-------- Assets/Scripts/Players/Player.cs | 2 ++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Assets/Scripts/Networking/Instances/Client.cs b/Assets/Scripts/Networking/Instances/Client.cs index 78b4f00..8ee47b8 100644 --- a/Assets/Scripts/Networking/Instances/Client.cs +++ b/Assets/Scripts/Networking/Instances/Client.cs @@ -68,22 +68,19 @@ namespace NeonTea.Quakeball.Networking.Instances { Player obj = Net.SpawnPlayer(spawn.Location).GetComponent(); NetPlayer player = new NetPlayer(spawn.PlayerId, obj); Players.Add(spawn.PlayerId, player); - } else if (packet is PlayerUpdatePckt) { - PlayerUpdatePckt updatePckt = (PlayerUpdatePckt)packet; - HandleUpdatePlayer(updatePckt); } else if (packet is MultiplePlayerUpdatesPckt) { MultiplePlayerUpdatesPckt multiple = (MultiplePlayerUpdatesPckt)packet; foreach (PlayerUpdatePckt pckt in multiple.Updates) { HandleUpdatePlayer(pckt); } + } else if (packet is MultipleSyncsPckt) { + MultipleSyncsPckt multiple = (MultipleSyncsPckt)packet; + foreach (PlayerSyncPacket pckt in multiple.Syncs) { + HandleSyncPckt(pckt); + } } else if (packet is PlayerJumpPckt) { PlayerJumpPckt jump = (PlayerJumpPckt)packet; Players[jump.PlayerId].Controlled.Jump(); - } else if (packet is PlayerSyncPacket) { - PlayerSyncPacket syncPckt = (PlayerSyncPacket)packet; - if (syncPckt.Unsynced || syncPckt.PlayerId != LocalPlayer.Id) { - Players[syncPckt.PlayerId].Controlled.ProcessSyncPacket(syncPckt); - } } } @@ -94,6 +91,12 @@ namespace NeonTea.Quakeball.Networking.Instances { Players[pckt.PlayerId].Controlled.ProcessUpdatePacket(pckt); } + private void HandleSyncPckt(PlayerSyncPacket syncPckt) { + if (syncPckt.Unsynced || syncPckt.PlayerId != LocalPlayer.Id) { + Players[syncPckt.PlayerId].Controlled.ProcessSyncPacket(syncPckt); + } + } + public override void UpdateLocalPlayer() { if (SelfIdentified && Server != null) { PlayerUpdatePckt pckt = LocalPlayer.Controlled.CreateUpdatePacket(); diff --git a/Assets/Scripts/Players/Player.cs b/Assets/Scripts/Players/Player.cs index 74d6823..062ca01 100644 --- a/Assets/Scripts/Players/Player.cs +++ b/Assets/Scripts/Players/Player.cs @@ -1,5 +1,6 @@ using UnityEngine; using NeonTea.Quakeball.Networking.Packets; +using NeonTea.Quakeball.Interface; namespace NeonTea.Quakeball.Players { /// The central glue class for players (both local and remote). @@ -90,6 +91,7 @@ namespace NeonTea.Quakeball.Players { transform.position = syncPckt.Location; GroundVelocity = syncPckt.GroundVelocity; } + Terminal.Singleton.Println($"Processing sync: {syncPckt.Unsynced}"); return ShouldApply; }