diff --git a/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs b/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs index a80147b79a..9b9c285aee 100644 --- a/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs +++ b/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs @@ -29,7 +29,7 @@ namespace osu.Game.Beatmaps.Formats private readonly int onlineRulesetID; - private List customSoundBanks = new List(); + private readonly List customSoundBanks = new List(); /// /// Creates a new . @@ -387,6 +387,7 @@ namespace osu.Game.Beatmaps.Formats private void checkCustomSoundBank(HitObject h) { string? bank = h.Samples.SingleOrDefault(s => s.Name == HitSampleInfo.HIT_NORMAL)?.Bank; + if (bank != null && !customSoundBanks.Contains(bank) && bank != "none" && bank != "normal" && bank != "soft" && bank != "drum") @@ -396,10 +397,10 @@ namespace osu.Game.Beatmaps.Formats if (h is IHasRepeats hr) { - foreach (List node in hr.NodeSamples) + foreach (IList node in hr.NodeSamples) { - if (node.Count > 0 && !customSoundBanks.Contains(node[0].Bank) - && node[0].Bank != "none" && node[0].Bank != "normal" && node[0].Bank != "soft" && node[0].Bank != "drum") + if (node.Count > 0 && !customSoundBanks.Contains(node[0].Bank) && + node[0].Bank != "none" && node[0].Bank != "normal" && node[0].Bank != "soft" && node[0].Bank != "drum") { customSoundBanks.Add(node[0].Bank); } @@ -640,8 +641,8 @@ namespace osu.Game.Beatmaps.Formats private int toLegacySampleBank(string? sampleBank) { - string? sampleBankLower = sampleBank?.ToLowerInvariant(); + switch (sampleBankLower) { case HitSampleInfo.BANK_NORMAL: @@ -655,6 +656,7 @@ namespace osu.Game.Beatmaps.Formats default: if (sampleBankLower != null) return customSoundBanks.IndexOf(sampleBankLower) + 4; + return 0; } } diff --git a/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs b/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs index 05f2d4ba83..93f70ea1c7 100644 --- a/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs +++ b/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs @@ -194,11 +194,11 @@ namespace osu.Game.Rulesets.Objects.Legacy string[] split = str.Split(':'); - string bank = (Parsing.ParseInt(split[0]) > AvailableSampleBanks.Count - 1) ? "normal" : AvailableSampleBanks[Parsing.ParseInt(split[0])]; string addBank = (Parsing.ParseInt(split[1]) > AvailableSampleBanks.Count - 1) ? "normal" : AvailableSampleBanks[Parsing.ParseInt(split[1])]; - if (bank == @"none") { bank = null; }; + if (bank == @"none") { bank = null; } + if (addBank == @"none") { addBank = null; } bankInfo.BankForNormal = bank;