/* * TV_Upstream_ParseFrame */ static void TV_Upstream_ParseFrame( upstream_t *upstream, msg_t *msg ) { static snapshot_t snap; SNAP_SkipFrame( msg, &snap ); if( upstream->demo.recording ) { if( upstream->demo.waiting && !snap.delta && snap.multipov ) { upstream->demo.waiting = false; // we can start recording now upstream->demo.basetime = snap.serverTime; upstream->demo.localtime = time( NULL ); // clear demo meta data, we'll write some keys later upstream->demo.meta_data_realsize = SNAP_ClearDemoMeta( upstream->demo.meta_data, sizeof( upstream->demo.meta_data ) ); // write out messages to hold the startup information SNAP_BeginDemoRecording( upstream->demo.filehandle, 0x10000 + upstream->servercount, upstream->snapFrameTime, upstream->levelname, upstream->reliable ? SV_BITFLAGS_RELIABLE : 0, upstream->purelist, upstream->configstrings[0], upstream->baselines ); } if( !upstream->demo.waiting ) upstream->demo.duration = snap.serverTime - upstream->demo.basetime; } upstream->serverTime = snap.serverTime; upstream->serverFrame = snap.serverFrame; // getting a valid frame message ends the upstream process if( upstream->state != CA_ACTIVE ) upstream->state = CA_ACTIVE; }
/* * SV_Demo_WriteStartMessages */ static void SV_Demo_WriteStartMessages( void ) { // clear demo meta data, we'll write some keys later svs.demo.meta_data_realsize = SNAP_ClearDemoMeta( svs.demo.meta_data, sizeof( svs.demo.meta_data ) ); SNAP_BeginDemoRecording( svs.demo.file, svs.spawncount, svc.snapFrameTime, sv.mapname, SV_BITFLAGS_RELIABLE, svs.purelist, sv.configstrings[0], sv.baselines ); }
/* * CL_ParseFrame */ static void CL_ParseFrame( msg_t *msg ) { snapshot_t *snap, *oldSnap; int delta; oldSnap = ( cl.receivedSnapNum > 0 ) ? &cl.snapShots[cl.receivedSnapNum & UPDATE_MASK] : NULL; snap = SNAP_ParseFrame( msg, oldSnap, &cl.suppressCount, cl.snapShots, cl_baselines, cl_shownet->integer ); if( snap->valid ) { cl.receivedSnapNum = snap->serverFrame; if( cls.demo.recording ) { if( cls.demo.waiting && !snap->delta ) { cls.demo.waiting = qfalse; // we can start recording now cls.demo.basetime = snap->serverTime; cls.demo.localtime = time( NULL ); // clear demo meta data, we'll write some keys later cls.demo.meta_data_realsize = SNAP_ClearDemoMeta( cls.demo.meta_data, sizeof( cls.demo.meta_data ) ); // write out messages to hold the startup information SNAP_BeginDemoRecording( cls.demo.file, 0x10000 + cl.servercount, cl.snapFrameTime, cl.servermessage, cls.reliable ? SV_BITFLAGS_RELIABLE : 0, cls.purelist, cl.configstrings[0], cl_baselines ); // the rest of the demo file will be individual frames } if( !cls.demo.waiting ) cls.demo.duration = snap->serverTime - cls.demo.basetime; cls.demo.time = cls.demo.duration; } if( cl_debug_timeDelta->integer ) { if( oldSnap != NULL && ( oldSnap->serverFrame + 1 != snap->serverFrame ) ) Com_Printf( S_COLOR_RED"***** SnapShot lost\n" ); } // the first snap, fill all the timeDeltas with the same value // don't let delta add big jumps to the smoothing ( a stable connection produces jumps inside +-3 range) delta = ( snap->serverTime - cl.snapFrameTime ) - cls.gametime; if( cl.currentSnapNum <= 0 || delta < cl.newServerTimeDelta - 175 || delta > cl.newServerTimeDelta + 175 ) { CL_RestartTimeDeltas( delta ); } else { if( cl_debug_timeDelta->integer ) { if( delta < cl.newServerTimeDelta - (int)cl.snapFrameTime ) Com_Printf( S_COLOR_CYAN"***** timeDelta low clamp\n" ); else if( delta > cl.newServerTimeDelta + (int)cl.snapFrameTime ) Com_Printf( S_COLOR_CYAN"***** timeDelta high clamp\n" ); } clamp( delta, cl.newServerTimeDelta - (int)cl.snapFrameTime, cl.newServerTimeDelta + (int)cl.snapFrameTime ); cl.serverTimeDeltas[cl.receivedSnapNum & MASK_TIMEDELTAS_BACKUP] = delta; } } }