diff --git a/BeatTogether.DedicatedServer.Kernel/DedicatedInstance.cs b/BeatTogether.DedicatedServer.Kernel/DedicatedInstance.cs index df450ed..a1dc6b2 100644 --- a/BeatTogether.DedicatedServer.Kernel/DedicatedInstance.cs +++ b/BeatTogether.DedicatedServer.Kernel/DedicatedInstance.cs @@ -325,14 +325,11 @@ public void SetState(MultiplayerGameState state) _waitForPlayerCts.Cancel(); //UserID, UserName, and session - _logger.Information("Applying session data recv from master"); - if (GetPlayerRegistry().RemoveExtraPlayerSessionDataAndApply(player)) + if (!GetPlayerRegistry().RemoveExtraPlayerSessionDataAndApply(player)) { - _logger.Information("Successfull session data extraction"); + goto EndOfTryAccept; } - _logger.Information("Client ver: " + player.PlayerClientVersion.ToString()); - _logger.Information("Client platform: " + player.PlayerPlatform.ToString()); - _logger.Information("Client PlatformUserId: " + player.PlatformUserId); + return player; @@ -354,7 +351,7 @@ public override void OnReceive(EndPoint remoteEndPoint, ref SpanBuffer reader, I public override void OnConnect(EndPoint endPoint) { - _logger.Information($"Endpoint connected (RemoteEndPoint='{endPoint}')"); + //_logger.Information($"Endpoint connected (RemoteEndPoint='{endPoint}')"); if (!_playerRegistry.TryGetPlayer(endPoint, out var player)) { @@ -390,6 +387,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 @@ -527,7 +528,7 @@ public override void OnConnect(EndPoint endPoint) Text = player.UserName + " Joined, Platform: " + player.PlayerPlatform.ToString() + " Version: " + player.PlayerClientVersion.ToString() }, IgnoranceChannelTypes.Reliable); - _logger.Information($"Sent connection data though for (RemoteEndPoint='{endPoint}')"); + //_logger.Information($"Sent connection data though for (RemoteEndPoint='{endPoint}')"); } public void DisconnectPlayer(IPlayer player) diff --git a/BeatTogether.DedicatedServer.Kernel/Managers/LobbyManager.cs b/BeatTogether.DedicatedServer.Kernel/Managers/LobbyManager.cs index c30e5b5..cd7b36e 100644 --- a/BeatTogether.DedicatedServer.Kernel/Managers/LobbyManager.cs +++ b/BeatTogether.DedicatedServer.Kernel/Managers/LobbyManager.cs @@ -222,6 +222,10 @@ private void CountingDown(bool isReady, bool NotStartable) if (CountDownState != CountdownState.WaitingForEntitlement) { SetCountdown(CountdownState.WaitingForEntitlement); + _packetDispatcher.SendToPlayers(_playerRegistry.Players.Where(p => p.GetEntitlement(SelectedBeatmap!.LevelId) == Messaging.Enums.EntitlementStatus.Unknown).ToArray(), new GetIsEntitledToLevelPacket + { + LevelId = SelectedBeatmap!.LevelId + }, IgnoranceChannelTypes.Reliable); } if (_playerRegistry.Players.All(p => (p.GetEntitlement(SelectedBeatmap!.LevelId) is EntitlementStatus.Ok) || p.IsSpectating || !p.WantsToPlayNextLevel || p.IsBackgrounded || p.ForceLateJoin)) { diff --git a/BeatTogether.DedicatedServer.Kernel/PacketHandlers/MultiplayerSession/MenuRpc/GetPlayersPermissionConfigurationPacketHandler.cs b/BeatTogether.DedicatedServer.Kernel/PacketHandlers/MultiplayerSession/MenuRpc/GetPlayersPermissionConfigurationPacketHandler.cs index 2d8dd78..14b243e 100644 --- a/BeatTogether.DedicatedServer.Kernel/PacketHandlers/MultiplayerSession/MenuRpc/GetPlayersPermissionConfigurationPacketHandler.cs +++ b/BeatTogether.DedicatedServer.Kernel/PacketHandlers/MultiplayerSession/MenuRpc/GetPlayersPermissionConfigurationPacketHandler.cs @@ -30,7 +30,7 @@ public override void Handle(IPlayer sender, GetPlayersPermissionConfigurationPac $"Handling packet of type '{nameof(GetPlayersPermissionConfigurationPacket)}' " + $"(SenderId={sender.ConnectionId})." ); - + //sends player there own permissions, and those of the player who is the current manager. bool HasManager = (_playerRegistry.TryGetPlayer(_configuration.ServerOwnerId, out var ServerOwner) && !sender.IsServerOwner); PlayerPermissionConfiguration[] playerPermissionConfigurations = new PlayerPermissionConfiguration[HasManager ? 2 : 1]; playerPermissionConfigurations[0] = new PlayerPermissionConfiguration diff --git a/BeatTogether.DedicatedServer.Kernel/Player.cs b/BeatTogether.DedicatedServer.Kernel/Player.cs index 2cf4b44..b6b5ddc 100644 --- a/BeatTogether.DedicatedServer.Kernel/Player.cs +++ b/BeatTogether.DedicatedServer.Kernel/Player.cs @@ -25,7 +25,7 @@ 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; } @@ -59,7 +59,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,