Skip to content

Commit

Permalink
Fix incorrect bank set / sample addition logic
Browse files Browse the repository at this point in the history
Closes ppy#29361.

Typical case of a few early-returns gone wrong leading to `NodeSamples`
not being checked correctly.
  • Loading branch information
bdach committed Aug 20, 2024
1 parent 3202c77 commit c9f1ef5
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ bool hasRelevantBank(HitObject hitObject)

EditorBeatmap.PerformOnSelection(h =>
{
if (h.Samples.All(s => s.Bank == bankName))
if (hasRelevantBank(h))
return;
h.Samples = h.Samples.Select(s => s.With(newBank: bankName)).ToList();
Expand Down Expand Up @@ -269,10 +269,8 @@ public void AddHitSample(string sampleName)
EditorBeatmap.PerformOnSelection(h =>
{
// Make sure there isn't already an existing sample
if (h.Samples.Any(s => s.Name == sampleName))
return;
h.Samples.Add(h.CreateHitSampleInfo(sampleName));
if (h.Samples.All(s => s.Name != sampleName))
h.Samples.Add(h.CreateHitSampleInfo(sampleName));
if (h is IHasRepeats hasRepeats)
{
Expand Down

0 comments on commit c9f1ef5

Please sign in to comment.