Skip to content

Commit cfc4940

Browse files
committed
lint fixes
1 parent a20c2f3 commit cfc4940

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

src/Backdash/Backends/RemoteBackend.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ void DisconnectPlayerQueue(in PlayerHandle player, in Frame syncTo)
698698
$"Changing player {player} local connect status for last frame from {connStatus.LastFrame} to {syncTo} on disconnect request (current: {frameCount})");
699699
connStatus.Disconnected = true;
700700
connStatus.LastFrame = syncTo;
701-
if (syncTo < frameCount)
701+
if (syncTo < frameCount && syncTo.IsNotNull)
702702
{
703703
logger.Write(LogLevel.Information,
704704
$"adjusting simulation to account for the fact that {player} disconnected on frame {syncTo}");

src/Backdash/Core/BackgroundJob.cs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,15 @@ public async Task Start(CancellationToken cancellationToken)
3131
{
3232
if (isRunning) return;
3333
if (jobs.Count is 0) throw new NetcodeException("No jobs registered");
34-
cancellationToken.Register(() => Stop(TimeSpan.Zero));
34+
3535
logger.Write(LogLevel.Debug, "Starting background tasks");
36-
foreach (var job in jobs) AddJobTask(new(job.Job, job.StoppingToken));
36+
cancellationToken.Register(() => Stop(TimeSpan.Zero));
37+
38+
foreach (var job in jobs)
39+
AddJobTask(new(job.Job, job.StoppingToken));
40+
3741
isRunning = true;
42+
3843
while (tasks.Keys.Any(x => !x.IsCompleted))
3944
{
4045
var completed = await Task.WhenAny(tasks.Keys).ConfigureAwait(false);
@@ -54,19 +59,18 @@ void AddJobTask(JobEntry entry)
5459
logger.Write(LogLevel.Trace, $"job {job.JobName} start");
5560
var task = Task.Run(async () =>
5661
{
57-
var jobCancellation = entry.StoppingToken;
58-
using var linkedCts = CancellationTokenSource.CreateLinkedTokenSource(StoppingToken, jobCancellation);
62+
using var linkedCts = CancellationTokenSource.CreateLinkedTokenSource(StoppingToken, entry.StoppingToken);
5963
try
6064
{
6165
await job.Start(linkedCts.Token).ConfigureAwait(false);
6266
}
6367
catch (OperationCanceledException)
6468
{
65-
logger.Write(LogLevel.Trace, $"job {job.JobName} stopped");
69+
logger.Write(LogLevel.Debug, $"job {job.JobName} stopped");
6670
}
6771
catch (ChannelClosedException)
6872
{
69-
logger.Write(LogLevel.Trace, $"job {job.JobName} channel closed");
73+
logger.Write(LogLevel.Debug, $"job {job.JobName} channel closed");
7074
}
7175
catch (Exception ex)
7276
{
@@ -87,21 +91,21 @@ public void ThrowIfError()
8791
public void Register(IBackgroundJob job, CancellationToken cancellationToken = default)
8892
{
8993
JobEntry entry = new(job, cancellationToken);
90-
if (!jobs.Add(entry))
91-
return;
92-
if (!isRunning) return;
93-
AddJobTask(entry);
94+
if (!jobs.Add(entry)) return;
95+
if (isRunning)
96+
AddJobTask(entry);
9497
}
9598

9699
public void Stop(TimeSpan timeout = default)
97100
{
98101
if (!isRunning) return;
99102
isRunning = false;
100-
if (!cts.IsCancellationRequested)
101-
if (timeout <= TimeSpan.Zero)
102-
cts.Cancel();
103-
else
104-
cts.CancelAfter(timeout);
103+
if (cts.IsCancellationRequested) return;
104+
105+
if (timeout <= TimeSpan.Zero)
106+
cts.Cancel();
107+
else
108+
cts.CancelAfter(timeout);
105109
}
106110

107111
public void Dispose()

src/Backdash/Synchronizing/Input/IRandomInputGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public interface IInputGenerator<out TInput> where TInput : unmanaged
1313
/// <summary>
1414
/// Returns the next input
1515
/// </summary>
16-
public TInput Generate();
16+
TInput Generate();
1717
}
1818

1919
/// <summary>

0 commit comments

Comments
 (0)