Skip to content

Commit

Permalink
Prevent crashes from seeking very close to end of Loop Regions
Browse files Browse the repository at this point in the history
  • Loading branch information
poco0317 committed Nov 5, 2019
1 parent e0d022f commit f4153d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1019,13 +1019,21 @@ local function duminput(event)
if GAMESTATE:IsPaused() then
local pos = SCREENMAN:GetTopScreen():GetSongPosition()
local dir = GAMESTATE:GetPlayerState(PLAYER_1):GetCurrentPlayerOptions():UsingReverse() and 1 or -1
SCREENMAN:GetTopScreen():SetSongPosition(pos + dir * 0.05, 0, false)
local nextpos = pos + dir * 0.05
if loopEndPos ~= nil and nextpos >= loopEndPos then
handleRegionSetting(nextpos + 1)
end
SCREENMAN:GetTopScreen():SetSongPosition(nextpos, 0, false)
end
elseif event.DeviceInput.button == "DeviceButton_mousewheel down" then
if GAMESTATE:IsPaused() then
local pos = SCREENMAN:GetTopScreen():GetSongPosition()
local dir = GAMESTATE:GetPlayerState(PLAYER_1):GetCurrentPlayerOptions():UsingReverse() and 1 or -1
SCREENMAN:GetTopScreen():SetSongPosition(pos - dir * 0.05, 0, false)
local nextpos = pos - dir * 0.05
if loopEndPos ~= nil and nextpos >= loopEndPos then
handleRegionSetting(nextpos + 1)
end
SCREENMAN:GetTopScreen():SetSongPosition(nextpos, 0, false)
end
end
end
Expand Down
6 changes: 4 additions & 2 deletions src/Etterna/Screen/Gameplay/ScreenGameplayPractice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ ScreenGameplayPractice::Update(float fDeltaTime)
const int rowStart = BeatToNoteRow(startBeat);
const int rowEnd = BeatToNoteRow(endBeat);

SetupNoteDataFromRow(GAMESTATE->m_pCurSteps, rowStart, rowEnd);
if (rowStart < rowEnd)
SetupNoteDataFromRow(GAMESTATE->m_pCurSteps, rowStart, rowEnd);
}
lastReportedSeconds = GAMESTATE->m_Position.m_fMusicSeconds;

Expand Down Expand Up @@ -287,7 +288,8 @@ ScreenGameplayPractice::SetSongPosition(float newSongPositionSeconds,
if (loopStart != loopEnd) {
const float endBeat = pTiming->GetBeatFromElapsedTime(loopEnd);
const int rowEnd = BeatToNoteRow(endBeat);
SetupNoteDataFromRow(pSteps, rowNow, rowEnd);
if (rowNow < rowEnd)
SetupNoteDataFromRow(pSteps, rowNow, rowEnd);
} else {
SetupNoteDataFromRow(pSteps, rowNow);
}
Expand Down

0 comments on commit f4153d1

Please sign in to comment.