mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Make merging more robust
This commit is contained in:
@@ -172,18 +172,19 @@ namespace SabreTools
|
|||||||
Dictionary<string, List<RomData>> netNew = new Dictionary<string, List<RomData>>();
|
Dictionary<string, List<RomData>> netNew = new Dictionary<string, List<RomData>>();
|
||||||
foreach (string key in completeDats.Keys)
|
foreach (string key in completeDats.Keys)
|
||||||
{
|
{
|
||||||
if (completeDats[key].Count == 1)
|
List<RomData> templist = RomManipulation.Merge(completeDats[key]);
|
||||||
|
foreach (RomData rom in templist)
|
||||||
{
|
{
|
||||||
if (completeDats[key][0].System == _currentNewMerged)
|
if (!rom.Dupe && rom.System == _currentNewMerged)
|
||||||
{
|
{
|
||||||
if (netNew.ContainsKey(key))
|
if (netNew.ContainsKey(key))
|
||||||
{
|
{
|
||||||
netNew[key].Add(completeDats[key][0]);
|
netNew[key].Add(rom);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<RomData> temp = new List<RomData>();
|
List<RomData> temp = new List<RomData>();
|
||||||
temp.Add(completeDats[key][0]);
|
temp.Add(rom);
|
||||||
netNew.Add(key, temp);
|
netNew.Add(key, temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -195,18 +196,19 @@ namespace SabreTools
|
|||||||
Dictionary<string, List<RomData>> unneeded = new Dictionary<string, List<RomData>>();
|
Dictionary<string, List<RomData>> unneeded = new Dictionary<string, List<RomData>>();
|
||||||
foreach (string key in completeDats.Keys)
|
foreach (string key in completeDats.Keys)
|
||||||
{
|
{
|
||||||
if (completeDats[key].Count == 1)
|
List<RomData> templist = RomManipulation.Merge(completeDats[key]);
|
||||||
|
foreach (RomData rom in templist)
|
||||||
{
|
{
|
||||||
if (completeDats[key][0].System == _currentAllMerged)
|
if (!rom.Dupe && rom.System == _currentAllMerged)
|
||||||
{
|
{
|
||||||
if (unneeded.ContainsKey(key))
|
if (unneeded.ContainsKey(key))
|
||||||
{
|
{
|
||||||
unneeded[key].Add(completeDats[key][0]);
|
unneeded[key].Add(rom);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<RomData> temp = new List<RomData>();
|
List<RomData> temp = new List<RomData>();
|
||||||
temp.Add(completeDats[key][0]);
|
temp.Add(rom);
|
||||||
unneeded.Add(key, temp);
|
unneeded.Add(key, temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -231,18 +233,19 @@ namespace SabreTools
|
|||||||
Dictionary<string, List<RomData>> newMissing = new Dictionary<string, List<RomData>>();
|
Dictionary<string, List<RomData>> newMissing = new Dictionary<string, List<RomData>>();
|
||||||
foreach (string key in midMissing.Keys)
|
foreach (string key in midMissing.Keys)
|
||||||
{
|
{
|
||||||
if (midMissing[key].Count == 1)
|
List<RomData> templist = RomManipulation.Merge(midMissing[key]);
|
||||||
|
foreach (RomData rom in templist)
|
||||||
{
|
{
|
||||||
if (midMissing[key][0].System == _currentMissingMerged)
|
if (!rom.Dupe && rom.System == _currentMissingMerged)
|
||||||
{
|
{
|
||||||
if (newMissing.ContainsKey(key))
|
if (newMissing.ContainsKey(key))
|
||||||
{
|
{
|
||||||
newMissing[key].Add(midMissing[key][0]);
|
newMissing[key].Add(rom);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<RomData> temp = new List<RomData>();
|
List<RomData> temp = new List<RomData>();
|
||||||
temp.Add(midMissing[key][0]);
|
temp.Add(rom);
|
||||||
newMissing.Add(key, temp);
|
newMissing.Add(key, temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -302,18 +305,19 @@ namespace SabreTools
|
|||||||
Dictionary<string, List<RomData>> have = new Dictionary<string, List<RomData>>();
|
Dictionary<string, List<RomData>> have = new Dictionary<string, List<RomData>>();
|
||||||
foreach (string key in midHave.Keys)
|
foreach (string key in midHave.Keys)
|
||||||
{
|
{
|
||||||
if (midHave[key].Count == 1)
|
List<RomData> templist = RomManipulation.Merge(midHave[key]);
|
||||||
|
foreach (RomData rom in templist)
|
||||||
{
|
{
|
||||||
if (midHave[key][0].System == _currentNewMerged)
|
if (!rom.Dupe && rom.System == _currentNewMerged)
|
||||||
{
|
{
|
||||||
if (have.ContainsKey(key))
|
if (have.ContainsKey(key))
|
||||||
{
|
{
|
||||||
have[key].Add(midHave[key][0]);
|
have[key].Add(rom);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<RomData> temp = new List<RomData>();
|
List<RomData> temp = new List<RomData>();
|
||||||
temp.Add(midHave[key][0]);
|
temp.Add(rom);
|
||||||
have.Add(key, temp);
|
have.Add(key, temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,7 +154,13 @@ namespace SabreTools.Helper
|
|||||||
long count = 0;
|
long count = 0;
|
||||||
foreach (List<RomData> roms in dict.Values)
|
foreach (List<RomData> roms in dict.Values)
|
||||||
{
|
{
|
||||||
foreach (RomData rom in roms)
|
List<RomData> newroms = roms;
|
||||||
|
if (merge)
|
||||||
|
{
|
||||||
|
newroms = RomManipulation.Merge(newroms);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (RomData rom in newroms)
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
string key = rom.SystemID + "-" + rom.SourceID + "-" + rom.Game + "-" + rom.Name;
|
string key = rom.SystemID + "-" + rom.SourceID + "-" + rom.Game + "-" + rom.Name;
|
||||||
@@ -168,11 +174,6 @@ namespace SabreTools.Helper
|
|||||||
temp.Add(rom);
|
temp.Add(rom);
|
||||||
sortable.Add(key, temp);
|
sortable.Add(key, temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (merge)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -467,7 +467,7 @@ namespace SabreTools.Helper
|
|||||||
sha1 = (sha1.StartsWith("0x") ? sha1.Remove(0, 2) : sha1);
|
sha1 = (sha1.StartsWith("0x") ? sha1.Remove(0, 2) : sha1);
|
||||||
|
|
||||||
// Get the new values to add
|
// Get the new values to add
|
||||||
string key = crc + "-" + md5 + "-" + sha1 + "-" + size;
|
string key = crc + "-" + size;
|
||||||
RomData value = new RomData
|
RomData value = new RomData
|
||||||
{
|
{
|
||||||
Game = tempname,
|
Game = tempname,
|
||||||
@@ -590,6 +590,7 @@ namespace SabreTools.Helper
|
|||||||
last.CRC = (last.CRC == "" && rom.CRC != "" ? rom.CRC : last.CRC);
|
last.CRC = (last.CRC == "" && rom.CRC != "" ? rom.CRC : last.CRC);
|
||||||
last.MD5 = (last.MD5 == "" && rom.MD5 != "" ? rom.MD5 : last.MD5);
|
last.MD5 = (last.MD5 == "" && rom.MD5 != "" ? rom.MD5 : last.MD5);
|
||||||
last.SHA1 = (last.SHA1 == "" && rom.SHA1 != "" ? rom.SHA1 : last.SHA1);
|
last.SHA1 = (last.SHA1 == "" && rom.SHA1 != "" ? rom.SHA1 : last.SHA1);
|
||||||
|
last.Dupe = true;
|
||||||
|
|
||||||
outroms.RemoveAt(outroms.Count - 1);
|
outroms.RemoveAt(outroms.Count - 1);
|
||||||
outroms.Insert(outroms.Count, last);
|
outroms.Insert(outroms.Count, last);
|
||||||
@@ -611,7 +612,6 @@ namespace SabreTools.Helper
|
|||||||
return outroms;
|
return outroms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sort a list of RomData objects by SystemID, SourceID, Game, and Name (in order)
|
/// Sort a list of RomData objects by SystemID, SourceID, Game, and Name (in order)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -18,5 +18,6 @@
|
|||||||
public string CRC;
|
public string CRC;
|
||||||
public string MD5;
|
public string MD5;
|
||||||
public string SHA1;
|
public string SHA1;
|
||||||
|
public bool Dupe;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user