Skip to content

Commit

Permalink
Fix rate mods not working if pp counter is displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Oct 6, 2021
1 parent 622e81f commit 433e7cd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 3 additions & 2 deletions osu.Game/Rulesets/Difficulty/DifficultyCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,11 @@ public IEnumerable<DifficultyAttributes> CalculateAll()
private void preProcess(Mod[] mods)
{
playableMods = mods.Select(m => m.DeepClone()).ToArray();
Beatmap = beatmap.GetPlayableBeatmap(ruleset.RulesetInfo, mods);

Beatmap = beatmap.GetPlayableBeatmap(ruleset.RulesetInfo, playableMods);

var track = new TrackVirtual(10000);
mods.OfType<IApplicableToTrack>().ForEach(m => m.ApplyToTrack(track));
playableMods.OfType<IApplicableToTrack>().ForEach(m => m.ApplyToTrack(track));
clockRate = track.Rate;
}

Expand Down
12 changes: 10 additions & 2 deletions osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,19 @@ public PerformancePointsCounter()
Current.Value = DisplayedCount = 0;
}

private Mod[] clonedMods;

[BackgroundDependencyLoader]
private void load(OsuColour colours, BeatmapDifficultyCache difficultyCache)
{
Colour = colours.BlueLighter;

if (gameplayState != null)
{
clonedMods = gameplayState.Mods.Select(m => m.DeepClone()).ToArray();

var gameplayWorkingBeatmap = new GameplayWorkingBeatmap(gameplayState.Beatmap);
difficultyCache.GetTimedDifficultyAttributesAsync(gameplayWorkingBeatmap, gameplayState.Ruleset, gameplayState.Mods.ToArray(), loadCancellationSource.Token)
difficultyCache.GetTimedDifficultyAttributesAsync(gameplayWorkingBeatmap, gameplayState.Ruleset, gameplayState.Mods.Select(m => m.DeepClone()).ToArray(), loadCancellationSource.Token)
.ContinueWith(r => Schedule(() =>
{
timedAttributes = r.Result;
Expand Down Expand Up @@ -116,7 +120,11 @@ private void onJudgementChanged(JudgementResult judgement)
return;
}

var calculator = gameplayState.Ruleset.CreatePerformanceCalculator(attrib, gameplayState.Score.ScoreInfo);
// awkward but we need to make sure the true mods are not passed to PerformanceCalculator as it makes a mess of track applications.
var scoreInfo = gameplayState.Score.ScoreInfo.DeepClone();
scoreInfo.Mods = clonedMods;

var calculator = gameplayState.Ruleset.CreatePerformanceCalculator(attrib, scoreInfo);

Current.Value = (int)Math.Round(calculator?.Calculate() ?? 0, MidpointRounding.AwayFromZero);
IsValid = true;
Expand Down

0 comments on commit 433e7cd

Please sign in to comment.