Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1903 for code


Ignore:
Timestamp:
Oct 12, 2008, 1:46:31 PM (16 years ago)
Author:
scheusso
Message:

improved (clientbased) diffing for Gamestates

Location:
code/branches/network/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network/src/network/packet/Gamestate.cc

    r1901 r1903  
    340340  std::map<unsigned int, Synchronisable *>::iterator it;
    341341 
    342   Gamestate *gs = new Gamestate(*this);
    343   uint8_t *ndata = gs->data_ + sizeof(GamestateHeader);
    344   synchronisableHeader *objectheader;
     342  // allocate memory for new data
     343  uint8_t *gdata = new uint8_t[HEADER->datasize+sizeof(GamestateHeader)];
     344  // create a gamestate out of it
     345  Gamestate *gs = new Gamestate(gdata);
     346  uint8_t *newdata = gdata + sizeof(GamestateHeader);
     347  uint8_t *origdata = GAMESTATE_START(data_);
     348 
     349  //copy the GamestateHeader
     350  *(GamestateHeader*)gdata = *HEADER;
     351 
     352  synchronisableHeader *oldobjectheader, *newobjectheader;
    345353  unsigned int objectOffset;
    346354 
    347355  //copy in the zeros
    348356  for(it=dataMap_.begin(); it!=dataMap_.end(); it++){
    349     objectheader = (synchronisableHeader*)ndata;
    350     unsigned int objectsize = objectheader->size;
    351     assert(it->second->objectID==objectheader->objectID);
     357    oldobjectheader = (synchronisableHeader*)origdata;
     358    newobjectheader = (synchronisableHeader*)newdata;
     359    unsigned int objectsize = oldobjectheader->size;
     360    assert(it->second->objectID==oldobjectheader->objectID);
     361    *newobjectheader = *oldobjectheader;
    352362    objectOffset=sizeof(uint8_t)+sizeof(bool); //skip the size and the availableDate variables in the objectheader
    353     if(!it->second->doSelection(HEADER->id)){
     363    if(it->second->doSelection(HEADER->id)){
     364      newobjectheader->dataAvailable=true; //TODO: probably not neccessary
    354365      while(objectOffset<objectsize){
    355         objectheader->dataAvailable=false;
    356         *(ndata+objectOffset)=0;    // set to 0
     366        *(newdata + objectOffset)=*(origdata + objectOffset);    // copy the data
     367        objectOffset++;
     368      }
     369    }else{
     370      newobjectheader->dataAvailable=false;
     371      while(objectOffset<objectsize){
     372        *(newdata+objectOffset)=0;    // set to 0
    357373        objectOffset++;
    358374      }
    359375      assert(objectOffset==objectsize);
    360376    }
    361     ndata+=objectsize;
     377    newdata += objectsize;
     378    origdata += objectsize;
    362379  }
    363380  return gs;
  • code/branches/network/src/orxonox/gamestates/GSServer.cc

    r1902 r1903  
    7878
    7979        // TODO: Remove and destroy console command
    80         Settings::_getInstance().bHasServer_ = false;
    8180
    8281        this->unloadLevel();
     
    8483        this->server_->close();
    8584        delete this->server_;
     85        Settings::_getInstance().bHasServer_ = false;
    8686
    8787        GSLevel::leave();
Note: See TracChangeset for help on using the changeset viewer.