mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 12:42:54 +08:00
Fix multiple instances of last hitobject time being calculated incorrectly
This commit is contained in:
parent
c5bc071c4b
commit
896f2d8f74
@ -17,7 +17,6 @@ using osu.Game.Configuration;
|
|||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Overlays.Settings;
|
using osu.Game.Overlays.Settings;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Objects;
|
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using osu.Game.Rulesets.Osu.Beatmaps;
|
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)
|
private IEnumerable<double> generateBeats(IBeatmap beatmap, IReadOnlyCollection<OsuHitObject> originalHitObjects)
|
||||||
{
|
{
|
||||||
double startTime = originalHitObjects.First().StartTime;
|
double startTime = beatmap.HitObjects.First().StartTime;
|
||||||
double endTime = originalHitObjects.Last().GetEndTime();
|
double endTime = beatmap.GetLastObjectTime();
|
||||||
|
|
||||||
var beats = beatmap.ControlPointInfo.TimingPoints
|
var beats = beatmap.ControlPointInfo.TimingPoints
|
||||||
// Ignore timing points after endTime
|
// Ignore timing points after endTime
|
||||||
|
@ -81,9 +81,12 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
public double GetMostCommonBeatLength()
|
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.
|
// 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.
|
// 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 =
|
var mostCommon =
|
||||||
// Construct a set of (beatLength, duration) tuples for each individual timing point.
|
// Construct a set of (beatLength, duration) tuples for each individual timing point.
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Beatmaps.Timing;
|
using osu.Game.Beatmaps.Timing;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
@ -102,5 +103,16 @@ namespace osu.Game.Beatmaps
|
|||||||
addCombo(nested, ref combo);
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,11 +27,8 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
if (beatmap.HitObjects.Count == 0)
|
if (beatmap.HitObjects.Count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
HitObject firstObject = beatmap.HitObjects.First();
|
double firstHitTime = beatmap.HitObjects.First().StartTime;
|
||||||
HitObject lastObject = beatmap.HitObjects.Last();
|
double lastHitTime = 1 + beatmap.GetLastObjectTime();
|
||||||
|
|
||||||
double firstHitTime = firstObject.StartTime;
|
|
||||||
double lastHitTime = 1 + lastObject.GetEndTime();
|
|
||||||
|
|
||||||
var timingPoints = beatmap.ControlPointInfo.TimingPoints;
|
var timingPoints = beatmap.ControlPointInfo.TimingPoints;
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
double lastObjectTime = Objects.LastOrDefault()?.GetEndTime() ?? double.MaxValue;
|
double lastObjectTime = Beatmap.GetLastObjectTime();
|
||||||
double baseBeatLength = TimingControlPoint.DEFAULT_BEAT_LENGTH;
|
double baseBeatLength = TimingControlPoint.DEFAULT_BEAT_LENGTH;
|
||||||
|
|
||||||
if (RelativeScaleBeatLengths)
|
if (RelativeScaleBeatLengths)
|
||||||
|
@ -40,7 +40,6 @@ using osu.Game.Overlays.Notifications;
|
|||||||
using osu.Game.Overlays.OSD;
|
using osu.Game.Overlays.OSD;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Objects;
|
|
||||||
using osu.Game.Screens.Edit.Components.Menus;
|
using osu.Game.Screens.Edit.Components.Menus;
|
||||||
using osu.Game.Screens.Edit.Compose;
|
using osu.Game.Screens.Edit.Compose;
|
||||||
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
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.
|
// 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.
|
// 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.
|
// This has intentionally been changed to make it more useful.
|
||||||
double? lastObjectTime = editorBeatmap.HitObjects.LastOrDefault()?.GetEndTime();
|
if (!editorBeatmap.HitObjects.Any() || clock.CurrentTime == editorBeatmap.GetLastObjectTime())
|
||||||
|
|
||||||
if (lastObjectTime == null || clock.CurrentTime == lastObjectTime)
|
|
||||||
clock.Seek(clock.TrackLength);
|
clock.Seek(clock.TrackLength);
|
||||||
else
|
else
|
||||||
clock.Seek(lastObjectTime.Value);
|
clock.Seek(editorBeatmap.GetLastObjectTime());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
@ -13,7 +12,6 @@ using osu.Framework.Input.Events;
|
|||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Objects;
|
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
using osu.Game.Screens.Play.HUD;
|
using osu.Game.Screens.Play.HUD;
|
||||||
using osu.Game.Screens.Ranking;
|
using osu.Game.Screens.Ranking;
|
||||||
@ -94,7 +92,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
void keyboardSeek(int direction)
|
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);
|
Seek(target);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user