mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Fix CMP/DC parsing, strip DC down
This commit is contained in:
@@ -64,7 +64,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
if (normalizedValue == "doscenter")
|
if (normalizedValue == "doscenter")
|
||||||
ReadHeader(sr, keep);
|
ReadHeader(sr, keep);
|
||||||
|
|
||||||
// If we have a known set type
|
// If we have a game
|
||||||
else if (normalizedValue == "game" )
|
else if (normalizedValue == "game" )
|
||||||
ReadGame(sr, filename, sysid, srcid, clean, remUnicode);
|
ReadGame(sr, filename, sysid, srcid, clean, remUnicode);
|
||||||
}
|
}
|
||||||
@@ -80,8 +80,6 @@ namespace SabreTools.Library.DatFiles
|
|||||||
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
|
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
|
||||||
private void ReadHeader(StreamReader reader, bool keep)
|
private void ReadHeader(StreamReader reader, bool keep)
|
||||||
{
|
{
|
||||||
bool superdat = false;
|
|
||||||
|
|
||||||
// If there's no subtree to the header, skip it
|
// If there's no subtree to the header, skip it
|
||||||
if (reader == null || reader.EndOfStream)
|
if (reader == null || reader.EndOfStream)
|
||||||
return;
|
return;
|
||||||
@@ -97,12 +95,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
// Some dats don't have the space between "Name:" and the dat name
|
// Some dats don't have the space between "Name:" and the dat name
|
||||||
if (line.Trim().StartsWith("Name:"))
|
if (line.Trim().StartsWith("Name:"))
|
||||||
{
|
{
|
||||||
Name = (string.IsNullOrWhiteSpace(Name) ? line.Substring(6) : Name);
|
Name = (string.IsNullOrWhiteSpace(Name) ? line.Substring(6).Trim() : Name);
|
||||||
superdat = superdat || itemval.Contains(" - SuperDAT");
|
|
||||||
|
|
||||||
if (keep && superdat)
|
|
||||||
Type = (string.IsNullOrWhiteSpace(Type) ? "SuperDAT" : Type);
|
|
||||||
|
|
||||||
line = reader.ReadLine();
|
line = reader.ReadLine();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -111,11 +104,6 @@ namespace SabreTools.Library.DatFiles
|
|||||||
{
|
{
|
||||||
case "Name:":
|
case "Name:":
|
||||||
Name = (string.IsNullOrWhiteSpace(Name) ? itemval : Name);
|
Name = (string.IsNullOrWhiteSpace(Name) ? itemval : Name);
|
||||||
superdat = superdat || itemval.Contains(" - SuperDAT");
|
|
||||||
|
|
||||||
if (keep && superdat)
|
|
||||||
Type = (string.IsNullOrWhiteSpace(Type) ? "SuperDAT" : Type);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "Description:":
|
case "Description:":
|
||||||
Description = (string.IsNullOrWhiteSpace(Description) ? itemval : Description);
|
Description = (string.IsNullOrWhiteSpace(Description) ? itemval : Description);
|
||||||
@@ -246,6 +234,18 @@ namespace SabreTools.Library.DatFiles
|
|||||||
continue;
|
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();
|
line = reader.ReadLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2843,8 +2843,8 @@ namespace SabreTools.Library.Tools
|
|||||||
|
|
||||||
// Now we get each string, divided up as cleanly as possible
|
// Now we get each string, divided up as cleanly as possible
|
||||||
string[] matches = Regex
|
string[] matches = Regex
|
||||||
//.Matches(s, @"([^\s]*string.Empty[^string.Empty]+string.Empty[^\s]*)|[^string.Empty]?\w+[^string.Empty]?")
|
//.Matches(s, @"([^\s]*""[^""]+""[^\s]*)|[^""]?\w+[^""]?")
|
||||||
.Matches(s, @"[^\sstring.Empty]+|string.Empty[^string.Empty]*string.Empty")
|
.Matches(s, @"[^\s""]+|""[^""]*""")
|
||||||
.Cast<Match>()
|
.Cast<Match>()
|
||||||
.Select(m => m.Groups[0].Value)
|
.Select(m => m.Groups[0].Value)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"profiles": {
|
"profiles": {
|
||||||
"SabreTools": {
|
"SabreTools": {
|
||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"commandLineArgs": "--help update"
|
"commandLineArgs": "--update --output-dir=B:\\_TEMP --output-type=xml \"C:\\Users\\Matt\\Downloads\\DC_DAT.DAT\""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user