mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[Structs] Add Machine struct
This commit is contained in:
@@ -46,8 +46,7 @@ namespace SabreTools.Helper
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public struct Rom : IComparable, IEquatable<Rom>
|
public struct Rom : IComparable, IEquatable<Rom>
|
||||||
{
|
{
|
||||||
public string Game;
|
public Machine Game;
|
||||||
public string GameDescription;
|
|
||||||
public string Name;
|
public string Name;
|
||||||
public string Type;
|
public string Type;
|
||||||
public HashData HashData;
|
public HashData HashData;
|
||||||
@@ -67,7 +66,7 @@ namespace SabreTools.Helper
|
|||||||
{
|
{
|
||||||
Rom comp = (Rom)obj;
|
Rom comp = (Rom)obj;
|
||||||
|
|
||||||
if (this.Game == comp.Game)
|
if (this.Game.Name == comp.Game.Name)
|
||||||
{
|
{
|
||||||
if (this.Name == comp.Name)
|
if (this.Name == comp.Name)
|
||||||
{
|
{
|
||||||
@@ -75,7 +74,7 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
ret = String.Compare(this.Name, comp.Name);
|
ret = String.Compare(this.Name, comp.Name);
|
||||||
}
|
}
|
||||||
ret = String.Compare(this.Game, comp.Game);
|
ret = String.Compare(this.Game.Name, comp.Game.Name);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@@ -93,7 +92,7 @@ namespace SabreTools.Helper
|
|||||||
bool isdupe = RomTools.IsDuplicate(this, other, temp);
|
bool isdupe = RomTools.IsDuplicate(this, other, temp);
|
||||||
temp.Close();
|
temp.Close();
|
||||||
|
|
||||||
return (this.Game == other.Game &&
|
return (this.Game.Name == other.Game.Name &&
|
||||||
this.Name == other.Name &&
|
this.Name == other.Name &&
|
||||||
isdupe);
|
isdupe);
|
||||||
}
|
}
|
||||||
@@ -110,6 +109,25 @@ namespace SabreTools.Helper
|
|||||||
public string Source;
|
public string Source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Intermediate struct for holding and processing Rom/Machine data
|
||||||
|
/// </summary>
|
||||||
|
public struct Machine
|
||||||
|
{
|
||||||
|
public string Name;
|
||||||
|
public string Comment;
|
||||||
|
public string Description;
|
||||||
|
public string Year;
|
||||||
|
public string Manufacturer;
|
||||||
|
public string RomOf;
|
||||||
|
public string CloneOf;
|
||||||
|
public string SampleOf;
|
||||||
|
public string SourceFile;
|
||||||
|
public bool IsBios;
|
||||||
|
public string Board;
|
||||||
|
public string RebuildTo;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Intermediate struct for holding DAT information
|
/// Intermediate struct for holding DAT information
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -538,7 +538,10 @@ namespace SabreTools.Helper
|
|||||||
{
|
{
|
||||||
Type = "rom",
|
Type = "rom",
|
||||||
Name = reader.Entry.Key,
|
Name = reader.Entry.Key,
|
||||||
Game = gamename,
|
Game = new Machine
|
||||||
|
{
|
||||||
|
Name = gamename,
|
||||||
|
},
|
||||||
HashData = new HashData
|
HashData = new HashData
|
||||||
{
|
{
|
||||||
Size = (size == 0 ? reader.Entry.Size : size),
|
Size = (size == 0 ? reader.Entry.Size : size),
|
||||||
@@ -618,7 +621,10 @@ namespace SabreTools.Helper
|
|||||||
Rom rom = new Rom
|
Rom rom = new Rom
|
||||||
{
|
{
|
||||||
Type = "rom",
|
Type = "rom",
|
||||||
Game = Path.GetFileNameWithoutExtension(input).ToLowerInvariant(),
|
Game = new Machine
|
||||||
|
{
|
||||||
|
Name = Path.GetFileNameWithoutExtension(input).ToLowerInvariant(),
|
||||||
|
},
|
||||||
Name = Path.GetFileNameWithoutExtension(input).ToLowerInvariant(),
|
Name = Path.GetFileNameWithoutExtension(input).ToLowerInvariant(),
|
||||||
HashData = new HashData
|
HashData = new HashData
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -172,8 +172,11 @@ namespace SabreTools.Helper
|
|||||||
|
|
||||||
Rom rom = new Rom
|
Rom rom = new Rom
|
||||||
{
|
{
|
||||||
Game = gamename,
|
Game = new Machine
|
||||||
GameDescription = gamedesc,
|
{
|
||||||
|
Name = gamename,
|
||||||
|
Description = gamedesc,
|
||||||
|
},
|
||||||
Type = (line.Trim().StartsWith("disk (") ? "disk" : "rom"),
|
Type = (line.Trim().StartsWith("disk (") ? "disk" : "rom"),
|
||||||
Metadata = new SourceMetadata { SystemID = sysid, SourceID = srcid },
|
Metadata = new SourceMetadata { SystemID = sysid, SourceID = srcid },
|
||||||
};
|
};
|
||||||
@@ -565,8 +568,11 @@ namespace SabreTools.Helper
|
|||||||
|
|
||||||
Rom rom = new Rom
|
Rom rom = new Rom
|
||||||
{
|
{
|
||||||
Game = rominfo[3],
|
Game = new Machine
|
||||||
GameDescription = rominfo[4],
|
{
|
||||||
|
Name = rominfo[3],
|
||||||
|
Description = rominfo[4],
|
||||||
|
},
|
||||||
Name = rominfo[5],
|
Name = rominfo[5],
|
||||||
HashData = new HashData
|
HashData = new HashData
|
||||||
{
|
{
|
||||||
@@ -675,8 +681,11 @@ namespace SabreTools.Helper
|
|||||||
{
|
{
|
||||||
Type = "rom",
|
Type = "rom",
|
||||||
Name = "null",
|
Name = "null",
|
||||||
Game = tempgame,
|
Game = new Machine
|
||||||
GameDescription = tempgame,
|
{
|
||||||
|
Name = tempgame,
|
||||||
|
Description = tempgame,
|
||||||
|
},
|
||||||
HashData = new HashData
|
HashData = new HashData
|
||||||
{
|
{
|
||||||
Size = -1,
|
Size = -1,
|
||||||
@@ -1120,8 +1129,11 @@ namespace SabreTools.Helper
|
|||||||
|
|
||||||
Rom rom = new Rom
|
Rom rom = new Rom
|
||||||
{
|
{
|
||||||
Game = tempname,
|
Game = new Machine
|
||||||
GameDescription = gamedesc,
|
{
|
||||||
|
Name = tempname,
|
||||||
|
Description = gamedesc,
|
||||||
|
},
|
||||||
Name = subreader.GetAttribute("name"),
|
Name = subreader.GetAttribute("name"),
|
||||||
Type = subreader.Name,
|
Type = subreader.Name,
|
||||||
HashData = new HashData
|
HashData = new HashData
|
||||||
@@ -1178,8 +1190,11 @@ namespace SabreTools.Helper
|
|||||||
{
|
{
|
||||||
Type = "rom",
|
Type = "rom",
|
||||||
Name = "null",
|
Name = "null",
|
||||||
Game = tempname,
|
Game = new Machine
|
||||||
GameDescription = tempname,
|
{
|
||||||
|
Name = tempname,
|
||||||
|
Description = tempname,
|
||||||
|
},
|
||||||
HashData = new HashData
|
HashData = new HashData
|
||||||
{
|
{
|
||||||
Size = -1,
|
Size = -1,
|
||||||
@@ -1354,7 +1369,10 @@ namespace SabreTools.Helper
|
|||||||
|
|
||||||
Rom rom = new Rom
|
Rom rom = new Rom
|
||||||
{
|
{
|
||||||
Game = tempname,
|
Game = new Machine
|
||||||
|
{
|
||||||
|
Name = tempname,
|
||||||
|
},
|
||||||
Name = xtr.GetAttribute("name"),
|
Name = xtr.GetAttribute("name"),
|
||||||
Type = xtr.GetAttribute("type"),
|
Type = xtr.GetAttribute("type"),
|
||||||
HashData = new HashData
|
HashData = new HashData
|
||||||
@@ -1452,7 +1470,13 @@ namespace SabreTools.Helper
|
|||||||
foreach (Rom rom in roms)
|
foreach (Rom rom in roms)
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
string newkey = (norename ? "" : rom.Metadata.SystemID.ToString().PadLeft(10, '0') + "-" + rom.Metadata.SourceID.ToString().PadLeft(10, '0') + "-") + (String.IsNullOrEmpty(rom.Game) ? "" : rom.Game.ToLowerInvariant());
|
string newkey = (norename ? ""
|
||||||
|
: rom.Metadata.SystemID.ToString().PadLeft(10, '0')
|
||||||
|
+ "-"
|
||||||
|
+ rom.Metadata.SourceID.ToString().PadLeft(10, '0') + "-")
|
||||||
|
+ (String.IsNullOrEmpty(rom.Game.Name)
|
||||||
|
? ""
|
||||||
|
: rom.Game.Name.ToLowerInvariant());
|
||||||
if (sortable.ContainsKey(newkey))
|
if (sortable.ContainsKey(newkey))
|
||||||
{
|
{
|
||||||
sortable[newkey].Add(rom);
|
sortable[newkey].Add(rom);
|
||||||
@@ -1808,15 +1832,15 @@ namespace SabreTools.Helper
|
|||||||
// Filter on game name
|
// Filter on game name
|
||||||
if (gamename != "")
|
if (gamename != "")
|
||||||
{
|
{
|
||||||
if (gamename.StartsWith("*") && gamename.EndsWith("*") && !rom.Game.ToLowerInvariant().Contains(gamename.ToLowerInvariant().Replace("*", "")))
|
if (gamename.StartsWith("*") && gamename.EndsWith("*") && !rom.Game.Name.ToLowerInvariant().Contains(gamename.ToLowerInvariant().Replace("*", "")))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (gamename.StartsWith("*") && !rom.Game.EndsWith(gamename.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
else if (gamename.StartsWith("*") && !rom.Game.Name.EndsWith(gamename.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (gamename.EndsWith("*") && !rom.Game.StartsWith(gamename.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
else if (gamename.EndsWith("*") && !rom.Game.Name.StartsWith(gamename.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1916,14 +1940,14 @@ namespace SabreTools.Helper
|
|||||||
// If we are in single game mode, rename all games
|
// If we are in single game mode, rename all games
|
||||||
if (single)
|
if (single)
|
||||||
{
|
{
|
||||||
rom.Game = "!";
|
rom.Game.Name = "!";
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we are in NTFS trim mode, trim the game name
|
// If we are in NTFS trim mode, trim the game name
|
||||||
if (trim)
|
if (trim)
|
||||||
{
|
{
|
||||||
// Windows max name length is 260
|
// Windows max name length is 260
|
||||||
int usableLength = 260 - rom.Game.Length - root.Length;
|
int usableLength = 260 - rom.Game.Name.Length - root.Length;
|
||||||
if (rom.Name.Length > usableLength)
|
if (rom.Name.Length > usableLength)
|
||||||
{
|
{
|
||||||
string ext = Path.GetExtension(rom.Name);
|
string ext = Path.GetExtension(rom.Name);
|
||||||
@@ -2047,7 +2071,7 @@ namespace SabreTools.Helper
|
|||||||
if ((diff & DiffMode.NoDupes) != 0)
|
if ((diff & DiffMode.NoDupes) != 0)
|
||||||
{
|
{
|
||||||
Rom newrom = rom;
|
Rom newrom = rom;
|
||||||
newrom.Game += " (" + Path.GetFileNameWithoutExtension(inputs[newrom.Metadata.SystemID].Split('¬')[0]) + ")";
|
newrom.Game.Name += " (" + Path.GetFileNameWithoutExtension(inputs[newrom.Metadata.SystemID].Split('¬')[0]) + ")";
|
||||||
|
|
||||||
if (outerDiffData.Roms.ContainsKey(key))
|
if (outerDiffData.Roms.ContainsKey(key))
|
||||||
{
|
{
|
||||||
@@ -2069,7 +2093,7 @@ namespace SabreTools.Helper
|
|||||||
if (rom.Dupe >= DupeType.ExternalHash)
|
if (rom.Dupe >= DupeType.ExternalHash)
|
||||||
{
|
{
|
||||||
Rom newrom = rom;
|
Rom newrom = rom;
|
||||||
newrom.Game += " (" + Path.GetFileNameWithoutExtension(inputs[newrom.Metadata.SystemID].Split('¬')[0]) + ")";
|
newrom.Game.Name += " (" + Path.GetFileNameWithoutExtension(inputs[newrom.Metadata.SystemID].Split('¬')[0]) + ")";
|
||||||
|
|
||||||
if (dupeData.Roms.ContainsKey(key))
|
if (dupeData.Roms.ContainsKey(key))
|
||||||
{
|
{
|
||||||
@@ -2241,9 +2265,9 @@ namespace SabreTools.Helper
|
|||||||
|
|
||||||
rootpath += (rootpath == "" ? "" : Path.DirectorySeparatorChar.ToString());
|
rootpath += (rootpath == "" ? "" : Path.DirectorySeparatorChar.ToString());
|
||||||
filename = filename.Remove(0, rootpath.Length);
|
filename = filename.Remove(0, rootpath.Length);
|
||||||
newrom.Game = Path.GetDirectoryName(filename) + Path.DirectorySeparatorChar
|
newrom.Game.Name = Path.GetDirectoryName(filename) + Path.DirectorySeparatorChar
|
||||||
+ Path.GetFileNameWithoutExtension(filename) + Path.DirectorySeparatorChar
|
+ Path.GetFileNameWithoutExtension(filename) + Path.DirectorySeparatorChar
|
||||||
+ newrom.Game;
|
+ newrom.Game.Name;
|
||||||
newroms.Add(newrom);
|
newroms.Add(newrom);
|
||||||
}
|
}
|
||||||
userData.Roms[key] = newroms;
|
userData.Roms[key] = newroms;
|
||||||
|
|||||||
@@ -100,16 +100,16 @@ namespace SabreTools.Helper
|
|||||||
for (int index = 0; index < roms.Count; index++)
|
for (int index = 0; index < roms.Count; index++)
|
||||||
{
|
{
|
||||||
Rom rom = roms[index];
|
Rom rom = roms[index];
|
||||||
List<string> newsplit = rom.Game.Split('\\').ToList();
|
List<string> newsplit = rom.Game.Name.Split('\\').ToList();
|
||||||
|
|
||||||
// If we have a different game and we're not at the start of the list, output the end of last item
|
// 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() != rom.Game.ToLowerInvariant())
|
if (lastgame != null && lastgame.ToLowerInvariant() != rom.Game.Name.ToLowerInvariant())
|
||||||
{
|
{
|
||||||
depth = WriteEndGame(sw, rom, splitpath, newsplit, lastgame, datdata, depth, out last, logger);
|
depth = WriteEndGame(sw, rom, splitpath, newsplit, lastgame, datdata, depth, out last, logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have a new game, output the beginning of the new item
|
// If we have a new game, output the beginning of the new item
|
||||||
if (lastgame == null || lastgame.ToLowerInvariant() != rom.Game.ToLowerInvariant())
|
if (lastgame == null || lastgame.ToLowerInvariant() != rom.Game.Name.ToLowerInvariant())
|
||||||
{
|
{
|
||||||
depth = WriteStartGame(sw, rom, newsplit, lastgame, datdata, depth, last, logger);
|
depth = WriteStartGame(sw, rom, newsplit, lastgame, datdata, depth, last, logger);
|
||||||
}
|
}
|
||||||
@@ -133,7 +133,7 @@ namespace SabreTools.Helper
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
splitpath = newsplit;
|
splitpath = newsplit;
|
||||||
lastgame = rom.Game;
|
lastgame = rom.Game.Name;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,7 +143,7 @@ namespace SabreTools.Helper
|
|||||||
|
|
||||||
// Set the new data to compare against
|
// Set the new data to compare against
|
||||||
splitpath = newsplit;
|
splitpath = newsplit;
|
||||||
lastgame = rom.Game;
|
lastgame = rom.Game.Name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,9 +290,9 @@ namespace SabreTools.Helper
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// No game should start with a path separator
|
// No game should start with a path separator
|
||||||
if (rom.Game.StartsWith(Path.DirectorySeparatorChar.ToString()))
|
if (rom.Game.Name.StartsWith(Path.DirectorySeparatorChar.ToString()))
|
||||||
{
|
{
|
||||||
rom.Game = rom.Game.Substring(1);
|
rom.Game.Name = rom.Game.Name.Substring(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
string state = "";
|
string state = "";
|
||||||
@@ -300,7 +300,7 @@ namespace SabreTools.Helper
|
|||||||
{
|
{
|
||||||
case OutputFormat.ClrMamePro:
|
case OutputFormat.ClrMamePro:
|
||||||
state += "game (\n\tname \"" + rom.Game + "\"\n" +
|
state += "game (\n\tname \"" + rom.Game + "\"\n" +
|
||||||
"\tdescription \"" + (String.IsNullOrEmpty(rom.GameDescription) ? rom.Game : rom.GameDescription) + "\"\n";
|
"\tdescription \"" + (String.IsNullOrEmpty(rom.Game.Description) ? rom.Game.Name : rom.Game.Description) + "\"\n";
|
||||||
break;
|
break;
|
||||||
case OutputFormat.SabreDat:
|
case OutputFormat.SabreDat:
|
||||||
for (int i = (last == -1 ? 0 : last); i < newsplit.Count; i++)
|
for (int i = (last == -1 ? 0 : last); i < newsplit.Count; i++)
|
||||||
@@ -316,7 +316,7 @@ namespace SabreTools.Helper
|
|||||||
break;
|
break;
|
||||||
case OutputFormat.Xml:
|
case OutputFormat.Xml:
|
||||||
state += "\t<machine name=\"" + HttpUtility.HtmlEncode(rom.Game) + "\">\n" +
|
state += "\t<machine name=\"" + HttpUtility.HtmlEncode(rom.Game) + "\">\n" +
|
||||||
"\t\t<description>" + HttpUtility.HtmlEncode((String.IsNullOrEmpty(rom.GameDescription) ? rom.Game : rom.GameDescription)) + "</description>\n";
|
"\t\t<description>" + HttpUtility.HtmlEncode((String.IsNullOrEmpty(rom.Game.Description) ? rom.Game.Name : rom.Game.Description)) + "</description>\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -468,7 +468,7 @@ namespace SabreTools.Helper
|
|||||||
// Otherwise, use any flags
|
// Otherwise, use any flags
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string name = (datdata.UseGame ? rom.Game : rom.Name);
|
string name = (datdata.UseGame ? rom.Game.Name : rom.Name);
|
||||||
if (datdata.RepExt != "")
|
if (datdata.RepExt != "")
|
||||||
{
|
{
|
||||||
string dir = Path.GetDirectoryName(name);
|
string dir = Path.GetDirectoryName(name);
|
||||||
@@ -481,13 +481,13 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
if (!datdata.UseGame && datdata.GameName)
|
if (!datdata.UseGame && datdata.GameName)
|
||||||
{
|
{
|
||||||
name = Path.Combine(rom.Game, name);
|
name = Path.Combine(rom.Game.Name, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (datdata.UseGame && rom.Game != lastgame)
|
if (datdata.UseGame && rom.Game.Name != lastgame)
|
||||||
{
|
{
|
||||||
state += pre + name + post + "\n";
|
state += pre + name + post + "\n";
|
||||||
lastgame = rom.Game;
|
lastgame = rom.Game.Name;
|
||||||
}
|
}
|
||||||
else if (!datdata.UseGame)
|
else if (!datdata.UseGame)
|
||||||
{
|
{
|
||||||
@@ -497,7 +497,7 @@ namespace SabreTools.Helper
|
|||||||
break;
|
break;
|
||||||
case OutputFormat.RomCenter:
|
case OutputFormat.RomCenter:
|
||||||
state += "¬¬¬" + HttpUtility.HtmlEncode(rom.Game) +
|
state += "¬¬¬" + HttpUtility.HtmlEncode(rom.Game) +
|
||||||
"¬" + HttpUtility.HtmlEncode((String.IsNullOrEmpty(rom.GameDescription) ? rom.Game : rom.GameDescription)) +
|
"¬" + HttpUtility.HtmlEncode((String.IsNullOrEmpty(rom.Game.Description) ? rom.Game.Name : rom.Game.Description)) +
|
||||||
"¬" + HttpUtility.HtmlEncode(rom.Name) +
|
"¬" + HttpUtility.HtmlEncode(rom.Name) +
|
||||||
"¬" + rom.HashData.CRC.ToLowerInvariant() +
|
"¬" + rom.HashData.CRC.ToLowerInvariant() +
|
||||||
"¬" + (rom.HashData.Size != -1 ? rom.HashData.Size.ToString() : "") + "¬¬¬\n";
|
"¬" + (rom.HashData.Size != -1 ? rom.HashData.Size.ToString() : "") + "¬¬¬\n";
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ namespace SabreTools.Helper
|
|||||||
{
|
{
|
||||||
savedrom.Metadata.SystemID = rom.Metadata.SystemID;
|
savedrom.Metadata.SystemID = rom.Metadata.SystemID;
|
||||||
savedrom.Metadata.System = rom.Metadata.System;
|
savedrom.Metadata.System = rom.Metadata.System;
|
||||||
savedrom.Game = rom.Game;
|
savedrom.Game.Name = rom.Game.Name;
|
||||||
savedrom.Name = rom.Name;
|
savedrom.Name = rom.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,7 +156,7 @@ namespace SabreTools.Helper
|
|||||||
{
|
{
|
||||||
savedrom.Metadata.SourceID = rom.Metadata.SourceID;
|
savedrom.Metadata.SourceID = rom.Metadata.SourceID;
|
||||||
savedrom.Metadata.Source = rom.Metadata.Source;
|
savedrom.Metadata.Source = rom.Metadata.Source;
|
||||||
savedrom.Game = rom.Game;
|
savedrom.Game.Name = rom.Game.Name;
|
||||||
savedrom.Name = rom.Name;
|
savedrom.Name = rom.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,7 +287,7 @@ namespace SabreTools.Helper
|
|||||||
// If the duplicate is external already or should be, set it
|
// If the duplicate is external already or should be, set it
|
||||||
if (lastrom.Dupe >= DupeType.ExternalHash || lastrom.Metadata.SystemID != rom.Metadata.SystemID || lastrom.Metadata.SourceID != rom.Metadata.SourceID)
|
if (lastrom.Dupe >= DupeType.ExternalHash || lastrom.Metadata.SystemID != rom.Metadata.SystemID || lastrom.Metadata.SourceID != rom.Metadata.SourceID)
|
||||||
{
|
{
|
||||||
if (lastrom.Game == rom.Game && lastrom.Name == rom.Name)
|
if (lastrom.Game.Name == rom.Game.Name && lastrom.Name == rom.Name)
|
||||||
{
|
{
|
||||||
output = DupeType.ExternalAll;
|
output = DupeType.ExternalAll;
|
||||||
}
|
}
|
||||||
@@ -300,7 +300,7 @@ namespace SabreTools.Helper
|
|||||||
// Otherwise, it's considered an internal dupe
|
// Otherwise, it's considered an internal dupe
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (lastrom.Game == rom.Game && lastrom.Name == rom.Name)
|
if (lastrom.Game.Name == rom.Game.Name && lastrom.Name == rom.Name)
|
||||||
{
|
{
|
||||||
output = DupeType.InternalAll;
|
output = DupeType.InternalAll;
|
||||||
}
|
}
|
||||||
@@ -327,15 +327,15 @@ namespace SabreTools.Helper
|
|||||||
{
|
{
|
||||||
if (x.Metadata.SourceID == y.Metadata.SourceID)
|
if (x.Metadata.SourceID == y.Metadata.SourceID)
|
||||||
{
|
{
|
||||||
if (x.Game == y.Game)
|
if (x.Game.Name == y.Game.Name)
|
||||||
{
|
{
|
||||||
return String.Compare(x.Name, y.Name);
|
return String.Compare(x.Name, y.Name);
|
||||||
}
|
}
|
||||||
return String.Compare(x.Game, y.Game);
|
return String.Compare(x.Game.Name, y.Game.Name);
|
||||||
}
|
}
|
||||||
return (norename ? String.Compare(x.Game, y.Game) : x.Metadata.SourceID - y.Metadata.SourceID);
|
return (norename ? String.Compare(x.Game.Name, y.Game.Name) : x.Metadata.SourceID - y.Metadata.SourceID);
|
||||||
}
|
}
|
||||||
return (norename ? String.Compare(x.Game, y.Game) : x.Metadata.SystemID - y.Metadata.SystemID);
|
return (norename ? String.Compare(x.Game.Name, y.Game.Name) : x.Metadata.SystemID - y.Metadata.SystemID);
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -173,11 +173,14 @@ namespace SabreTools
|
|||||||
Rom rom = new Rom
|
Rom rom = new Rom
|
||||||
{
|
{
|
||||||
Name = "null",
|
Name = "null",
|
||||||
Game = (_datdata.Type == "SuperDAT" ?
|
Game = new Machine
|
||||||
(actualroot != "" && !actualroot.StartsWith(Path.DirectorySeparatorChar.ToString()) ?
|
{
|
||||||
Path.DirectorySeparatorChar.ToString() :
|
Name = (_datdata.Type == "SuperDAT" ?
|
||||||
"") + actualroot :
|
(actualroot != "" && !actualroot.StartsWith(Path.DirectorySeparatorChar.ToString()) ?
|
||||||
actualroot),
|
Path.DirectorySeparatorChar.ToString() :
|
||||||
|
"") + actualroot :
|
||||||
|
actualroot),
|
||||||
|
},
|
||||||
HashData = new HashData
|
HashData = new HashData
|
||||||
{
|
{
|
||||||
Size = -1,
|
Size = -1,
|
||||||
@@ -209,11 +212,14 @@ namespace SabreTools
|
|||||||
Rom rom = new Rom
|
Rom rom = new Rom
|
||||||
{
|
{
|
||||||
Name = "null",
|
Name = "null",
|
||||||
Game = (_datdata.Type == "SuperDAT" ?
|
Game = new Machine
|
||||||
(actualroot != "" && !actualroot.StartsWith(Path.DirectorySeparatorChar.ToString()) ?
|
{
|
||||||
Path.DirectorySeparatorChar.ToString() :
|
Name = (_datdata.Type == "SuperDAT" ?
|
||||||
"") + actualroot :
|
(actualroot != "" && !actualroot.StartsWith(Path.DirectorySeparatorChar.ToString()) ?
|
||||||
actualroot),
|
Path.DirectorySeparatorChar.ToString() :
|
||||||
|
"") + actualroot :
|
||||||
|
actualroot),
|
||||||
|
},
|
||||||
HashData = new HashData
|
HashData = new HashData
|
||||||
{
|
{
|
||||||
Size = -1,
|
Size = -1,
|
||||||
@@ -287,13 +293,13 @@ namespace SabreTools
|
|||||||
{
|
{
|
||||||
// If we have a different game and we're not at the start of the list, output the end of last item
|
// If we have a different game and we're not at the start of the list, output the end of last item
|
||||||
int last = 0;
|
int last = 0;
|
||||||
if (lastparent != null && lastparent.ToLowerInvariant() != rom.Game.ToLowerInvariant())
|
if (lastparent != null && lastparent.ToLowerInvariant() != rom.Game.Name.ToLowerInvariant())
|
||||||
{
|
{
|
||||||
Output.WriteEndGame(sw, rom, new List<string>(), new List<string>(), lastparent, _datdata, 0, out last, _logger);
|
Output.WriteEndGame(sw, rom, new List<string>(), new List<string>(), lastparent, _datdata, 0, out last, _logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have a new game, output the beginning of the new item
|
// If we have a new game, output the beginning of the new item
|
||||||
if (lastparent == null || lastparent.ToLowerInvariant() != rom.Game.ToLowerInvariant())
|
if (lastparent == null || lastparent.ToLowerInvariant() != rom.Game.Name.ToLowerInvariant())
|
||||||
{
|
{
|
||||||
Output.WriteStartGame(sw, rom, new List<string>(), lastparent, _datdata, 0, last, _logger);
|
Output.WriteStartGame(sw, rom, new List<string>(), lastparent, _datdata, 0, last, _logger);
|
||||||
}
|
}
|
||||||
@@ -305,7 +311,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lastparent = rom.Game;
|
lastparent = rom.Game.Name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -374,7 +380,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
|
|
||||||
_logger.User("File added: " + Path.GetFileNameWithoutExtension(item) + Environment.NewLine);
|
_logger.User("File added: " + Path.GetFileNameWithoutExtension(item) + Environment.NewLine);
|
||||||
return rom.Game;
|
return rom.Game.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If both deep hash skip flags are set, do a quickscan
|
// If both deep hash skip flags are set, do a quickscan
|
||||||
@@ -511,12 +517,15 @@ namespace SabreTools
|
|||||||
_logger.Log("Actual item added: " + actualitem);
|
_logger.Log("Actual item added: " + actualitem);
|
||||||
|
|
||||||
// Update rom information
|
// Update rom information
|
||||||
rom.Game = (datdata.Type == "SuperDAT" ?
|
rom.Game = new Machine
|
||||||
|
{
|
||||||
|
Name = (datdata.Type == "SuperDAT" ?
|
||||||
(actualroot != "" && !actualroot.StartsWith(Path.DirectorySeparatorChar.ToString()) ?
|
(actualroot != "" && !actualroot.StartsWith(Path.DirectorySeparatorChar.ToString()) ?
|
||||||
Path.DirectorySeparatorChar.ToString() :
|
Path.DirectorySeparatorChar.ToString() :
|
||||||
"") + actualroot :
|
"") + actualroot :
|
||||||
actualroot);
|
actualroot),
|
||||||
rom.Game = rom.Game.Replace(Path.DirectorySeparatorChar.ToString() + Path.DirectorySeparatorChar.ToString(), Path.DirectorySeparatorChar.ToString());
|
};
|
||||||
|
rom.Game.Name = rom.Game.Name.Replace(Path.DirectorySeparatorChar.ToString() + Path.DirectorySeparatorChar.ToString(), Path.DirectorySeparatorChar.ToString());
|
||||||
rom.Name = actualitem;
|
rom.Name = actualitem;
|
||||||
|
|
||||||
if (_nowrite)
|
if (_nowrite)
|
||||||
@@ -537,13 +546,13 @@ namespace SabreTools
|
|||||||
{
|
{
|
||||||
// If we have a different game and we're not at the start of the list, output the end of last item
|
// If we have a different game and we're not at the start of the list, output the end of last item
|
||||||
int last = 0;
|
int last = 0;
|
||||||
if (lastparent != null && lastparent.ToLowerInvariant() != rom.Game.ToLowerInvariant())
|
if (lastparent != null && lastparent.ToLowerInvariant() != rom.Game.Name.ToLowerInvariant())
|
||||||
{
|
{
|
||||||
Output.WriteEndGame(sw, rom, new List<string>(), new List<string>(), lastparent, datdata, 0, out last, _logger);
|
Output.WriteEndGame(sw, rom, new List<string>(), new List<string>(), lastparent, datdata, 0, out last, _logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have a new game, output the beginning of the new item
|
// If we have a new game, output the beginning of the new item
|
||||||
if (lastparent == null || lastparent.ToLowerInvariant() != rom.Game.ToLowerInvariant())
|
if (lastparent == null || lastparent.ToLowerInvariant() != rom.Game.Name.ToLowerInvariant())
|
||||||
{
|
{
|
||||||
Output.WriteStartGame(sw, rom, new List<string>(), lastparent, datdata, 0, last, _logger);
|
Output.WriteStartGame(sw, rom, new List<string>(), lastparent, datdata, 0, last, _logger);
|
||||||
}
|
}
|
||||||
@@ -553,7 +562,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
_logger.User("File added: " + actualitem + Environment.NewLine);
|
_logger.User("File added: " + actualitem + Environment.NewLine);
|
||||||
|
|
||||||
return rom.Game;
|
return rom.Game.Name;
|
||||||
}
|
}
|
||||||
catch (IOException ex)
|
catch (IOException ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ namespace SabreTools
|
|||||||
Rom rom = newroms[i];
|
Rom rom = newroms[i];
|
||||||
|
|
||||||
// In the case that the RomData is incomplete, skip it
|
// In the case that the RomData is incomplete, skip it
|
||||||
if (rom.Name == null || rom.Game == null)
|
if (rom.Name == null || rom.Game.Name == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -209,21 +209,21 @@ namespace SabreTools
|
|||||||
rom.Name = Regex.Replace(rom.Name, @"(.*) \.(.*)", "$1.$2");
|
rom.Name = Regex.Replace(rom.Name, @"(.*) \.(.*)", "$1.$2");
|
||||||
|
|
||||||
// Run the name through the filters to make sure that it's correct
|
// Run the name through the filters to make sure that it's correct
|
||||||
rom.Game = Style.NormalizeChars(rom.Game);
|
rom.Game.Name = Style.NormalizeChars(rom.Game.Name);
|
||||||
rom.Game = Style.RussianToLatin(rom.Game);
|
rom.Game.Name = Style.RussianToLatin(rom.Game.Name);
|
||||||
rom.Game = Style.SearchPattern(rom.Game);
|
rom.Game.Name = Style.SearchPattern(rom.Game.Name);
|
||||||
|
|
||||||
// WoD gets rid of anything past the first "(" or "[" as the name, we will do the same
|
// WoD gets rid of anything past the first "(" or "[" as the name, we will do the same
|
||||||
string stripPattern = @"(([[(].*[\)\]] )?([^([]+))";
|
string stripPattern = @"(([[(].*[\)\]] )?([^([]+))";
|
||||||
Regex stripRegex = new Regex(stripPattern);
|
Regex stripRegex = new Regex(stripPattern);
|
||||||
Match stripMatch = stripRegex.Match(rom.Game);
|
Match stripMatch = stripRegex.Match(rom.Game.Name);
|
||||||
rom.Game = stripMatch.Groups[1].Value;
|
rom.Game.Name = stripMatch.Groups[1].Value;
|
||||||
|
|
||||||
rom.Game = rom.Game.TrimEnd().TrimStart();
|
rom.Game.Name = rom.Game.Name.TrimEnd().TrimStart();
|
||||||
|
|
||||||
if (!_norename)
|
if (!_norename)
|
||||||
{
|
{
|
||||||
rom.Game += " [" + sources[rom.Metadata.SourceID] + "]";
|
rom.Game.Name += " [" + sources[rom.Metadata.SourceID] + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a game has source "0" it's Default. Make this Int32.MaxValue for sorting purposes
|
// If a game has source "0" it's Default. Make this Int32.MaxValue for sorting purposes
|
||||||
|
|||||||
@@ -523,7 +523,7 @@ namespace SabreTools
|
|||||||
if (_toFolder)
|
if (_toFolder)
|
||||||
{
|
{
|
||||||
// Copy file to output directory
|
// Copy file to output directory
|
||||||
string gamedir = Path.Combine(_outdir, found.Game);
|
string gamedir = Path.Combine(_outdir, found.Game.Name);
|
||||||
if (!Directory.Exists(gamedir))
|
if (!Directory.Exists(gamedir))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(gamedir);
|
Directory.CreateDirectory(gamedir);
|
||||||
@@ -590,7 +590,7 @@ namespace SabreTools
|
|||||||
if (_toFolder)
|
if (_toFolder)
|
||||||
{
|
{
|
||||||
// Copy file to output directory
|
// Copy file to output directory
|
||||||
string gamedir = Path.Combine(_outdir, found.Game);
|
string gamedir = Path.Combine(_outdir, found.Game.Name);
|
||||||
if (!Directory.Exists(gamedir))
|
if (!Directory.Exists(gamedir))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(gamedir);
|
Directory.CreateDirectory(gamedir);
|
||||||
@@ -635,7 +635,7 @@ namespace SabreTools
|
|||||||
if (_toFolder)
|
if (_toFolder)
|
||||||
{
|
{
|
||||||
// Copy file to output directory
|
// Copy file to output directory
|
||||||
string gamedir = Path.Combine(_outdir, found.Game);
|
string gamedir = Path.Combine(_outdir, found.Game.Name);
|
||||||
if (!Directory.Exists(gamedir))
|
if (!Directory.Exists(gamedir))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(gamedir);
|
Directory.CreateDirectory(gamedir);
|
||||||
@@ -714,7 +714,7 @@ namespace SabreTools
|
|||||||
string outfile = ArchiveTools.ExtractSingleItemFromArchive(input, rom.Name, _tempdir, _logger);
|
string outfile = ArchiveTools.ExtractSingleItemFromArchive(input, rom.Name, _tempdir, _logger);
|
||||||
if (File.Exists(outfile))
|
if (File.Exists(outfile))
|
||||||
{
|
{
|
||||||
string gamedir = Path.Combine(_outdir, found.Game);
|
string gamedir = Path.Combine(_outdir, found.Game.Name);
|
||||||
if (!Directory.Exists(gamedir))
|
if (!Directory.Exists(gamedir))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(gamedir);
|
Directory.CreateDirectory(gamedir);
|
||||||
|
|||||||
Reference in New Issue
Block a user