diff --git a/SabreTools.Library/DatFiles/DosCenter.cs b/SabreTools.Library/DatFiles/DosCenter.cs index 1189e116..01ef9645 100644 --- a/SabreTools.Library/DatFiles/DosCenter.cs +++ b/SabreTools.Library/DatFiles/DosCenter.cs @@ -64,7 +64,7 @@ namespace SabreTools.Library.DatFiles if (normalizedValue == "doscenter") ReadHeader(sr, keep); - // If we have a known set type + // If we have a game else if (normalizedValue == "game" ) ReadGame(sr, filename, sysid, srcid, clean, remUnicode); } @@ -80,8 +80,6 @@ namespace SabreTools.Library.DatFiles /// True if full pathnames are to be kept, false otherwise (default) private void ReadHeader(StreamReader reader, bool keep) { - bool superdat = false; - // If there's no subtree to the header, skip it if (reader == null || reader.EndOfStream) return; @@ -97,12 +95,7 @@ namespace SabreTools.Library.DatFiles // Some dats don't have the space between "Name:" and the dat name if (line.Trim().StartsWith("Name:")) { - Name = (string.IsNullOrWhiteSpace(Name) ? line.Substring(6) : Name); - superdat = superdat || itemval.Contains(" - SuperDAT"); - - if (keep && superdat) - Type = (string.IsNullOrWhiteSpace(Type) ? "SuperDAT" : Type); - + Name = (string.IsNullOrWhiteSpace(Name) ? line.Substring(6).Trim() : Name); line = reader.ReadLine(); continue; } @@ -111,11 +104,6 @@ namespace SabreTools.Library.DatFiles { case "Name:": Name = (string.IsNullOrWhiteSpace(Name) ? itemval : Name); - superdat = superdat || itemval.Contains(" - SuperDAT"); - - if (keep && superdat) - Type = (string.IsNullOrWhiteSpace(Type) ? "SuperDAT" : Type); - break; case "Description:": Description = (string.IsNullOrWhiteSpace(Description) ? itemval : Description); @@ -246,6 +234,18 @@ namespace SabreTools.Library.DatFiles continue; } + // Game-specific lines have a known pattern + GroupCollection setgc = Regex.Match(line, Constants.ItemPatternCMP).Groups; + string itemval = setgc[2].Value.Replace("\"", string.Empty); + + switch (setgc[1].Value) + { + case "name": + machine.Name = (itemval.ToLowerInvariant().EndsWith(".zip") ? itemval.Remove(itemval.Length - 4) : itemval); + machine.Description = (itemval.ToLowerInvariant().EndsWith(".zip") ? itemval.Remove(itemval.Length - 4) : itemval); + break; + } + line = reader.ReadLine(); } diff --git a/SabreTools.Library/Tools/Utilities.cs b/SabreTools.Library/Tools/Utilities.cs index a9a1b91d..0c516b43 100644 --- a/SabreTools.Library/Tools/Utilities.cs +++ b/SabreTools.Library/Tools/Utilities.cs @@ -2843,8 +2843,8 @@ namespace SabreTools.Library.Tools // Now we get each string, divided up as cleanly as possible string[] matches = Regex - //.Matches(s, @"([^\s]*string.Empty[^string.Empty]+string.Empty[^\s]*)|[^string.Empty]?\w+[^string.Empty]?") - .Matches(s, @"[^\sstring.Empty]+|string.Empty[^string.Empty]*string.Empty") + //.Matches(s, @"([^\s]*""[^""]+""[^\s]*)|[^""]?\w+[^""]?") + .Matches(s, @"[^\s""]+|""[^""]*""") .Cast() .Select(m => m.Groups[0].Value) .ToArray(); diff --git a/SabreTools/Properties/launchSettings.json b/SabreTools/Properties/launchSettings.json index 572e6910..03753970 100644 --- a/SabreTools/Properties/launchSettings.json +++ b/SabreTools/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "SabreTools": { "commandName": "Project", - "commandLineArgs": "--help update" + "commandLineArgs": "--update --output-dir=B:\\_TEMP --output-type=xml \"C:\\Users\\Matt\\Downloads\\DC_DAT.DAT\"" } } } \ No newline at end of file