Fix broken GetKeyDB and related

This commit is contained in:
Matt Nadareski
2025-01-14 14:22:18 -05:00
parent 688e7772e4
commit 222944fae6
13 changed files with 51 additions and 113 deletions

View File

@@ -246,7 +246,7 @@ namespace SabreTools.DatFiles
}
// Get the key and add the file
key = item.GetKey(ItemKey.Machine);
key = GetBucketKey(item, _bucketedBy, lower: true, norename: true);
// If only adding statistics, we add an empty key for games and then just item stats
if (statsOnly)
@@ -644,6 +644,26 @@ namespace SabreTools.DatFiles
return ItemKey.CRC;
}
/// <summary>
/// Get the bucketing key for a given item
/// <param name="datItem">The current item</param>
/// <param name="bucketBy">ItemKey value representing what key to get</param>
/// <param name="lower">True if the key should be lowercased, false otherwise</param>
/// <param name="norename">True if games should only be compared on game and file name, false if system and source are counted</param>
/// </summary>
private string GetBucketKey(DatItem datItem, ItemKey bucketBy, bool lower, bool norename)
{
if (datItem == null)
return string.Empty;
// Treat NULL like machine
if (bucketBy == ItemKey.NULL)
bucketBy = ItemKey.Machine;
// Get the bucket key
return datItem.GetKey(bucketBy, lower, norename);
}
/// <summary>
/// Perform bucketing based on the item key provided
/// </summary>