Use Null-Propagation Operator

This commit is contained in:
teinarss
2020-08-16 11:38:14 +02:00
committed by Paul Chote
parent 8d27d22100
commit 9c4fd0e3d3
113 changed files with 219 additions and 464 deletions

View File

@@ -73,8 +73,7 @@ namespace OpenRA
{
entries[Index(cell)] = value;
if (CellEntryChanged != null)
CellEntryChanged(cell);
CellEntryChanged?.Invoke(cell);
}
}
@@ -90,8 +89,7 @@ namespace OpenRA
{
entries[Index(uv)] = value;
if (CellEntryChanged != null)
CellEntryChanged(uv.ToCPos(GridType));
CellEntryChanged?.Invoke(uv.ToCPos(GridType));
}
}

View File

@@ -111,8 +111,7 @@ namespace OpenRA
}
catch (Exception e)
{
if (mapPackage != null)
mapPackage.Dispose();
mapPackage?.Dispose();
Console.WriteLine("Failed to load map: {0}", map);
Console.WriteLine("Details: {0}", e);
Log.Write("debug", "Failed to load map: {0}", map);
@@ -192,8 +191,7 @@ namespace OpenRA
foreach (var p in maps.Values)
p.UpdateRemoteSearch(MapStatus.Unavailable, null);
if (queryFailed != null)
queryFailed();
queryFailed?.Invoke();
return;
}
@@ -213,8 +211,7 @@ namespace OpenRA
{
Log.Write("debug", "Can't parse remote map search data:\n{0}", data);
Log.Write("debug", "Exception: {0}", e);
if (queryFailed != null)
queryFailed();
queryFailed?.Invoke();
}
};
@@ -298,8 +295,7 @@ namespace OpenRA
Game.RunAfterTick(() =>
{
// Wait for any existing thread to exit before starting a new one.
if (previewLoaderThread != null)
previewLoaderThread.Join();
previewLoaderThread?.Join();
previewLoaderThread = new Thread(LoadAsyncInternal)
{

View File

@@ -412,8 +412,7 @@ namespace OpenRA
if (innerData.Preview != null)
cache.CacheMinimap(this);
if (parseMetadata != null)
parseMetadata(this);
parseMetadata?.Invoke(this);
}
// Update the status and class unconditionally
@@ -522,9 +521,7 @@ namespace OpenRA
public void Delete()
{
Invalidate();
var deleteFromPackage = parentPackage as IReadWritePackage;
if (deleteFromPackage != null)
deleteFromPackage.Delete(Package.Name);
(parentPackage as IReadWritePackage)?.Delete(Package.Name);
}
Stream IReadOnlyFileSystem.Open(string filename)