Skip to content

Commit 95237ed

Browse files
authored
Merge pull request #33908 from bdach/custom-sample-bank-buggery
Fix beatmap skin sample lookups falling back to non-custom sample banks if the custom bank sample was not found
2 parents 5c89644 + edafac2 commit 95237ed

File tree

4 files changed

+31
-27
lines changed

4 files changed

+31
-27
lines changed

osu.Game.Rulesets.Osu.Tests/TestSceneOsuHitObjectSamples.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,27 @@ public partial class TestSceneOsuHitObjectSamples : HitObjectSampleTest
1414

1515
protected override IResourceStore<byte[]> RulesetResources => new DllResourceStore(Assembly.GetAssembly(typeof(TestSceneOsuHitObjectSamples)));
1616

17-
[TestCase("normal-hitnormal")]
18-
[TestCase("hitnormal")]
19-
public void TestDefaultCustomSampleFromBeatmap(string expectedSample)
17+
[TestCase("normal-hitnormal2", "normal-hitnormal")]
18+
[TestCase("hitnormal", "hitnormal")]
19+
public void TestDefaultCustomSampleFromBeatmap(string beatmapSkinSampleName, string userSkinSampleName)
2020
{
21-
SetupSkins(expectedSample, expectedSample);
21+
SetupSkins(beatmapSkinSampleName, userSkinSampleName);
2222

2323
CreateTestWithBeatmap("osu-hitobject-beatmap-custom-sample-bank.osu");
2424

25-
AssertBeatmapLookup(expectedSample);
25+
AssertBeatmapLookup(beatmapSkinSampleName);
2626
}
2727

28-
[TestCase("normal-hitnormal")]
29-
[TestCase("hitnormal")]
30-
public void TestDefaultCustomSampleFromUserSkinFallback(string expectedSample)
28+
[TestCase("", "normal-hitnormal")]
29+
[TestCase("normal-hitnormal", "normal-hitnormal")]
30+
[TestCase("", "hitnormal")]
31+
public void TestDefaultCustomSampleFromUserSkinFallback(string beatmapSkinSampleName, string userSkinSampleName)
3132
{
32-
SetupSkins(string.Empty, expectedSample);
33+
SetupSkins(beatmapSkinSampleName, userSkinSampleName);
3334

3435
CreateTestWithBeatmap("osu-hitobject-beatmap-custom-sample-bank.osu");
3536

36-
AssertUserLookup(expectedSample);
37+
AssertUserLookup(userSkinSampleName);
3738
}
3839

3940
[TestCase("normal-hitnormal2")]

osu.Game.Rulesets.Taiko.Tests/TestSceneTaikoHitObjectSamples.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,27 @@ public partial class TestSceneTaikoHitObjectSamples : HitObjectSampleTest
1414

1515
protected override IResourceStore<byte[]> RulesetResources => new DllResourceStore(Assembly.GetAssembly(typeof(TestSceneTaikoHitObjectSamples)));
1616

17-
[TestCase("taiko-normal-hitnormal")]
18-
[TestCase("hitnormal")]
19-
public void TestDefaultCustomSampleFromBeatmap(string expectedSample)
17+
[TestCase("taiko-normal-hitnormal2", "taiko-normal-hitnormal")]
18+
[TestCase("hitnormal", "hitnormal")]
19+
public void TestDefaultCustomSampleFromBeatmap(string beatmapSkinSampleName, string userSkinSampleName)
2020
{
21-
SetupSkins(expectedSample, expectedSample);
21+
SetupSkins(beatmapSkinSampleName, userSkinSampleName);
2222

2323
CreateTestWithBeatmap("taiko-hitobject-beatmap-custom-sample-bank.osu");
2424

25-
AssertBeatmapLookup(expectedSample);
25+
AssertBeatmapLookup(beatmapSkinSampleName);
2626
}
2727

28-
[TestCase("taiko-normal-hitnormal")]
29-
[TestCase("hitnormal")]
30-
public void TestDefaultCustomSampleFromUserSkinFallback(string expectedSample)
28+
[TestCase("", "taiko-normal-hitnormal")]
29+
[TestCase("taiko-normal-hitnormal", "taiko-normal-hitnormal")]
30+
[TestCase("", "hitnormal")]
31+
public void TestDefaultCustomSampleFromUserSkinFallback(string beatmapSkinSampleName, string userSkinSampleName)
3132
{
32-
SetupSkins(string.Empty, expectedSample);
33+
SetupSkins(beatmapSkinSampleName, userSkinSampleName);
3334

3435
CreateTestWithBeatmap("taiko-hitobject-beatmap-custom-sample-bank.osu");
3536

36-
AssertUserLookup(expectedSample);
37+
AssertUserLookup(userSkinSampleName);
3738
}
3839

3940
[TestCase("taiko-normal-hitnormal2")]

osu.Game.Tests/Gameplay/TestSceneHitObjectSamples.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,9 @@ public void TestDefaultSampleFromUserSkinFallback()
6464
/// <summary>
6565
/// Tests that a hitobject which provides a custom sample set of 2 retrieves the following samples from the beatmap skin:
6666
/// normal-hitnormal2
67-
/// normal-hitnormal
6867
/// hitnormal
6968
/// </summary>
7069
[TestCase("normal-hitnormal2")]
71-
[TestCase("normal-hitnormal")]
7270
[TestCase("hitnormal")]
7371
public void TestDefaultCustomSampleFromBeatmap(string expectedSample)
7472
{
@@ -162,7 +160,6 @@ public void TestControlPointSampleFromBeatmap()
162160
/// Tests that a control point that provides a custom sample of 2 causes <see cref="TestDefaultCustomSampleFromBeatmap"/>.
163161
/// </summary>
164162
[TestCase("normal-hitnormal2")]
165-
[TestCase("normal-hitnormal")]
166163
[TestCase("hitnormal")]
167164
public void TestControlPointCustomSampleFromBeatmap(string sampleName)
168165
{

osu.Game/Skinning/LegacySkin.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -594,12 +594,17 @@ private IEnumerable<string> getLegacyLookupNames(HitSampleInfo hitSample)
594594
{
595595
var lookupNames = hitSample.LookupNames.SelectMany(getFallbackSampleNames);
596596

597-
if (!UseCustomSampleBanks && !string.IsNullOrEmpty(hitSample.Suffix))
597+
if (!string.IsNullOrEmpty(hitSample.Suffix))
598598
{
599-
// for compatibility with stable, exclude the lookup names with the custom sample bank suffix, if they are not valid for use in this skin.
599+
// for compatibility with stable:
600+
// - if the skin can use custom sample banks, it MUST use the custom sample bank suffix. it is not allowed to fall back to a non-custom sound.
601+
// - if the skin cannot use custom sample banks, it MUST NOT use the custom sample bank suffix.
600602
// using .EndsWith() is intentional as it ensures parity in all edge cases
601-
// (see LegacyTaikoSampleInfo for an example of one - prioritising the taiko prefix should still apply, but the sample bank should not).
602-
lookupNames = lookupNames.Where(name => !name.EndsWith(hitSample.Suffix, StringComparison.Ordinal));
603+
// (see LegacyTaikoSampleInfo for an example of one - prioritising the taiko prefix should still apply).
604+
if (UseCustomSampleBanks)
605+
lookupNames = lookupNames.Where(name => name.EndsWith(hitSample.Suffix, StringComparison.Ordinal));
606+
else
607+
lookupNames = lookupNames.Where(name => !name.EndsWith(hitSample.Suffix, StringComparison.Ordinal));
603608
}
604609

605610
foreach (string l in lookupNames)

0 commit comments

Comments
 (0)