mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge #6211
6211: Fix edge cases where demo tick seeking did not work r=Chairn a=Robyt3 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. ## Checklist - [X] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test (especially base/) or added coverage to integration test - [ ] Considered possible null pointers and out of bounds array indexing - [ ] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: Robert Müller <robytemueller@gmail.com>
This commit is contained in:
commit
1ad36b2073
|
@ -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