mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Add nullable context to SabreTools.DatItems
This change also starts migrating the internals of the DatItem formats to the new internal models. Right now, it's basically just acting like a wrapper around those models.
This commit is contained in:
@@ -316,7 +316,7 @@ namespace SabreTools.DatFiles
|
||||
{
|
||||
// Initialize strings
|
||||
string fix,
|
||||
game = item.Machine.Name,
|
||||
game = item.Machine?.Name ?? string.Empty,
|
||||
name = item.GetName() ?? item.ItemType.ToString(),
|
||||
crc = string.Empty,
|
||||
md5 = string.Empty,
|
||||
@@ -365,9 +365,9 @@ namespace SabreTools.DatFiles
|
||||
.Replace("%game%", game)
|
||||
.Replace("%machine%", game)
|
||||
.Replace("%name%", name)
|
||||
.Replace("%manufacturer%", item.Machine.Manufacturer ?? string.Empty)
|
||||
.Replace("%publisher%", item.Machine.Publisher ?? string.Empty)
|
||||
.Replace("%category%", item.Machine.Category ?? string.Empty)
|
||||
.Replace("%manufacturer%", item.Machine?.Manufacturer ?? string.Empty)
|
||||
.Replace("%publisher%", item.Machine?.Publisher ?? string.Empty)
|
||||
.Replace("%category%", item.Machine?.Category ?? string.Empty)
|
||||
.Replace("%crc%", crc)
|
||||
.Replace("%md5%", md5)
|
||||
.Replace("%sha1%", sha1)
|
||||
@@ -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);
|
||||
@@ -454,13 +454,13 @@ namespace SabreTools.DatFiles
|
||||
name += Header.AddExtension;
|
||||
|
||||
if (Header.UseRomName && Header.GameName)
|
||||
name = Path.Combine(item.Machine.Name, name);
|
||||
name = Path.Combine(item.Machine?.Name ?? string.Empty, name);
|
||||
|
||||
// Now assign back the formatted name
|
||||
name = $"{pre}{name}{post}";
|
||||
if (Header.UseRomName)
|
||||
item.SetName(name);
|
||||
else
|
||||
else if (item.Machine != null)
|
||||
item.Machine.Name = name;
|
||||
|
||||
// Restore all relevant values
|
||||
@@ -489,7 +489,7 @@ namespace SabreTools.DatFiles
|
||||
// If the Rom has "null" characteristics, ensure all fields
|
||||
if (rom.Size == null && rom.CRC == "null")
|
||||
{
|
||||
logger.Verbose($"Empty folder found: {datItem.Machine.Name}");
|
||||
logger.Verbose($"Empty folder found: {datItem.Machine?.Name}");
|
||||
|
||||
rom.Name = (rom.Name == "null" ? "-" : rom.Name);
|
||||
rom.Size = Constants.SizeZero;
|
||||
|
||||
Reference in New Issue
Block a user