1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 18:07:23 +08:00

Fix multiple instances of last hitobject time being calculated incorrectly

This commit is contained in:
Dean Herbert 2022-12-01 17:43:54 +09:00
parent c5bc071c4b
commit 896f2d8f74
7 changed files with 24 additions and 18 deletions

View File

@ -17,7 +17,6 @@ using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Overlays.Settings;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Osu.Beatmaps;
@ -196,8 +195,8 @@ namespace osu.Game.Rulesets.Osu.Mods
private IEnumerable<double> generateBeats(IBeatmap beatmap, IReadOnlyCollection<OsuHitObject> originalHitObjects)
{
double startTime = originalHitObjects.First().StartTime;
double endTime = originalHitObjects.Last().GetEndTime();
double startTime = beatmap.HitObjects.First().StartTime;
double endTime = beatmap.GetLastObjectTime();
var beats = beatmap.ControlPointInfo.TimingPoints
// Ignore timing points after endTime

View File

@ -81,9 +81,12 @@ namespace osu.Game.Beatmaps
public double GetMostCommonBeatLength()
{
if (!HitObjects.Any())
return ControlPointInfo.TimingPoints.LastOrDefault()?.Time ?? 0;
// The last playable time in the beatmap - the last timing point extends to this time.
// Note: This is more accurate and may present different results because osu-stable didn't have the ability to calculate slider durations in this context.
double lastTime = HitObjects.LastOrDefault()?.GetEndTime() ?? ControlPointInfo.TimingPoints.LastOrDefault()?.Time ?? 0;
double lastTime = this.GetLastObjectTime();
var mostCommon =
// Construct a set of (beatLength, duration) tuples for each individual timing point.

View File

@ -4,6 +4,7 @@
#nullable disable
using System.Collections.Generic;
using System.Linq;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Beatmaps.Timing;
using osu.Game.Rulesets.Objects;
@ -102,5 +103,16 @@ namespace osu.Game.Beatmaps
addCombo(nested, ref combo);
}
}
/// <summary>
/// Find the absolute end time of the latest <see cref="HitObject"/> in a beatmap. Will throw if beatmap contains no objects.
/// </summary>
/// <remarks>
/// This correctly accounts for rulesets which have concurrent hitobjects which may have durations, causing the .Last() object
/// to not necessarily have the latest end time.
///
/// It's not super efficient so calls should be kept to a minimum.
/// </remarks>
public static double GetLastObjectTime(this IBeatmap beatmap) => beatmap.HitObjects.Max(h => h.GetEndTime());
}
}

View File

@ -27,11 +27,8 @@ namespace osu.Game.Rulesets.Objects
if (beatmap.HitObjects.Count == 0)
return;
HitObject firstObject = beatmap.HitObjects.First();
HitObject lastObject = beatmap.HitObjects.Last();
double firstHitTime = firstObject.StartTime;
double lastHitTime = 1 + lastObject.GetEndTime();
double firstHitTime = beatmap.HitObjects.First().StartTime;
double lastHitTime = 1 + beatmap.GetLastObjectTime();
var timingPoints = beatmap.ControlPointInfo.TimingPoints;

View File

@ -114,7 +114,7 @@ namespace osu.Game.Rulesets.UI.Scrolling
break;
}
double lastObjectTime = Objects.LastOrDefault()?.GetEndTime() ?? double.MaxValue;
double lastObjectTime = Beatmap.GetLastObjectTime();
double baseBeatLength = TimingControlPoint.DEFAULT_BEAT_LENGTH;
if (RelativeScaleBeatLengths)

View File

@ -40,7 +40,6 @@ using osu.Game.Overlays.Notifications;
using osu.Game.Overlays.OSD;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects;
using osu.Game.Screens.Edit.Components.Menus;
using osu.Game.Screens.Edit.Compose;
using osu.Game.Screens.Edit.Compose.Components.Timeline;
@ -538,12 +537,10 @@ namespace osu.Game.Screens.Edit
// Seek to last object time, or track end if already there.
// Note that in osu-stable subsequent presses when at track end won't return to last object.
// This has intentionally been changed to make it more useful.
double? lastObjectTime = editorBeatmap.HitObjects.LastOrDefault()?.GetEndTime();
if (lastObjectTime == null || clock.CurrentTime == lastObjectTime)
if (!editorBeatmap.HitObjects.Any() || clock.CurrentTime == editorBeatmap.GetLastObjectTime())
clock.Seek(clock.TrackLength);
else
clock.Seek(lastObjectTime.Value);
clock.Seek(editorBeatmap.GetLastObjectTime());
return true;
}

View File

@ -5,7 +5,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using osu.Framework.Bindables;
using osu.Framework.Input.Bindings;
@ -13,7 +12,6 @@ using osu.Framework.Input.Events;
using osu.Game.Beatmaps;
using osu.Game.Input.Bindings;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects;
using osu.Game.Scoring;
using osu.Game.Screens.Play.HUD;
using osu.Game.Screens.Ranking;
@ -94,7 +92,7 @@ namespace osu.Game.Screens.Play
void keyboardSeek(int direction)
{
double target = Math.Clamp(GameplayClockContainer.CurrentTime + direction * keyboard_seek_amount, 0, GameplayState.Beatmap.HitObjects.Last().GetEndTime());
double target = Math.Clamp(GameplayClockContainer.CurrentTime + direction * keyboard_seek_amount, 0, GameplayState.Beatmap.GetLastObjectTime());
Seek(target);
}