mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Fix edge cases where demo tick seeking did not work
Instead of using hardcoded tick offsets, use the current/previous/next tick values from the demo info. This fixes seeking the next tick not working for demos where the difference between the current and the next tick was greater than 3.
This commit is contained in:
parent
9071a4a08f
commit
6800bd90a4
|
@ -77,9 +77,9 @@ public:
|
|||
|
||||
enum ETickOffset
|
||||
{
|
||||
TICK_CURRENT = 1, // update the current tick again
|
||||
TICK_PREVIOUS = 0, // go to the previous tick
|
||||
TICK_NEXT = 3, // go to the next tick
|
||||
TICK_CURRENT, // update the current tick again
|
||||
TICK_PREVIOUS, // go to the previous tick
|
||||
TICK_NEXT, // go to the next tick
|
||||
};
|
||||
|
||||
~IDemoPlayer() {}
|
||||
|
|
|
@ -944,7 +944,27 @@ int CDemoPlayer::SeekTime(float Seconds)
|
|||
|
||||
int CDemoPlayer::SeekTick(ETickOffset TickOffset)
|
||||
{
|
||||
return SetPos(m_Info.m_Info.m_CurrentTick + (int)TickOffset);
|
||||
int WantedTick;
|
||||
switch(TickOffset)
|
||||
{
|
||||
case TICK_CURRENT:
|
||||
WantedTick = m_Info.m_Info.m_CurrentTick;
|
||||
break;
|
||||
case TICK_PREVIOUS:
|
||||
WantedTick = m_Info.m_PreviousTick;
|
||||
break;
|
||||
case TICK_NEXT:
|
||||
WantedTick = m_Info.m_NextTick;
|
||||
break;
|
||||
default:
|
||||
dbg_assert(false, "Invalid TickOffset");
|
||||
WantedTick = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
// +1 because SetPos will seek until the given tick is the next tick that
|
||||
// will be played back, whereas we want the wanted tick to be played now.
|
||||
return SetPos(WantedTick + 1);
|
||||
}
|
||||
|
||||
int CDemoPlayer::SetPos(int WantedTick)
|
||||
|
|
Loading…
Reference in a new issue