Fix issues found during testing

This commit is contained in:
Matt Nadareski
2023-08-15 01:38:01 -04:00
parent 3d99cf828f
commit ede4487cf0
56 changed files with 203 additions and 116 deletions

View File

@@ -316,7 +316,7 @@ namespace SabreTools.DatFiles
{
// Initialize strings
string fix,
game = item.Machine?.Name ?? string.Empty,
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,7 +454,7 @@ namespace SabreTools.DatFiles
name += Header.AddExtension;
if (Header.UseRomName && Header.GameName)
name = Path.Combine(item.Machine?.Name ?? string.Empty, name);
name = Path.Combine(item.Machine.Name ?? string.Empty, name);
// Now assign back the formatted name
name = $"{pre}{name}{post}";
@@ -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;

View File

@@ -121,23 +121,23 @@ namespace SabreTools.DatFiles.Formats
{
var row = new Models.AttractMode.Row
{
Name = rom.Machine?.Name,
Title = rom.Machine?.Description,
Name = rom.Machine.Name,
Title = rom.Machine.Description,
Emulator = Header.FileName,
CloneOf = rom.Machine?.CloneOf,
Year = rom.Machine?.Year,
Manufacturer = rom.Machine?.Manufacturer,
Category = rom.Machine?.Category,
Players = rom.Machine?.Players,
Rotation = rom.Machine?.Rotation,
Control = rom.Machine?.Control,
Status = rom.Machine?.Status,
DisplayCount = rom.Machine?.DisplayCount,
DisplayType = rom.Machine?.DisplayType,
CloneOf = rom.Machine.CloneOf,
Year = rom.Machine.Year,
Manufacturer = rom.Machine.Manufacturer,
Category = rom.Machine.Category,
Players = rom.Machine.Players,
Rotation = rom.Machine.Rotation,
Control = rom.Machine.Control,
Status = rom.Machine.Status,
DisplayCount = rom.Machine.DisplayCount,
DisplayType = rom.Machine.DisplayType,
AltRomname = rom.AltName,
AltTitle = rom.AltTitle,
Extra = rom.Machine?.Comment,
Buttons = rom.Machine?.Buttons,
Extra = rom.Machine.Comment,
Buttons = rom.Machine.Buttons,
// TODO: Add extended fields
};
return row;

View File

@@ -139,7 +139,7 @@ namespace SabreTools.DatFiles.Formats
var row = new Models.EverdriveSMDB.Row
{
SHA256 = rom.SHA256,
Name = $"{rom.Machine?.Name ?? string.Empty}/{rom.Name}",
Name = $"{rom.Machine.Name ?? string.Empty}/{rom.Name}",
SHA1 = rom.SHA1,
MD5 = rom.MD5,
CRC32 = rom.CRC,

View File

@@ -63,7 +63,7 @@ namespace SabreTools.DatFiles.Formats
WriteDatItem(sw, datItem, lastgame);
// Set the new data to compare against
lastgame = datItem.Machine?.Name;
lastgame = datItem.Machine.Name;
}
}
@@ -94,8 +94,8 @@ namespace SabreTools.DatFiles.Formats
// Romba mode automatically uses item name
if (Header.OutputDepot?.IsActive == true || Header.UseRomName)
sw.Write($"{datItem.GetName() ?? string.Empty}\n");
else if (!Header.UseRomName && datItem.Machine?.Name != lastgame)
sw.Write($"{datItem.Machine?.Name ?? string.Empty}\n");
else if (!Header.UseRomName && datItem.Machine.Name != lastgame)
sw.Write($"{datItem.Machine.Name ?? string.Empty}\n");
sw.Flush();
}

View File

@@ -183,14 +183,14 @@ namespace SabreTools.DatFiles.Formats
{
var rom = new Models.RomCenter.Rom
{
ParentName = item.Machine?.CloneOf,
//ParentDescription = item.Machine?.CloneOfDescription, // TODO: Add to internal model or find mapping
GameName = item.Machine?.Name,
GameDescription = item.Machine?.Description,
ParentName = item.Machine.CloneOf,
//ParentDescription = item.Machine.CloneOfDescription, // TODO: Add to internal model or find mapping
GameName = item.Machine.Name,
GameDescription = item.Machine.Description,
RomName = item.Name,
RomCRC = item.CRC,
RomSize = item.Size?.ToString(),
RomOf = item.Machine?.RomOf,
RomOf = item.Machine.RomOf,
MergeName = item.MergeTag,
};
return rom;

View File

@@ -395,11 +395,11 @@ namespace SabreTools.DatFiles.Formats
DatItem datItem = datItems[index];
// If we have a different game and we're not at the start of the list, output the end of last item
if (lastgame != null && lastgame.ToLowerInvariant() != datItem.Machine?.Name?.ToLowerInvariant())
if (lastgame != null && lastgame.ToLowerInvariant() != datItem.Machine.Name?.ToLowerInvariant())
WriteEndGame(jtw);
// If we have a new game, output the beginning of the new item
if (lastgame == null || lastgame.ToLowerInvariant() != datItem.Machine?.Name?.ToLowerInvariant())
if (lastgame == null || lastgame.ToLowerInvariant() != datItem.Machine.Name?.ToLowerInvariant())
WriteStartGame(jtw, datItem);
// Check for a "null" item
@@ -410,7 +410,7 @@ namespace SabreTools.DatFiles.Formats
WriteDatItem(jtw, datItem);
// Set the new data to compare against
lastgame = datItem.Machine?.Name;
lastgame = datItem.Machine.Name;
}
}
@@ -457,7 +457,7 @@ namespace SabreTools.DatFiles.Formats
private void WriteStartGame(JsonTextWriter jtw, DatItem datItem)
{
// No game should start with a path separator
if (!string.IsNullOrWhiteSpace(datItem.Machine?.Name))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Name))
datItem.Machine.Name = datItem.Machine.Name.TrimStart(Path.DirectorySeparatorChar) ?? string.Empty;
// Build the state

View File

@@ -223,11 +223,11 @@ namespace SabreTools.DatFiles.Formats
DatItem datItem = datItems[index];
// If we have a different game and we're not at the start of the list, output the end of last item
if (lastgame != null && lastgame.ToLowerInvariant() != datItem.Machine?.Name?.ToLowerInvariant())
if (lastgame != null && lastgame.ToLowerInvariant() != datItem.Machine.Name?.ToLowerInvariant())
WriteEndGame(xtw);
// If we have a new game, output the beginning of the new item
if (lastgame == null || lastgame.ToLowerInvariant() != datItem.Machine?.Name?.ToLowerInvariant())
if (lastgame == null || lastgame.ToLowerInvariant() != datItem.Machine.Name?.ToLowerInvariant())
WriteStartGame(xtw, datItem);
// Check for a "null" item
@@ -238,7 +238,7 @@ namespace SabreTools.DatFiles.Formats
WriteDatItem(xtw, datItem);
// Set the new data to compare against
lastgame = datItem.Machine?.Name;
lastgame = datItem.Machine.Name;
}
}

View File

@@ -162,8 +162,8 @@ namespace SabreTools.DatFiles.Formats
FileName = Header.FileName,
InternalName = Header.Name,
Description = Header.Description,
GameName = disk.Machine?.Name,
GameDescription = disk.Machine?.Description,
GameName = disk.Machine.Name,
GameDescription = disk.Machine.Description,
Type = disk.ItemType.FromItemType(),
RomName = string.Empty,
DiskName = disk.Name,
@@ -190,8 +190,8 @@ namespace SabreTools.DatFiles.Formats
FileName = Header.FileName,
InternalName = Header.Name,
Description = Header.Description,
GameName = media.Machine?.Name,
GameDescription = media.Machine?.Description,
GameName = media.Machine.Name,
GameDescription = media.Machine.Description,
Type = media.ItemType.FromItemType(),
RomName = string.Empty,
DiskName = media.Name,
@@ -218,8 +218,8 @@ namespace SabreTools.DatFiles.Formats
FileName = Header.FileName,
InternalName = Header.Name,
Description = Header.Description,
GameName = rom.Machine?.Name,
GameDescription = rom.Machine?.Description,
GameName = rom.Machine.Name,
GameDescription = rom.Machine.Description,
Type = rom.ItemType.FromItemType(),
RomName = rom.Name,
DiskName = string.Empty,

View File

@@ -728,7 +728,7 @@ namespace SabreTools.DatFiles
// Filter the list
return fi.Where(i => i != null)
.Where(i => !i.Remove)
.Where(i => i.Machine?.Name != null)
.Where(i => i.Machine.Name != null)
.ToConcurrentList();
}
}

View File

@@ -869,7 +869,7 @@ namespace SabreTools.DatFiles
// Filter the list
return fi.Where(i => i != null)
.Where(i => !i.Remove)
.Where(i => i.Machine?.Name != null)
.Where(i => i.Machine.Name != null)
.ToConcurrentList();
}
}