Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 31, 2011, 9:09:23 PM (13 years ago)
Author:
landauf
Message:

Replaced COUT with orxout in network library. Tried to set levels and contexts in a more or less useful way, but not really optimized. Used contexts network, packets, and master_server.
Please use endl instead of \n in the future (@smerkli) ;)

Location:
code/branches/output/src/libraries/network/packet
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/branches/output/src/libraries/network/packet/Acknowledgement.cc

    r8788 r8807  
    6464
    6565bool Acknowledgement::process(orxonox::Host* host){
    66   COUT(5) << "processing ACK with ID: " << getAckID() << endl;
     66  orxout(verbose_more, context::packets) << "processing ACK with ID: " << getAckID() << endl;
    6767  bool b = host->ackGamestate(getAckID(), peerID_);
    6868  delete this;
  • code/branches/output/src/libraries/network/packet/ClassID.cc

    r7801 r8807  
    9292  assert(tempsize==packetSize);
    9393
    94   COUT(5) << "classid packetSize is " << packetSize << endl;
     94  orxout(verbose_more, context::packets) << "classid packetSize is " << packetSize << endl;
    9595
    9696}
     
    131131  Identifier::clearNetworkIDs();
    132132
    133   COUT(4) << "=== processing classids: " << endl;
     133  orxout(verbose, context::packets) << "=== processing classids: " << endl;
    134134  std::pair<uint32_t, std::string> tempPair;
    135135  Identifier *id;
     
    143143    classname = temp+2*sizeof(uint32_t);
    144144    id=ClassByString( std::string((const char*)classname) );
    145     COUT(3) << "processing classid: " << networkID << " name: " << classname << " id: " << id << std::endl;
     145    orxout(internal_info, context::packets) << "processing classid: " << networkID << " name: " << classname << " id: " << id << endl;
    146146    if(id==NULL){
    147       COUT(0) << "Received a bad classname" << endl;
     147      orxout(user_error, context::packets) << "Received a bad classname" << endl;
    148148      abort();
    149149    }
  • code/branches/output/src/libraries/network/packet/DeleteObjects.cc

    r8788 r8807  
    6262  if(number==0)
    6363    return false;
    64   COUT(4) << "sending DeleteObjects: ";
     64  orxout(verbose, context::packets) << "sending DeleteObjects: ";
    6565  unsigned int size = sizeof(Type::Value) + sizeof(uint32_t)*(number+1);
    6666  data_ = new uint8_t[size];
     
    7373    unsigned int temp = Synchronisable::popDeletedObject();
    7474    *reinterpret_cast<uint32_t*>(tdata) = temp;
    75     COUT(4) << temp << ' ';
     75    orxout(verbose, context::packets) << temp << ' ';
    7676    tdata += sizeof(uint32_t);
    7777  }
    78   COUT(4) << std::endl;
     78  orxout(verbose, context::packets) << endl;
    7979  return true;
    8080}
     
    9090  for(unsigned int i=0; i<*(unsigned int *)(data_+_QUANTITY); i++)
    9191  {
    92     COUT(4) << "deleting object with id: " << *(uint32_t*)(data_+_OBJECTIDS+i*sizeof(uint32_t)) << std::endl;
     92    orxout(verbose, context::packets) << "deleting object with id: " << *(uint32_t*)(data_+_OBJECTIDS+i*sizeof(uint32_t)) << endl;
    9393    Synchronisable::deleteObject( *(uint32_t*)(data_+_OBJECTIDS+i*sizeof(uint32_t)) );
    9494  }
  • code/branches/output/src/libraries/network/packet/FunctionIDs.cc

    r8788 r8807  
    8888  }
    8989
    90   COUT(5) << "FunctionIDs packetSize is " << packetSize << endl;
     90  orxout(verbose_more, context::packets) << "FunctionIDs packetSize is " << packetSize << endl;
    9191
    9292}
     
    126126  unsigned char *functionname;
    127127
    128   COUT(4) << "=== processing functionids: " << endl;
     128  orxout(verbose, context::packets) << "=== processing functionids: " << endl;
    129129  std::pair<uint32_t, std::string> tempPair;
    130130  // read the total number of classes
     
    137137    stringsize = *(uint32_t*)(temp+sizeof(uint32_t));
    138138    functionname = temp+2*sizeof(uint32_t);
    139     COUT(3) << "processing functionid: " << networkID << " name: " << functionname << std::endl;
     139    orxout(internal_info, context::packets) << "processing functionid: " << networkID << " name: " << functionname << endl;
    140140    NetworkFunctionBase::setNetworkID((const char*)functionname, networkID);
    141141    temp += 2*sizeof(uint32_t) + stringsize;
  • code/branches/output/src/libraries/network/packet/Gamestate.cc

    r8788 r8807  
    108108  uint32_t size = calcGamestateSize(id, mode);
    109109
    110   COUT(5) << "G.ST.Man: producing gamestate with id: " << id << std::endl;
     110  orxout(verbose_more, context::packets) << "G.ST.Man: producing gamestate with id: " << id << endl;
    111111  if(size==0)
    112112    return false;
     
    114114  if(!data_)
    115115  {
    116     COUT(2) << "GameStateManager: could not allocate memory" << std::endl;
     116    orxout(internal_warning, context::packets) << "GameStateManager: could not allocate memory" << endl;
    117117    return false;
    118118  }
     
    139139      assert(0); // if we don't use multithreading this part shouldn't be neccessary
    140140      // start allocate additional memory
    141       COUT(3) << "Gamestate: need additional memory" << std::endl;
     141      orxout(internal_info, context::packets) << "Gamestate: need additional memory" << endl;
    142142      ObjectList<Synchronisable>::iterator temp = it;
    143143      uint32_t addsize=tempsize;
     
    167167  //stop write gamestate header
    168168
    169   COUT(5) << "Gamestate: Gamestate size: " << currentsize << std::endl;
    170   COUT(5) << "Gamestate: 'estimated' (and corrected) Gamestate size: " << size << std::endl;
     169  orxout(verbose_more, context::packets) << "Gamestate: Gamestate size: " << currentsize << endl;
     170  orxout(verbose_more, context::packets) << "Gamestate: 'estimated' (and corrected) Gamestate size: " << size << endl;
    171171  return true;
    172172}
     
    175175bool Gamestate::spreadData(uint8_t mode)
    176176{
    177   COUT(5) << "processing gamestate with id " << header_.getID() << endl;
     177  orxout(verbose_more, context::packets) << "processing gamestate with id " << header_.getID() << endl;
    178178  assert(data_);
    179179  assert(!header_.isCompressed());
     
    195195      else
    196196      {
    197 //         COUT(4) << "not creating object of classid " << objectheader.getClassID() << endl;
     197//         orxout(verbose, context::packets) << "not creating object of classid " << objectheader.getClassID() << endl;
    198198        mem += objectheader.getDataSize() + ( objectheader.isDiffed() ? SynchronisableHeaderLight::getSize() : SynchronisableHeader::getSize() );
    199199      }
     
    201201    else
    202202    {
    203 //       COUT(4) << "updating object of classid " << objectheader.getClassID() << endl;
     203//       orxout(verbose, context::packets) << "updating object of classid " << objectheader.getClassID() << endl;
    204204      OrxVerify(s->updateData(mem, mode), "ERROR: could not update Synchronisable with Gamestate data");
    205205    }
     
    219219        if (it->objectMode_ != 0x0)
    220220        {
    221           COUT(0) << "Found object with OBJECTID_UNKNOWN on the client with objectMode != 0x0!" << std::endl;
    222           COUT(0) << "Possible reason for this error: Client created a synchronized object without the Server's approval." << std::endl;
    223           COUT(0) << "Objects class: " << it->getIdentifier()->getName() << std::endl;
     221          orxout(user_error, context::packets) << "Found object with OBJECTID_UNKNOWN on the client with objectMode != 0x0!" << endl;
     222          orxout(user_error, context::packets) << "Possible reason for this error: Client created a synchronized object without the Server's approval." << endl;
     223          orxout(user_error, context::packets) << "Objects class: " << it->getIdentifier()->getName() << endl;
    224224          assert(false);
    225225        }
     
    232232          if (it->getObjectID() == *it2)
    233233          {
    234             COUT(0) << "Found duplicate objectIDs on the client!" << std::endl
    235                     << "Are you sure you don't create a Sychnronisable objcect with 'new' \
    236                         that doesn't have objectMode = 0x0?" << std::endl;
     234            orxout(user_error, context::packets) << "Found duplicate objectIDs on the client!" << endl
     235                                                 << "Are you sure you don't create a Sychnronisable objcect with 'new' \
     236                                                     that doesn't have objectMode = 0x0?" << endl;
    237237            assert(false);
    238238          }
     
    293293  switch ( retval )
    294294  {
    295     case Z_OK: COUT(5) << "G.St.Man: compress: successfully compressed" << std::endl; break;
    296     case Z_MEM_ERROR: COUT(1) << "G.St.Man: compress: not enough memory available in gamestate.compress" << std::endl; return false;
    297     case Z_BUF_ERROR: COUT(2) << "G.St.Man: compress: not enough memory available in the buffer in gamestate.compress" << std::endl; return false;
    298     case Z_DATA_ERROR: COUT(2) << "G.St.Man: compress: data corrupted in gamestate.compress" << std::endl; return false;
     295    case Z_OK: orxout(verbose_more, context::packets) << "G.St.Man: compress: successfully compressed" << endl; break;
     296    case Z_MEM_ERROR: orxout(internal_error, context::packets) << "G.St.Man: compress: not enough memory available in gamestate.compress" << endl; return false;
     297    case Z_BUF_ERROR: orxout(internal_warning, context::packets) << "G.St.Man: compress: not enough memory available in the buffer in gamestate.compress" << endl; return false;
     298    case Z_DATA_ERROR: orxout(internal_warning, context::packets) << "G.St.Man: compress: data corrupted in gamestate.compress" << endl; return false;
    299299  }
    300300
     
    310310  header_.setCompSize( buffer );
    311311  header_.setCompressed( true );
    312   COUT(4) << "gamestate compress datasize: " << header_.getDataSize() << " compsize: " << header_.getCompSize() << std::endl;
     312  orxout(verbose, context::packets) << "gamestate compress datasize: " << header_.getDataSize() << " compsize: " << header_.getCompSize() << endl;
    313313  return true;
    314314}
     
    319319  assert(data_);
    320320  assert(header_.isCompressed());
    321   COUT(4) << "GameStateClient: uncompressing gamestate. id: " << header_.getID() << ", baseid: " << header_.getBaseID() << ", datasize: " << header_.getDataSize() << ", compsize: " << header_.getCompSize() << std::endl;
     321  orxout(verbose, context::packets) << "GameStateClient: uncompressing gamestate. id: " << header_.getID() << ", baseid: " << header_.getBaseID() << ", datasize: " << header_.getDataSize() << ", compsize: " << header_.getCompSize() << endl;
    322322  uint32_t datasize = header_.getDataSize();
    323323  uint32_t compsize = header_.getCompSize();
     
    333333  switch ( retval )
    334334  {
    335     case Z_OK: COUT(5) << "successfully decompressed" << std::endl; break;
    336     case Z_MEM_ERROR: COUT(1) << "not enough memory available" << std::endl; return false;
    337     case Z_BUF_ERROR: COUT(2) << "not enough memory available in the buffer" << std::endl; return false;
    338     case Z_DATA_ERROR: COUT(2) << "data corrupted (zlib)" << std::endl; return false;
     335    case Z_OK: orxout(verbose_more, context::packets) << "successfully decompressed" << endl; break;
     336    case Z_MEM_ERROR: orxout(internal_error, context::packets) << "not enough memory available" << endl; return false;
     337    case Z_BUF_ERROR: orxout(internal_warning, context::packets) << "not enough memory available in the buffer" << endl; return false;
     338    case Z_DATA_ERROR: orxout(internal_warning, context::packets) << "data corrupted (zlib)" << endl; return false;
    339339  }
    340340
     
    375375  if( memcmp( origDataPtr+objectOffset, baseDataPtr+objectOffset, objectHeader.getDataSize()) == 0 )
    376376  {
    377 //     COUT(4) << "skip object " << Synchronisable::getSynchronisable(objectHeader.getObjectID())->getIdentifier()->getName() << endl;
     377//     orxout(verbose, context::packets) << "skip object " << Synchronisable::getSynchronisable(objectHeader.getObjectID())->getIdentifier()->getName() << endl;
    378378    origDataPtr += objectOffset + objectHeader.getDataSize(); // skip the whole object
    379379    baseDataPtr += objectOffset + objectHeader.getDataSize();
     
    431431inline void /*Gamestate::*/copyObject( uint8_t*& newData, uint8_t*& origData, uint8_t*& baseData, SynchronisableHeader& objectHeader, std::vector<uint32_t>::iterator& sizes )
    432432{
    433   //       COUT(4) << "docopy" << endl;
     433  //       orxout(verbose, context::packets) << "docopy" << endl;
    434434  // Just copy over the whole Object
    435435  memcpy( newData, origData, objectHeader.getDataSize()+SynchronisableHeader::getSize() );
     
    440440//   SynchronisableHeader baseHeader( baseData );
    441441//   baseData += baseHeader.getDataSize()+SynchronisableHeader::getSize();
    442   //       COUT(4) << "copy " << h.getObjectID() << endl;
    443   //       COUT(4) << "copy " << h.getObjectID() << ":";
     442  //       orxout(verbose, context::packets) << "copy " << h.getObjectID() << endl;
     443  //       orxout(verbose, context::packets) << "copy " << h.getObjectID() << ":";
    444444  sizes += Synchronisable::getSynchronisable(objectHeader.getObjectID())->getNrOfVariables();
    445445//   for( unsigned int i = 0; i < Synchronisable::getSynchronisable(objectHeader.getObjectID())->getNrOfVariables(); ++i )
    446446//   {
    447 //     //         COUT(4) << " " << *sizes;
     447//     //         orxout(verbose, context::packets) << " " << *sizes;
    448448//     ++sizes;
    449449//   }
    450     //       COUT(4) << endl;
     450    //       orxout(verbose, context::packets) << endl;
    451451}
    452452
     
    541541      if( SynchronisableHeader(baseDataPtr).getDataSize()==origHeader.getDataSize() )
    542542      {
    543 //         COUT(4) << "diffing object in order: " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl;
     543//         orxout(verbose, context::packets) << "diffing object in order: " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl;
    544544        diffObject(destDataPtr, origDataPtr, baseDataPtr, origHeader, sizesIt);
    545545        diffedObject = true;
     
    547547      else
    548548      {
    549 //         COUT(4) << "copy object because of different data sizes (1): " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl;
     549//         orxout(verbose, context::packets) << "copy object because of different data sizes (1): " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl;
    550550        copyObject(destDataPtr, origDataPtr, baseDataPtr, origHeader, sizesIt);
    551551        assert(sizesIt != this->sizes_.end() || origDataPtr==origDataEnd);
     
    565565        if( SynchronisableHeader(baseDataPtr).getDataSize()==origHeader.getDataSize() )
    566566        {
    567 //           COUT(4) << "diffing object out of order: " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl;
     567//           orxout(verbose, context::packets) << "diffing object out of order: " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl;
    568568          diffObject(destDataPtr, origDataPtr, baseDataPtr, origHeader, sizesIt);
    569569          diffedObject = true;
     
    571571        else
    572572        {
    573 //           COUT(4) << "copy object because of different data sizes (2): " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl;
     573//           orxout(verbose, context::packets) << "copy object because of different data sizes (2): " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl;
    574574          copyObject(destDataPtr, origDataPtr, baseDataPtr, origHeader, sizesIt);
    575575          assert(sizesIt != this->sizes_.end() || origDataPtr==origDataEnd);
     
    578578      else
    579579      {
    580 //         COUT(4) << "copy object: " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl;
     580//         orxout(verbose, context::packets) << "copy object: " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl;
    581581        assert(baseDataPtr == oldBaseDataPtr);
    582582        copyObject(destDataPtr, origDataPtr, baseDataPtr, origHeader, sizesIt);
     
    718718  //copy in the zeros
    719719//   std::list<obj>::iterator itt;
    720 //   COUT(0) << "myvector contains:";
     720//   orxout() << "myvector contains:";
    721721//   for ( itt=dataVector_.begin() ; itt!=dataVector_.end(); itt++ )
    722 //     COUT(0) << " " << (*itt).objID;
    723 //   COUT(0) << endl;
     722//     orxout() << " " << (*itt).objID;
     723//   orxout() << endl;
    724724  for(it=dataVector_.begin(); it!=dataVector_.end();){
    725725    SynchronisableHeader oldobjectheader(origdata);
     
    771771    nrOfVariables += it->getNrOfVariables();
    772772  }
    773 //   COUT(0) << "allocating " << nrOfVariables << " ints" << endl;
     773//   orxout() << "allocating " << nrOfVariables << " ints" << endl;
    774774  this->sizes_.reserve(nrOfVariables);
    775775  return size;
  • code/branches/output/src/libraries/network/packet/Packet.cc

    r8788 r8807  
    192192//     peerID = NETWORK_PEER_ID_SERVER;
    193193  Packet *p = 0;
    194 //   COUT(6) << "packet type: " << *(Type::Value *)&data[_PACKETID] << std::endl;
     194//   orxout(verbose_ultra, context::packets) << "packet type: " << *(Type::Value *)&data[_PACKETID] << endl;
    195195  switch( *(Type::Value *)(data + _PACKETID) )
    196196  {
    197197    case Type::Acknowledgement:
    198 //       COUT(5) << "ack" << std::endl;
     198//       orxout(verbose_more, context::packets) << "ack" << endl;
    199199    p = new Acknowledgement( data, peerID );
    200200      break;
    201201    case Type::Chat:
    202 //       COUT(5) << "chat" << std::endl;
     202//       orxout(verbose_more, context::packets) << "chat" << endl;
    203203      p = new Chat( data, peerID );
    204204      break;
    205205    case Type::ClassID:
    206 //       COUT(5) << "classid" << std::endl;
     206//       orxout(verbose_more, context::packets) << "classid" << endl;
    207207      p = new ClassID( data, peerID );
    208208      break;
    209209    case Type::Gamestate:
    210 //       COUT(5) << "gamestate" << std::endl;
     210//       orxout(verbose_more, context::packets) << "gamestate" << endl;
    211211      p = new Gamestate( data, peerID );
    212212      break;
    213213    case Type::Welcome:
    214 //       COUT(5) << "welcome" << std::endl;
     214//       orxout(verbose_more, context::packets) << "welcome" << endl;
    215215      p = new Welcome( data, peerID );
    216216      break;
    217217    case Type::DeleteObjects:
    218 //       COUT(5) << "deleteobjects" << std::endl;
     218//       orxout(verbose_more, context::packets) << "deleteobjects" << endl;
    219219      p = new DeleteObjects( data, peerID );
    220220      break;
    221221    case Type::FunctionCalls:
    222 //       COUT(5) << "functionCalls" << std::endl;
     222//       orxout(verbose_more, context::packets) << "functionCalls" << endl;
    223223      p = new FunctionCalls( data, peerID );
    224224      break;
    225225    case Type::FunctionIDs:
    226 //       COUT(5) << "functionIDs" << std::endl;
     226//       orxout(verbose_more, context::packets) << "functionIDs" << endl;
    227227      p = new FunctionIDs( data, peerID );
    228228      break;
     
    255255  packetMap_.erase(it);
    256256  Packet::packetMapMutex_.unlock();
    257 //   COUT(6) << "PacketMap size: " << packetMap_.size() << std::endl;
     257//   orxout(verbose_ultra, context::packets) << "PacketMap size: " << packetMap_.size() << endl;
    258258}
    259259
  • code/branches/output/src/libraries/network/packet/Welcome.cc

    r8788 r8807  
    7878  assert(*(uint32_t *)(data_ + _ENDIANTEST ) == 0xFEDC4321);
    7979  host->setClientID(clientID);
    80   COUT(3) << "Welcome set clientId: " << clientID << endl;
     80  orxout(internal_info, context::packets) << "Welcome set clientId: " << clientID << endl;
    8181  Synchronisable::setClient(true);
    8282  delete this;
Note: See TracChangeset for help on using the changeset viewer.