From 6a82b7331fd0da4208d3f3c760df44717b83ee7c Mon Sep 17 00:00:00 2001 From: Binwalker Date: Tue, 26 Aug 2025 21:27:57 +0900 Subject: [PATCH] refactor(ManiaFilterCriteria): exclude converted beatmaps from long note filter --- .../ManiaFilterCriteria.cs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/osu.Game.Rulesets.Mania/ManiaFilterCriteria.cs b/osu.Game.Rulesets.Mania/ManiaFilterCriteria.cs index 60dd8e1dae..3f7a018dd1 100644 --- a/osu.Game.Rulesets.Mania/ManiaFilterCriteria.cs +++ b/osu.Game.Rulesets.Mania/ManiaFilterCriteria.cs @@ -20,16 +20,16 @@ namespace osu.Game.Rulesets.Mania public class ManiaFilterCriteria : IRulesetFilterCriteria { private readonly HashSet includedKeyCounts = Enumerable.Range(1, LegacyBeatmapDecoder.MAX_MANIA_KEY_COUNT).ToHashSet(); - private FilterCriteria.OptionalRange longNoteRatio; + private FilterCriteria.OptionalRange longNotePercentage; public bool Matches(BeatmapInfo beatmapInfo, FilterCriteria criteria) { int keyCount = ManiaBeatmapConverter.GetColumnCount(LegacyBeatmapConversionDifficultyInfo.FromBeatmapInfo(beatmapInfo), criteria.Mods); bool keyCountMatch = includedKeyCounts.Contains(keyCount); - bool longNoteRatioMatch = !longNoteRatio.HasFilter || (!isConvertedBeatMap(beatmapInfo, criteria) && longNoteRatio.IsInRange(calculateLongNoteRatio(beatmapInfo))); + bool longNotePercentageMatch = !longNotePercentage.HasFilter || (!isConvertedBeatmap(beatmapInfo) && longNotePercentage.IsInRange(calculateLongNotePercentage(beatmapInfo))); - return keyCountMatch && longNoteRatioMatch; + return keyCountMatch && longNotePercentageMatch; } public bool TryParseCustomKeywordCriteria(string key, Operator op, string strValues) @@ -92,7 +92,7 @@ namespace osu.Game.Rulesets.Mania case "ln": case "lns": - return FilterQueryParser.TryUpdateCriteriaRange(ref longNoteRatio, op, strValues); + return FilterQueryParser.TryUpdateCriteriaRange(ref longNotePercentage, op, strValues); } return false; @@ -113,18 +113,17 @@ namespace osu.Game.Rulesets.Mania return false; } - private static bool isConvertedBeatMap(BeatmapInfo beatmapInfo, FilterCriteria criteria) + private static bool isConvertedBeatmap(BeatmapInfo beatmapInfo) { - return criteria.Ruleset == null || beatmapInfo.Ruleset.ShortName != criteria.Ruleset!.ShortName; + return !beatmapInfo.Ruleset.Equals(new ManiaRuleset().RulesetInfo); } - private static float calculateLongNoteRatio(BeatmapInfo beatmapInfo) + private static float calculateLongNotePercentage(BeatmapInfo beatmapInfo) { int holdNotes = beatmapInfo.EndTimeObjectCount; - int totalNotes = beatmapInfo.TotalObjectCount; - int sum = Math.Max(1, totalNotes); + int totalNotes = Math.Max(1, beatmapInfo.TotalObjectCount); - return holdNotes / (float)sum * 100; + return holdNotes / (float)totalNotes * 100; } } }