Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions osu.Game/Screens/Edit/EditorBeatmap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -515,13 +515,19 @@ private void trackStartTime(HitObject hitObject)

private int findInsertionIndex(IReadOnlyList<HitObject> list, double startTime)
{
for (int i = 0; i < list.Count; i++)
int min = 0;
int max = list.Count - 1;

while (min <= max)
{
if (list[i].StartTime > startTime)
return i - 1;
int mid = min + (max - min) / 2;
if (list[mid].StartTime <= startTime)
min = mid + 1;
else
max = mid - 1;
}

return list.Count - 1;
return min - 1;
}

public double SnapTime(double time, double? referenceTime) => ControlPointInfo.GetClosestSnappedTime(time, BeatDivisor, referenceTime);
Expand Down
51 changes: 51 additions & 0 deletions replace_method.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import sys

filepath = "osu.Game/Screens/Edit/EditorBeatmap.cs"
with open(filepath, 'r') as f:
content = f.read()

old_method = """ public int findInsertionIndex(IReadOnlyList<HitObject> list, double startTime)
{
for (int i = 0; i < list.Count; i++)
{
if (list[i].StartTime > startTime)
return i - 1;
}

return list.Count - 1;
}"""

new_method = """ public int findInsertionIndex(IReadOnlyList<HitObject> list, double startTime)
{
int min = 0;
int max = list.Count - 1;

while (min <= max)
{
int mid = min + (max - min) / 2;
if (list[mid].StartTime <= startTime)
min = mid + 1;
else
max = mid - 1;
}

return min - 1;
}"""

if old_method not in content:
# Try normalizing line endings or whitespace if needed, but let's check exact match first
# Maybe try stripping whitespace
# Actually, I'll print a snippet to debug if it fails
print("Method not found!")
# Find approximate location
start_idx = content.find("public int findInsertionIndex")
if start_idx != -1:
print("Found start at:", start_idx)
print("Content snippet:")
print(content[start_idx:start_idx+300])
sys.exit(1)

new_content = content.replace(old_method, new_method)

with open(filepath, 'w') as f:
f.write(new_content)
Loading