mirror of
https://bitbucket.org/CPMADevs/cnq3
synced 2024-11-10 06:31:48 +00:00
tweaked NDP behavior for beta 2
- more accurate seeking to enable scrubbing - rate-limiting is now the mod's reponsability - using the same FULL_SNAPSHOT_INTERVAL in all builds to make bugs less difficult to track
This commit is contained in:
parent
8ed8d26481
commit
ab44152713
1 changed files with 16 additions and 14 deletions
|
@ -102,11 +102,7 @@ There's no need to make the player more complex for such an edge case.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined(_DEBUG)
|
|
||||||
#define FULL_SNAPSHOT_INTERVAL_MS (1 * 1000)
|
|
||||||
#else
|
|
||||||
#define FULL_SNAPSHOT_INTERVAL_MS (8 * 1000)
|
#define FULL_SNAPSHOT_INTERVAL_MS (8 * 1000)
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MAX_COMMANDS ARRAY_LEN(demo.commands)
|
#define MAX_COMMANDS ARRAY_LEN(demo.commands)
|
||||||
|
|
||||||
|
@ -933,6 +929,14 @@ static void ReadNextSnapshot()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int PeekNextSnapshotTime()
|
||||||
|
{
|
||||||
|
const int serverTime = demo.nextSnap != NULL ? demo.nextSnap->serverTime : INT_MIN;
|
||||||
|
|
||||||
|
return serverTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void AddCommand( const char* string )
|
static void AddCommand( const char* string )
|
||||||
{
|
{
|
||||||
PrintCmd(string);
|
PrintCmd(string);
|
||||||
|
@ -1170,12 +1174,7 @@ qbool CL_NDP_GetServerCommand( int serverCommandNumber )
|
||||||
|
|
||||||
int CL_NDP_Seek( int serverTime )
|
int CL_NDP_Seek( int serverTime )
|
||||||
{
|
{
|
||||||
// rate-limit the command to avoid lags etc.
|
const int seekStartTime = Sys_Milliseconds();
|
||||||
static int prevSeekTime = 0;
|
|
||||||
const int currSeekTime = Sys_Milliseconds();
|
|
||||||
if (currSeekTime <= prevSeekTime + 100) {
|
|
||||||
return INT_MIN;
|
|
||||||
}
|
|
||||||
|
|
||||||
// figure out which full snapshot we want to jump to
|
// figure out which full snapshot we want to jump to
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
@ -1201,8 +1200,13 @@ int CL_NDP_Seek( int serverTime )
|
||||||
SeekToIndex(index);
|
SeekToIndex(index);
|
||||||
|
|
||||||
// read more snapshots until we're close to the target time for more precise jumps
|
// read more snapshots until we're close to the target time for more precise jumps
|
||||||
|
// we want the the closest snapshot whose time is less or equal to the target time
|
||||||
int numSnapshotsRead = 2;
|
int numSnapshotsRead = 2;
|
||||||
while (!demo.isLastSnapshot && demo.currSnap->serverTime < serverTime) {
|
while (!demo.isLastSnapshot) {
|
||||||
|
const int nextServerTime = PeekNextSnapshotTime();
|
||||||
|
if (nextServerTime == INT_MIN || nextServerTime > serverTime) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
// add all commands from the snapshot we're about to evict
|
// add all commands from the snapshot we're about to evict
|
||||||
PrintCmdListBegin("evicted snap commands");
|
PrintCmdListBegin("evicted snap commands");
|
||||||
AddAllCommands(&demo.currSnap->serverCommands);
|
AddAllCommands(&demo.currSnap->serverCommands);
|
||||||
|
@ -1212,9 +1216,7 @@ int CL_NDP_Seek( int serverTime )
|
||||||
}
|
}
|
||||||
|
|
||||||
Com_DPrintf("New Demo Player: sought and read %d snaps in %d ms\n",
|
Com_DPrintf("New Demo Player: sought and read %d snaps in %d ms\n",
|
||||||
numSnapshotsRead, Sys_Milliseconds() - currSeekTime);
|
numSnapshotsRead, Sys_Milliseconds() - seekStartTime);
|
||||||
|
|
||||||
prevSeekTime = currSeekTime;
|
|
||||||
|
|
||||||
return demo.currSnap->serverTime;
|
return demo.currSnap->serverTime;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue