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:
Robert Müller 2022-12-30 20:24:11 +01:00
parent 9071a4a08f
commit 6800bd90a4
2 changed files with 24 additions and 4 deletions

View file

@ -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() {}

View file

@ -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)