[Structs] Rename Rom field "Game" to "Machine"

This commit is contained in:
Matt Nadareski
2016-08-29 13:42:27 -07:00
parent 5c0b5bfcbb
commit 19a210562e
8 changed files with 77 additions and 77 deletions

View File

@@ -46,7 +46,7 @@ namespace SabreTools.Helper
/// </summary> /// </summary>
public struct Rom : IComparable, IEquatable<Rom> public struct Rom : IComparable, IEquatable<Rom>
{ {
public Machine Game; public Machine Machine;
public string Name; public string Name;
public string Type; public string Type;
public HashData HashData; public HashData HashData;
@@ -66,7 +66,7 @@ namespace SabreTools.Helper
{ {
Rom comp = (Rom)obj; Rom comp = (Rom)obj;
if (this.Game.Name == comp.Game.Name) if (this.Machine.Name == comp.Machine.Name)
{ {
if (this.Name == comp.Name) if (this.Name == comp.Name)
{ {
@@ -74,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.Name, comp.Game.Name); ret = String.Compare(this.Machine.Name, comp.Machine.Name);
} }
catch catch
{ {
@@ -92,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.Name == other.Game.Name && return (this.Machine.Name == other.Machine.Name &&
this.Name == other.Name && this.Name == other.Name &&
isdupe); isdupe);
} }

View File

@@ -21,7 +21,7 @@ namespace SabreTools.Helper
/// <param name="rom">RomData representing the new information</param> /// <param name="rom">RomData representing the new information</param>
public static void WriteToArchive(string input, string output, Rom rom) public static void WriteToArchive(string input, string output, Rom rom)
{ {
string archiveFileName = Path.Combine(output, rom.Game + ".zip"); string archiveFileName = Path.Combine(output, rom.Machine + ".zip");
System.IO.Compression.ZipArchive outarchive = null; System.IO.Compression.ZipArchive outarchive = null;
try try
@@ -71,7 +71,7 @@ namespace SabreTools.Helper
/// <param name="rom">RomData representing the new information</param> /// <param name="rom">RomData representing the new information</param>
public static void WriteToManagedArchive(string input, string output, Rom rom) public static void WriteToManagedArchive(string input, string output, Rom rom)
{ {
string archiveFileName = Path.Combine(output, rom.Game + ".zip"); string archiveFileName = Path.Combine(output, rom.Machine + ".zip");
// Delete an empty file first // Delete an empty file first
if (File.Exists(archiveFileName) && new FileInfo(archiveFileName).Length == 0) if (File.Exists(archiveFileName) && new FileInfo(archiveFileName).Length == 0)
@@ -538,7 +538,7 @@ namespace SabreTools.Helper
{ {
Type = "rom", Type = "rom",
Name = reader.Entry.Key, Name = reader.Entry.Key,
Game = new Machine Machine = new Machine
{ {
Name = gamename, Name = gamename,
}, },
@@ -621,7 +621,7 @@ namespace SabreTools.Helper
Rom rom = new Rom Rom rom = new Rom
{ {
Type = "rom", Type = "rom",
Game = new Machine Machine = new Machine
{ {
Name = Path.GetFileNameWithoutExtension(input).ToLowerInvariant(), Name = Path.GetFileNameWithoutExtension(input).ToLowerInvariant(),
}, },

View File

@@ -172,7 +172,7 @@ namespace SabreTools.Helper
Rom rom = new Rom Rom rom = new Rom
{ {
Game = new Machine Machine = new Machine
{ {
Name = gamename, Name = gamename,
Description = gamedesc, Description = gamedesc,
@@ -568,7 +568,7 @@ namespace SabreTools.Helper
Rom rom = new Rom Rom rom = new Rom
{ {
Game = new Machine Machine = new Machine
{ {
Name = rominfo[3], Name = rominfo[3],
Description = rominfo[4], Description = rominfo[4],
@@ -681,7 +681,7 @@ namespace SabreTools.Helper
{ {
Type = "rom", Type = "rom",
Name = "null", Name = "null",
Game = new Machine Machine = new Machine
{ {
Name = tempgame, Name = tempgame,
Description = tempgame, Description = tempgame,
@@ -1129,7 +1129,7 @@ namespace SabreTools.Helper
Rom rom = new Rom Rom rom = new Rom
{ {
Game = new Machine Machine = new Machine
{ {
Name = tempname, Name = tempname,
Description = gamedesc, Description = gamedesc,
@@ -1190,7 +1190,7 @@ namespace SabreTools.Helper
{ {
Type = "rom", Type = "rom",
Name = "null", Name = "null",
Game = new Machine Machine = new Machine
{ {
Name = tempname, Name = tempname,
Description = tempname, Description = tempname,
@@ -1369,7 +1369,7 @@ namespace SabreTools.Helper
Rom rom = new Rom Rom rom = new Rom
{ {
Game = new Machine Machine = new Machine
{ {
Name = tempname, Name = tempname,
}, },
@@ -1474,9 +1474,9 @@ namespace SabreTools.Helper
: rom.Metadata.SystemID.ToString().PadLeft(10, '0') : rom.Metadata.SystemID.ToString().PadLeft(10, '0')
+ "-" + "-"
+ rom.Metadata.SourceID.ToString().PadLeft(10, '0') + "-") + rom.Metadata.SourceID.ToString().PadLeft(10, '0') + "-")
+ (String.IsNullOrEmpty(rom.Game.Name) + (String.IsNullOrEmpty(rom.Machine.Name)
? "" ? ""
: rom.Game.Name.ToLowerInvariant()); : rom.Machine.Name.ToLowerInvariant());
if (sortable.ContainsKey(newkey)) if (sortable.ContainsKey(newkey))
{ {
sortable[newkey].Add(rom); sortable[newkey].Add(rom);
@@ -1832,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.Name.ToLowerInvariant().Contains(gamename.ToLowerInvariant().Replace("*", ""))) if (gamename.StartsWith("*") && gamename.EndsWith("*") && !rom.Machine.Name.ToLowerInvariant().Contains(gamename.ToLowerInvariant().Replace("*", "")))
{ {
continue; continue;
} }
else if (gamename.StartsWith("*") && !rom.Game.Name.EndsWith(gamename.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase)) else if (gamename.StartsWith("*") && !rom.Machine.Name.EndsWith(gamename.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
{ {
continue; continue;
} }
else if (gamename.EndsWith("*") && !rom.Game.Name.StartsWith(gamename.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase)) else if (gamename.EndsWith("*") && !rom.Machine.Name.StartsWith(gamename.Replace("*", ""), StringComparison.InvariantCultureIgnoreCase))
{ {
continue; continue;
} }
@@ -1940,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.Name = "!"; rom.Machine.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.Name.Length - root.Length; int usableLength = 260 - rom.Machine.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);
@@ -2071,7 +2071,7 @@ namespace SabreTools.Helper
if ((diff & DiffMode.NoDupes) != 0) if ((diff & DiffMode.NoDupes) != 0)
{ {
Rom newrom = rom; Rom newrom = rom;
newrom.Game.Name += " (" + Path.GetFileNameWithoutExtension(inputs[newrom.Metadata.SystemID].Split('¬')[0]) + ")"; newrom.Machine.Name += " (" + Path.GetFileNameWithoutExtension(inputs[newrom.Metadata.SystemID].Split('¬')[0]) + ")";
if (outerDiffData.Roms.ContainsKey(key)) if (outerDiffData.Roms.ContainsKey(key))
{ {
@@ -2093,7 +2093,7 @@ namespace SabreTools.Helper
if (rom.Dupe >= DupeType.ExternalHash) if (rom.Dupe >= DupeType.ExternalHash)
{ {
Rom newrom = rom; Rom newrom = rom;
newrom.Game.Name += " (" + Path.GetFileNameWithoutExtension(inputs[newrom.Metadata.SystemID].Split('¬')[0]) + ")"; newrom.Machine.Name += " (" + Path.GetFileNameWithoutExtension(inputs[newrom.Metadata.SystemID].Split('¬')[0]) + ")";
if (dupeData.Roms.ContainsKey(key)) if (dupeData.Roms.ContainsKey(key))
{ {
@@ -2265,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.Name = Path.GetDirectoryName(filename) + Path.DirectorySeparatorChar newrom.Machine.Name = Path.GetDirectoryName(filename) + Path.DirectorySeparatorChar
+ Path.GetFileNameWithoutExtension(filename) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(filename) + Path.DirectorySeparatorChar
+ newrom.Game.Name; + newrom.Machine.Name;
newroms.Add(newrom); newroms.Add(newrom);
} }
userData.Roms[key] = newroms; userData.Roms[key] = newroms;

View File

@@ -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.Name.Split('\\').ToList(); List<string> newsplit = rom.Machine.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.Name.ToLowerInvariant()) if (lastgame != null && lastgame.ToLowerInvariant() != rom.Machine.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.Name.ToLowerInvariant()) if (lastgame == null || lastgame.ToLowerInvariant() != rom.Machine.Name.ToLowerInvariant())
{ {
depth = WriteStartGame(sw, rom, newsplit, lastgame, datdata, depth, last, logger); depth = WriteStartGame(sw, rom, newsplit, lastgame, datdata, depth, last, logger);
} }
@@ -117,7 +117,7 @@ namespace SabreTools.Helper
// If we have a "null" game (created by DATFromDir or something similar), log it to file // If we have a "null" game (created by DATFromDir or something similar), log it to file
if (rom.Name == "null" && rom.HashData.Size == -1 && rom.HashData.CRC == "null" && rom.HashData.MD5 == "null" && rom.HashData.SHA1 == "null") if (rom.Name == "null" && rom.HashData.Size == -1 && rom.HashData.CRC == "null" && rom.HashData.MD5 == "null" && rom.HashData.SHA1 == "null")
{ {
logger.Log("Empty folder found: " + rom.Game); logger.Log("Empty folder found: " + rom.Machine);
// If we're in a mode that doesn't allow for actual empty folders, add the blank info // If we're in a mode that doesn't allow for actual empty folders, add the blank info
if (datdata.OutputFormat != OutputFormat.SabreDat && datdata.OutputFormat != OutputFormat.MissFile) if (datdata.OutputFormat != OutputFormat.SabreDat && datdata.OutputFormat != OutputFormat.MissFile)
@@ -133,7 +133,7 @@ namespace SabreTools.Helper
else else
{ {
splitpath = newsplit; splitpath = newsplit;
lastgame = rom.Game.Name; lastgame = rom.Machine.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.Name; lastgame = rom.Machine.Name;
} }
} }
@@ -290,17 +290,17 @@ namespace SabreTools.Helper
try try
{ {
// No game should start with a path separator // No game should start with a path separator
if (rom.Game.Name.StartsWith(Path.DirectorySeparatorChar.ToString())) if (rom.Machine.Name.StartsWith(Path.DirectorySeparatorChar.ToString()))
{ {
rom.Game.Name = rom.Game.Name.Substring(1); rom.Machine.Name = rom.Machine.Name.Substring(1);
} }
string state = ""; string state = "";
switch (datdata.OutputFormat) switch (datdata.OutputFormat)
{ {
case OutputFormat.ClrMamePro: case OutputFormat.ClrMamePro:
state += "game (\n\tname \"" + rom.Game + "\"\n" + state += "game (\n\tname \"" + rom.Machine + "\"\n" +
"\tdescription \"" + (String.IsNullOrEmpty(rom.Game.Description) ? rom.Game.Name : rom.Game.Description) + "\"\n"; "\tdescription \"" + (String.IsNullOrEmpty(rom.Machine.Description) ? rom.Machine.Name : rom.Machine.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++)
@@ -315,8 +315,8 @@ namespace SabreTools.Helper
depth = depth - (last == -1 ? 0 : last) + newsplit.Count; depth = depth - (last == -1 ? 0 : last) + newsplit.Count;
break; break;
case OutputFormat.Xml: case OutputFormat.Xml:
state += "\t<machine name=\"" + HttpUtility.HtmlEncode(rom.Game) + "\">\n" + state += "\t<machine name=\"" + HttpUtility.HtmlEncode(rom.Machine) + "\">\n" +
"\t\t<description>" + HttpUtility.HtmlEncode((String.IsNullOrEmpty(rom.Game.Description) ? rom.Game.Name : rom.Game.Description)) + "</description>\n"; "\t\t<description>" + HttpUtility.HtmlEncode((String.IsNullOrEmpty(rom.Machine.Description) ? rom.Machine.Name : rom.Machine.Description)) + "</description>\n";
break; break;
} }
@@ -452,7 +452,7 @@ namespace SabreTools.Helper
// If we're in TSV mode, similarly the state is consistent // If we're in TSV mode, similarly the state is consistent
else if (datdata.TSV == true) else if (datdata.TSV == true)
{ {
string inline = "\"" + datdata.FileName + "\"\t\"" + datdata.Name + "\"\t\"" + datdata.Description + "\"\t\"" + rom.Game + "\"\t\"" + rom.Game + "\"\t\"" + string inline = "\"" + datdata.FileName + "\"\t\"" + datdata.Name + "\"\t\"" + datdata.Description + "\"\t\"" + rom.Machine + "\"\t\"" + rom.Machine + "\"\t\"" +
rom.Type + "\"\t\"" + (rom.Type == "rom" ? rom.Name : "") + "\"\t\"" + (rom.Type == "disk" ? rom.Name : "") + "\"\t\"" + rom.HashData.Size + "\"\t\"" + rom.Type + "\"\t\"" + (rom.Type == "rom" ? rom.Name : "") + "\"\t\"" + (rom.Type == "disk" ? rom.Name : "") + "\"\t\"" + rom.HashData.Size + "\"\t\"" +
rom.HashData.CRC + "\"\t\"" + rom.HashData.MD5 + "\"\t\"" + rom.HashData.SHA1 + "\"\t" + (rom.Nodump ? "\"Nodump\"" : "\"\""); rom.HashData.CRC + "\"\t\"" + rom.HashData.MD5 + "\"\t\"" + rom.HashData.SHA1 + "\"\t" + (rom.Nodump ? "\"Nodump\"" : "\"\"");
state += pre + inline + post + "\n"; state += pre + inline + post + "\n";
@@ -460,7 +460,7 @@ namespace SabreTools.Helper
// If we're in CSV mode, similarly the state is consistent // If we're in CSV mode, similarly the state is consistent
else if (datdata.TSV == false) else if (datdata.TSV == false)
{ {
string inline = "\"" + datdata.FileName + "\",\"" + datdata.Name + "\",\"" + datdata.Description + "\",\"" + rom.Game + "\",\"" + rom.Game + "\",\"" + string inline = "\"" + datdata.FileName + "\",\"" + datdata.Name + "\",\"" + datdata.Description + "\",\"" + rom.Machine + "\",\"" + rom.Machine + "\",\"" +
rom.Type + "\",\"" + (rom.Type == "rom" ? rom.Name : "") + "\",\"" + (rom.Type == "disk" ? rom.Name : "") + "\",\"" + rom.HashData.Size + "\",\"" + rom.Type + "\",\"" + (rom.Type == "rom" ? rom.Name : "") + "\",\"" + (rom.Type == "disk" ? rom.Name : "") + "\",\"" + rom.HashData.Size + "\",\"" +
rom.HashData.CRC + "\",\"" + rom.HashData.MD5 + "\",\"" + rom.HashData.SHA1 + "\"," + (rom.Nodump ? "\"Nodump\"" : "\"\""); rom.HashData.CRC + "\",\"" + rom.HashData.MD5 + "\",\"" + rom.HashData.SHA1 + "\"," + (rom.Nodump ? "\"Nodump\"" : "\"\"");
state += pre + inline + post + "\n"; state += pre + inline + post + "\n";
@@ -468,7 +468,7 @@ namespace SabreTools.Helper
// Otherwise, use any flags // Otherwise, use any flags
else else
{ {
string name = (datdata.UseGame ? rom.Game.Name : rom.Name); string name = (datdata.UseGame ? rom.Machine.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); name = Path.Combine(rom.Machine.Name, name);
} }
if (datdata.UseGame && rom.Game.Name != lastgame) if (datdata.UseGame && rom.Machine.Name != lastgame)
{ {
state += pre + name + post + "\n"; state += pre + name + post + "\n";
lastgame = rom.Game.Name; lastgame = rom.Machine.Name;
} }
else if (!datdata.UseGame) else if (!datdata.UseGame)
{ {
@@ -496,8 +496,8 @@ namespace SabreTools.Helper
} }
break; break;
case OutputFormat.RomCenter: case OutputFormat.RomCenter:
state += "¬¬¬" + HttpUtility.HtmlEncode(rom.Game) + state += "¬¬¬" + HttpUtility.HtmlEncode(rom.Machine) +
"¬" + HttpUtility.HtmlEncode((String.IsNullOrEmpty(rom.Game.Description) ? rom.Game.Name : rom.Game.Description)) + "¬" + HttpUtility.HtmlEncode((String.IsNullOrEmpty(rom.Machine.Description) ? rom.Machine.Name : rom.Machine.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";

View File

@@ -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.Name = rom.Game.Name; savedrom.Machine.Name = rom.Machine.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.Name = rom.Game.Name; savedrom.Machine.Name = rom.Machine.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.Name == rom.Game.Name && lastrom.Name == rom.Name) if (lastrom.Machine.Name == rom.Machine.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.Name == rom.Game.Name && lastrom.Name == rom.Name) if (lastrom.Machine.Name == rom.Machine.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.Name == y.Game.Name) if (x.Machine.Name == y.Machine.Name)
{ {
return String.Compare(x.Name, y.Name); return String.Compare(x.Name, y.Name);
} }
return String.Compare(x.Game.Name, y.Game.Name); return String.Compare(x.Machine.Name, y.Machine.Name);
} }
return (norename ? String.Compare(x.Game.Name, y.Game.Name) : x.Metadata.SourceID - y.Metadata.SourceID); return (norename ? String.Compare(x.Machine.Name, y.Machine.Name) : x.Metadata.SourceID - y.Metadata.SourceID);
} }
return (norename ? String.Compare(x.Game.Name, y.Game.Name) : x.Metadata.SystemID - y.Metadata.SystemID); return (norename ? String.Compare(x.Machine.Name, y.Machine.Name) : x.Metadata.SystemID - y.Metadata.SystemID);
}); });
return true; return true;
} }

View File

@@ -173,7 +173,7 @@ namespace SabreTools
Rom rom = new Rom Rom rom = new Rom
{ {
Name = "null", Name = "null",
Game = new Machine Machine = new Machine
{ {
Name = (_datdata.Type == "SuperDAT" ? Name = (_datdata.Type == "SuperDAT" ?
(actualroot != "" && !actualroot.StartsWith(Path.DirectorySeparatorChar.ToString()) ? (actualroot != "" && !actualroot.StartsWith(Path.DirectorySeparatorChar.ToString()) ?
@@ -212,7 +212,7 @@ namespace SabreTools
Rom rom = new Rom Rom rom = new Rom
{ {
Name = "null", Name = "null",
Game = new Machine Machine = new Machine
{ {
Name = (_datdata.Type == "SuperDAT" ? Name = (_datdata.Type == "SuperDAT" ?
(actualroot != "" && !actualroot.StartsWith(Path.DirectorySeparatorChar.ToString()) ? (actualroot != "" && !actualroot.StartsWith(Path.DirectorySeparatorChar.ToString()) ?
@@ -293,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.Name.ToLowerInvariant()) if (lastparent != null && lastparent.ToLowerInvariant() != rom.Machine.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.Name.ToLowerInvariant()) if (lastparent == null || lastparent.ToLowerInvariant() != rom.Machine.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);
} }
@@ -311,7 +311,7 @@ namespace SabreTools
} }
} }
lastparent = rom.Game.Name; lastparent = rom.Machine.Name;
} }
} }
@@ -380,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.Name; return rom.Machine.Name;
} }
// If both deep hash skip flags are set, do a quickscan // If both deep hash skip flags are set, do a quickscan
@@ -517,7 +517,7 @@ namespace SabreTools
_logger.Log("Actual item added: " + actualitem); _logger.Log("Actual item added: " + actualitem);
// Update rom information // Update rom information
rom.Game = new Machine rom.Machine = new Machine
{ {
Name = (datdata.Type == "SuperDAT" ? Name = (datdata.Type == "SuperDAT" ?
(actualroot != "" && !actualroot.StartsWith(Path.DirectorySeparatorChar.ToString()) ? (actualroot != "" && !actualroot.StartsWith(Path.DirectorySeparatorChar.ToString()) ?
@@ -525,7 +525,7 @@ namespace SabreTools
"") + actualroot : "") + actualroot :
actualroot), actualroot),
}; };
rom.Game.Name = rom.Game.Name.Replace(Path.DirectorySeparatorChar.ToString() + Path.DirectorySeparatorChar.ToString(), Path.DirectorySeparatorChar.ToString()); rom.Machine.Name = rom.Machine.Name.Replace(Path.DirectorySeparatorChar.ToString() + Path.DirectorySeparatorChar.ToString(), Path.DirectorySeparatorChar.ToString());
rom.Name = actualitem; rom.Name = actualitem;
if (_nowrite) if (_nowrite)
@@ -546,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.Name.ToLowerInvariant()) if (lastparent != null && lastparent.ToLowerInvariant() != rom.Machine.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.Name.ToLowerInvariant()) if (lastparent == null || lastparent.ToLowerInvariant() != rom.Machine.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);
} }
@@ -562,7 +562,7 @@ namespace SabreTools
} }
_logger.User("File added: " + actualitem + Environment.NewLine); _logger.User("File added: " + actualitem + Environment.NewLine);
return rom.Game.Name; return rom.Machine.Name;
} }
catch (IOException ex) catch (IOException ex)
{ {

View File

@@ -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.Name == null) if (rom.Name == null || rom.Machine.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.Name = Style.NormalizeChars(rom.Game.Name); rom.Machine.Name = Style.NormalizeChars(rom.Machine.Name);
rom.Game.Name = Style.RussianToLatin(rom.Game.Name); rom.Machine.Name = Style.RussianToLatin(rom.Machine.Name);
rom.Game.Name = Style.SearchPattern(rom.Game.Name); rom.Machine.Name = Style.SearchPattern(rom.Machine.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.Name); Match stripMatch = stripRegex.Match(rom.Machine.Name);
rom.Game.Name = stripMatch.Groups[1].Value; rom.Machine.Name = stripMatch.Groups[1].Value;
rom.Game.Name = rom.Game.Name.TrimEnd().TrimStart(); rom.Machine.Name = rom.Machine.Name.TrimEnd().TrimStart();
if (!_norename) if (!_norename)
{ {
rom.Game.Name += " [" + sources[rom.Metadata.SourceID] + "]"; rom.Machine.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

View File

@@ -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.Name); string gamedir = Path.Combine(_outdir, found.Machine.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.Name); string gamedir = Path.Combine(_outdir, found.Machine.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.Name); string gamedir = Path.Combine(_outdir, found.Machine.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.Name); string gamedir = Path.Combine(_outdir, found.Machine.Name);
if (!Directory.Exists(gamedir)) if (!Directory.Exists(gamedir))
{ {
Directory.CreateDirectory(gamedir); Directory.CreateDirectory(gamedir);
@@ -755,7 +755,7 @@ namespace SabreTools
} }
else else
{ {
string archiveFileName = Path.Combine(_outdir, found.Game + ".zip"); string archiveFileName = Path.Combine(_outdir, found.Machine + ".zip");
ArchiveTools.CopyFileBetweenManagedArchives(input, archiveFileName, rom.Name, found.Name, _logger); ArchiveTools.CopyFileBetweenManagedArchives(input, archiveFileName, rom.Name, found.Name, _logger);
} }
} }