Changeset 1903
- Timestamp:
- Oct 12, 2008, 1:46:31 PM (16 years ago)
- Location:
- code/branches/network/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/network/packet/Gamestate.cc
r1901 r1903 340 340 std::map<unsigned int, Synchronisable *>::iterator it; 341 341 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; 345 353 unsigned int objectOffset; 346 354 347 355 //copy in the zeros 348 356 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; 352 362 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 354 365 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 357 373 objectOffset++; 358 374 } 359 375 assert(objectOffset==objectsize); 360 376 } 361 ndata+=objectsize; 377 newdata += objectsize; 378 origdata += objectsize; 362 379 } 363 380 return gs; -
code/branches/network/src/orxonox/gamestates/GSServer.cc
r1902 r1903 78 78 79 79 // TODO: Remove and destroy console command 80 Settings::_getInstance().bHasServer_ = false;81 80 82 81 this->unloadLevel(); … … 84 83 this->server_->close(); 85 84 delete this->server_; 85 Settings::_getInstance().bHasServer_ = false; 86 86 87 87 GSLevel::leave();
Note: See TracChangeset
for help on using the changeset viewer.