mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Ensure blanks during D2D are handled properly (fixes #80)
This commit is contained in:
@@ -692,39 +692,39 @@ namespace SabreTools.DatFiles
|
|||||||
#elif NET40_OR_GREATER
|
#elif NET40_OR_GREATER
|
||||||
Parallel.For(0, oldkeys.Count, k =>
|
Parallel.For(0, oldkeys.Count, k =>
|
||||||
#else
|
#else
|
||||||
for (int k = 0; k < oldkeys.Count; k++)
|
for (int k = 0; k < oldkeys.Count; k++)
|
||||||
#endif
|
#endif
|
||||||
{
|
|
||||||
string key = oldkeys[k];
|
|
||||||
if (this[key] == null)
|
|
||||||
Remove(key);
|
|
||||||
|
|
||||||
// Now add each of the roms to their respective keys
|
|
||||||
for (int i = 0; i < this[key]!.Count; i++)
|
|
||||||
{
|
{
|
||||||
DatItem item = this[key]![i];
|
string key = oldkeys[k];
|
||||||
if (item == null)
|
if (this[key] == null)
|
||||||
continue;
|
Remove(key);
|
||||||
|
|
||||||
// We want to get the key most appropriate for the given sorting type
|
// Now add each of the roms to their respective keys
|
||||||
string newkey = item.GetKey(bucketBy, lower, norename);
|
for (int i = 0; i < this[key]!.Count; i++)
|
||||||
|
|
||||||
// If the key is different, move the item to the new key
|
|
||||||
if (newkey != key)
|
|
||||||
{
|
{
|
||||||
Add(newkey, item);
|
DatItem item = this[key]![i];
|
||||||
Remove(key, item);
|
if (item == null)
|
||||||
i--; // This make sure that the pointer stays on the correct since one was removed
|
continue;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the key is now empty, remove it
|
// We want to get the key most appropriate for the given sorting type
|
||||||
if (this[key]!.Count == 0)
|
string newkey = item.GetKey(bucketBy, lower, norename);
|
||||||
Remove(key);
|
|
||||||
#if NET40_OR_GREATER || NETCOREAPP
|
// If the key is different, move the item to the new key
|
||||||
});
|
if (newkey != key)
|
||||||
#else
|
{
|
||||||
|
Add(newkey, item);
|
||||||
|
Remove(key, item);
|
||||||
|
i--; // This make sure that the pointer stays on the correct since one was removed
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the key is now empty, remove it
|
||||||
|
if (this[key]!.Count == 0)
|
||||||
|
Remove(key);
|
||||||
|
#if NET40_OR_GREATER || NETCOREAPP
|
||||||
|
});
|
||||||
|
#else
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace SabreTools.DatItems.Formats
|
|||||||
#region Constructors
|
#region Constructors
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a default, empty Archive object
|
/// Create a default, empty Blank object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Blank()
|
public Blank()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -378,7 +378,7 @@ namespace SabreTools.DatTools
|
|||||||
var blankMachine = new Machine();
|
var blankMachine = new Machine();
|
||||||
blankMachine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, gamename);
|
blankMachine.SetFieldValue<string?>(Models.Metadata.Machine.NameKey, gamename);
|
||||||
|
|
||||||
var blankRom = new Rom();
|
var blankRom = new Blank();
|
||||||
blankRom.SetName(romname);
|
blankRom.SetName(romname);
|
||||||
blankRom.SetFieldValue<Machine?>(DatItem.MachineKey, blankMachine);
|
blankRom.SetFieldValue<Machine?>(DatItem.MachineKey, blankMachine);
|
||||||
|
|
||||||
|
|||||||
@@ -73,6 +73,10 @@ namespace SabreTools.Features
|
|||||||
DatFile basedat = DatFile.Create(Header!);
|
DatFile basedat = DatFile.Create(Header!);
|
||||||
basedat.Header.SetFieldValue<string?>(Models.Metadata.Header.DateKey, DateTime.Now.ToString("yyyy-MM-dd"));
|
basedat.Header.SetFieldValue<string?>(Models.Metadata.Header.DateKey, DateTime.Now.ToString("yyyy-MM-dd"));
|
||||||
|
|
||||||
|
// Update the cleaner based on certain flags
|
||||||
|
if (addBlankFiles)
|
||||||
|
Cleaner!.KeepEmptyGames = true;
|
||||||
|
|
||||||
// For each input directory, create a DAT
|
// For each input directory, create a DAT
|
||||||
foreach (string path in Inputs)
|
foreach (string path in Inputs)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user