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

Address code quality issues

This commit is contained in:
kstefanowicz 2024-08-25 07:16:26 -04:00
parent e8984333f6
commit 7bb955b221
2 changed files with 9 additions and 7 deletions

View File

@ -29,7 +29,7 @@ namespace osu.Game.Beatmaps.Formats
private readonly int onlineRulesetID;
private List<string> customSoundBanks = new List<string>();
private readonly List<string> customSoundBanks = new List<string>();
/// <summary>
/// Creates a new <see cref="LegacyBeatmapEncoder"/>.
@ -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<HitSampleInfo> node in hr.NodeSamples)
foreach (IList<HitSampleInfo> 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;
}
}

View File

@ -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;