Merge pull request #7776 from peppy/fix-virtual-track-beatsync

Fix BeatSyncContainer failing at song select
This commit is contained in:
Dan Balasescu 2020-02-10 13:31:29 +09:00 committed by GitHub
commit 3627548389
2 changed files with 12 additions and 18 deletions

View File

@ -39,7 +39,7 @@ namespace osu.Game.Beatmaps
BeatmapSetInfo = beatmapInfo.BeatmapSet; BeatmapSetInfo = beatmapInfo.BeatmapSet;
Metadata = beatmapInfo.Metadata ?? BeatmapSetInfo?.Metadata ?? new BeatmapMetadata(); Metadata = beatmapInfo.Metadata ?? BeatmapSetInfo?.Metadata ?? new BeatmapMetadata();
track = new RecyclableLazy<Track>(() => GetTrack() ?? GetVirtualTrack()); track = new RecyclableLazy<Track>(() => GetTrack() ?? GetVirtualTrack(1000));
background = new RecyclableLazy<Texture>(GetBackground, BackgroundStillValid); background = new RecyclableLazy<Texture>(GetBackground, BackgroundStillValid);
waveform = new RecyclableLazy<Waveform>(GetWaveform); waveform = new RecyclableLazy<Waveform>(GetWaveform);
storyboard = new RecyclableLazy<Storyboard>(GetStoryboard); storyboard = new RecyclableLazy<Storyboard>(GetStoryboard);
@ -48,7 +48,7 @@ namespace osu.Game.Beatmaps
total_count.Value++; total_count.Value++;
} }
protected virtual Track GetVirtualTrack() protected virtual Track GetVirtualTrack(double emptyLength = 0)
{ {
const double excess_length = 1000; const double excess_length = 1000;
@ -59,7 +59,7 @@ namespace osu.Game.Beatmaps
switch (lastObject) switch (lastObject)
{ {
case null: case null:
length = excess_length; length = emptyLength;
break; break;
case IHasEndTime endTime: case IHasEndTime endTime:

View File

@ -59,9 +59,9 @@ namespace osu.Game.Graphics.Containers
Track track = null; Track track = null;
IBeatmap beatmap = null; IBeatmap beatmap = null;
double currentTrackTime; double currentTrackTime = 0;
TimingControlPoint timingPoint; TimingControlPoint timingPoint = null;
EffectControlPoint effectPoint; EffectControlPoint effectPoint = null;
if (Beatmap.Value.TrackLoaded && Beatmap.Value.BeatmapLoaded) if (Beatmap.Value.TrackLoaded && Beatmap.Value.BeatmapLoaded)
{ {
@ -69,24 +69,18 @@ namespace osu.Game.Graphics.Containers
beatmap = Beatmap.Value.Beatmap; beatmap = Beatmap.Value.Beatmap;
} }
if (track != null && beatmap != null && track.IsRunning) if (track != null && beatmap != null && track.IsRunning && track.Length > 0)
{ {
currentTrackTime = track.Length > 0 ? track.CurrentTime + EarlyActivationMilliseconds : Clock.CurrentTime; currentTrackTime = track.CurrentTime + EarlyActivationMilliseconds;
timingPoint = beatmap.ControlPointInfo.TimingPointAt(currentTrackTime); timingPoint = beatmap.ControlPointInfo.TimingPointAt(currentTrackTime);
effectPoint = beatmap.ControlPointInfo.EffectPointAt(currentTrackTime); effectPoint = beatmap.ControlPointInfo.EffectPointAt(currentTrackTime);
if (timingPoint.BeatLength == 0)
{
IsBeatSyncedWithTrack = false;
return;
} }
IsBeatSyncedWithTrack = true; IsBeatSyncedWithTrack = timingPoint?.BeatLength > 0;
}
else if (timingPoint == null || !IsBeatSyncedWithTrack)
{ {
IsBeatSyncedWithTrack = false;
currentTrackTime = Clock.CurrentTime; currentTrackTime = Clock.CurrentTime;
timingPoint = defaultTiming; timingPoint = defaultTiming;
effectPoint = defaultEffect; effectPoint = defaultEffect;