Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8623 in orxonox.OLD for trunk/src/lib/network/network_stream.cc


Ignore:
Timestamp:
Jun 20, 2006, 1:39:01 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the network branche back here
merged with command:
svn merge -r8230:HEAD https://svn.orxonox.net/orxonox/branches/network .
conflicts resolved in favour of the network branche (conflicts were in network)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/network/network_stream.cc

    r8228 r8623  
    9595  remainingBytesToWriteToDict = Preferences::getInstance()->getInt( "compression", "writedict", 0 );
    9696 
    97   assert( Zip::getInstance()->loadDictionary( "testdict" ) );
     97  assert( Zip::getInstance()->loadDictionary( "testdict" ) >= 0 );
     98  this->dictClient = Zip::getInstance()->loadDictionary( "dict2pl_client" );
     99  assert( this->dictClient >= 0 );
     100  this->dictServer = Zip::getInstance()->loadDictionary( "dict2p_server" );
     101  assert( this->dictServer >= 0 );
    98102}
    99103
     
    121125      delete i->second.handshake;
    122126      i->second.handshake = NULL;
     127    }
     128   
     129    if ( i->second.connectionMonitor )
     130    {
     131      delete i->second.connectionMonitor;
     132      i->second.connectionMonitor = NULL;
    123133    }
    124134  }
     
    198208        delete peers[0].handshake;
    199209      peers[0].handshake = NULL;
     210     
     211      if ( peers[0].connectionMonitor )
     212        delete peers[0].connectionMonitor;
     213      peers[0].connectionMonitor = NULL;
    200214    }
    201215  }
     
    282296      it->second.socket = NULL;
    283297
     298      if ( it->second.connectionMonitor )
     299        delete it->second.connectionMonitor;
     300      it->second.connectionMonitor = NULL;
     301     
    284302      if ( it->second.handshake )
    285303        delete it->second.handshake;
     
    490508    assert( Converter::intToByteArray( offset, buf, INTSIZE ) == INTSIZE );
    491509   
    492     int compLength = Zip::getInstance()->zip( buf, offset, compBuf, UDP_PACKET_SIZE );
    493    
    494     if ( compLength < 0 )
     510    int compLength = 0;
     511    if ( this->isServer() )
     512      compLength = Zip::getInstance()->zip( buf, offset, compBuf, UDP_PACKET_SIZE, dictServer );
     513    else
     514      compLength = Zip::getInstance()->zip( buf, offset, compBuf, UDP_PACKET_SIZE, dictClient );
     515   
     516    if ( compLength <= 0 )
    495517    {
    496518      PRINTF(1)("compression failed!\n");
     
    501523   
    502524    if ( this->remainingBytesToWriteToDict > 0 )
    503       writeToNewDict( buf, offset );
     525      writeToNewDict( buf, offset, true );
    504526   
    505527    peer->second.connectionMonitor->processUnzippedOutgoingPacket( tick, buf, offset, currentState );
     
    538560      //PRINTF(0)("GGGGGOOOOOOOOOOTTTTTTTT: %d\n", compLength);
    539561      packetLength = Zip::getInstance()->unZip( compBuf, compLength, buf, UDP_PACKET_SIZE );
    540      
     562
    541563      if ( packetLength < 4*INTSIZE )
    542564      {
     
    547569     
    548570      if ( this->remainingBytesToWriteToDict > 0 )
    549         writeToNewDict( buf, packetLength );
     571        writeToNewDict( buf, packetLength, false );
    550572   
    551573      assert( Converter::byteArrayToInt( buf, &length ) == INTSIZE );
     
    556578      offset = 4*INTSIZE;
    557579     
    558       peer->second.connectionMonitor->processUnzippedIncomingPacket( tick, buf, offset, state, ackedState );
     580      peer->second.connectionMonitor->processUnzippedIncomingPacket( tick, buf, packetLength, state, ackedState );
    559581
    560582      //NETPRINTF(n)("got packet: %d, %d\n", length, packetLength);
     
    729751 * @param length length
    730752 */
    731 void NetworkStream::writeToNewDict( byte * data, int length )
     753void NetworkStream::writeToNewDict( byte * data, int length, bool upstream )
    732754{
    733755  if ( remainingBytesToWriteToDict <= 0 )
     
    739761  std::string fileName = ResourceManager::getInstance()->getDataDir();
    740762  fileName += "/dicts/newdict";
     763 
     764  if ( upstream )
     765    fileName += "_upstream";
     766  else
     767    fileName += "_downstream";
    741768 
    742769  FILE * f = fopen( fileName.c_str(), "a" );
Note: See TracChangeset for help on using the changeset viewer.