From 9e773b39c371ecba08b0d882db6d379e8c27a6d0 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Fri, 28 Jul 2023 22:52:10 -0400 Subject: [PATCH] Fix ClrMamePro writer issues --- SabreTools.DatFiles/Formats/ClrMamePro.Writer.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/SabreTools.DatFiles/Formats/ClrMamePro.Writer.cs b/SabreTools.DatFiles/Formats/ClrMamePro.Writer.cs index fb8c701a..dde5f2d8 100644 --- a/SabreTools.DatFiles/Formats/ClrMamePro.Writer.cs +++ b/SabreTools.DatFiles/Formats/ClrMamePro.Writer.cs @@ -141,7 +141,7 @@ namespace SabreTools.DatFiles.Formats { logger.User($"Writing to '{outfile}'..."); - var metadataFile = CreateMetadataFile(); + var metadataFile = CreateMetadataFile(ignoreblanks); if (!Serialization.ClrMamePro.SerializeToFile(metadataFile, outfile, Quotes)) { logger.Warning($"File '{outfile}' could not be written! See the log for more details."); @@ -160,12 +160,13 @@ namespace SabreTools.DatFiles.Formats /// /// Create a MetadataFile from the current internal information /// - private Models.ClrMamePro.MetadataFile CreateMetadataFile() + /// True if blank roms should be skipped on output, false otherwise + private Models.ClrMamePro.MetadataFile CreateMetadataFile(bool ignoreblanks) { var metadataFile = new Models.ClrMamePro.MetadataFile { ClrMamePro = CreateClrMamePro(), - Game = CreateGames() + Game = CreateGames(ignoreblanks) }; return metadataFile; } @@ -206,7 +207,8 @@ namespace SabreTools.DatFiles.Formats /// /// Create an array of GameBase from the current internal information /// - private Models.ClrMamePro.GameBase[]? CreateGames() + /// True if blank roms should be skipped on output, false otherwise + private Models.ClrMamePro.GameBase[]? CreateGames(bool ignoreblanks) { // If we don't have items, we can't do anything if (this.Items == null || !this.Items.Any()) @@ -252,6 +254,10 @@ namespace SabreTools.DatFiles.Formats // Loop through and convert the items to respective lists foreach (var item in items) { + // Skip if we're ignoring the item + if (ShouldIgnore(item, ignoreblanks)) + continue; + switch (item) { case Release release: