Skip to content

Commit ef7982f

Browse files
authored
Merge pull request #31446 from EVAST9919/new-combo-editor
Fix performance degradation while trying to place object with a new combo in the editor.
2 parents ad14720 + 933f5db commit ef7982f

File tree

3 files changed

+40
-38
lines changed

3 files changed

+40
-38
lines changed

osu.Game.Rulesets.Catch/Objects/CatchHitObject.cs

+15-16
Original file line numberDiff line numberDiff line change
@@ -159,27 +159,26 @@ public void UpdateComboInformation(IHasComboInformation? lastObj)
159159
{
160160
// Note that this implementation is shared with the osu! ruleset's implementation.
161161
// If a change is made here, OsuHitObject.cs should also be updated.
162-
ComboIndex = lastObj?.ComboIndex ?? 0;
163-
ComboIndexWithOffsets = lastObj?.ComboIndexWithOffsets ?? 0;
164-
IndexInCurrentCombo = (lastObj?.IndexInCurrentCombo + 1) ?? 0;
165-
166-
if (this is BananaShower)
162+
int index = lastObj?.ComboIndex ?? 0;
163+
int indexWithOffsets = lastObj?.ComboIndexWithOffsets ?? 0;
164+
int inCurrentCombo = (lastObj?.IndexInCurrentCombo + 1) ?? 0;
165+
166+
// - For the purpose of combo colours, spinners never start a new combo even if they are flagged as doing so.
167+
// - At decode time, the first hitobject in the beatmap and the first hitobject after a banana shower are both enforced to be a new combo,
168+
// but this isn't directly enforced by the editor so the extra checks against the last hitobject are duplicated here.
169+
if (this is not BananaShower && (NewCombo || lastObj == null || lastObj is BananaShower))
167170
{
168-
// For the purpose of combo colours, spinners never start a new combo even if they are flagged as doing so.
169-
return;
170-
}
171-
172-
// At decode time, the first hitobject in the beatmap and the first hitobject after a banana shower are both enforced to be a new combo,
173-
// but this isn't directly enforced by the editor so the extra checks against the last hitobject are duplicated here.
174-
if (NewCombo || lastObj == null || lastObj is BananaShower)
175-
{
176-
IndexInCurrentCombo = 0;
177-
ComboIndex++;
178-
ComboIndexWithOffsets += ComboOffset + 1;
171+
inCurrentCombo = 0;
172+
index++;
173+
indexWithOffsets += ComboOffset + 1;
179174

180175
if (lastObj != null)
181176
lastObj.LastInCombo = true;
182177
}
178+
179+
ComboIndex = index;
180+
ComboIndexWithOffsets = indexWithOffsets;
181+
IndexInCurrentCombo = inCurrentCombo;
183182
}
184183

185184
protected override HitWindows CreateHitWindows() => HitWindows.Empty;

osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs

+15-16
Original file line numberDiff line numberDiff line change
@@ -184,27 +184,26 @@ public void UpdateComboInformation(IHasComboInformation? lastObj)
184184
{
185185
// Note that this implementation is shared with the osu!catch ruleset's implementation.
186186
// If a change is made here, CatchHitObject.cs should also be updated.
187-
ComboIndex = lastObj?.ComboIndex ?? 0;
188-
ComboIndexWithOffsets = lastObj?.ComboIndexWithOffsets ?? 0;
189-
IndexInCurrentCombo = (lastObj?.IndexInCurrentCombo + 1) ?? 0;
190-
191-
if (this is Spinner)
187+
int index = lastObj?.ComboIndex ?? 0;
188+
int indexWithOffsets = lastObj?.ComboIndexWithOffsets ?? 0;
189+
int inCurrentCombo = (lastObj?.IndexInCurrentCombo + 1) ?? 0;
190+
191+
// - For the purpose of combo colours, spinners never start a new combo even if they are flagged as doing so.
192+
// - At decode time, the first hitobject in the beatmap and the first hitobject after a spinner are both enforced to be a new combo,
193+
// but this isn't directly enforced by the editor so the extra checks against the last hitobject are duplicated here.
194+
if (this is not Spinner && (NewCombo || lastObj == null || lastObj is Spinner))
192195
{
193-
// For the purpose of combo colours, spinners never start a new combo even if they are flagged as doing so.
194-
return;
195-
}
196-
197-
// At decode time, the first hitobject in the beatmap and the first hitobject after a spinner are both enforced to be a new combo,
198-
// but this isn't directly enforced by the editor so the extra checks against the last hitobject are duplicated here.
199-
if (NewCombo || lastObj == null || lastObj is Spinner)
200-
{
201-
IndexInCurrentCombo = 0;
202-
ComboIndex++;
203-
ComboIndexWithOffsets += ComboOffset + 1;
196+
inCurrentCombo = 0;
197+
index++;
198+
indexWithOffsets += ComboOffset + 1;
204199

205200
if (lastObj != null)
206201
lastObj.LastInCombo = true;
207202
}
203+
204+
ComboIndex = index;
205+
ComboIndexWithOffsets = indexWithOffsets;
206+
IndexInCurrentCombo = inCurrentCombo;
208207
}
209208

210209
protected override HitWindows CreateHitWindows() => new OsuHitWindows();

osu.Game/Rulesets/Objects/Types/IHasComboInformation.cs

+10-6
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,23 @@ protected static Color4 GetSkinComboColour(IHasComboInformation combo, ISkin ski
8787
/// <param name="lastObj">The previous hitobject, or null if this is the first object in the beatmap.</param>
8888
void UpdateComboInformation(IHasComboInformation? lastObj)
8989
{
90-
ComboIndex = lastObj?.ComboIndex ?? 0;
91-
ComboIndexWithOffsets = lastObj?.ComboIndexWithOffsets ?? 0;
92-
IndexInCurrentCombo = (lastObj?.IndexInCurrentCombo + 1) ?? 0;
90+
int index = lastObj?.ComboIndex ?? 0;
91+
int indexWithOffsets = lastObj?.ComboIndexWithOffsets ?? 0;
92+
int inCurrentCombo = (lastObj?.IndexInCurrentCombo + 1) ?? 0;
9393

9494
if (NewCombo || lastObj == null)
9595
{
96-
IndexInCurrentCombo = 0;
97-
ComboIndex++;
98-
ComboIndexWithOffsets += ComboOffset + 1;
96+
inCurrentCombo = 0;
97+
index++;
98+
indexWithOffsets += ComboOffset + 1;
9999

100100
if (lastObj != null)
101101
lastObj.LastInCombo = true;
102102
}
103+
104+
ComboIndex = index;
105+
ComboIndexWithOffsets = indexWithOffsets;
106+
IndexInCurrentCombo = inCurrentCombo;
103107
}
104108
}
105109
}

0 commit comments

Comments
 (0)