Skip to content

Commit

Permalink
Skip sending judgment messages for misses in practice mode
Browse files Browse the repository at this point in the history
This will heavily reduce stutter when skipping around.
The denser the song and the deeper the seek, the worse the lag. By skipping message sending, we can avoid most of the lag.
Tested on a 6k note song, the lag is reduced to less than 200ms rather than as much as 1000ms.
  • Loading branch information
poco0317 committed Mar 7, 2019
1 parent 8cf63f5 commit dc08985
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3628,6 +3628,10 @@ Player::SetMineJudgment(TapNoteScore tns, int iTrack)
#endif
}

// hack for practice mode fps: dont send messages for missed mines in practice mode -poco
if (GAMESTATE->m_pPlayerState->m_PlayerOptions.GetCurrent().m_bPractice && tns == TNS_AvoidMine)
return;

MESSAGEMAN->Broadcast(msg);
if (m_pPlayerStageStats &&
((tns == TNS_AvoidMine && AVOID_MINE_INCREMENTS_COMBO) ||
Expand All @@ -3645,6 +3649,12 @@ Player::SetJudgment(int iRow,
TapNoteScore tns,
float fTapNoteOffset)
{
// skip misses older than a second in practice mode to prevent huge freezes
// when skipping in long songs -poco
if (GAMESTATE->m_pPlayerState->m_PlayerOptions.GetCurrent().m_bPractice &&
iRow < BeatToNoteRow(m_Timing->GetBeatFromElapsedTime(m_Timing->WhereUAtBro(m_pPlayerState->m_Position.m_fSongBeat) - 1)))
return;

if (tns == TNS_Miss && m_pPlayerStageStats != nullptr)
AddNoteToReplayData(
GAMESTATE->CountNotesSeparately() ? iTrack : -1, &tn, iRow);
Expand Down Expand Up @@ -3767,6 +3777,14 @@ Player::SetHoldJudgment(TapNote& tn, int iTrack, int iRow)

AddHoldToReplayData(iTrack, &tn, iRow);

// skip misses older than a second in practice mode to prevent
// huge freezes when skipping in long songs -poco
if (GAMESTATE->m_pPlayerState->m_PlayerOptions.GetCurrent().m_bPractice &&
iRow <
BeatToNoteRow(m_Timing->GetBeatFromElapsedTime(
m_Timing->WhereUAtBro(m_pPlayerState->m_Position.m_fSongBeat) - 5)))
return;

if (m_bSendJudgmentAndComboMessages) {
Message msg("Judgment");
msg.SetParam("Player", m_pPlayerState->m_PlayerNumber);
Expand Down Expand Up @@ -3967,10 +3985,9 @@ Player::RenderAllNotesIgnoreScores()
m_pJudgedRows->Reset(-1);

for (int i = 0;
i < GAMESTATE->GetCurrentStyle(GetPlayerState()->m_PlayerNumber)
->m_iColsPerPlayer;
++i)
{
i < GAMESTATE->GetCurrentStyle(GetPlayerState()->m_PlayerNumber)
->m_iColsPerPlayer;
++i) {
lastHoldHeadsSeconds[i] = -1000.f;
}

Expand Down

0 comments on commit dc08985

Please sign in to comment.