mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[Structs] Create different, single struct
This commit is contained in:
@@ -18,8 +18,7 @@ namespace SabreTools.Helper
|
|||||||
public DupeType Dupe;
|
public DupeType Dupe;
|
||||||
public bool Nodump;
|
public bool Nodump;
|
||||||
public string Date;
|
public string Date;
|
||||||
public SystemData SystemData;
|
public SourceMetadata Metadata;
|
||||||
public SourceData SourceData;
|
|
||||||
|
|
||||||
public int CompareTo(object obj)
|
public int CompareTo(object obj)
|
||||||
{
|
{
|
||||||
@@ -52,22 +51,14 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Intermediate struct for holding System information
|
/// Intermediate metadata kept with a RomData object representing source information
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public struct SystemData
|
public struct SourceMetadata
|
||||||
{
|
{
|
||||||
public int ID;
|
public int SystemID;
|
||||||
public string Name;
|
public string System;
|
||||||
}
|
public int SourceID;
|
||||||
|
public string Source;
|
||||||
/// <summary>
|
|
||||||
/// Intermediate struct for holding Source information
|
|
||||||
/// </summary>
|
|
||||||
public struct SourceData
|
|
||||||
{
|
|
||||||
public int ID;
|
|
||||||
public string Name;
|
|
||||||
public string URL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -173,8 +173,7 @@ namespace SabreTools.Helper
|
|||||||
{
|
{
|
||||||
Game = gamename,
|
Game = gamename,
|
||||||
Type = (line.Trim().StartsWith("disk (") ? "disk" : "rom"),
|
Type = (line.Trim().StartsWith("disk (") ? "disk" : "rom"),
|
||||||
SystemData = new SystemData { ID = sysid },
|
Metadata = new SourceMetadata { SystemID = sysid, SourceID = srcid },
|
||||||
SourceData = new SourceData { ID = srcid },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
string[] gc = line.Trim().Split(' ');
|
string[] gc = line.Trim().Split(' ');
|
||||||
@@ -577,8 +576,7 @@ namespace SabreTools.Helper
|
|||||||
Name = rominfo[5],
|
Name = rominfo[5],
|
||||||
CRC = rominfo[6].ToLowerInvariant(),
|
CRC = rominfo[6].ToLowerInvariant(),
|
||||||
Size = Int64.Parse(rominfo[7]),
|
Size = Int64.Parse(rominfo[7]),
|
||||||
SystemData = new SystemData { ID = sysid },
|
Metadata = new SourceMetadata { SystemID = sysid, SourceID = srcid },
|
||||||
SourceData = new SourceData { ID = srcid },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Sanitize the hashes from null, hex sizes, and "true blank" strings
|
// Sanitize the hashes from null, hex sizes, and "true blank" strings
|
||||||
@@ -1158,8 +1156,7 @@ namespace SabreTools.Helper
|
|||||||
SHA1 = sha1,
|
SHA1 = sha1,
|
||||||
Nodump = nodump,
|
Nodump = nodump,
|
||||||
Date = date,
|
Date = date,
|
||||||
SystemData = new SystemData { ID = sysid, Name = filename },
|
Metadata = new SourceMetadata { SystemID = sysid, System = filename, SourceID = srcid },
|
||||||
SourceData = new SourceData { ID = srcid },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (datdata.Roms.ContainsKey(key))
|
if (datdata.Roms.ContainsKey(key))
|
||||||
@@ -1394,8 +1391,7 @@ namespace SabreTools.Helper
|
|||||||
SHA1 = sha1,
|
SHA1 = sha1,
|
||||||
Nodump = nodump,
|
Nodump = nodump,
|
||||||
Date = date,
|
Date = date,
|
||||||
SystemData = new SystemData { ID = sysid, Name = filename },
|
Metadata = new SourceMetadata { SystemID = sysid, System = filename, SourceID = srcid },
|
||||||
SourceData = new SourceData { ID = srcid },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (datdata.Roms.ContainsKey(key))
|
if (datdata.Roms.ContainsKey(key))
|
||||||
@@ -1465,7 +1461,7 @@ namespace SabreTools.Helper
|
|||||||
foreach (RomData rom in newroms)
|
foreach (RomData rom in newroms)
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
string key = (norename ? "" : rom.SystemData.ID.ToString().PadLeft(10, '0') + "-" + rom.SourceData.ID.ToString().PadLeft(10, '0') + "-") + rom.Game.ToLowerInvariant();
|
string key = (norename ? "" : rom.Metadata.SystemID.ToString().PadLeft(10, '0') + "-" + rom.Metadata.SourceID.ToString().PadLeft(10, '0') + "-") + rom.Game.ToLowerInvariant();
|
||||||
if (sortable.ContainsKey(key))
|
if (sortable.ContainsKey(key))
|
||||||
{
|
{
|
||||||
sortable[key].Add(rom);
|
sortable[key].Add(rom);
|
||||||
|
|||||||
@@ -209,17 +209,19 @@ namespace SabreTools.Helper
|
|||||||
savedrom.Dupe = dupetype;
|
savedrom.Dupe = dupetype;
|
||||||
|
|
||||||
// If the current system has a lower ID than the previous, set the system accordingly
|
// If the current system has a lower ID than the previous, set the system accordingly
|
||||||
if (rom.SystemData.ID < savedrom.SystemData.ID)
|
if (rom.Metadata.SystemID < savedrom.Metadata.SystemID)
|
||||||
{
|
{
|
||||||
savedrom.SystemData = rom.SystemData;
|
savedrom.Metadata.SystemID = rom.Metadata.SystemID;
|
||||||
|
savedrom.Metadata.System = rom.Metadata.System;
|
||||||
savedrom.Game = rom.Game;
|
savedrom.Game = rom.Game;
|
||||||
savedrom.Name = rom.Name;
|
savedrom.Name = rom.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the current source has a lower ID than the previous, set the source accordingly
|
// If the current source has a lower ID than the previous, set the source accordingly
|
||||||
if (rom.SourceData.ID < savedrom.SourceData.ID)
|
if (rom.Metadata.SourceID < savedrom.Metadata.SourceID)
|
||||||
{
|
{
|
||||||
savedrom.SourceData = rom.SourceData;
|
savedrom.Metadata.SourceID = rom.Metadata.SourceID;
|
||||||
|
savedrom.Metadata.Source = rom.Metadata.Source;
|
||||||
savedrom.Game = rom.Game;
|
savedrom.Game = rom.Game;
|
||||||
savedrom.Name = rom.Name;
|
savedrom.Name = rom.Name;
|
||||||
}
|
}
|
||||||
@@ -332,7 +334,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.SystemData.ID != rom.SystemData.ID || lastrom.SourceData.ID != rom.SourceData.ID)
|
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 == rom.Game && lastrom.Name == rom.Name)
|
||||||
{
|
{
|
||||||
@@ -370,9 +372,9 @@ namespace SabreTools.Helper
|
|||||||
{
|
{
|
||||||
roms.Sort(delegate (RomData x, RomData y)
|
roms.Sort(delegate (RomData x, RomData y)
|
||||||
{
|
{
|
||||||
if (x.SystemData.ID == y.SystemData.ID)
|
if (x.Metadata.SystemID == y.Metadata.SystemID)
|
||||||
{
|
{
|
||||||
if (x.SourceData.ID == y.SourceData.ID)
|
if (x.Metadata.SourceID == y.Metadata.SourceID)
|
||||||
{
|
{
|
||||||
if (x.Game == y.Game)
|
if (x.Game == y.Game)
|
||||||
{
|
{
|
||||||
@@ -380,9 +382,9 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
return String.Compare(x.Game, y.Game);
|
return String.Compare(x.Game, y.Game);
|
||||||
}
|
}
|
||||||
return (norename ? String.Compare(x.Game, y.Game) : x.SourceData.ID - y.SourceData.ID);
|
return (norename ? String.Compare(x.Game, y.Game) : x.Metadata.SourceID - y.Metadata.SourceID);
|
||||||
}
|
}
|
||||||
return (norename ? String.Compare(x.Game, y.Game) : x.SystemData.ID - y.SystemData.ID);
|
return (norename ? String.Compare(x.Game, y.Game) : x.Metadata.SystemID - y.Metadata.SystemID);
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -223,13 +223,13 @@ namespace SabreTools
|
|||||||
|
|
||||||
if (!_norename)
|
if (!_norename)
|
||||||
{
|
{
|
||||||
rom.Game += " [" + sources[rom.SourceData.ID] + "]";
|
rom.Game += " [" + 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
|
||||||
if (rom.SourceData.ID == 0)
|
if (rom.Metadata.SourceID == 0)
|
||||||
{
|
{
|
||||||
rom.SourceData.ID = Int32.MaxValue;
|
rom.Metadata.SourceID = Int32.MaxValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
temp.Add(rom);
|
temp.Add(rom);
|
||||||
|
|||||||
@@ -287,20 +287,20 @@ namespace SabreTools
|
|||||||
if (rom.Dupe < DupeType.ExternalHash)
|
if (rom.Dupe < DupeType.ExternalHash)
|
||||||
{
|
{
|
||||||
// Individual DATs that are output
|
// Individual DATs that are output
|
||||||
if (outDats[rom.SystemData.ID].Roms.ContainsKey(key))
|
if (outDats[rom.Metadata.SystemID].Roms.ContainsKey(key))
|
||||||
{
|
{
|
||||||
outDats[rom.SystemData.ID].Roms[key].Add(rom);
|
outDats[rom.Metadata.SystemID].Roms[key].Add(rom);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<RomData> tl = new List<RomData>();
|
List<RomData> tl = new List<RomData>();
|
||||||
tl.Add(rom);
|
tl.Add(rom);
|
||||||
outDats[rom.SystemData.ID].Roms.Add(key, tl);
|
outDats[rom.Metadata.SystemID].Roms.Add(key, tl);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Merged no-duplicates DAT
|
// Merged no-duplicates DAT
|
||||||
RomData newrom = rom;
|
RomData newrom = rom;
|
||||||
newrom.Game += " (" + Path.GetFileNameWithoutExtension(_inputs[newrom.SystemData.ID].Split('¬')[0]) + ")";
|
newrom.Game += " (" + Path.GetFileNameWithoutExtension(_inputs[newrom.Metadata.SystemID].Split('¬')[0]) + ")";
|
||||||
|
|
||||||
if (outerDiffData.Roms.ContainsKey(key))
|
if (outerDiffData.Roms.ContainsKey(key))
|
||||||
{
|
{
|
||||||
@@ -318,7 +318,7 @@ namespace SabreTools
|
|||||||
if (rom.Dupe >= DupeType.ExternalHash)
|
if (rom.Dupe >= DupeType.ExternalHash)
|
||||||
{
|
{
|
||||||
RomData newrom = rom;
|
RomData newrom = rom;
|
||||||
newrom.Game += " (" + Path.GetFileNameWithoutExtension(_inputs[newrom.SystemData.ID].Split('¬')[0]) + ")";
|
newrom.Game += " (" + Path.GetFileNameWithoutExtension(_inputs[newrom.Metadata.SystemID].Split('¬')[0]) + ")";
|
||||||
|
|
||||||
if (dupeData.Roms.ContainsKey(key))
|
if (dupeData.Roms.ContainsKey(key))
|
||||||
{
|
{
|
||||||
@@ -420,15 +420,15 @@ namespace SabreTools
|
|||||||
{
|
{
|
||||||
foreach (RomData rom in roms)
|
foreach (RomData rom in roms)
|
||||||
{
|
{
|
||||||
if (outDats[rom.SystemData.ID].Roms.ContainsKey(key))
|
if (outDats[rom.Metadata.SystemID].Roms.ContainsKey(key))
|
||||||
{
|
{
|
||||||
outDats[rom.SystemData.ID].Roms[key].Add(rom);
|
outDats[rom.Metadata.SystemID].Roms[key].Add(rom);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<RomData> tl = new List<RomData>();
|
List<RomData> tl = new List<RomData>();
|
||||||
tl.Add(rom);
|
tl.Add(rom);
|
||||||
outDats[rom.SystemData.ID].Roms.Add(key, tl);
|
outDats[rom.Metadata.SystemID].Roms.Add(key, tl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -477,8 +477,8 @@ namespace SabreTools
|
|||||||
foreach (RomData rom in userData.Roms[key])
|
foreach (RomData rom in userData.Roms[key])
|
||||||
{
|
{
|
||||||
RomData newrom = rom;
|
RomData newrom = rom;
|
||||||
string filename = _inputs[newrom.SystemData.ID].Split('¬')[0];
|
string filename = _inputs[newrom.Metadata.SystemID].Split('¬')[0];
|
||||||
string rootpath = _inputs[newrom.SystemData.ID].Split('¬')[1];
|
string rootpath = _inputs[newrom.Metadata.SystemID].Split('¬')[1];
|
||||||
|
|
||||||
rootpath += (rootpath == "" ? "" : Path.DirectorySeparatorChar.ToString());
|
rootpath += (rootpath == "" ? "" : Path.DirectorySeparatorChar.ToString());
|
||||||
filename = filename.Remove(0, rootpath.Length);
|
filename = filename.Remove(0, rootpath.Length);
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ namespace SabreTools
|
|||||||
List<RomData> templist = RomTools.Merge(completeDats.Roms[key], _logger);
|
List<RomData> templist = RomTools.Merge(completeDats.Roms[key], _logger);
|
||||||
foreach (RomData rom in templist)
|
foreach (RomData rom in templist)
|
||||||
{
|
{
|
||||||
if (rom.Dupe == DupeType.None && rom.SystemData.Name == _currentNewMerged)
|
if (rom.Dupe == DupeType.None && rom.Metadata.System == _currentNewMerged)
|
||||||
{
|
{
|
||||||
if (netNew.ContainsKey(key))
|
if (netNew.ContainsKey(key))
|
||||||
{
|
{
|
||||||
@@ -93,7 +93,7 @@ namespace SabreTools
|
|||||||
List<RomData> templist = RomTools.Merge(completeDats.Roms[key], _logger);
|
List<RomData> templist = RomTools.Merge(completeDats.Roms[key], _logger);
|
||||||
foreach (RomData rom in templist)
|
foreach (RomData rom in templist)
|
||||||
{
|
{
|
||||||
if (rom.Dupe == DupeType.None && rom.SystemData.Name == _currentAllMerged)
|
if (rom.Dupe == DupeType.None && rom.Metadata.System == _currentAllMerged)
|
||||||
{
|
{
|
||||||
if (unneeded.ContainsKey(key))
|
if (unneeded.ContainsKey(key))
|
||||||
{
|
{
|
||||||
@@ -130,7 +130,7 @@ namespace SabreTools
|
|||||||
List<RomData> templist = RomTools.Merge(midMissing.Roms[key], _logger);
|
List<RomData> templist = RomTools.Merge(midMissing.Roms[key], _logger);
|
||||||
foreach (RomData rom in templist)
|
foreach (RomData rom in templist)
|
||||||
{
|
{
|
||||||
if (rom.Dupe == DupeType.None && rom.SystemData.Name == _currentMissingMerged)
|
if (rom.Dupe == DupeType.None && rom.Metadata.System == _currentMissingMerged)
|
||||||
{
|
{
|
||||||
if (newMissing.ContainsKey(key))
|
if (newMissing.ContainsKey(key))
|
||||||
{
|
{
|
||||||
@@ -177,7 +177,7 @@ namespace SabreTools
|
|||||||
{
|
{
|
||||||
foreach (RomData rom in completeDats.Roms[key])
|
foreach (RomData rom in completeDats.Roms[key])
|
||||||
{
|
{
|
||||||
if (rom.SystemData.Name == _currentNewMerged)
|
if (rom.Metadata.System == _currentNewMerged)
|
||||||
{
|
{
|
||||||
midHave[key].Add(rom);
|
midHave[key].Add(rom);
|
||||||
}
|
}
|
||||||
@@ -188,7 +188,7 @@ namespace SabreTools
|
|||||||
List<RomData> roms = new List<RomData>();
|
List<RomData> roms = new List<RomData>();
|
||||||
foreach (RomData rom in completeDats.Roms[key])
|
foreach (RomData rom in completeDats.Roms[key])
|
||||||
{
|
{
|
||||||
if (rom.SystemData.Name == _currentNewMerged)
|
if (rom.Metadata.System == _currentNewMerged)
|
||||||
{
|
{
|
||||||
roms.Add(rom);
|
roms.Add(rom);
|
||||||
}
|
}
|
||||||
@@ -202,7 +202,7 @@ namespace SabreTools
|
|||||||
List<RomData> templist = RomTools.Merge(midHave[key], _logger);
|
List<RomData> templist = RomTools.Merge(midHave[key], _logger);
|
||||||
foreach (RomData rom in templist)
|
foreach (RomData rom in templist)
|
||||||
{
|
{
|
||||||
if (rom.Dupe == DupeType.None && rom.SystemData.Name == _currentNewMerged)
|
if (rom.Dupe == DupeType.None && rom.Metadata.System == _currentNewMerged)
|
||||||
{
|
{
|
||||||
if (have.ContainsKey(key))
|
if (have.ContainsKey(key))
|
||||||
{
|
{
|
||||||
@@ -370,7 +370,7 @@ namespace SabreTools
|
|||||||
List<RomData> templist = RomTools.Merge(midHave.Roms[key], _logger);
|
List<RomData> templist = RomTools.Merge(midHave.Roms[key], _logger);
|
||||||
foreach (RomData rom in templist)
|
foreach (RomData rom in templist)
|
||||||
{
|
{
|
||||||
if (rom.Dupe == DupeType.None && rom.SystemData.Name == _currentAllMerged)
|
if (rom.Dupe == DupeType.None && rom.Metadata.System == _currentAllMerged)
|
||||||
{
|
{
|
||||||
if (have.ContainsKey(key))
|
if (have.ContainsKey(key))
|
||||||
{
|
{
|
||||||
@@ -440,7 +440,7 @@ namespace SabreTools
|
|||||||
List<RomData> templist = RomTools.Merge(midHave.Roms[key], _logger);
|
List<RomData> templist = RomTools.Merge(midHave.Roms[key], _logger);
|
||||||
foreach (RomData rom in templist)
|
foreach (RomData rom in templist)
|
||||||
{
|
{
|
||||||
if (rom.Dupe == DupeType.None && rom.SystemData.Name == _currentNewMerged)
|
if (rom.Dupe == DupeType.None && rom.Metadata.System == _currentNewMerged)
|
||||||
{
|
{
|
||||||
if (have.ContainsKey(key))
|
if (have.ContainsKey(key))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user