Skip to content

Commit 8d013de

Browse files
committed
improve async mismatch error
1 parent 5a1e9c5 commit 8d013de

3 files changed

Lines changed: 9 additions & 7 deletions

File tree

src/Backdash/Session/Backends/RemoteSession.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -615,9 +615,7 @@ void DoSync()
615615

616616
var eps = UpdateEndpoints();
617617
var specs = UpdateSpectators();
618-
619-
if (isSynchronizing) return;
620-
618+
if (isSynchronizing || closed) return;
621619
synchronizer.CheckSimulation();
622620

623621
// notify all of our endpoints of their local frame number for their next connection quality report
@@ -759,7 +757,10 @@ void OnNetworkEvent(in ProtocolEventInfo evt)
759757
if (player.Type is PlayerType.Spectator)
760758
RemoveSpectator(player);
761759
else
760+
{
762761
Close();
762+
udp.Stop();
763+
}
763764

764765
break;
765766
}
@@ -859,6 +860,9 @@ void DisconnectPlayerQueue(NetcodePlayer player, in Frame syncTo)
859860
$"Changing player {player} local connect status for last frame from {connStatus.LastFrame.Number} to {syncTo} on disconnect request (current: {frameCount})");
860861
connStatus.Disconnected = true;
861862
connStatus.LastFrame = syncTo;
863+
864+
if (closed) return;
865+
862866
if (syncTo < frameCount && !syncTo.IsNull)
863867
{
864868
logger.Write(LogLevel.Information,

src/Backdash/Session/Backends/SpectatorSession.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,7 @@ public void BeginFrame()
191191
ConsumeProtocolNetworkEvents();
192192
host.Update();
193193
jobManager.ThrowIfError();
194-
195-
if (isSynchronizing)
196-
return;
194+
if (isSynchronizing || closed) return;
197195

198196
if (lastReceivedInputTime > 0 &&
199197
Stopwatch.GetElapsedTime(lastReceivedInputTime) > options.Protocol.DisconnectTimeout)

src/Backdash/Synchronizing/Input/InputQueue.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public bool GetInput(in Frame requestedFrame, out GameInput<TInput> input)
138138

139139
// The requested frame isn't in the queue.
140140
// This means we need to return a prediction frame. Predict that the user will do the same thing they did last time.
141-
if (requestedFrame == 0)
141+
if (requestedFrame.IsZero)
142142
{
143143
logger.Write(LogLevel.Trace,
144144
$"Queue {QueueId} => basing new prediction frame from nothing, you're client wants frame 0.");

0 commit comments

Comments
 (0)