Use Null-Propagation Operator
This commit is contained in:
@@ -174,23 +174,21 @@ namespace OpenRA.Network
|
||||
foreach (var p in packets)
|
||||
{
|
||||
packetFn(p.FromClient, p.Data);
|
||||
if (Recorder != null)
|
||||
Recorder.Receive(p.FromClient, p.Data);
|
||||
Recorder?.Receive(p.FromClient, p.Data);
|
||||
}
|
||||
}
|
||||
|
||||
public void StartRecording(Func<string> chooseFilename)
|
||||
{
|
||||
// If we have a previous recording then save/dispose it and start a new one.
|
||||
if (Recorder != null)
|
||||
Recorder.Dispose();
|
||||
Recorder?.Dispose();
|
||||
Recorder = new ReplayRecorder(chooseFilename);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && Recorder != null)
|
||||
Recorder.Dispose();
|
||||
if (disposing)
|
||||
Recorder?.Dispose();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
@@ -372,8 +370,7 @@ namespace OpenRA.Network
|
||||
|
||||
// Closing the stream will cause any reads on the receiving thread to throw.
|
||||
// This will mark the connection as no longer connected and the thread will terminate cleanly.
|
||||
if (tcp != null)
|
||||
tcp.Close();
|
||||
tcp?.Close();
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
@@ -206,8 +206,7 @@ namespace OpenRA.Network
|
||||
public void Dispose()
|
||||
{
|
||||
disposed = true;
|
||||
if (Connection != null)
|
||||
Connection.Dispose();
|
||||
Connection?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -100,8 +100,7 @@ namespace OpenRA.Network
|
||||
Metadata.Write(writer);
|
||||
}
|
||||
|
||||
if (preStartBuffer != null)
|
||||
preStartBuffer.Dispose();
|
||||
preStartBuffer?.Dispose();
|
||||
writer.Close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,8 +145,7 @@ namespace OpenRA.Network
|
||||
var data = MiniYaml.FromString(order.TargetString)[0];
|
||||
var traitIndex = int.Parse(data.Key);
|
||||
|
||||
if (world != null)
|
||||
world.AddGameSaveTraitData(traitIndex, data.Value);
|
||||
world?.AddGameSaveTraitData(traitIndex, data.Value);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user