1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 20:07:25 +08:00

Move check to LegacyDifficultyControlPoint

This commit is contained in:
Dan Balasescu 2022-10-13 15:05:15 +09:00
parent 2579ed46ce
commit 338115ff6a
3 changed files with 11 additions and 24 deletions

View File

@ -162,14 +162,7 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
#pragma warning disable 618
if (difficultyPoint is LegacyBeatmapDecoder.LegacyDifficultyControlPoint legacyDifficultyPoint)
#pragma warning restore 618
{
double bpmMultiplier;
if (beatmap.BeatmapInfo.OnlineID == 1 || beatmap.BeatmapInfo.OnlineID == 3)
bpmMultiplier = legacyDifficultyPoint.BpmMultiplierMania;
else
bpmMultiplier = legacyDifficultyPoint.BpmMultiplier;
beatLength = timingPoint.BeatLength * bpmMultiplier;
}
beatLength = timingPoint.BeatLength * legacyDifficultyPoint.BpmMultiplier;
else
beatLength = timingPoint.BeatLength / difficultyPoint.SliderVelocity;

View File

@ -427,8 +427,10 @@ namespace osu.Game.Beatmaps.Formats
addControlPoint(time, controlPoint, true);
}
int onlineRulesetID = beatmap.BeatmapInfo.Ruleset.OnlineID;
#pragma warning disable 618
addControlPoint(time, new LegacyDifficultyControlPoint(beatLength)
addControlPoint(time, new LegacyDifficultyControlPoint(onlineRulesetID, beatLength)
#pragma warning restore 618
{
SliderVelocity = speedMultiplier,
@ -440,8 +442,6 @@ namespace osu.Game.Beatmaps.Formats
OmitFirstBarLine = omitFirstBarSignature,
};
int onlineRulesetID = beatmap.BeatmapInfo.Ruleset.OnlineID;
// osu!taiko and osu!mania use effect points rather than difficulty points for scroll speed adjustments.
if (onlineRulesetID == 1 || onlineRulesetID == 3)
effectPoint.ScrollSpeed = speedMultiplier;

View File

@ -168,25 +168,21 @@ namespace osu.Game.Beatmaps.Formats
/// </summary>
public double BpmMultiplier { get; private set; }
/// <summary>
/// Legacy BPM multiplier that introduces floating-point errors for rulesets that depend on it.
/// This is to be used for taiko and mania specific beatmaps.
/// DO NOT USE THIS UNLESS 100% SURE.
/// </summary>
public double BpmMultiplierMania { get; private set; }
/// <summary>
/// Whether or not slider ticks should be generated at this control point.
/// This exists for backwards compatibility with maps that abuse NaN slider velocity behavior on osu!stable (e.g. /b/2628991).
/// </summary>
public bool GenerateTicks { get; private set; } = true;
public LegacyDifficultyControlPoint(double beatLength)
public LegacyDifficultyControlPoint(int rulesetId, double beatLength)
: this()
{
// Note: In stable, the division occurs on floats, but with compiler optimisations turned on actually seems to occur on doubles via some .NET black magic (possibly inlining?).
BpmMultiplier = beatLength < 0 ? Math.Clamp((float)-beatLength, 10, 1000) / 100.0 : 1;
BpmMultiplierMania = beatLength < 0 ? Math.Clamp((float)-beatLength, 10, 10000) / 100.0 : 1;
if (rulesetId == 1 || rulesetId == 3)
BpmMultiplier = beatLength < 0 ? Math.Clamp((float)-beatLength, 10, 10000) / 100.0 : 1;
else
BpmMultiplier = beatLength < 0 ? Math.Clamp((float)-beatLength, 10, 1000) / 100.0 : 1;
GenerateTicks = !double.IsNaN(beatLength);
}
@ -204,7 +200,6 @@ namespace osu.Game.Beatmaps.Formats
base.CopyFrom(other);
BpmMultiplier = ((LegacyDifficultyControlPoint)other).BpmMultiplier;
BpmMultiplierMania = ((LegacyDifficultyControlPoint)other).BpmMultiplierMania;
GenerateTicks = ((LegacyDifficultyControlPoint)other).GenerateTicks;
}
@ -215,11 +210,10 @@ namespace osu.Game.Beatmaps.Formats
public bool Equals(LegacyDifficultyControlPoint? other)
=> base.Equals(other)
&& BpmMultiplier == other.BpmMultiplier
&& BpmMultiplierMania == other.BpmMultiplierMania
&& GenerateTicks == other.GenerateTicks;
// ReSharper disable twice NonReadonlyMemberInGetHashCode
public override int GetHashCode() => HashCode.Combine(base.GetHashCode(), BpmMultiplier, BpmMultiplierMania, GenerateTicks);
public override int GetHashCode() => HashCode.Combine(base.GetHashCode(), BpmMultiplier, GenerateTicks);
}
internal class LegacySampleControlPoint : SampleControlPoint, IEquatable<LegacySampleControlPoint>