Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions Source/Common/Networking/State/ServerJoiningState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ protected override async Task RunState()
if (Server.settings.pauseOnJoin)
Server.commands.PauseAll();

// On standalone, only request a fresh join point when another player is already active.
// For the normal first join, serve the persisted state immediately instead of blocking on WaitJoinPoint.
if ((Server.IsStandaloneServer && Server.PlayingPlayers.Any()) ||
(!Server.IsStandaloneServer && Server.settings.autoJoinPoint.HasFlag(AutoJoinPointFlags.Join)))
if (!Server.IsStandaloneServer && Server.settings.autoJoinPoint.HasFlag(AutoJoinPointFlags.Join))
Server.worldData.TryStartJoinPointCreation(sourcePlayer: Player);

Server.playerManager.OnJoin(Player);
Expand Down
29 changes: 29 additions & 0 deletions Source/Tests/ServerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,35 @@ public void LoadingStateHandlesKeepAliveWhileWaitingForJoinPoint()
}
}

[Test]
public void StandaloneJoinWithExistingPlayer_DoesNotStartJoinPoint()
{
var server = MakeServer(out var port);
server.IsStandaloneServer = true;

var existingConn = new RecordingConnection("existing");
existingConn.ChangeState(ConnectionStateEnum.ServerPlaying);
var existingPlayer = new ServerPlayer(100, existingConn);
existingConn.serverPlayer = existingPlayer;
server.playerManager.Players.Add(existingPlayer);

ConnectClient(port, typeof(TestJoiningState));

var timeoutWatch = Stopwatch.StartNew();
while (true)
{
if (server.playerManager.Players.Count == 1)
break;

if (timeoutWatch.ElapsedMilliseconds > 2000)
Assert.Fail("Timeout");

Thread.Sleep(50);
}

Assert.That(server.worldData.CreatingJoinPoint, Is.False);
}

private void ConnectClient(int port, Type joiningStateType)
{
var clientListener = new TestNetListener(joiningStateType);
Expand Down
Loading