Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 15, 2006, 4:59:47 PM (18 years ago)
Author:
rennerc
Message:

ConnectionMonitor removes old packets correctly now

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/lib/network/connection_monitor.cc

    r8068 r8481  
    130130
    131131/**
     132 * remove old packets
     133 * @param packetHistory
     134 * @param tick
     135 */
     136void ConnectionMonitor::removeOldPackets( std::map< int, int > & packetHistory, int tick )
     137{
     138  while ( packetHistory.begin()->first < tick - MSECS_TO_CALC_BWIDTH )
     139    packetHistory.erase( packetHistory.begin() );
     140}
     141
     142/**
    132143 * calculate bandwidth out of packethistory
    133144 * @param packetHistory packet history
     
    135146 * @return bandwidth in bytes/sec
    136147 */
    137 float ConnectionMonitor::calculateBandWidth( std::map< int, int > packetHistory, int tick )
    138 {
    139   // delete old packets
    140   while ( packetHistory.begin()->first < tick - MSECS_TO_CALC_BWIDTH )
    141     packetHistory.erase( packetHistory.begin() );
     148float ConnectionMonitor::calculateBandWidth( std::map< int, int > & packetHistory, int tick )
     149{
     150  removeOldPackets( packetHistory, tick );
    142151 
    143152  float res = 0.0f;
Note: See TracChangeset for help on using the changeset viewer.