Fix remove flag issues

This commit is contained in:
Matt Nadareski
2024-03-11 14:31:02 -04:00
parent 4db6d14ffb
commit 5188e8f3e0
13 changed files with 51 additions and 52 deletions

View File

@@ -336,7 +336,7 @@ namespace SabreTools.DatFiles
TotalCount++;
// Increment removal count
if (item.GetFieldValue<bool>(DatItem.RemoveKey))
if (item.GetFieldValue<bool?>(DatItem.RemoveKey) == true)
RemovedCount++;
// Increment the item count for the type
@@ -530,7 +530,7 @@ namespace SabreTools.DatFiles
// Filter the list
return fi.Where(i => i != null)
.Where(i => !i.GetFieldValue<bool>(DatItem.RemoveKey))
.Where(i => i.GetFieldValue<bool?>(DatItem.RemoveKey) != true)
.Where(i => i.GetFieldValue<Machine>(DatItem.MachineKey)!.GetFieldValue<string?>(Models.Metadata.Machine.NameKey) != null)
.ToConcurrentList();
}
@@ -644,7 +644,7 @@ namespace SabreTools.DatFiles
TotalCount--;
// Decrement removal count
if (item.GetFieldValue<bool>(DatItem.RemoveKey))
if (item.GetFieldValue<bool?>(DatItem.RemoveKey) == true)
RemovedCount--;
// Decrement the item count for the type
@@ -1079,7 +1079,7 @@ CREATE TABLE IF NOT EXISTS groups (
foreach (string key in keys)
{
ConcurrentList<DatItem>? oldItemList = this[key];
ConcurrentList<DatItem>? newItemList = oldItemList?.Where(i => !i.GetFieldValue<bool>(DatItem.RemoveKey))?.ToConcurrentList();
ConcurrentList<DatItem>? newItemList = oldItemList?.Where(i => i.GetFieldValue<bool>(DatItem.RemoveKey) != true)?.ToConcurrentList();
Remove(key);
AddRange(key, newItemList);
@@ -1113,12 +1113,12 @@ CREATE TABLE IF NOT EXISTS groups (
for (int i = 0; i < roms.Count; i++)
{
DatItem other = roms[i];
if (other.GetFieldValue<bool>(DatItem.RemoveKey))
if (other.GetFieldValue<bool?>(DatItem.RemoveKey) == true)
continue;
if (datItem.Equals(other))
{
other.SetFieldValue<bool>(DatItem.RemoveKey, true);
other.SetFieldValue<bool?>(DatItem.RemoveKey, true);
output.Add(other);
}
else