mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Change handling of duplicate roms
If a rom or disk is found to be a duplicate (by using the actual last item in the list instead of unnecessary cached values), it then checks to see if any information is missing from the rom it's a duplicate of. If the CRC, MD5, or SHA1 are empty and a new value is available, it uses the new value dynamically. This way, the original information in the database is untouched but the generated DAT is more complete.
This commit is contained in:
@@ -293,8 +293,6 @@ JOIN checksums
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve and process the roms for merging
|
// Retrieve and process the roms for merging
|
||||||
string lasttype = "", lastcrc = "", lastmd5 = "", lastsha1 = "";
|
|
||||||
int lastsize = -1;
|
|
||||||
while (sldr.Read())
|
while (sldr.Read())
|
||||||
{
|
{
|
||||||
RomData temp = new RomData
|
RomData temp = new RomData
|
||||||
@@ -317,33 +315,32 @@ JOIN checksums
|
|||||||
if (merged)
|
if (merged)
|
||||||
{
|
{
|
||||||
// Check if the rom is a duplicate
|
// Check if the rom is a duplicate
|
||||||
|
RomData last = roms[roms.Count - 1];
|
||||||
bool shouldcont = false;
|
bool shouldcont = false;
|
||||||
if (temp.Type == "rom" && lasttype == "rom")
|
if (temp.Type == "rom" && last.Type == "rom")
|
||||||
{
|
{
|
||||||
shouldcont = ((temp.Size != -1 && temp.Size == lastsize) && (
|
shouldcont = ((temp.Size != -1 && temp.Size == last.Size) && (
|
||||||
(temp.CRC != "" && lastcrc != "" && temp.CRC == lastcrc) ||
|
(temp.CRC != "" && last.CRC != "" && temp.CRC == last.CRC) ||
|
||||||
(temp.MD5 != "" && lastmd5 != "" && temp.MD5 == lastmd5) ||
|
(temp.MD5 != "" && last.MD5 != "" && temp.MD5 == last.MD5) ||
|
||||||
(temp.SHA1 != "" && lastsha1 != "" && temp.SHA1 == lastsha1)
|
(temp.SHA1 != "" && last.SHA1 != "" && temp.SHA1 == last.SHA1)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if (temp.Type == "disk" && lasttype == "disk")
|
else if (temp.Type == "disk" && last.Type == "disk")
|
||||||
{
|
{
|
||||||
shouldcont = ((temp.MD5 != "" && lastmd5 != "" && temp.MD5 == lastmd5) ||
|
shouldcont = ((temp.MD5 != "" && last.MD5 != "" && temp.MD5 == last.MD5) ||
|
||||||
(temp.SHA1 != "" && lastsha1 != "" && temp.SHA1 == lastsha1)
|
(temp.SHA1 != "" && last.SHA1 != "" && temp.SHA1 == last.SHA1)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the next variables
|
// If it's a duplicate, skip adding it to the output but add any missing information
|
||||||
lasttype = temp.Type;
|
|
||||||
lastsize = temp.Size;
|
|
||||||
lastcrc = temp.CRC;
|
|
||||||
lastmd5 = temp.MD5;
|
|
||||||
lastsha1 = temp.SHA1;
|
|
||||||
|
|
||||||
// If it's a duplicate, skip adding it to the output
|
|
||||||
if (shouldcont)
|
if (shouldcont)
|
||||||
{
|
{
|
||||||
|
last.CRC = (last.CRC == "" && temp.CRC != "" ? temp.CRC : last.CRC);
|
||||||
|
last.MD5 = (last.MD5 == "" && temp.MD5 != "" ? temp.MD5 : last.MD5);
|
||||||
|
last.SHA1 = (last.SHA1 == "" && temp.SHA1 != "" ? temp.SHA1 : last.SHA1);
|
||||||
|
roms.Insert(roms.Count - 1, last);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user