mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Add nullable context to SabreTools.Core
This commit is contained in:
@@ -397,7 +397,7 @@ namespace SabreTools.DatFiles
|
||||
Header.UseRomName = true;
|
||||
|
||||
// Get the name to update
|
||||
string name = (Header.UseRomName ? item.GetName() : item.Machine.Name) ?? string.Empty;
|
||||
string? name = (Header.UseRomName ? item.GetName() : item.Machine.Name) ?? string.Empty;
|
||||
|
||||
// Create the proper Prefix and Postfix
|
||||
string pre = CreatePrefixPostfix(item, true);
|
||||
@@ -411,7 +411,7 @@ namespace SabreTools.DatFiles
|
||||
// We can only write out if there's a SHA-1
|
||||
if (!string.IsNullOrWhiteSpace(disk.SHA1))
|
||||
{
|
||||
name = Utilities.GetDepotPath(disk.SHA1, Header.OutputDepot.Depth).Replace('\\', '/');
|
||||
name = Utilities.GetDepotPath(disk.SHA1, Header.OutputDepot.Depth)?.Replace('\\', '/');
|
||||
item.SetName($"{pre}{name}{post}");
|
||||
}
|
||||
}
|
||||
@@ -420,7 +420,7 @@ namespace SabreTools.DatFiles
|
||||
// We can only write out if there's a SHA-1
|
||||
if (!string.IsNullOrWhiteSpace(media.SHA1))
|
||||
{
|
||||
name = Utilities.GetDepotPath(media.SHA1, Header.OutputDepot.Depth).Replace('\\', '/');
|
||||
name = Utilities.GetDepotPath(media.SHA1, Header.OutputDepot.Depth)?.Replace('\\', '/');
|
||||
item.SetName($"{pre}{name}{post}");
|
||||
}
|
||||
}
|
||||
@@ -429,7 +429,7 @@ namespace SabreTools.DatFiles
|
||||
// We can only write out if there's a SHA-1
|
||||
if (!string.IsNullOrWhiteSpace(rom.SHA1))
|
||||
{
|
||||
name = Utilities.GetDepotPath(rom.SHA1, Header.OutputDepot.Depth).Replace('\\', '/');
|
||||
name = Utilities.GetDepotPath(rom.SHA1, Header.OutputDepot.Depth)?.Replace('\\', '/');
|
||||
item.SetName($"{pre}{name}{post}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,11 +60,11 @@ namespace SabreTools.DatFiles.Formats
|
||||
Header.HeaderSkipper ??= cmp.Header;
|
||||
Header.Type ??= cmp.Type;
|
||||
if (Header.ForceMerging == MergingFlag.None)
|
||||
Header.ForceMerging = cmp.ForceMerging.AsMergingFlag();
|
||||
Header.ForceMerging = cmp.ForceMerging?.AsMergingFlag() ?? MergingFlag.None;
|
||||
if (Header.ForcePacking == PackingFlag.None)
|
||||
Header.ForcePacking = cmp.ForceZipping.AsPackingFlag();
|
||||
Header.ForcePacking = cmp.ForceZipping?.AsPackingFlag() ?? PackingFlag.None;
|
||||
if (Header.ForcePacking == PackingFlag.None)
|
||||
Header.ForcePacking = cmp.ForcePacking.AsPackingFlag();
|
||||
Header.ForcePacking = cmp.ForcePacking?.AsPackingFlag() ?? PackingFlag.None;
|
||||
|
||||
// Handle implied SuperDAT
|
||||
if (cmp.Name?.Contains(" - SuperDAT") == true && keep)
|
||||
|
||||
@@ -1040,7 +1040,9 @@ namespace SabreTools.DatFiles
|
||||
Parallel.ForEach(keys, Globals.ParallelOptions, key =>
|
||||
{
|
||||
// Get the possibly unsorted list
|
||||
ConcurrentList<DatItem> sortedlist = this[key].ToConcurrentList();
|
||||
ConcurrentList<DatItem>? sortedlist = this[key]?.ToConcurrentList();
|
||||
if (sortedlist == null)
|
||||
return;
|
||||
|
||||
// Sort the list of items to be consistent
|
||||
DatItem.Sort(ref sortedlist, false);
|
||||
|
||||
@@ -1240,7 +1240,9 @@ CREATE TABLE IF NOT EXISTS groups (
|
||||
Parallel.ForEach(keys, Globals.ParallelOptions, key =>
|
||||
{
|
||||
// Get the possibly unsorted list
|
||||
ConcurrentList<DatItem> sortedlist = this[key].ToConcurrentList();
|
||||
ConcurrentList<DatItem>? sortedlist = this[key]?.ToConcurrentList();
|
||||
if (sortedlist == null)
|
||||
return;
|
||||
|
||||
// Sort the list of items to be consistent
|
||||
DatItem.Sort(ref sortedlist, false);
|
||||
|
||||
Reference in New Issue
Block a user