Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clamping to SliderMultiplier and SliderTickRate at parsing time #23433

Closed
wants to merge 11 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public partial class TestSceneJuiceStreamPlacementBlueprint : CatchPlacementBlue
protected override IBeatmap GetPlayableBeatmap()
{
var playable = base.GetPlayableBeatmap();
playable.Difficulty.SliderTickRate = 5;
playable.Difficulty.SliderMultiplier = velocity_factor * 10;
playable.Difficulty.TickRate = 5;
playable.Difficulty.BaseVelocity = velocity_factor * 10;
return playable;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ private void addBlueprintStep(double time, float x, SliderPath sliderPath, doubl
X = x,
Path = sliderPath,
};
EditorBeatmap.Difficulty.SliderMultiplier = velocity;
EditorBeatmap.Difficulty.BaseVelocity = velocity;
EditorBeatmap.Add(hitObject);
EditorBeatmap.Update(hitObject);
Assert.That(hitObject.Velocity, Is.EqualTo(velocity));
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Catch.Tests/TestSceneAutoJuiceStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
{
BeatmapInfo = new BeatmapInfo
{
Difficulty = new BeatmapDifficulty { CircleSize = 6, SliderMultiplier = 3 },
Difficulty = new BeatmapDifficulty { CircleSize = 6, BaseVelocity = 3 },
Ruleset = ruleset
}
};
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Catch.Tests/TestSceneJuiceStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void TestJuiceStreamEndingCombo()
{
BeatmapInfo = new BeatmapInfo
{
Difficulty = new BeatmapDifficulty { CircleSize = 5, SliderMultiplier = 2 },
Difficulty = new BeatmapDifficulty { CircleSize = 5, BaseVelocity = 2 },
Ruleset = ruleset
},
HitObjects = new List<HitObject>
Expand Down
4 changes: 2 additions & 2 deletions osu.Game.Rulesets.Catch/Objects/JuiceStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, I

TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);

velocityFactor = base_scoring_distance * difficulty.SliderMultiplier / timingPoint.BeatLength;
tickDistanceFactor = base_scoring_distance * difficulty.SliderMultiplier / difficulty.SliderTickRate;
velocityFactor = base_scoring_distance * difficulty.BaseVelocity / timingPoint.BeatLength;
tickDistanceFactor = base_scoring_distance * difficulty.BaseVelocity / difficulty.TickRate;
}

protected override void CreateNestedHitObjects(CancellationToken cancellationToken)
Expand Down
12 changes: 6 additions & 6 deletions osu.Game.Rulesets.Mania.Tests/TestSceneHoldNoteInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public void TestPressAndReleaseJustBeforeTailWithNearbyNoteAndCloseByHead()
},
BeatmapInfo =
{
Difficulty = new BeatmapDifficulty { SliderTickRate = 4 },
Difficulty = new BeatmapDifficulty { TickRate = 4 },
Ruleset = new ManiaRuleset().RulesetInfo
},
};
Expand Down Expand Up @@ -310,7 +310,7 @@ public void TestPressAndReleaseJustBeforeTailWithNearbyNote()
},
BeatmapInfo =
{
Difficulty = new BeatmapDifficulty { SliderTickRate = 4 },
Difficulty = new BeatmapDifficulty { TickRate = 4 },
Ruleset = new ManiaRuleset().RulesetInfo
},
};
Expand Down Expand Up @@ -357,7 +357,7 @@ public void TestPressAndReleaseJustAfterTailWithNearbyNote()
},
BeatmapInfo =
{
Difficulty = new BeatmapDifficulty { SliderTickRate = 4 },
Difficulty = new BeatmapDifficulty { TickRate = 4 },
Ruleset = new ManiaRuleset().RulesetInfo
},
};
Expand Down Expand Up @@ -420,7 +420,7 @@ public void TestMissReleaseAndHitSecondRelease()
{
Difficulty = new BeatmapDifficulty
{
SliderTickRate = 4,
TickRate = 4,
OverallDifficulty = 10,
},
Ruleset = new ManiaRuleset().RulesetInfo
Expand Down Expand Up @@ -460,7 +460,7 @@ public void TestHitTailBeforeLastTick()
},
BeatmapInfo =
{
Difficulty = new BeatmapDifficulty { SliderTickRate = tick_rate },
Difficulty = new BeatmapDifficulty { TickRate = tick_rate },
Ruleset = new ManiaRuleset().RulesetInfo
},
};
Expand Down Expand Up @@ -540,7 +540,7 @@ private void performTest(List<ReplayFrame> frames, Beatmap<ManiaHitObject> beatm
},
BeatmapInfo =
{
Difficulty = new BeatmapDifficulty { SliderTickRate = 4 },
Difficulty = new BeatmapDifficulty { TickRate = 4 },
Ruleset = new ManiaRuleset().RulesetInfo
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public DistanceObjectPatternGenerator(LegacyRandom random, HitObject hitObject,
StartTime = (int)Math.Round(hitObject.StartTime);

// This matches stable's calculation.
EndTime = (int)Math.Floor(StartTime + distanceData.Distance * beatLength * SpanCount * 0.01 / beatmap.Difficulty.SliderMultiplier);
EndTime = (int)Math.Floor(StartTime + distanceData.Distance * beatLength * SpanCount * 0.01 / beatmap.Difficulty.BaseVelocity);

SegmentDuration = (EndTime - StartTime) / SpanCount;
}
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Mania/Objects/HoldNote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, I
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);

TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
tickSpacing = timingPoint.BeatLength / difficulty.SliderTickRate;
tickSpacing = timingPoint.BeatLength / difficulty.TickRate;
}

protected override void CreateNestedHitObjects(CancellationToken cancellationToken)
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Mania/UI/DrawableManiaRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private void load()
{
// Mania doesn't care about global velocity
p.Velocity = 1;
p.BaseBeatLength *= Beatmap.Difficulty.SliderMultiplier;
p.BaseBeatLength *= Beatmap.Difficulty.BaseVelocity;

// For non-mania beatmap, speed changes should only happen through timing points
if (!isForCurrentRuleset)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public TestSceneOsuDistanceSnapGrid()
[SetUp]
public void Setup() => Schedule(() =>
{
editorBeatmap.Difficulty.SliderMultiplier = 1;
editorBeatmap.Difficulty.BaseVelocity = 1;
editorBeatmap.ControlPointInfo.Clear();
editorBeatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = beat_length });
snapProvider.DistanceSpacingMultiplier.Value = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public void TestFloatEdgeCaseConversion()

AddStep("change to these specific circumstances", () =>
{
EditorBeatmap.Difficulty.SliderMultiplier = 1;
EditorBeatmap.Difficulty.BaseVelocity = 1;
var timingPoint = EditorBeatmap.ControlPointInfo.TimingPointAt(slider.StartTime);
timingPoint.BeatLength = 352.941176470588;
slider.Path.ControlPoints[^1].Position = new Vector2(-110, 16);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ private void performTest(List<OsuHitObject> hitObjects, List<ReplayFrame> frames
Beatmap.Value = CreateWorkingBeatmap(new Beatmap<OsuHitObject>
{
HitObjects = hitObjects,
Difficulty = new BeatmapDifficulty { SliderTickRate = 3 },
Difficulty = new BeatmapDifficulty { TickRate = 3 },
BeatmapInfo =
{
Ruleset = new OsuRuleset().RulesetInfo
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Osu.Tests/TestSceneSlider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ private Drawable createDrawable(Slider slider, float circleSize, double speedMul
slider.ApplyDefaults(cpi, new BeatmapDifficulty
{
CircleSize = circleSize,
SliderTickRate = 3
TickRate = 3
});

var drawable = CreateDrawableSlider(slider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void TestMaximumDistanceTrackingWithoutMovement(
Difficulty = new BeatmapDifficulty
{
CircleSize = circleSize,
SliderTickRate = 1
TickRate = 1
},
Ruleset = new OsuRuleset().RulesetInfo
},
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Osu.Tests/TestSceneSliderInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ private void performTest(List<ReplayFrame> frames)
},
BeatmapInfo =
{
Difficulty = new BeatmapDifficulty { SliderTickRate = 3 },
Difficulty = new BeatmapDifficulty { TickRate = 3 },
Ruleset = new OsuRuleset().RulesetInfo
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ private void performTest(List<OsuHitObject> hitObjects, List<ReplayFrame> frames
HitObjects = hitObjects,
BeatmapInfo =
{
Difficulty = new BeatmapDifficulty { SliderTickRate = 3 },
Difficulty = new BeatmapDifficulty { TickRate = 3 },
Ruleset = new OsuRuleset().RulesetInfo
},
});
Expand Down
4 changes: 2 additions & 2 deletions osu.Game.Rulesets.Osu/Objects/Slider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, I

TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);

double scoringDistance = BASE_SCORING_DISTANCE * difficulty.SliderMultiplier * SliderVelocity;
double scoringDistance = BASE_SCORING_DISTANCE * difficulty.BaseVelocity * SliderVelocity;

Velocity = scoringDistance / timingPoint.BeatLength;
TickDistance = GenerateTicks ? (scoringDistance / difficulty.SliderTickRate * TickDistanceMultiplier) : double.PositiveInfinity;
TickDistance = GenerateTicks ? (scoringDistance / difficulty.TickRate * TickDistanceMultiplier) : double.PositiveInfinity;
}

protected override void CreateNestedHitObjects(CancellationToken cancellationToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public partial class TestSceneTaikoEditorSaving : EditorSavingTestScene
[Test]
public void TestTaikoSliderMultiplier()
{
AddStep("Set slider multiplier", () => EditorBeatmap.Difficulty.SliderMultiplier = 2);
AddStep("Set slider multiplier", () => EditorBeatmap.Difficulty.BaseVelocity = 2);

SaveEditor();

Expand All @@ -33,7 +33,7 @@ bool assertTaikoSliderMulitplier()
// therefore, ensure that we have that difficulty type by calling .CopyFrom(), which is a no-op if the type is already correct.
var taikoDifficulty = new TaikoBeatmapConverter.TaikoMultiplierAppliedDifficulty();
taikoDifficulty.CopyFrom(EditorBeatmap.Difficulty);
return Precision.AlmostEquals(taikoDifficulty.SliderMultiplier, 2);
return Precision.AlmostEquals(taikoDifficulty.BaseVelocity, 2);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Taiko.Tests/Judgements/JudgementTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected Beatmap<TaikoHitObject> CreateBeatmap(params TaikoHitObject[] hitObjec
HitObjects = hitObjects.ToList(),
BeatmapInfo =
{
Difficulty = new BeatmapDifficulty { SliderTickRate = 4 },
Difficulty = new BeatmapDifficulty { TickRate = 4 },
Ruleset = new TaikoRuleset().RulesetInfo
},
};
Expand Down
6 changes: 3 additions & 3 deletions osu.Game.Rulesets.Taiko.Tests/TestSceneBarLineGeneration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void TestCloseBarLineGeneration()
},
BeatmapInfo =
{
Difficulty = new BeatmapDifficulty { SliderTickRate = 4 },
Difficulty = new BeatmapDifficulty { TickRate = 4 },
Ruleset = new TaikoRuleset().RulesetInfo
},
};
Expand Down Expand Up @@ -65,7 +65,7 @@ public void TestOmitBarLineEffectPoint()
},
BeatmapInfo =
{
Difficulty = new BeatmapDifficulty { SliderTickRate = 4 },
Difficulty = new BeatmapDifficulty { TickRate = 4 },
Ruleset = new TaikoRuleset().RulesetInfo
},
};
Expand Down Expand Up @@ -102,7 +102,7 @@ public void TestNegativeStartTimeTimingPoint()
},
BeatmapInfo =
{
Difficulty = new BeatmapDifficulty { SliderTickRate = 4 },
Difficulty = new BeatmapDifficulty { TickRate = 4 },
Ruleset = new TaikoRuleset().RulesetInfo
},
};
Expand Down
12 changes: 6 additions & 6 deletions osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ protected override IEnumerable<TaikoHitObject> ConvertHitObject(HitObject obj, I
StartTime = obj.StartTime,
Samples = obj.Samples,
Duration = taikoDuration,
TickRate = beatmap.Difficulty.SliderTickRate == 3 ? 3 : 4,
TickRate = beatmap.Difficulty.TickRate == 3 ? 3 : 4,
SliderVelocity = obj is IHasSliderVelocity velocityData ? velocityData.SliderVelocity : 1
};
}
Expand Down Expand Up @@ -189,10 +189,10 @@ private bool shouldConvertSliderToHits(HitObject obj, IBeatmap beatmap, IHasDist
else
beatLength = timingPoint.BeatLength;

double sliderScoringPointDistance = osu_base_scoring_distance * beatmap.Difficulty.SliderMultiplier / beatmap.Difficulty.SliderTickRate;
double sliderScoringPointDistance = osu_base_scoring_distance * beatmap.Difficulty.BaseVelocity / beatmap.Difficulty.TickRate;

// The velocity and duration of the taiko hit object - calculated as the velocity of a drum roll.
double taikoVelocity = sliderScoringPointDistance * beatmap.Difficulty.SliderTickRate;
double taikoVelocity = sliderScoringPointDistance * beatmap.Difficulty.TickRate;
taikoDuration = (int)(distance / taikoVelocity * beatLength);

if (isForCurrentRuleset)
Expand All @@ -208,7 +208,7 @@ private bool shouldConvertSliderToHits(HitObject obj, IBeatmap beatmap, IHasDist
beatLength = timingPoint.BeatLength;

// If the drum roll is to be split into hit circles, assume the ticks are 1/8 spaced within the duration of one beat
tickSpacing = Math.Min(beatLength / beatmap.Difficulty.SliderTickRate, (double)taikoDuration / spans);
tickSpacing = Math.Min(beatLength / beatmap.Difficulty.TickRate, (double)taikoDuration / spans);

return tickSpacing > 0
&& distance / osuVelocity * 1000 < 2 * beatLength;
Expand Down Expand Up @@ -239,14 +239,14 @@ public override void CopyTo(BeatmapDifficulty other)
{
base.CopyTo(other);
if (!(other is TaikoMultiplierAppliedDifficulty))
other.SliderMultiplier /= LegacyBeatmapEncoder.LEGACY_TAIKO_VELOCITY_MULTIPLIER;
other.BaseVelocity /= LegacyBeatmapEncoder.LEGACY_TAIKO_VELOCITY_MULTIPLIER;
}

public override void CopyFrom(IBeatmapDifficultyInfo other)
{
base.CopyFrom(other);
if (!(other is TaikoMultiplierAppliedDifficulty))
SliderMultiplier *= LegacyBeatmapEncoder.LEGACY_TAIKO_VELOCITY_MULTIPLIER;
BaseVelocity *= LegacyBeatmapEncoder.LEGACY_TAIKO_VELOCITY_MULTIPLIER;
}

#endregion
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Taiko/Mods/TaikoModDifficultyAdjust.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected override void ApplySettings(BeatmapDifficulty difficulty)
{
base.ApplySettings(difficulty);

if (ScrollSpeed.Value != null) difficulty.SliderMultiplier *= ScrollSpeed.Value.Value;
if (ScrollSpeed.Value != null) difficulty.BaseVelocity *= ScrollSpeed.Value.Value;
}
}
}
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Taiko/Mods/TaikoModEasy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class TaikoModEasy : ModEasy
public override void ApplyToDifficulty(BeatmapDifficulty difficulty)
{
base.ApplyToDifficulty(difficulty);
difficulty.SliderMultiplier *= slider_multiplier;
difficulty.BaseVelocity *= slider_multiplier;
}
}
}
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Taiko/Mods/TaikoModHardRock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class TaikoModHardRock : ModHardRock
public override void ApplyToDifficulty(BeatmapDifficulty difficulty)
{
base.ApplyToDifficulty(difficulty);
difficulty.SliderMultiplier *= slider_multiplier;
difficulty.BaseVelocity *= slider_multiplier;
}
}
}
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Taiko/Objects/DrumRoll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, I

TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);

double scoringDistance = base_distance * difficulty.SliderMultiplier * SliderVelocity;
double scoringDistance = base_distance * difficulty.BaseVelocity * SliderVelocity;
Velocity = scoringDistance / timingPoint.BeatLength;

tickSpacing = timingPoint.BeatLength / TickRate;
Expand Down
4 changes: 2 additions & 2 deletions osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ public void TestDecodeBeatmapDifficulty()
Assert.AreEqual(4, difficulty.CircleSize);
Assert.AreEqual(8, difficulty.OverallDifficulty);
Assert.AreEqual(9, difficulty.ApproachRate);
Assert.AreEqual(1.8, difficulty.SliderMultiplier);
Assert.AreEqual(2, difficulty.SliderTickRate);
Assert.AreEqual(1.8, difficulty.BaseVelocity);
Assert.AreEqual(2, difficulty.TickRate);
}
}

Expand Down
4 changes: 2 additions & 2 deletions osu.Game.Tests/Beatmaps/Formats/OsuJsonDecoderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ public void TestDecodeDifficulty()
Assert.AreEqual(4, difficulty.CircleSize);
Assert.AreEqual(8, difficulty.OverallDifficulty);
Assert.AreEqual(9, difficulty.ApproachRate);
Assert.AreEqual(1.8, difficulty.SliderMultiplier);
Assert.AreEqual(2, difficulty.SliderTickRate);
Assert.AreEqual(1.8, difficulty.BaseVelocity);
Assert.AreEqual(2, difficulty.TickRate);
}

[Test]
Expand Down
Loading