1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 08:12:56 +08:00

Invert if statements.

This commit is contained in:
smoogipooo 2017-05-22 16:56:40 +09:00
parent 07d148f708
commit abe9c464a8

View File

@ -20,29 +20,29 @@ namespace osu.Game.Graphics.Containers
protected override void Update() protected override void Update()
{ {
if (beatmap.Value != null) if (beatmap.Value == null)
{ return;
double trackCurrentTime = beatmap.Value.Track.CurrentTime;
ControlPoint kiaiControlPoint;
ControlPoint controlPoint = beatmap.Value.Beatmap.TimingInfo.TimingPointAt(trackCurrentTime, out kiaiControlPoint);
if (controlPoint != null) double trackCurrentTime = beatmap.Value.Track.CurrentTime;
{ ControlPoint kiaiControlPoint;
double beatLength = controlPoint.BeatLength; ControlPoint controlPoint = beatmap.Value.Beatmap.TimingInfo.TimingPointAt(trackCurrentTime, out kiaiControlPoint);
bool kiai = kiaiControlPoint?.KiaiMode ?? false;
double timingPointStart = controlPoint.Time;
int beat = beatLength > min_beat_length ? (int)((trackCurrentTime - timingPointStart) / beatLength) : 0;
//The beats before the start of the first control point are off by 1, this should do the trick if (controlPoint == null)
if (trackCurrentTime < timingPointStart) return;
beat--;
if ((timingPointStart != lastTimingPointStart || beat != lastBeat) && (int)((trackCurrentTime - timingPointStart) % beatLength) <= seek_tolerance) double beatLength = controlPoint.BeatLength;
OnNewBeat(beat, beatLength, controlPoint.TimeSignature, kiai); bool kiai = kiaiControlPoint?.KiaiMode ?? false;
lastBeat = beat; double timingPointStart = controlPoint.Time;
lastTimingPointStart = timingPointStart; int beat = beatLength > min_beat_length ? (int)((trackCurrentTime - timingPointStart) / beatLength) : 0;
}
} //The beats before the start of the first control point are off by 1, this should do the trick
if (trackCurrentTime < timingPointStart)
beat--;
if ((timingPointStart != lastTimingPointStart || beat != lastBeat) && (int)((trackCurrentTime - timingPointStart) % beatLength) <= seek_tolerance)
OnNewBeat(beat, beatLength, controlPoint.TimeSignature, kiai);
lastBeat = beat;
lastTimingPointStart = timingPointStart;
} }
protected virtual void OnNewBeat(int newBeat, double beatLength, TimeSignatures timeSignature, bool kiai) protected virtual void OnNewBeat(int newBeat, double beatLength, TimeSignatures timeSignature, bool kiai)