Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 24, 2018, 1:57:50 PM (6 years ago)
Author:
varyo
Message:

Only removed old commented-out code

Location:
code/branches/Masterserver_FS18/src/libraries/network
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/Masterserver_FS18/src/libraries/network/Client.cc

    r11071 r11983  
    166166          }
    167167        }
    168         //assert(gs); <--- there might be the case that no data has to be sent, so its commented out now
    169 //         if(gs){
    170 //           orxout(verbose, context::network) << "client tick: sending gs " << gs << endl;
    171 //           if( !gs->send() )
    172 //             orxout(internal_warning, context::network) << "Problem adding partial gamestate to queue" << endl;
    173 //         // gs gets automatically deleted by enet callback
    174 //         }
     168
    175169        FunctionCallManager::sendCalls(static_cast<Host*>(this));
    176170      }
    177171    }
    178 //     sendPackets(); // flush the enet queue
    179172
    180173    Connection::processQueue();
     
    185178        isSynched_=true;
    186179    }
    187 //     GamestateManager::cleanup();;
    188 //     Connection::sendPackets();
     180
    189181
    190182    return;
  • code/branches/Masterserver_FS18/src/libraries/network/packet/Gamestate.cc

    r11907 r11983  
    4646#define GAMESTATE_START(data) (data + GamestateHeader::getSize())
    4747
    48 // #define PACKET_FLAG_GAMESTATE  PacketFlag::Reliable
    4948#define PACKET_FLAG_GAMESTATE  0
    5049
     
    128127  for(it = ObjectList<Synchronisable>().begin(); it; ++it)
    129128  {
    130 
    131 //     tempsize=it->getSize(id, mode);
    132129
    133130    tempsize = it->getData(mem, this->sizes_, id, mode);
     
    196193      else
    197194      {
    198 //         orxout(verbose, context::packets) << "not creating object of classid " << objectheader.getClassID() << endl;
    199195        mem += objectheader.getDataSize() + ( objectheader.isDiffed() ? SynchronisableHeaderLight::getSize() : SynchronisableHeader::getSize() );
    200196      }
     
    202198    else
    203199    {
    204 //       orxout(verbose, context::packets) << "updating object of classid " << objectheader.getClassID() << endl;
    205200      OrxVerify(s->updateData(mem, mode), "ERROR: could not update Synchronisable with Gamestate data");
    206201    }
     
    339334  if( memcmp( origDataPtr+objectOffset, baseDataPtr+objectOffset, objectHeader.getDataSize()) == 0 )
    340335  {
    341 //     orxout(verbose, context::packets) << "skip object " << Synchronisable::getSynchronisable(objectHeader.getObjectID())->getIdentifier()->getName() << endl;
    342336    origDataPtr += objectOffset + objectHeader.getDataSize(); // skip the whole object
    343337    baseDataPtr += objectOffset + objectHeader.getDataSize();
     
    395389inline void /*Gamestate::*/copyObject( uint8_t*& newData, uint8_t*& origData, uint8_t*& baseData, SynchronisableHeader& objectHeader, std::vector<uint32_t>::iterator& sizes )
    396390{
    397   //       orxout(verbose, context::packets) << "docopy" << endl;
    398391  // Just copy over the whole Object
    399392  memcpy( newData, origData, objectHeader.getDataSize()+SynchronisableHeader::getSize() );
     
    402395  newData += objectHeader.getDataSize()+SynchronisableHeader::getSize();
    403396  origData += objectHeader.getDataSize()+SynchronisableHeader::getSize();
    404 //   SynchronisableHeader baseHeader( baseData );
    405 //   baseData += baseHeader.getDataSize()+SynchronisableHeader::getSize();
    406   //       orxout(verbose, context::packets) << "copy " << h.getObjectID() << endl;
    407   //       orxout(verbose, context::packets) << "copy " << h.getObjectID() << ":";
     397
    408398  sizes += Synchronisable::getSynchronisable(objectHeader.getObjectID())->getNrOfVariables();
    409 //   for( unsigned int i = 0; i < Synchronisable::getSynchronisable(objectHeader.getObjectID())->getNrOfVariables(); ++i )
    410 //   {
    411 //     //         orxout(verbose, context::packets) << " " << *sizes;
    412 //     ++sizes;
    413 //   }
    414     //       orxout(verbose, context::packets) << endl;
     399
    415400}
    416401
     
    466451  uint8_t *origDataEnd = origDataPtr + header_.getDataSize();
    467452  uint8_t *baseDataEnd = baseDataPtr + base->header_.getDataSize();
    468 //   uint32_t origLength = header_.getDataSize();
    469 //   uint32_t baseLength = base->header_.getDataSize();
     453
    470454
    471455  // Allocate new space for diffed gamestate
     
    560544
    561545
    562 /*Gamestate* Gamestate::diffData(Gamestate *base)
    563 {
    564   assert(this && base); assert(data_ && base->data_);
    565   assert(!header_.isCompressed() && !base->header_.isCompressed());
    566   assert(!header_.isDiffed());
    567 
    568   uint8_t *basep = GAMESTATE_START(base->data_);
    569   uint8_t *gs = GAMESTATE_START(this->data_);
    570   uint32_t dest_length = header_.getDataSize();
    571 
    572   if(dest_length==0)
    573     return nullptr;
    574 
    575   uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+GamestateHeader::getSize()];
    576   uint8_t *dest = GAMESTATE_START(ndata);
    577 
    578   rawDiff( dest, gs, basep, header_.getDataSize(), base->header_.getDataSize() );
    579 #ifndef NDEBUG
    580   uint8_t *dest2 = new uint8_t[dest_length];
    581   rawDiff( dest2, dest, basep, header_.getDataSize(), base->header_.getDataSize() );
    582   assert( memcmp( dest2, gs, dest_length) == 0 );
    583   delete dest2;
    584 #endif
    585 
    586   Gamestate *g = new Gamestate(ndata, getClientID());
    587   assert(g->header_);
    588   *(g->header_) = *header_;
    589   g->header_.setDiffed( true );
    590   g->header_.setBaseID( base->getID() );
    591   g->flags_=flags_;
    592   g->packetDirection_ = packetDirection_;
    593   assert(g->isDiffed());
    594   assert(!g->isCompressed());
    595   return g;
    596 }
    597 
    598 
    599 Gamestate* Gamestate::undiff(Gamestate *base)
    600 {
    601   assert(this && base); assert(data_ && base->data_);
    602   assert(!header_.isCompressed() && !base->header_.isCompressed());
    603   assert(header_.isDiffed());
    604 
    605   uint8_t *basep = GAMESTATE_START(base->data_);
    606   uint8_t *gs = GAMESTATE_START(this->data_);
    607   uint32_t dest_length = header_.getDataSize();
    608 
    609   if(dest_length==0)
    610     return nullptr;
    611 
    612   uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+GamestateHeader::getSize()];
    613   uint8_t *dest = ndata + GamestateHeader::getSize();
    614 
    615   rawDiff( dest, gs, basep, header_.getDataSize(), base->header_.getDataSize() );
    616 
    617   Gamestate *g = new Gamestate(ndata, getClientID());
    618   assert(g->header_);
    619   *(g->header_) = *header_;
    620   g->header_.setDiffed( false );
    621   g->flags_=flags_;
    622   g->packetDirection_ = packetDirection_;
    623   assert(!g->isDiffed());
    624   assert(!g->isCompressed());
    625   return g;
    626 }
    627 
    628 
    629 void Gamestate::rawDiff( uint8_t* newdata, uint8_t* data, uint8_t* basedata, uint32_t datalength, uint32_t baselength)
    630 {
    631   uint64_t* gd = (uint64_t*)data;
    632   uint64_t* bd = (uint64_t*)basedata;
    633   uint64_t* nd = (uint64_t*)newdata;
    634 
    635   unsigned int i;
    636   for( i=0; i<datalength/8; i++ )
    637   {
    638     if( i<baselength/8 )
    639       *(nd+i) = *(gd+i) ^ *(bd+i);  // xor the data
    640     else
    641       *(nd+i) = *(gd+i); // just copy over the data
    642   }
    643   unsigned int j;
    644   // now process the rest (when datalength isn't a multiple of 4)
    645   for( j = 8*(datalength/8); j<datalength; j++ )
    646   {
    647     if( j<baselength )
    648       *(newdata+j) = *(data+j) ^ *(basedata+j); // xor
    649     else
    650       *(newdata+j) = *(data+j); // just copy
    651   }
    652   assert(j==datalength);
    653 }*/
    654 
    655 
    656 /*Gamestate* Gamestate::doSelection(unsigned int clientID, unsigned int targetSize){
    657   assert(data_);
    658   std::list<obj>::iterator it;
    659 
    660   // allocate memory for new data
    661   uint8_t *gdata = new uint8_t[header_.getDataSize()+GamestateHeader::getSize()];
    662   // create a gamestate out of it
    663   Gamestate *gs = new Gamestate(gdata);
    664   uint8_t *newdata = gdata + GamestateHeader::getSize();
    665   uint8_t *origdata = GAMESTATE_START(data_);
    666 
    667   //copy the GamestateHeader
    668   assert(gs->header_);
    669   *(gs->header_) = *header_;
    670 
    671   uint32_t objectOffset;
    672   unsigned int objectsize, destsize=0;
    673   // TODO: Why is this variable not used?
    674   //Synchronisable *object;
    675 
    676   //call TrafficControl
    677   TrafficControl::getInstance()->processObjectList( clientID, header_.getID(), dataVector_ );
    678 
    679   //copy in the zeros
    680 //   std::list<obj>::iterator itt;
    681 //   orxout() << "myvector contains:";
    682 //   for ( itt=dataVector_.begin() ; itt!=dataVector_.end(); itt++ )
    683 //     orxout() << " " << (*itt).objID;
    684 //   orxout() << endl;
    685   for(it=dataVector_.begin(); it!=dataVector_.end();){
    686     SynchronisableHeader oldobjectheader(origdata);
    687     SynchronisableHeader newobjectheader(newdata);
    688     if ( (*it).objSize == 0 )
    689     {
    690       ++it;
    691       continue;
    692     }
    693     objectsize = oldobjectheader.getDataSize()+SynchronisableHeader::getSize();
    694     objectOffset=SynchronisableHeader::getSize(); //skip the size and the availableData variables in the objectheader
    695     if ( (*it).objID == oldobjectheader.getObjectID() ){
    696       memcpy(newdata, origdata, objectsize);
    697       ++it;
    698     }else{
    699       newobjectheader = oldobjectheader;
    700       memset(newdata+objectOffset, 0, objectsize-objectOffset);
    701     }
    702     newdata += objectsize;
    703     origdata += objectsize;
    704     destsize += objectsize;
    705   }
    706 #ifndef NDEBUG
    707   uint32_t origsize = destsize;
    708   while ( origsize < header_.getDataSize() )
    709   {
    710     SynchronisableHeader oldobjectheader(origdata);
    711     objectsize = oldobjectheader.getDataSize()+SynchronisableHeader::getSize();
    712     origdata += objectsize;
    713     origsize += objectsize;
    714   }
    715   assert(origsize==header_.getDataSize());
    716   assert(destsize!=0);
    717 #endif
    718   gs->header_.setDataSize( destsize );
    719   return gs;
    720 }*/
    721 
    722 
    723546uint32_t Gamestate::calcGamestateSize(uint32_t id, uint8_t mode)
    724547{
  • code/branches/Masterserver_FS18/src/libraries/network/packet/Gamestate.h

    r11071 r11983  
    5757    GamestateHeader(uint8_t* data)
    5858      { assert(data); data_ = data; *(Type*)data_ = Type::Gamestate; }
    59     /*GamestateHeader(uint8_t* data, GamestateHeader* h)
    60       { assert(data); data_=data; memcpy(data_, h->data_, getSize()); }*/
    6159    void setData(uint8_t* data)
    6260      { assert(data); data_ = data; *(Type*)data_ = Type::Gamestate; }
     
    127125    inline uint32_t getDataSize() const { return header_.getDataSize(); }
    128126    Gamestate* diffVariables(Gamestate *base);
    129 //     Gamestate* diffData(Gamestate *base);
    130 //     Gamestate *undiff(Gamestate *base);
    131 //     Gamestate* doSelection(unsigned int clientID, unsigned int targetSize);
     127
    132128    bool compressData();
    133129    bool decompressData();
     
    136132    // Packet functions
    137133  private:
    138 //     void rawDiff( uint8_t* newdata, uint8_t* data, uint8_t* basedata, uint32_t datalength, uint32_t baselength);
    139 //     inline uint32_t findObject( const SynchronisableHeader& header, uint8_t* mem, uint32_t dataLength, uint32_t startPosition = 0 );
     134
    140135    virtual uint32_t getSize() const override;
    141136    virtual bool process(orxonox::Host* host) override;
    142137    uint32_t calcGamestateSize(uint32_t id, uint8_t mode=0x0);
    143 //     inline void diffObject( uint8_t*& newData, uint8_t*& origData, uint8_t*& baseData, SynchronisableHeader& objectHeader, std::vector<uint32_t>::iterator& sizes );
    144 //     inline void copyObject( uint8_t*& newData, uint8_t*& origData, uint8_t*& baseData, SynchronisableHeader& objectHeader, std::vector<uint32_t>::iterator& sizes );
    145    
     138   
    146139    std::list<obj>          dataVector_;
    147140    GamestateHeader         header_;
  • code/branches/Masterserver_FS18/src/libraries/network/synchronisable/Synchronisable.cc

    r11907 r11983  
    4343  std::queue<uint32_t> Synchronisable::deletedObjects_;
    4444
    45   uint8_t Synchronisable::state_=0x1; // detemines wheter we are server (default) or client
     45  uint8_t Synchronisable::state_=0x1; // determines wheter we are server (default) or client
    4646
    4747  RegisterAbstractClass(Synchronisable).inheritsFrom<OrxonoxInterface>();
     
    179179    assert( Synchronisable::objectMap_.find(header.getObjectID()) == Synchronisable::objectMap_.end() );
    180180    no->setObjectID(header.getObjectID());
    181     //no->contextID=header.getContextID(); //TODO: remove this
    182181    no->setClassID(header.getClassID());
    183182    assert(no->contextID_ == header.getContextID());
    184     //assert(no->classID_ == header.getClassID());
    185183    orxout(verbose, context::network) << "fabricate objectID_: " << no->objectID_ << " classID_: " << no->classID_ << endl;
    186184          // update data and create object/entity...
     
    189187    if (b)
    190188    {
    191 //        b = no->create();
    192189        assert(b);
    193190    }
     
    273270
    274271    orxout(verbose_more, context::network) << "getting data from objectID_: " << objectID_ << ", classID_: " << classID_ << endl;
    275 //     orxout(verbose, context::network) << "objectid: " << this->objectID_ << ":";
    276272    // copy to location
    277273    for(SynchronisableVariableBase* variable : syncList_)
    278274    {
    279275      uint32_t varsize = variable->getData( mem, mode );
    280 //       orxout(verbose, context::network) << " " << varsize;
    281276      tempsize += varsize;
    282277      sizes.push_back(varsize);
    283278      ++test;
    284       //tempsize += (*i)->getSize( mode );
    285279    }
    286280    assert(tempsize!=0);  // if this happens an empty object (with no variables) would be transmitted
    287 //     orxout(verbose, context::network) << endl;
    288281
    289282    header.setObjectID( this->objectID_ );
     
    340333    }
    341334
    342     //orxout(verbose_more, context::network) << "Synchronisable: objectID_ " << syncHeader.getObjectID() << ", classID_ " << syncHeader.getClassID() << " size: " << syncHeader.getDataSize() << " synchronising data" << endl;
    343335    if( !syncHeaderLight.isDiffed() )
    344336    {
     
    357349    {
    358350      mem += SynchronisableHeaderLight::getSize();
    359 //       orxout(debug_output, context::network) << "objectID: " << this->objectID_ << endl;
    360351      while( mem < data+syncHeaderLight.getDataSize()+SynchronisableHeaderLight::getSize() )
    361352      {
    362353        VariableID varID = *(VariableID*)mem;
    363 //         orxout(debug_output, context::network) << "varID: " << varID << endl;
    364354        assert( varID < syncList_.size() );
    365355        mem += sizeof(VariableID);
     
    400390  bool Synchronisable::doSync(/*int32_t id,*/ uint8_t mode)
    401391  {
    402 //     if(mode==0x0)
    403 //       mode=state_;
    404392    assert(mode!=0x0);
    405393    return ( (this->objectMode_ & mode)!=0 && (!syncList_.empty() ) );
  • code/branches/Masterserver_FS18/src/libraries/network/synchronisable/Synchronisable.h

    r11071 r11983  
    134134        { memcpy(data_, h.data_, getSize()); }
    135135  };
    136  
    137 //   inline void operator=(SynchronisableHeaderLight& h1, SynchronisableHeader& h2)
    138 //   {
    139 //     memcpy(h1.data_, h2.data_, h1.getSize());
    140 //   }
    141136
    142137  /**
Note: See TracChangeset for help on using the changeset viewer.