Skip to content

Commit

Permalink
Address null reference warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
kstefanowicz committed Aug 24, 2024
1 parent 9ae49f8 commit 2c65fe1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,9 @@ private void flushPendingPoints()

private void handleCustomSoundBanks(string line)
{
// If the ruleset wasn't specified, assume the osu!standard ruleset.
parser ??= new Rulesets.Objects.Legacy.Osu.ConvertHitObjectParser(getOffsetTime(), FormatVersion);

if (!parser.AvailableSampleBanks.Contains(line))
{
parser.AvailableSampleBanks.Add(line);
Expand Down
8 changes: 5 additions & 3 deletions osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,9 @@ private void handleCustomSoundBanks(TextWriter writer)

private void checkCustomSoundBank(HitObject h)
{
string bank = h.Samples.SingleOrDefault(s => s.Name == HitSampleInfo.HIT_NORMAL)?.Bank;
if (!customSoundBanks.Contains(bank)
string? bank = h.Samples.SingleOrDefault(s => s.Name == HitSampleInfo.HIT_NORMAL)?.Bank;
if (bank != null

Check failure on line 390 in osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs

View workflow job for this annotation

GitHub Actions / Code Quality

Blank lines are missing, expected minimum 1 instead of 0 in osu.Game\Beatmaps\Formats\LegacyBeatmapEncoder.cs on line 390
&& !customSoundBanks.Contains(bank)
&& bank != "none" && bank != "normal" && bank != "soft" && bank != "drum")
{
customSoundBanks.Add(bank);
Expand Down Expand Up @@ -653,7 +654,8 @@ private int toLegacySampleBank(string? sampleBank)
return (int)LegacySampleBank.Drum;

default:
return customSoundBanks.IndexOf(sampleBankLower) + 4;
if (sampleBankLower != null) return customSoundBanks.IndexOf(sampleBankLower) + 4;
return 0;

Check failure on line 658 in osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs

View workflow job for this annotation

GitHub Actions / Code Quality

Separate control transfer statement with empty line in osu.Game\Beatmaps\Formats\LegacyBeatmapEncoder.cs on line 658
}
}

Expand Down

0 comments on commit 2c65fe1

Please sign in to comment.