Skip to content

Commit

Permalink
WIP: Refactor LobbyManager countdown
Browse files Browse the repository at this point in the history
Probably some internal logic being broken and causing the countdown to be skipped
  • Loading branch information
michael-r-elp committed Dec 19, 2023
1 parent 444d1e6 commit 6a2c70c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public interface ILobbyManager
BeatmapIdentifier? SelectedBeatmap { get; }
GameplayModifiers SelectedModifiers { get; }
CountdownState CountDownState { get; }
float CountdownEndTime { get; }
long CountdownEndTime { get; }
GameplayModifiers EmptyModifiers {get; }
public bool SpectatingPlayersUpdated { get; set; }
public bool ForceStartSelectedBeatmap { get; set; }
Expand Down
12 changes: 7 additions & 5 deletions BeatTogether.DedicatedServer.Kernel/Managers/LobbyManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public sealed class LobbyManager : ILobbyManager, IDisposable
public BeatmapIdentifier? SelectedBeatmap { get; private set; } = null;
public GameplayModifiers SelectedModifiers { get; private set; } = new();
public CountdownState CountDownState { get; private set; } = CountdownState.NotCountingDown;
public float CountdownEndTime { get; private set; } = 0;
public long CountdownEndTime { get; private set; } = 0;

private BeatmapIdentifier? _lastBeatmap = null;
private bool _lastSpectatorState;
Expand Down Expand Up @@ -352,9 +352,10 @@ public BeatmapDifficulty[] GetSelectedBeatmapDifficulties()


// Sets countdown and beatmap how the client would expect it to
// If you want to cancel the countdown use CancelCountdown(), Not SetCountdown as CancelCountdown() ALSO informs the clients it has been canceled, whereas SetCountdown will now
private void SetCountdown(CountdownState countdownState, float countdown = 0)
// If you want to cancel the countdown use CancelCountdown(), Not SetCountdown as CancelCountdown() ALSO informs the clients it has been canceled, whereas SetCountdown will not
private void SetCountdown(CountdownState countdownState, long countdown = 0)
{
_logger.Error($"CountdownEndTime currently is '{CountdownEndTime}' countdown is set to '{countdown}' state will be set to '{countdownState}'");
CountDownState = countdownState;
switch (CountDownState)
{
Expand All @@ -365,7 +366,7 @@ private void SetCountdown(CountdownState countdownState, float countdown = 0)
break;
case CountdownState.CountingDown:
if (countdown == 0)
countdown = 30f;
countdown = 30*2;
CountdownEndTime = _instance.RunTime + countdown;
_packetDispatcher.SendToNearbyPlayers(new SetCountdownEndTimePacket
{
Expand All @@ -374,14 +375,15 @@ private void SetCountdown(CountdownState countdownState, float countdown = 0)
break;
case CountdownState.StartBeatmapCountdown:
if (countdown == 0)
countdown = 5f;
countdown = 5*2;
CountdownEndTime = _instance.RunTime + countdown;
StartBeatmapPacket();
break;
case CountdownState.WaitingForEntitlement:
StartBeatmapPacket();
break;
}
_logger.Error($"CountdownEndTime final set to '{CountdownEndTime}' CountdownState '{CountDownState}' countdown is '{countdown}' RunTime is '{_instance.RunTime}'");
}

//Checks the lobby settings and sends the player the correct beatmap
Expand Down

0 comments on commit 6a2c70c

Please sign in to comment.