From b2fef2db49f45ae9d05d3b0265b83bf8ddeb01f8 Mon Sep 17 00:00:00 2001 From: KadeDeveloper Date: Fri, 13 Aug 2021 02:12:21 -0700 Subject: [PATCH] fix steps reseting in gameplay --- source/MusicBeatState.hx | 2 ++ source/PlayState.hx | 56 ++++++++++++++++++++++------------------ 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/source/MusicBeatState.hx b/source/MusicBeatState.hx index 202f5ba..47dac29 100644 --- a/source/MusicBeatState.hx +++ b/source/MusicBeatState.hx @@ -101,6 +101,7 @@ class MusicBeatState extends FlxUIState } else if (ste < curStep) { + trace("reset steps for some reason?? at " + Conductor.songPosition); //Song reset? curStep = ste; updateBeat(); @@ -126,6 +127,7 @@ class MusicBeatState extends FlxUIState else if (nextStep < curStep) { //Song reset? + trace("(no bpm change) reset steps for some reason?? at " + Conductor.songPosition); curStep = nextStep; updateBeat(); stepHit(); diff --git a/source/PlayState.hx b/source/PlayState.hx index a823847..fc424da 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -2226,36 +2226,42 @@ class PlayState extends MusicBeatState } } - if (updateFrame == 4) - { - TimingStruct.clearTimings(); - - var currentIndex = 0; - for (i in SONG.eventObjects) - { - if (i.type == "BPM Change") + if (updateFrame == 4) + { + TimingStruct.clearTimings(); + + var currentIndex = 0; + for (i in SONG.eventObjects) { - var beat:Float = i.position; - - var endBeat:Float = Math.POSITIVE_INFINITY; - - TimingStruct.addTiming(beat,i.value,endBeat, 0); // offset in this case = start time since we don't have a offset - - if (currentIndex != 0) + if (i.type == "BPM Change") { - var data = TimingStruct.AllTimings[currentIndex - 1]; - data.endBeat = beat; - data.length = (data.endBeat - data.startBeat) / (data.bpm / 60); - TimingStruct.AllTimings[currentIndex].startTime = data.startTime + data.length; + var beat:Float = i.position; + + var endBeat:Float = Math.POSITIVE_INFINITY; + + TimingStruct.addTiming(beat,i.value,endBeat, 0); // offset in this case = start time since we don't have a offset + + if (currentIndex != 0) + { + var data = TimingStruct.AllTimings[currentIndex - 1]; + data.endBeat = beat; + data.length = (data.endBeat - data.startBeat) / (data.bpm / 60); + var step = ((60 / data.bpm) * 1000) / 4; + TimingStruct.AllTimings[currentIndex].startStep = Math.floor(((data.endBeat / (data.bpm / 60)) * 1000) / step); + TimingStruct.AllTimings[currentIndex].startTime = data.startTime + data.length; + } + + currentIndex++; } - - currentIndex++; } - } + + recalculateAllSectionTimes(); + + regenerateLines(); + updateFrame++; + } + else if (updateFrame != 5) updateFrame++; - } - else if (updateFrame != 5) - updateFrame++; var timingSeg = TimingStruct.getTimingAtTimestamp(Conductor.songPosition);