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

@@ -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