/* =============== idCommonLocal::SendUsercmd =============== */ void idCommonLocal::SendUsercmds( int localClientNum ) { if ( !mapSpawned ) { return; } int currentTime = Sys_Milliseconds(); if ( currentTime < nextUsercmdSendTime ) { return; } idLobbyBase & lobby = session->GetActingGameStateLobbyBase(); if ( lobby.IsHost() ) { return; } // We always send the last NUM_USERCMD_SEND usercmds // Which may result in duplicate usercmds being sent in the case of a low net_ucmdRate // But the LZW compressor means the extra usercmds are not large and the redundancy can smooth packet loss byte buffer[idPacketProcessor::MAX_FINAL_PACKET_SIZE]; idBitMsg msg( buffer, sizeof( buffer ) ); idSerializer ser( msg, true ); usercmd_t empty; usercmd_t * last = ∅ usercmd_t * cmdBuffer[NUM_USERCMD_SEND]; const int numCmds = userCmdMgr.GetPlayerCmds( localClientNum, cmdBuffer, NUM_USERCMD_SEND ); msg.WriteByte( numCmds ); for ( int i = 0; i < numCmds; i++ ) { cmdBuffer[i]->Serialize( ser, *last ); last = cmdBuffer[i]; } session->SendUsercmds( msg ); nextUsercmdSendTime = MSEC_ALIGN_TO_FRAME( currentTime + net_ucmdRate.GetInteger() ); }
/* =============== idCommonLocal::SendSnapshots =============== */ void idCommonLocal::SendSnapshots() { if( !mapSpawned ) { return; } int currentTime = Sys_Milliseconds(); if( currentTime < nextSnapshotSendTime ) { return; } idLobbyBase& lobby = session->GetActingGameStateLobbyBase(); if( !lobby.IsHost() ) { return; } if( !lobby.HasActivePeers() ) { return; } idSnapShot ss; game->ServerWriteSnapshot( ss ); session->SendSnapshot( ss ); nextSnapshotSendTime = MSEC_ALIGN_TO_FRAME( currentTime + net_snapRate.GetInteger() ); }
/* ================ idPhysics::SnapTimeToPhysicsFrame ================ */ int idPhysics::SnapTimeToPhysicsFrame( int t ) { return MSEC_ALIGN_TO_FRAME( t ); }