Skip to content

Commit 775966c

Browse files
committed
fixing issue when no one is left in char select and DGS comes back to waiting for players
1 parent a701622 commit 775966c

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

Assets/Scripts/Gameplay/GameState/ServerCharSelectState.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,12 @@ int FindLobbyPlayerIdx(ulong clientId)
149149
/// </summary>
150150
void CloseLobbyIfReady()
151151
{
152+
// If dedicated server, leave char select open if there's no one left
153+
if (DedicatedServerUtilities.IsServerBuildTarget && CharSelectData.LobbyPlayers.Count == 0)
154+
{
155+
return;
156+
}
157+
152158
foreach (CharSelectData.LobbyPlayerState playerInfo in CharSelectData.LobbyPlayers)
153159
{
154160
if (playerInfo.SeatState != CharSelectData.SeatState.LockedIn)
@@ -162,6 +168,11 @@ void CloseLobbyIfReady()
162168
SaveLobbyResults();
163169

164170
// Delay a few seconds to give the UI time to react, then switch scenes
171+
IEnumerator WaitToEndLobby()
172+
{
173+
yield return new WaitForSeconds(3);
174+
SceneLoaderWrapper.Instance.LoadScene(SceneNames.BossRoom, useNetworkSceneManager: true);
175+
}
165176
m_WaitToEndLobbyCoroutine = StartCoroutine(WaitToEndLobby());
166177
}
167178

@@ -193,11 +204,7 @@ void SaveLobbyResults()
193204
}
194205
}
195206

196-
IEnumerator WaitToEndLobby()
197-
{
198-
yield return new WaitForSeconds(3);
199-
SceneLoaderWrapper.Instance.LoadScene(SceneNames.BossRoom, useNetworkSceneManager: true);
200-
}
207+
201208

202209
public void OnNetworkDespawn()
203210
{

Assets/Scripts/Gameplay/GameplayObjects/PersistentPlayer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void RemovePersistentPlayer()
7575
if (IsServer)
7676
{
7777
var sessionPlayerData = SessionManager<SessionPlayerData>.Instance.GetPlayerData(OwnerClientId);
78-
if (sessionPlayerData.HasValue)
78+
if (sessionPlayerData.HasValue) // it's possible no session has started yet (for ex when in character select)
7979
{
8080
var playerData = sessionPlayerData.Value;
8181
playerData.PlayerName = m_NetworkNameState.Name.Value;

0 commit comments

Comments
 (0)