Changeset 8623 in orxonox.OLD for trunk/src/lib/network/network_stream.cc
- Timestamp:
- Jun 20, 2006, 1:39:01 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/network/network_stream.cc
r8228 r8623 95 95 remainingBytesToWriteToDict = Preferences::getInstance()->getInt( "compression", "writedict", 0 ); 96 96 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 ); 98 102 } 99 103 … … 121 125 delete i->second.handshake; 122 126 i->second.handshake = NULL; 127 } 128 129 if ( i->second.connectionMonitor ) 130 { 131 delete i->second.connectionMonitor; 132 i->second.connectionMonitor = NULL; 123 133 } 124 134 } … … 198 208 delete peers[0].handshake; 199 209 peers[0].handshake = NULL; 210 211 if ( peers[0].connectionMonitor ) 212 delete peers[0].connectionMonitor; 213 peers[0].connectionMonitor = NULL; 200 214 } 201 215 } … … 282 296 it->second.socket = NULL; 283 297 298 if ( it->second.connectionMonitor ) 299 delete it->second.connectionMonitor; 300 it->second.connectionMonitor = NULL; 301 284 302 if ( it->second.handshake ) 285 303 delete it->second.handshake; … … 490 508 assert( Converter::intToByteArray( offset, buf, INTSIZE ) == INTSIZE ); 491 509 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 ) 495 517 { 496 518 PRINTF(1)("compression failed!\n"); … … 501 523 502 524 if ( this->remainingBytesToWriteToDict > 0 ) 503 writeToNewDict( buf, offset );525 writeToNewDict( buf, offset, true ); 504 526 505 527 peer->second.connectionMonitor->processUnzippedOutgoingPacket( tick, buf, offset, currentState ); … … 538 560 //PRINTF(0)("GGGGGOOOOOOOOOOTTTTTTTT: %d\n", compLength); 539 561 packetLength = Zip::getInstance()->unZip( compBuf, compLength, buf, UDP_PACKET_SIZE ); 540 562 541 563 if ( packetLength < 4*INTSIZE ) 542 564 { … … 547 569 548 570 if ( this->remainingBytesToWriteToDict > 0 ) 549 writeToNewDict( buf, packetLength );571 writeToNewDict( buf, packetLength, false ); 550 572 551 573 assert( Converter::byteArrayToInt( buf, &length ) == INTSIZE ); … … 556 578 offset = 4*INTSIZE; 557 579 558 peer->second.connectionMonitor->processUnzippedIncomingPacket( tick, buf, offset, state, ackedState );580 peer->second.connectionMonitor->processUnzippedIncomingPacket( tick, buf, packetLength, state, ackedState ); 559 581 560 582 //NETPRINTF(n)("got packet: %d, %d\n", length, packetLength); … … 729 751 * @param length length 730 752 */ 731 void NetworkStream::writeToNewDict( byte * data, int length )753 void NetworkStream::writeToNewDict( byte * data, int length, bool upstream ) 732 754 { 733 755 if ( remainingBytesToWriteToDict <= 0 ) … … 739 761 std::string fileName = ResourceManager::getInstance()->getDataDir(); 740 762 fileName += "/dicts/newdict"; 763 764 if ( upstream ) 765 fileName += "_upstream"; 766 else 767 fileName += "_downstream"; 741 768 742 769 FILE * f = fopen( fileName.c_str(), "a" );
Note: See TracChangeset
for help on using the changeset viewer.