Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 26, 2009, 9:20:57 PM (15 years ago)
Author:
landauf
Message:

merged netp3 branch back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/network/synchronisable/Synchronisable.cc

    r3068 r3084  
    6666      objectID=OBJECTID_UNKNOWN;
    6767    classID = static_cast<uint32_t>(-1);
    68 
     68   
     69    // set dataSize to 0
     70    this->dataSize_ = 0;
    6971    // set standard priority
    7072    this->setPriority( priority::normal );
     
    9698    // delete callback function objects
    9799    if(!Identifier::isCreatingHierarchy()){
    98       for(std::list<SynchronisableVariableBase*>::iterator it = syncList.begin(); it!=syncList.end(); it++)
     100      for(std::vector<SynchronisableVariableBase*>::iterator it = syncList.begin(); it!=syncList.end(); it++)
    99101        delete (*it);
    100102      if (this->objectMode_ != 0x0 && (Host::running() && Host::isServer()))
     
    236238   * @return true: if !doSync or if everything was successfully saved
    237239   */
    238   bool Synchronisable::getData(uint8_t*& mem, int32_t id, uint8_t mode){
     240  uint32_t Synchronisable::getData(uint8_t*& mem, int32_t id, uint8_t mode){
    239241    if(mode==0x0)
    240242      mode=state_;
    241243    //if this tick is we dont synchronise, then abort now
    242244    if(!doSync(id, mode))
    243       return true;
     245      return 0;
    244246    uint32_t tempsize = 0;
    245247    if (this->classID==0)
     
    250252
    251253    assert(this->classID==this->getIdentifier()->getNetworkID());
    252     std::list<SynchronisableVariableBase*>::iterator i;
    253     uint32_t size;
    254     size=getSize(id, mode);
     254    std::vector<SynchronisableVariableBase*>::iterator i;
    255255
    256256    // start copy header
    257257    SynchronisableHeader header(mem);
    258     header.setDataSize( size );
     258    mem += SynchronisableHeader::getSize();
     259    // end copy header
     260
     261
     262    COUT(5) << "Synchronisable getting data from objectID: " << objectID << " classID: " << classID << std::endl;
     263    // copy to location
     264    for(i=syncList.begin(); i!=syncList.end(); ++i){
     265      tempsize += (*i)->getData( mem, mode );
     266      //tempsize += (*i)->getSize( mode );
     267    }
     268   
     269    tempsize += SynchronisableHeader::getSize();
    259270    header.setObjectID( this->objectID );
    260271    header.setCreatorID( this->creatorID );
    261272    header.setClassID( this->classID );
    262273    header.setDataAvailable( true );
    263     tempsize += SynchronisableHeader::getSize();
    264     mem += SynchronisableHeader::getSize();
    265     // end copy header
    266 
    267 
    268     COUT(5) << "Synchronisable getting data from objectID: " << objectID << " classID: " << classID << " length: " << size << std::endl;
    269     // copy to location
    270     for(i=syncList.begin(); i!=syncList.end(); ++i){
    271       (*i)->getData( mem, mode );
    272       tempsize += (*i)->getSize( mode );
    273     }
     274    header.setDataSize( tempsize );
     275   
     276#ifndef NDEBUG
     277    uint32_t size;
     278    size=getSize(id, mode);
    274279    assert(tempsize==size);
    275     return true;
     280#endif
     281    return tempsize;
    276282  }
    277283
     
    286292    if(mode==0x0)
    287293      mode=state_;
    288     std::list<SynchronisableVariableBase *>::iterator i;
     294    std::vector<SynchronisableVariableBase *>::iterator i;
    289295    if(syncList.empty()){
    290296      assert(0);
     
    325331  uint32_t Synchronisable::getSize(int32_t id, uint8_t mode){
    326332    int tsize=SynchronisableHeader::getSize();
    327     if(mode==0x0)
     333    if (mode==0x0)
    328334      mode=state_;
    329     if(!doSync(id, mode))
     335    if (!doSync(id, mode))
    330336      return 0;
    331     std::list<SynchronisableVariableBase*>::iterator i;
    332     for(i=syncList.begin(); i!=syncList.end(); i++){
     337    assert( mode==state_ );
     338    tsize += this->dataSize_;
     339    std::vector<SynchronisableVariableBase*>::iterator i;
     340    for(i=stringList.begin(); i!=stringList.end(); ++i){
    333341      tsize += (*i)->getSize( mode );
    334342    }
Note: See TracChangeset for help on using the changeset viewer.