mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 17:43:05 +08:00
Merge pull request #24800 from sw1tchbl4d3r/invalid_bank
Default to normal bank if invalid sample bank is specified
This commit is contained in:
commit
aea7f81f1c
@ -621,6 +621,38 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestInvalidBankDefaultsToNormal()
|
||||
{
|
||||
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
||||
|
||||
using (var resStream = TestResources.OpenResource("invalid-bank.osu"))
|
||||
using (var stream = new LineBufferedReader(resStream))
|
||||
{
|
||||
var hitObjects = decoder.Decode(stream).HitObjects;
|
||||
|
||||
assertObjectHasBanks(hitObjects[0], HitSampleInfo.BANK_DRUM);
|
||||
assertObjectHasBanks(hitObjects[1], HitSampleInfo.BANK_NORMAL);
|
||||
assertObjectHasBanks(hitObjects[2], HitSampleInfo.BANK_SOFT);
|
||||
assertObjectHasBanks(hitObjects[3], HitSampleInfo.BANK_DRUM);
|
||||
assertObjectHasBanks(hitObjects[4], HitSampleInfo.BANK_NORMAL);
|
||||
|
||||
assertObjectHasBanks(hitObjects[5], HitSampleInfo.BANK_DRUM, HitSampleInfo.BANK_DRUM);
|
||||
assertObjectHasBanks(hitObjects[6], HitSampleInfo.BANK_DRUM, HitSampleInfo.BANK_NORMAL);
|
||||
assertObjectHasBanks(hitObjects[7], HitSampleInfo.BANK_DRUM, HitSampleInfo.BANK_SOFT);
|
||||
assertObjectHasBanks(hitObjects[8], HitSampleInfo.BANK_DRUM, HitSampleInfo.BANK_DRUM);
|
||||
assertObjectHasBanks(hitObjects[9], HitSampleInfo.BANK_DRUM, HitSampleInfo.BANK_NORMAL);
|
||||
}
|
||||
|
||||
void assertObjectHasBanks(HitObject hitObject, string normalBank, string? additionsBank = null)
|
||||
{
|
||||
Assert.AreEqual(normalBank, hitObject.Samples[0].Bank);
|
||||
|
||||
if (additionsBank != null)
|
||||
Assert.AreEqual(additionsBank, hitObject.Samples[1].Bank);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFallbackDecoderForCorruptedHeader()
|
||||
{
|
||||
|
19
osu.Game.Tests/Resources/invalid-bank.osu
Normal file
19
osu.Game.Tests/Resources/invalid-bank.osu
Normal file
@ -0,0 +1,19 @@
|
||||
osu file format v14
|
||||
|
||||
[General]
|
||||
SampleSet: Normal
|
||||
|
||||
[TimingPoints]
|
||||
0,500,4,3,0,100,1,0
|
||||
|
||||
[HitObjects]
|
||||
256,192,1000,5,0,0:0:0:0:
|
||||
256,192,2000,1,0,1:0:0:0:
|
||||
256,192,3000,1,0,2:0:0:0:
|
||||
256,192,4000,1,0,3:0:0:0:
|
||||
256,192,5000,1,0,42:0:0:0:
|
||||
256,192,6000,5,4,0:0:0:0:
|
||||
256,192,7000,1,4,0:1:0:0:
|
||||
256,192,8000,1,4,0:2:0:0:
|
||||
256,192,9000,1,4,0:3:0:0:
|
||||
256,192,10000,1,4,0:42:0:0:
|
@ -190,7 +190,12 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
||||
string[] split = str.Split(':');
|
||||
|
||||
var bank = (LegacySampleBank)Parsing.ParseInt(split[0]);
|
||||
if (!Enum.IsDefined(bank))
|
||||
bank = LegacySampleBank.Normal;
|
||||
|
||||
var addBank = (LegacySampleBank)Parsing.ParseInt(split[1]);
|
||||
if (!Enum.IsDefined(addBank))
|
||||
addBank = LegacySampleBank.Normal;
|
||||
|
||||
string stringBank = bank.ToString().ToLowerInvariant();
|
||||
if (stringBank == @"none")
|
||||
|
Loading…
Reference in New Issue
Block a user