|
16 | 16 | using osu.Game.Rulesets.Catch.Difficulty; |
17 | 17 | using osu.Game.Rulesets.Difficulty; |
18 | 18 | using osu.Game.Rulesets.Mania.Difficulty; |
| 19 | +using osu.Game.Rulesets.Mods; |
19 | 20 | using osu.Game.Rulesets.Osu.Difficulty; |
20 | 21 | using osu.Game.Rulesets.Taiko.Difficulty; |
21 | 22 | using osu.Game.Scoring; |
@@ -46,13 +47,13 @@ public override void Execute() |
46 | 47 |
|
47 | 48 | if (OnlineAttributes) |
48 | 49 | { |
49 | | - LegacyMods legacyMods = LegacyHelper.ConvertToLegacyDifficultyAdjustmentMods(workingBeatmap.BeatmapInfo, ruleset, score.Mods); |
| 50 | + LegacyMods legacyMods = convertToLegacyMods(workingBeatmap.BeatmapInfo, ruleset, score.Mods); |
50 | 51 | attributes = queryApiAttributes(apiScore.BeatmapID, apiScore.RulesetID, legacyMods); |
51 | 52 | } |
52 | 53 | else |
53 | 54 | { |
54 | 55 | var difficultyCalculator = ruleset.CreateDifficultyCalculator(workingBeatmap); |
55 | | - attributes = difficultyCalculator.Calculate(LegacyHelper.FilterDifficultyAdjustmentMods(workingBeatmap.BeatmapInfo, ruleset, score.Mods)); |
| 56 | + attributes = difficultyCalculator.Calculate(score.Mods); |
56 | 57 | } |
57 | 58 |
|
58 | 59 | var performanceCalculator = ruleset.CreatePerformanceCalculator(); |
@@ -121,6 +122,47 @@ DifficultyAttributes getMergedAttributes<TAttributes>(APIBeatmap apiBeatmap) |
121 | 122 | } |
122 | 123 | } |
123 | 124 |
|
| 125 | + /// <summary> |
| 126 | + /// Transforms a given <see cref="Mod"/> combination into one which is applicable to legacy scores. |
| 127 | + /// This should only be used to match performance calculations using databased attributes. |
| 128 | + /// </summary> |
| 129 | + private static LegacyMods convertToLegacyMods(BeatmapInfo beatmapInfo, Ruleset ruleset, Mod[] mods) |
| 130 | + { |
| 131 | + var legacyMods = ruleset.ConvertToLegacyMods(mods); |
| 132 | + |
| 133 | + // mods that are not represented in `LegacyMods` (but we can approximate them well enough with others) |
| 134 | + if (mods.Any(mod => mod is ModDaycore)) |
| 135 | + legacyMods |= LegacyMods.HalfTime; |
| 136 | + |
| 137 | + // See: https://github.com/ppy/osu-queue-score-statistics/blob/2264bfa68e14bb16ec71a7cac2072bdcfaf565b6/osu.Server.Queues.ScoreStatisticsProcessor/Helpers/LegacyModsHelper.cs |
| 138 | + static LegacyMods maskRelevantMods(LegacyMods mods, bool isConvertedBeatmap, int rulesetId) |
| 139 | + { |
| 140 | + const LegacyMods key_mods = LegacyMods.Key1 | LegacyMods.Key2 | LegacyMods.Key3 | LegacyMods.Key4 | LegacyMods.Key5 | LegacyMods.Key6 | LegacyMods.Key7 | LegacyMods.Key8 |
| 141 | + | LegacyMods.Key9 | LegacyMods.KeyCoop; |
| 142 | + |
| 143 | + LegacyMods relevantMods = LegacyMods.DoubleTime | LegacyMods.HalfTime | LegacyMods.HardRock | LegacyMods.Easy; |
| 144 | + |
| 145 | + switch (rulesetId) |
| 146 | + { |
| 147 | + case 0: |
| 148 | + if ((mods & LegacyMods.Flashlight) > 0) |
| 149 | + relevantMods |= LegacyMods.Flashlight | LegacyMods.Hidden | LegacyMods.TouchDevice; |
| 150 | + else |
| 151 | + relevantMods |= LegacyMods.Flashlight | LegacyMods.TouchDevice; |
| 152 | + break; |
| 153 | + |
| 154 | + case 3: |
| 155 | + if (isConvertedBeatmap) |
| 156 | + relevantMods |= key_mods; |
| 157 | + break; |
| 158 | + } |
| 159 | + |
| 160 | + return mods & relevantMods; |
| 161 | + } |
| 162 | + |
| 163 | + return maskRelevantMods(legacyMods, ruleset.RulesetInfo.OnlineID != beatmapInfo.Ruleset.OnlineID, ruleset.RulesetInfo.OnlineID); |
| 164 | + } |
| 165 | + |
124 | 166 | [JsonObject(MemberSerialization.OptIn)] |
125 | 167 | private class AttributesResponse<T> |
126 | 168 | where T : DifficultyAttributes |
|
0 commit comments