Hopefully fix error with vector iterators.
That's what I get for pretending I know how to use C++.
This commit is contained in:
+21
-22
@@ -277,7 +277,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Precondition: no BPM change or stop has 0 for its value (change->second).
|
// Precondition: no BPM change or stop has 0 for its value (change.second).
|
||||||
// (The ParseBPMs and ParseStops functions make sure of this.)
|
// (The ParseBPMs and ParseStops functions make sure of this.)
|
||||||
// Postcondition: all BPM changes, stops, and warps are added to the out
|
// Postcondition: all BPM changes, stops, and warps are added to the out
|
||||||
// parameter, already sorted by beat.
|
// parameter, already sorted by beat.
|
||||||
@@ -367,23 +367,22 @@ void SMLoader::ProcessBPMsAndStops(TimingData &out,
|
|||||||
{
|
{
|
||||||
// Get the next change in order, with BPMs taking precedence
|
// Get the next change in order, with BPMs taking precedence
|
||||||
// when they fall on the same beat.
|
// when they fall on the same beat.
|
||||||
vector< pair<float, float> >::const_iterator & change =
|
bool changeIsBpm = istop == istopend || (ibpm != ibpmend && ibpm->first <= istop->first);
|
||||||
(ibpm == ibpmend || (istop != istopend && istop->first < ibpm->first))
|
const pair<float, float> & change = changeIsBpm ? *ibpm : *istop;
|
||||||
? istop : ibpm;
|
|
||||||
|
|
||||||
// Calculate the effects of time at the current BPM. "Infinite"
|
// Calculate the effects of time at the current BPM. "Infinite"
|
||||||
// BPMs (SM4 warps) imply that zero time passes, so skip this
|
// BPMs (SM4 warps) imply that zero time passes, so skip this
|
||||||
// step in that case.
|
// step in that case.
|
||||||
if (bpm <= FAST_BPM_WARP)
|
if (bpm <= FAST_BPM_WARP)
|
||||||
{
|
{
|
||||||
timeofs += (change->first - prevbeat) * 60/bpm;
|
timeofs += (change.first - prevbeat) * 60/bpm;
|
||||||
|
|
||||||
// If we were in a warp and it finished during this
|
// If we were in a warp and it finished during this
|
||||||
// timeframe, create the warp segment.
|
// timeframe, create the warp segment.
|
||||||
if (warpstart >= 0 && bpm > 0 && timeofs > 0)
|
if (warpstart >= 0 && bpm > 0 && timeofs > 0)
|
||||||
{
|
{
|
||||||
// timeofs represents how far past the end we are
|
// timeofs represents how far past the end we are
|
||||||
warpend = change->first - (timeofs * bpm/60);
|
warpend = change.first - (timeofs * bpm/60);
|
||||||
out.AddSegment(WarpSegment(BeatToNoteRow(warpstart),
|
out.AddSegment(WarpSegment(BeatToNoteRow(warpstart),
|
||||||
warpend - warpstart));
|
warpend - warpstart));
|
||||||
|
|
||||||
@@ -399,16 +398,16 @@ void SMLoader::ProcessBPMsAndStops(TimingData &out,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Save the current beat for the next round of calculations
|
// Save the current beat for the next round of calculations
|
||||||
prevbeat = change->first;
|
prevbeat = change.first;
|
||||||
|
|
||||||
// Now handle the timing changes themselves
|
// Now handle the timing changes themselves
|
||||||
if (change == ibpm)
|
if (changeIsBpm)
|
||||||
{
|
{
|
||||||
// Does this BPM change start a new warp?
|
// Does this BPM change start a new warp?
|
||||||
if (warpstart < 0 && (change->second < 0 || change->second > FAST_BPM_WARP))
|
if (warpstart < 0 && (change.second < 0 || change.second > FAST_BPM_WARP))
|
||||||
{
|
{
|
||||||
// Yes.
|
// Yes.
|
||||||
warpstart = change->first;
|
warpstart = change.first;
|
||||||
prewarpbpm = bpm;
|
prewarpbpm = bpm;
|
||||||
timeofs = 0;
|
timeofs = 0;
|
||||||
}
|
}
|
||||||
@@ -416,49 +415,49 @@ void SMLoader::ProcessBPMsAndStops(TimingData &out,
|
|||||||
{
|
{
|
||||||
// No, and we aren't currently warping either.
|
// No, and we aren't currently warping either.
|
||||||
// Just a normal BPM change.
|
// Just a normal BPM change.
|
||||||
out.AddSegment(BPMSegment(BeatToNoteRow(change->first), change->second));
|
out.AddSegment(BPMSegment(BeatToNoteRow(change.first), change.second));
|
||||||
}
|
}
|
||||||
bpm = change->second;
|
bpm = change.second;
|
||||||
ibpm++;
|
ibpm++;
|
||||||
}
|
}
|
||||||
else if (change == istop)
|
else
|
||||||
{
|
{
|
||||||
// Does this stop start a new warp?
|
// Does this stop start a new warp?
|
||||||
if (warpstart < 0 && change->second < 0)
|
if (warpstart < 0 && change.second < 0)
|
||||||
{
|
{
|
||||||
// Yes.
|
// Yes.
|
||||||
warpstart = change->first;
|
warpstart = change.first;
|
||||||
prewarpbpm = bpm;
|
prewarpbpm = bpm;
|
||||||
timeofs = change->second;
|
timeofs = change.second;
|
||||||
}
|
}
|
||||||
else if (warpstart < 0)
|
else if (warpstart < 0)
|
||||||
{
|
{
|
||||||
// No, and we aren't currently warping either.
|
// No, and we aren't currently warping either.
|
||||||
// Just a normal stop.
|
// Just a normal stop.
|
||||||
out.AddSegment(StopSegment(BeatToNoteRow(change->first), change->second));
|
out.AddSegment(StopSegment(BeatToNoteRow(change.first), change.second));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// We're warping already. Stops affect the time
|
// We're warping already. Stops affect the time
|
||||||
// offset directly.
|
// offset directly.
|
||||||
timeofs += change->second;
|
timeofs += change.second;
|
||||||
|
|
||||||
// If a stop overcompensates for the time
|
// If a stop overcompensates for the time
|
||||||
// deficit, the warp ends and we stop for the
|
// deficit, the warp ends and we stop for the
|
||||||
// amount it goes over.
|
// amount it goes over.
|
||||||
if (change->second > 0 && timeofs > 0)
|
if (change.second > 0 && timeofs > 0)
|
||||||
{
|
{
|
||||||
warpend = change->first;
|
warpend = change.first;
|
||||||
out.AddSegment(WarpSegment(BeatToNoteRow(warpstart),
|
out.AddSegment(WarpSegment(BeatToNoteRow(warpstart),
|
||||||
warpend - warpstart));
|
warpend - warpstart));
|
||||||
out.AddSegment(StopSegment(BeatToNoteRow(change->first), timeofs));
|
out.AddSegment(StopSegment(BeatToNoteRow(change.first), timeofs));
|
||||||
|
|
||||||
// Now, are we still warping because of
|
// Now, are we still warping because of
|
||||||
// the BPM value?
|
// the BPM value?
|
||||||
if (bpm < 0 || bpm > FAST_BPM_WARP)
|
if (bpm < 0 || bpm > FAST_BPM_WARP)
|
||||||
{
|
{
|
||||||
// Yep.
|
// Yep.
|
||||||
warpstart = change->first;
|
warpstart = change.first;
|
||||||
// prewarpbpm remains the same
|
// prewarpbpm remains the same
|
||||||
timeofs = 0;
|
timeofs = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user