diff --git a/src/engine/demo.h b/src/engine/demo.h index faf5d2676..f37153272 100644 --- a/src/engine/demo.h +++ b/src/engine/demo.h @@ -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() {} diff --git a/src/engine/shared/demo.cpp b/src/engine/shared/demo.cpp index 6193e2755..7ed9daf24 100644 --- a/src/engine/shared/demo.cpp +++ b/src/engine/shared/demo.cpp @@ -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)