Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void CL_Move(float accumulated_extra_samples, bool bFinalTick )
- {
- if ( !cl.IsConnected() )
- return;
- if ( !Host_ShouldRun() )
- return;
- // only send packets on the final tick in one engine frame
- bool bSendPacket = true;
- // Don't create usercmds here during playback, they were encoded into the packet already
- if ( demoplayer->IsPlayingBack() )
- {
- if ( cl.ishltv )
- {
- // still do it when playing back a HLTV demo
- bSendPacket = false;
- }
- else
- {
- return;
- }
- }
- // don't send packets if update time not reached or chnnel still sending
- // in loopback mode don't send only if host_limitlocal is enabled
- if ( ( !cl.m_NetChannel->IsLoopback() || host_limitlocal.GetInt() ) &&
- ( ( net_time < cl.m_flNextCmdTime ) || !cl.m_NetChannel->CanPacket() || !bFinalTick ) )
- {
- bSendPacket = false;
- }
- if ( cl.IsActive() )
- {
- VPROF( "CL_Move" );
- int nextcommandnr = cl.lastoutgoingcommand + cl.chokedcommands + 1;
- // Have client .dll create and store usercmd structure
- g_ClientDLL->CreateMove(
- nextcommandnr,
- host_state.interval_per_tick - accumulated_extra_samples,
- !cl.IsPaused() );
- // Store new usercmd to dem file
- if ( demorecorder->IsRecording() )
- {
- // Back up one because we've incremented outgoing_sequence each frame by 1 unit
- demorecorder->RecordUserInput( nextcommandnr );
- }
- if ( bSendPacket )
- {
- CL_SendMove();
- }
- else
- {
- // netchanll will increase internal outgoing sequnce number too
- cl.m_NetChannel->SetChoked();
- // Mark command as held back so we'll send it next time
- cl.chokedcommands++;
- }
- }
- if ( !bSendPacket )
- return;
- // Request non delta compression if high packet loss, show warning message
- bool hasProblem = cl.m_NetChannel->IsTimingOut() && !demoplayer->IsPlayingBack() && cl.IsActive();
- // Request non delta compression if high packet loss, show warning message
- if ( hasProblem )
- {
- con_nprint_t np;
- np.time_to_live = 1.0;
- np.index = 2;
- np.fixed_width_font = false;
- np.color[ 0 ] = 1.0;
- np.color[ 1 ] = 0.2;
- np.color[ 2 ] = 0.2;
- float flTimeOut = cl.m_NetChannel->GetTimeoutSeconds();
- Assert( flTimeOut != -1.0f );
- float flRemainingTime = flTimeOut - cl.m_NetChannel->GetTimeSinceLastReceived();
- Con_NXPrintf( &np, "WARNING: Connection Problem" );
- np.index = 3;
- Con_NXPrintf( &np, "Auto-disconnect in %.1f seconds", flRemainingTime );
- cl.ForceFullUpdate(); // sets m_nDeltaTick to -1
- }
- if ( cl.IsActive() )
- {
- NET_Tick mymsg( cl.m_nDeltaTick, host_frametime_unbounded, host_frametime_stddeviation );
- cl.m_NetChannel->SendNetMsg( mymsg );
- }
- //COM_Log( "cl.log", "Sending command number %i(%i) to server\n", cl.m_NetChan->m_nOutSequenceNr, cl.m_NetChan->m_nOutSequenceNr & CL_UPDATE_MASK );
- // Remember outgoing command that we are sending
- cl.lastoutgoingcommand = cl.m_NetChannel->SendDatagram( NULL );
- cl.chokedcommands = 0;
- // calc next packet send time
- if ( cl.IsActive() )
- {
- // use full update rate when active
- float commandInterval = 1.0f / cl_cmdrate->GetFloat();
- float maxDelta = min ( host_state.interval_per_tick, commandInterval );
- float delta = clamp( net_time - cl.m_flNextCmdTime, 0.0f, maxDelta );
- cl.m_flNextCmdTime = net_time + commandInterval - delta;
- }
- else
- {
- // during signon process send only 5 packets/second
- cl.m_flNextCmdTime = net_time + ( 1.0f / 5.0f );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment