mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[DatItem] Make name resolution better
This commit is contained in:
@@ -545,7 +545,8 @@ namespace SabreTools.Helper.Dats
|
|||||||
|
|
||||||
// Now we want to loop through and check names
|
// Now we want to loop through and check names
|
||||||
string last = null;
|
string last = null;
|
||||||
int lastid = 1;
|
string lastrenamed = null;
|
||||||
|
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];
|
||||||
@@ -558,17 +559,30 @@ namespace SabreTools.Helper.Dats
|
|||||||
Disk disk = (Disk)datItem;
|
Disk disk = (Disk)datItem;
|
||||||
disk.Name += "_" + (!String.IsNullOrEmpty(disk.MD5) ? disk.MD5 : disk.SHA1);
|
disk.Name += "_" + (!String.IsNullOrEmpty(disk.MD5) ? disk.MD5 : disk.SHA1);
|
||||||
datItem = disk;
|
datItem = disk;
|
||||||
|
lastrenamed = lastrenamed == null ? datItem.Name : lastrenamed;
|
||||||
}
|
}
|
||||||
else if (datItem.Type == ItemType.Rom)
|
else if (datItem.Type == ItemType.Rom)
|
||||||
{
|
{
|
||||||
Rom rom = (Rom)datItem;
|
Rom rom = (Rom)datItem;
|
||||||
rom.Name += "_" + (!String.IsNullOrEmpty(rom.CRC) ? rom.CRC : !String.IsNullOrEmpty(rom.MD5) ? rom.MD5 : rom.SHA1);
|
rom.Name += "_" + (!String.IsNullOrEmpty(rom.CRC) ? rom.CRC :
|
||||||
|
!String.IsNullOrEmpty(rom.MD5) ? rom.MD5 :
|
||||||
|
!String.IsNullOrEmpty(rom.SHA1) ? rom.SHA1 : "(alt)");
|
||||||
datItem = rom;
|
datItem = rom;
|
||||||
|
lastrenamed = lastrenamed == null ? datItem.Name : lastrenamed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we have a conflict with the last renamed item, do the right thing
|
||||||
|
if (datItem.Name == lastrenamed)
|
||||||
|
{
|
||||||
|
lastrenamed = datItem.Name;
|
||||||
|
datItem.Name += (lastid == 0 ? "" : "_" + lastid);
|
||||||
|
lastid++;
|
||||||
|
}
|
||||||
|
// If we have no conflict, then we want to reset the lastrenamed and id
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
datItem.Name += "_" + lastid;
|
lastrenamed = null;
|
||||||
lastid++;
|
lastid = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
output.Add(datItem);
|
output.Add(datItem);
|
||||||
@@ -579,7 +593,8 @@ namespace SabreTools.Helper.Dats
|
|||||||
{
|
{
|
||||||
output.Add(datItem);
|
output.Add(datItem);
|
||||||
last = datItem.Name;
|
last = datItem.Name;
|
||||||
lastid = 1;
|
lastrenamed = null;
|
||||||
|
lastid = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -139,11 +139,13 @@ namespace SabreTools.Helper.Dats
|
|||||||
sortable.Add(newkey, new List<DatItem>());
|
sortable.Add(newkey, new List<DatItem>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
// Here, we want to see if there is a duplicate-named file already in the game
|
// Here, we want to see if there is a duplicate-named file already in the game
|
||||||
if (sortable[newkey].Where(i => i.Name == rom.Name).Count() > 0)
|
if (sortable[newkey].Where(i => i.Name == rom.Name).Count() > 0)
|
||||||
{
|
{
|
||||||
logger.Error("Duplicate named-file '" + rom.Name + "' detected in machine '" + newkey + "'");
|
logger.Error("Duplicate named-file '" + rom.Name + "' detected in machine '" + newkey + "'");
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
sortable[newkey].Add(rom);
|
sortable[newkey].Add(rom);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user