mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 06:42:56 +08:00
Merge pull request #9381 from bdach/mania-conversion-precision
Fix incorrect sample list slicing in mania conversion algorithm
This commit is contained in:
commit
e1423dff36
@ -20,6 +20,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
|
||||
[TestCase("convert-samples")]
|
||||
[TestCase("mania-samples")]
|
||||
[TestCase("slider-convert-samples")]
|
||||
public void Test(string name) => base.Test(name);
|
||||
|
||||
protected override IEnumerable<SampleConvertValue> CreateConvertValue(HitObject hitObject)
|
||||
@ -29,13 +30,16 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
StartTime = hitObject.StartTime,
|
||||
EndTime = hitObject.GetEndTime(),
|
||||
Column = ((ManiaHitObject)hitObject).Column,
|
||||
NodeSamples = getSampleNames((hitObject as HoldNote)?.NodeSamples)
|
||||
Samples = getSampleNames(hitObject.Samples),
|
||||
NodeSamples = getNodeSampleNames((hitObject as HoldNote)?.NodeSamples)
|
||||
};
|
||||
}
|
||||
|
||||
private IList<IList<string>> getSampleNames(List<IList<HitSampleInfo>> hitSampleInfo)
|
||||
=> hitSampleInfo?.Select(samples =>
|
||||
(IList<string>)samples.Select(sample => sample.LookupNames.First()).ToList())
|
||||
private IList<string> getSampleNames(IList<HitSampleInfo> hitSampleInfo)
|
||||
=> hitSampleInfo.Select(sample => sample.LookupNames.First()).ToList();
|
||||
|
||||
private IList<IList<string>> getNodeSampleNames(List<IList<HitSampleInfo>> hitSampleInfo)
|
||||
=> hitSampleInfo?.Select(getSampleNames)
|
||||
.ToList();
|
||||
|
||||
protected override Ruleset CreateRuleset() => new ManiaRuleset();
|
||||
@ -51,14 +55,19 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
public double StartTime;
|
||||
public double EndTime;
|
||||
public int Column;
|
||||
public IList<string> Samples;
|
||||
public IList<IList<string>> NodeSamples;
|
||||
|
||||
public bool Equals(SampleConvertValue other)
|
||||
=> Precision.AlmostEquals(StartTime, other.StartTime, conversion_lenience)
|
||||
&& Precision.AlmostEquals(EndTime, other.EndTime, conversion_lenience)
|
||||
&& samplesEqual(NodeSamples, other.NodeSamples);
|
||||
&& samplesEqual(Samples, other.Samples)
|
||||
&& nodeSamplesEqual(NodeSamples, other.NodeSamples);
|
||||
|
||||
private static bool samplesEqual(ICollection<IList<string>> firstSampleList, ICollection<IList<string>> secondSampleList)
|
||||
private static bool samplesEqual(ICollection<string> firstSampleList, ICollection<string> secondSampleList)
|
||||
=> firstSampleList.SequenceEqual(secondSampleList);
|
||||
|
||||
private static bool nodeSamplesEqual(ICollection<IList<string>> firstSampleList, ICollection<IList<string>> secondSampleList)
|
||||
{
|
||||
if (firstSampleList == null && secondSampleList == null)
|
||||
return true;
|
||||
|
@ -483,9 +483,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
||||
if (!(HitObject is IHasPathWithRepeats curveData))
|
||||
return null;
|
||||
|
||||
double segmentTime = (EndTime - HitObject.StartTime) / spanCount;
|
||||
|
||||
int index = (int)(segmentTime == 0 ? 0 : (time - HitObject.StartTime) / segmentTime);
|
||||
// mathematically speaking this should be a whole number always, but floating-point arithmetic is not so kind
|
||||
var index = (int)Math.Round(SegmentDuration == 0 ? 0 : (time - HitObject.StartTime) / SegmentDuration, MidpointRounding.AwayFromZero);
|
||||
|
||||
// avoid slicing the list & creating copies, if at all possible.
|
||||
return index == 0 ? curveData.NodeSamples : curveData.NodeSamples.Skip(index).ToList();
|
||||
|
@ -9,7 +9,8 @@
|
||||
["normal-hitnormal"],
|
||||
["soft-hitnormal"],
|
||||
["drum-hitnormal"]
|
||||
]
|
||||
],
|
||||
"Samples": ["drum-hitnormal"]
|
||||
}, {
|
||||
"StartTime": 1875.0,
|
||||
"EndTime": 2750.0,
|
||||
@ -17,14 +18,16 @@
|
||||
"NodeSamples": [
|
||||
["soft-hitnormal"],
|
||||
["drum-hitnormal"]
|
||||
]
|
||||
],
|
||||
"Samples": ["drum-hitnormal"]
|
||||
}]
|
||||
}, {
|
||||
"StartTime": 3750.0,
|
||||
"Objects": [{
|
||||
"StartTime": 3750.0,
|
||||
"EndTime": 3750.0,
|
||||
"Column": 3
|
||||
"Column": 3,
|
||||
"Samples": ["normal-hitnormal"]
|
||||
}]
|
||||
}]
|
||||
}
|
@ -13,4 +13,4 @@ SliderTickRate:1
|
||||
|
||||
[HitObjects]
|
||||
88,99,1000,6,0,L|306:259,2,245,0|0|0,1:0|2:0|3:0,0:0:0:0:
|
||||
259,118,3750,1,0,0:0:0:0:
|
||||
259,118,3750,1,0,1:0:0:0:
|
||||
|
@ -8,7 +8,8 @@
|
||||
"NodeSamples": [
|
||||
["normal-hitnormal"],
|
||||
[]
|
||||
]
|
||||
],
|
||||
"Samples": ["normal-hitnormal"]
|
||||
}]
|
||||
}, {
|
||||
"StartTime": 2000.0,
|
||||
@ -19,7 +20,8 @@
|
||||
"NodeSamples": [
|
||||
["drum-hitnormal"],
|
||||
[]
|
||||
]
|
||||
],
|
||||
"Samples": ["drum-hitnormal"]
|
||||
}]
|
||||
}]
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
{
|
||||
"Mappings": [{
|
||||
"StartTime": 8470.0,
|
||||
"Objects": [{
|
||||
"StartTime": 8470.0,
|
||||
"EndTime": 8470.0,
|
||||
"Column": 0,
|
||||
"Samples": ["normal-hitnormal", "normal-hitclap"]
|
||||
}, {
|
||||
"StartTime": 8626.470587768974,
|
||||
"EndTime": 8626.470587768974,
|
||||
"Column": 1,
|
||||
"Samples": ["normal-hitnormal"]
|
||||
}, {
|
||||
"StartTime": 8782.941175537948,
|
||||
"EndTime": 8782.941175537948,
|
||||
"Column": 2,
|
||||
"Samples": ["normal-hitnormal", "normal-hitclap"]
|
||||
}]
|
||||
}]
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
osu file format v14
|
||||
|
||||
[Difficulty]
|
||||
HPDrainRate:6
|
||||
CircleSize:4
|
||||
OverallDifficulty:8
|
||||
ApproachRate:9.5
|
||||
SliderMultiplier:2.00000000596047
|
||||
SliderTickRate:1
|
||||
|
||||
[TimingPoints]
|
||||
0,312.941176470588,4,1,0,100,1,0
|
||||
|
||||
[HitObjects]
|
||||
82,216,8470,6,0,P|52:161|99:113,2,100,8|0|8,1:0|1:0|1:0,0:0:0:0:
|
Loading…
Reference in New Issue
Block a user