From 10ed37b6d97b66bc2327787019579839b3ff45d2 Mon Sep 17 00:00:00 2001 From: cubic Date: Thu, 9 May 2024 00:29:23 +0100 Subject: [PATCH] Fix joining and removed constant sync time offset --- BeatTogether.DedicatedServer.Kernel/DedicatedInstance.cs | 4 ++++ BeatTogether.DedicatedServer.Kernel/Player.cs | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/BeatTogether.DedicatedServer.Kernel/DedicatedInstance.cs b/BeatTogether.DedicatedServer.Kernel/DedicatedInstance.cs index d6b6bad..a128e0c 100644 --- a/BeatTogether.DedicatedServer.Kernel/DedicatedInstance.cs +++ b/BeatTogether.DedicatedServer.Kernel/DedicatedInstance.cs @@ -386,6 +386,10 @@ public override void OnConnect(EndPoint endPoint) //Send server infomation to player var Player_ConnectPacket = new INetSerializable[] { + new PingPacket + { + PingTime = RunTime + }, new SyncTimePacket { SyncTime = RunTime diff --git a/BeatTogether.DedicatedServer.Kernel/Player.cs b/BeatTogether.DedicatedServer.Kernel/Player.cs index e216d37..9d4c83e 100644 --- a/BeatTogether.DedicatedServer.Kernel/Player.cs +++ b/BeatTogether.DedicatedServer.Kernel/Player.cs @@ -25,8 +25,9 @@ public sealed class Player : IPlayer public RollingAverage Latency { get; } = new(30); public long SyncTime => - Math.Min(Instance.RunTime - Latency.CurrentAverage - _syncTimeOffset, + Math.Min(Instance.RunTime - Latency.CurrentAverage, Instance.RunTime); + public int SortIndex { get; set; } public byte[]? Random { get; set; } public byte[]? PublicEncryptionKey { get; set; } @@ -59,7 +60,6 @@ public sealed class Player : IPlayer public bool FinishedLevel => State.Contains("finished_level"); //If the player has finished the level public bool InMenu => State.Contains("in_menu"); //Should be true while in lobby - private const long _syncTimeOffset = 6L; private readonly ConcurrentDictionary _entitlements = new(); //Set a max amount of like 50 or something. public Player(EndPoint endPoint, IDedicatedInstance instance,