mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[Filter] Fix filtering after last cleanup
This commit is contained in:
@@ -184,13 +184,13 @@ namespace SabreTools.Library.DatFiles
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on machine type
|
// Filter on machine type
|
||||||
if (!this.MachineTypes.MatchesPositive(MachineType.NULL, item.MachineType))
|
if (this.MachineTypes.MatchesPositive(MachineType.NULL, item.MachineType) == false)
|
||||||
return false;
|
return false;
|
||||||
if (this.MachineTypes.MatchesNegative(MachineType.NULL, item.MachineType))
|
if (this.MachineTypes.MatchesNegative(MachineType.NULL, item.MachineType) == true)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on machine runability
|
// Filter on machine runability
|
||||||
if (!this.Runnable.MatchesNeutral(null, item.Runnable))
|
if (this.Runnable.MatchesNeutral(null, item.Runnable) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Take care of Rom and Disk specific differences
|
// Take care of Rom and Disk specific differences
|
||||||
@@ -199,53 +199,53 @@ namespace SabreTools.Library.DatFiles
|
|||||||
Rom rom = (Rom)item;
|
Rom rom = (Rom)item;
|
||||||
|
|
||||||
// Filter on status
|
// Filter on status
|
||||||
if (!this.ItemStatuses.MatchesPositive(ItemStatus.NULL, rom.ItemStatus))
|
if (this.ItemStatuses.MatchesPositive(ItemStatus.NULL, rom.ItemStatus) == false)
|
||||||
return false;
|
return false;
|
||||||
if (this.ItemStatuses.MatchesNegative(ItemStatus.NULL, rom.ItemStatus))
|
if (this.ItemStatuses.MatchesNegative(ItemStatus.NULL, rom.ItemStatus) == true)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on rom size
|
// Filter on rom size
|
||||||
if (!this.Size.MatchesNeutral(-1, rom.Size))
|
if (this.Size.MatchesNeutral(-1, rom.Size) == false)
|
||||||
return false;
|
return false;
|
||||||
else if (!this.Size.MatchesPositive(-1, rom.Size))
|
else if (this.Size.MatchesPositive(-1, rom.Size) == false)
|
||||||
return false;
|
return false;
|
||||||
else if (!this.Size.MatchesNegative(-1, rom.Size))
|
else if (this.Size.MatchesNegative(-1, rom.Size) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on CRC
|
// Filter on CRC
|
||||||
if (!this.CRC.MatchesPositiveSet(rom.CRC))
|
if (this.CRC.MatchesPositiveSet(rom.CRC) == false)
|
||||||
return false;
|
return false;
|
||||||
if (this.CRC.MatchesNegativeSet(rom.CRC))
|
if (this.CRC.MatchesNegativeSet(rom.CRC) == true)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on MD5
|
// Filter on MD5
|
||||||
if (!this.MD5.MatchesPositiveSet(rom.MD5))
|
if (this.MD5.MatchesPositiveSet(rom.MD5) == false)
|
||||||
return false;
|
return false;
|
||||||
if (this.MD5.MatchesNegativeSet(rom.MD5))
|
if (this.MD5.MatchesNegativeSet(rom.MD5) == true)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on SHA-1
|
// Filter on SHA-1
|
||||||
if (!this.SHA1.MatchesPositiveSet(rom.SHA1))
|
if (this.SHA1.MatchesPositiveSet(rom.SHA1) == false)
|
||||||
return false;
|
return false;
|
||||||
if (this.SHA1.MatchesNegativeSet(rom.SHA1))
|
if (this.SHA1.MatchesNegativeSet(rom.SHA1) == true)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on SHA-256
|
// Filter on SHA-256
|
||||||
if (!this.SHA256.MatchesPositiveSet(rom.SHA256))
|
if (this.SHA256.MatchesPositiveSet(rom.SHA256) == false)
|
||||||
return false;
|
return false;
|
||||||
if (this.SHA256.MatchesNegativeSet(rom.SHA256))
|
if (this.SHA256.MatchesNegativeSet(rom.SHA256) == true)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on SHA-384
|
// Filter on SHA-384
|
||||||
if (!this.SHA384.MatchesPositiveSet(rom.SHA384))
|
if (this.SHA384.MatchesPositiveSet(rom.SHA384) == false)
|
||||||
return false;
|
return false;
|
||||||
if (this.SHA384.MatchesNegativeSet(rom.SHA384))
|
if (this.SHA384.MatchesNegativeSet(rom.SHA384) == true)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on SHA-512
|
// Filter on SHA-512
|
||||||
if (!this.SHA512.MatchesPositiveSet(rom.SHA512))
|
if (this.SHA512.MatchesPositiveSet(rom.SHA512) == false)
|
||||||
return false;
|
return false;
|
||||||
if (this.SHA512.MatchesNegativeSet(rom.SHA512))
|
if (this.SHA512.MatchesNegativeSet(rom.SHA512) == true)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (item.ItemType == ItemType.Disk)
|
else if (item.ItemType == ItemType.Disk)
|
||||||
@@ -253,80 +253,80 @@ namespace SabreTools.Library.DatFiles
|
|||||||
Disk rom = (Disk)item;
|
Disk rom = (Disk)item;
|
||||||
|
|
||||||
// Filter on status
|
// Filter on status
|
||||||
if (!this.ItemStatuses.MatchesPositive(ItemStatus.NULL, rom.ItemStatus))
|
if (this.ItemStatuses.MatchesPositive(ItemStatus.NULL, rom.ItemStatus) == false)
|
||||||
return false;
|
return false;
|
||||||
if (this.ItemStatuses.MatchesNegative(ItemStatus.NULL, rom.ItemStatus))
|
if (this.ItemStatuses.MatchesNegative(ItemStatus.NULL, rom.ItemStatus) == true)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on MD5
|
// Filter on MD5
|
||||||
if (!this.MD5.MatchesPositiveSet(rom.MD5))
|
if (this.MD5.MatchesPositiveSet(rom.MD5) == false)
|
||||||
return false;
|
return false;
|
||||||
if (this.MD5.MatchesNegativeSet(rom.MD5))
|
if (this.MD5.MatchesNegativeSet(rom.MD5) == true)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on SHA-1
|
// Filter on SHA-1
|
||||||
if (!this.SHA1.MatchesPositiveSet(rom.SHA1))
|
if (this.SHA1.MatchesPositiveSet(rom.SHA1) == false)
|
||||||
return false;
|
return false;
|
||||||
if (this.SHA1.MatchesNegativeSet(rom.SHA1))
|
if (this.SHA1.MatchesNegativeSet(rom.SHA1) == true)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on SHA-256
|
// Filter on SHA-256
|
||||||
if (!this.SHA256.MatchesPositiveSet(rom.SHA256))
|
if (this.SHA256.MatchesPositiveSet(rom.SHA256) == false)
|
||||||
return false;
|
return false;
|
||||||
if (this.SHA256.MatchesNegativeSet(rom.SHA256))
|
if (this.SHA256.MatchesNegativeSet(rom.SHA256) == true)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on SHA-384
|
// Filter on SHA-384
|
||||||
if (!this.SHA384.MatchesPositiveSet(rom.SHA384))
|
if (this.SHA384.MatchesPositiveSet(rom.SHA384) == false)
|
||||||
return false;
|
return false;
|
||||||
if (this.SHA384.MatchesNegativeSet(rom.SHA384))
|
if (this.SHA384.MatchesNegativeSet(rom.SHA384) == true)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on SHA-512
|
// Filter on SHA-512
|
||||||
if (!this.SHA512.MatchesPositiveSet(rom.SHA512))
|
if (this.SHA512.MatchesPositiveSet(rom.SHA512) == false)
|
||||||
return false;
|
return false;
|
||||||
if (this.SHA512.MatchesNegativeSet(rom.SHA512))
|
if (this.SHA512.MatchesNegativeSet(rom.SHA512) == true)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter on machine name
|
// Filter on machine name
|
||||||
bool machineNameFound = this.MachineName.MatchesPositiveSet(item.MachineName);
|
bool? machineNameFound = this.MachineName.MatchesPositiveSet(item.MachineName);
|
||||||
if (this.IncludeOfInGame.Neutral)
|
if (this.IncludeOfInGame.Neutral)
|
||||||
{
|
{
|
||||||
machineNameFound |= this.MachineName.MatchesPositiveSet(item.CloneOf);
|
machineNameFound |= (this.MachineName.MatchesPositiveSet(item.CloneOf) == true);
|
||||||
machineNameFound |= this.MachineName.MatchesPositiveSet(item.RomOf);
|
machineNameFound |= (this.MachineName.MatchesPositiveSet(item.RomOf) == true);
|
||||||
}
|
}
|
||||||
if (!machineNameFound)
|
if (machineNameFound == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
machineNameFound = this.MachineName.MatchesNegativeSet(item.MachineName);
|
machineNameFound = this.MachineName.MatchesNegativeSet(item.MachineName);
|
||||||
if (this.IncludeOfInGame.Neutral)
|
if (this.IncludeOfInGame.Neutral)
|
||||||
{
|
{
|
||||||
machineNameFound |= this.MachineName.MatchesNegativeSet(item.CloneOf);
|
machineNameFound |= (this.MachineName.MatchesNegativeSet(item.CloneOf) == true);
|
||||||
machineNameFound |= this.MachineName.MatchesNegativeSet(item.RomOf);
|
machineNameFound |= (this.MachineName.MatchesNegativeSet(item.RomOf) == true);
|
||||||
}
|
}
|
||||||
if (machineNameFound)
|
if (machineNameFound == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on machine description
|
// Filter on machine description
|
||||||
if (!this.MachineDescription.MatchesPositiveSet(item.MachineDescription))
|
if (this.MachineDescription.MatchesPositiveSet(item.MachineDescription) == false)
|
||||||
return false;
|
return false;
|
||||||
if (this.MachineDescription.MatchesNegativeSet(item.MachineDescription))
|
if (this.MachineDescription.MatchesNegativeSet(item.MachineDescription) == true)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on item name
|
// Filter on item name
|
||||||
if (!this.ItemName.MatchesPositiveSet(item.Name))
|
if (this.ItemName.MatchesPositiveSet(item.Name) == false)
|
||||||
return false;
|
return false;
|
||||||
if (this.ItemName.MatchesNegativeSet(item.Name))
|
if (this.ItemName.MatchesNegativeSet(item.Name) == true)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on item type
|
// Filter on item type
|
||||||
if (this.ItemTypes.PositiveSet.Count == 0 && this.ItemTypes.NegativeSet.Count == 0
|
if (this.ItemTypes.PositiveSet.Count == 0 && this.ItemTypes.NegativeSet.Count == 0
|
||||||
&& item.ItemType != ItemType.Rom && item.ItemType != ItemType.Disk && item.ItemType != ItemType.Blank)
|
&& item.ItemType != ItemType.Rom && item.ItemType != ItemType.Disk && item.ItemType != ItemType.Blank)
|
||||||
return false;
|
return false;
|
||||||
if (!this.ItemTypes.MatchesPositiveSet(item.ItemType.ToString()))
|
if (this.ItemTypes.MatchesPositiveSet(item.ItemType.ToString()) == false)
|
||||||
return false;
|
return false;
|
||||||
if (this.ItemTypes.MatchesNegativeSet(item.ItemType.ToString()))
|
if (this.ItemTypes.MatchesNegativeSet(item.ItemType.ToString()) == true)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ namespace SabreTools.Library.DatFiles
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="def">Default value to check filter value</param>
|
/// <param name="def">Default value to check filter value</param>
|
||||||
/// <param name="value">Value to check</param>
|
/// <param name="value">Value to check</param>
|
||||||
/// <returns>True if the value was found in the positive filter, false otherwise</returns>
|
/// <returns>True if the value was found in the positive filter, null on default value, false otherwise</returns>
|
||||||
public bool MatchesPositive(T def, T value)
|
public bool? MatchesPositive(T def, T value)
|
||||||
{
|
{
|
||||||
return Matches(this.Positive, def, value);
|
return Matches(this.Positive, def, value);
|
||||||
}
|
}
|
||||||
@@ -56,8 +56,8 @@ namespace SabreTools.Library.DatFiles
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="def">Default value to check filter value</param>
|
/// <param name="def">Default value to check filter value</param>
|
||||||
/// <param name="value">Value to check</param>
|
/// <param name="value">Value to check</param>
|
||||||
/// <returns>True if the value was found in the negative filter, false otherwise</returns>
|
/// <returns>True if the value was found in the negative filter, null on default value, false otherwise</returns>
|
||||||
public bool MatchesNegative(T def, T value)
|
public bool? MatchesNegative(T def, T value)
|
||||||
{
|
{
|
||||||
return Matches(this.Negative, def, value);
|
return Matches(this.Negative, def, value);
|
||||||
}
|
}
|
||||||
@@ -67,8 +67,8 @@ namespace SabreTools.Library.DatFiles
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="def">Default value to check filter value</param>
|
/// <param name="def">Default value to check filter value</param>
|
||||||
/// <param name="value">Value to check</param>
|
/// <param name="value">Value to check</param>
|
||||||
/// <returns>True if the value was found in the neutral filter, false otherwise</returns>
|
/// <returns>True if the value was found in the neutral filter, null on default value, false otherwise</returns>
|
||||||
public bool MatchesNeutral(T def, T value)
|
public bool? MatchesNeutral(T def, T value)
|
||||||
{
|
{
|
||||||
return Matches(this.Neutral, def, value);
|
return Matches(this.Neutral, def, value);
|
||||||
}
|
}
|
||||||
@@ -77,8 +77,8 @@ namespace SabreTools.Library.DatFiles
|
|||||||
/// Check if the given value matches any of the positive filters
|
/// Check if the given value matches any of the positive filters
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value">Value to check</param>
|
/// <param name="value">Value to check</param>
|
||||||
/// <returns>True if the value was found in a positive filter, false otherwise</returns>
|
/// <returns>True if the value was found in a positive filter, null on an empty set, false otherwise</returns>
|
||||||
public bool MatchesPositiveSet(T value)
|
public bool? MatchesPositiveSet(T value)
|
||||||
{
|
{
|
||||||
return MatchesSet(this.PositiveSet, value);
|
return MatchesSet(this.PositiveSet, value);
|
||||||
}
|
}
|
||||||
@@ -87,8 +87,8 @@ namespace SabreTools.Library.DatFiles
|
|||||||
/// Check if the given value matches any of the negative filters
|
/// Check if the given value matches any of the negative filters
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value">Value to check</param>
|
/// <param name="value">Value to check</param>
|
||||||
/// <returns>True if the value was found in a negative filter, false otherwise</returns>
|
/// <returns>True if the value was found in a negative filter, null on an empty set, false otherwise</returns>
|
||||||
public bool MatchesNegativeSet(T value)
|
public bool? MatchesNegativeSet(T value)
|
||||||
{
|
{
|
||||||
return MatchesSet(this.NegativeSet, value);
|
return MatchesSet(this.NegativeSet, value);
|
||||||
}
|
}
|
||||||
@@ -97,8 +97,8 @@ namespace SabreTools.Library.DatFiles
|
|||||||
/// Check if the given value matches any of the neutral filters
|
/// Check if the given value matches any of the neutral filters
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value">Value to check</param>
|
/// <param name="value">Value to check</param>
|
||||||
/// <returns>True if the value was found in a neutral filter, false otherwise</returns>
|
/// <returns>True if the value was found in a neutral filter, null on an empty set, false otherwise</returns>
|
||||||
public bool MatchesNeutralSet(T value)
|
public bool? MatchesNeutralSet(T value)
|
||||||
{
|
{
|
||||||
return MatchesSet(this.NeutralSet, value);
|
return MatchesSet(this.NeutralSet, value);
|
||||||
}
|
}
|
||||||
@@ -109,12 +109,12 @@ namespace SabreTools.Library.DatFiles
|
|||||||
/// <param name="single">Value to check against</param>
|
/// <param name="single">Value to check against</param>
|
||||||
/// <param name="def">Default value to check filter value</param>
|
/// <param name="def">Default value to check filter value</param>
|
||||||
/// <param name="value">Value to check</param>
|
/// <param name="value">Value to check</param>
|
||||||
/// <returns>True if the value was found in the supplied filter, false otherwise</returns>
|
/// <returns>True if the value was found in the supplied filter, null on default value, false otherwise</returns>
|
||||||
private bool Matches(T single, T def, T value)
|
private bool? Matches(T single, T def, T value)
|
||||||
{
|
{
|
||||||
// If the filter is default, we ignore
|
// If the filter is default, we ignore
|
||||||
if (single.Equals(def))
|
if (single.Equals(def))
|
||||||
return true;
|
return null;
|
||||||
|
|
||||||
// If we have a flag
|
// If we have a flag
|
||||||
if (typeof(T).IsEnum && (single as Enum).HasFlag(value as Enum))
|
if (typeof(T).IsEnum && (single as Enum).HasFlag(value as Enum))
|
||||||
@@ -128,14 +128,14 @@ namespace SabreTools.Library.DatFiles
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="set">Set to check against</param>
|
/// <param name="set">Set to check against</param>
|
||||||
/// <param name="value">Value to check</param>
|
/// <param name="value">Value to check</param>
|
||||||
/// <returns>True if the value was found in the supplied filter, false otherwise</returns>
|
/// <returns>True if the value was found in the supplied filter, null on an empty set, false otherwise</returns>
|
||||||
private bool MatchesSet(List<T> set, T value)
|
private bool? MatchesSet(List<T> set, T value)
|
||||||
{
|
|
||||||
if (set.Count > 0)
|
|
||||||
{
|
{
|
||||||
|
if (set.Count == 0)
|
||||||
|
return null;
|
||||||
|
|
||||||
if (this.FindValueInList(set, value))
|
if (this.FindValueInList(set, value))
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user