mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[DatFile] If, on write-out, a game contains the exact same item multiple times, then don't write out the duplicates
This commit is contained in:
@@ -544,16 +544,33 @@ namespace SabreTools.Helper.Dats
|
|||||||
Sort(ref infiles, true);
|
Sort(ref infiles, true);
|
||||||
|
|
||||||
// Now we want to loop through and check names
|
// Now we want to loop through and check names
|
||||||
string last = null;
|
DatItem lastItem = null;
|
||||||
string lastrenamed = null;
|
string lastrenamed = null;
|
||||||
int lastid = 0;
|
int lastid = 0;
|
||||||
for (int i = 0; i < infiles.Count; i++)
|
for (int i = 0; i < infiles.Count; i++)
|
||||||
{
|
{
|
||||||
DatItem datItem = infiles[i];
|
DatItem datItem = infiles[i];
|
||||||
|
|
||||||
// If the current name matches the previous name, rename the current item
|
// If we have the first item, we automatically add it
|
||||||
if (datItem.Name == last)
|
if (lastItem == null)
|
||||||
{
|
{
|
||||||
|
output.Add(datItem);
|
||||||
|
lastItem = datItem;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the current item exactly matches the last item, then we don't add it
|
||||||
|
if ((datItem.GetDuplicateStatus(lastItem, logger) & DupeType.All) != 0)
|
||||||
|
{
|
||||||
|
logger.Verbose("Exact duplicate found for '" + datItem.Name + "'");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the current name matches the previous name, rename the current item
|
||||||
|
else if (datItem.Name == lastItem.Name)
|
||||||
|
{
|
||||||
|
logger.Verbose("Name duplicate found for '" + datItem.Name + "'");
|
||||||
|
|
||||||
if (datItem.Type == ItemType.Disk)
|
if (datItem.Type == ItemType.Disk)
|
||||||
{
|
{
|
||||||
Disk disk = (Disk)datItem;
|
Disk disk = (Disk)datItem;
|
||||||
@@ -591,8 +608,9 @@ namespace SabreTools.Helper.Dats
|
|||||||
// Otherwise, we say that we have a valid named file
|
// Otherwise, we say that we have a valid named file
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
logger.Verbose("Adding unmatched file '" + datItem.Name + "'");
|
||||||
output.Add(datItem);
|
output.Add(datItem);
|
||||||
last = datItem.Name;
|
lastItem = datItem;
|
||||||
lastrenamed = null;
|
lastrenamed = null;
|
||||||
lastid = 0;
|
lastid = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ namespace SabreTools.Helper.Dats
|
|||||||
List<DatItem> roms = this[key];
|
List<DatItem> roms = this[key];
|
||||||
|
|
||||||
// Resolve the names in the block
|
// Resolve the names in the block
|
||||||
DatItem.ResolveNames(roms, logger);
|
roms = DatItem.ResolveNames(roms, logger);
|
||||||
|
|
||||||
for (int index = 0; index < roms.Count; index++)
|
for (int index = 0; index < roms.Count; index++)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user