Changeset 2309 for code/branches/network64/src/network/packet
- Timestamp:
- Dec 2, 2008, 9:10:00 PM (16 years ago)
- Location:
- code/branches/network64/src/network/packet
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network64/src/network/packet/Gamestate.cc
r2171 r2309 73 73 bool Gamestate::collectData(int id, uint8_t mode) 74 74 { 75 u nsigned int tempsize=0, currentsize=0;75 uint32_t tempsize=0, currentsize=0; 76 76 assert(data_==0); 77 u nsigned int size = calcGamestateSize(id, mode);77 uint32_t size = calcGamestateSize(id, mode); 78 78 79 79 COUT(4) << "G.ST.Man: producing gamestate with id: " << id << std::endl; … … 166 166 } 167 167 168 u nsigned int Gamestate::getSize() const168 uint32_t Gamestate::getSize() const 169 169 { 170 170 assert(data_); … … 251 251 assert(HEADER->compressed); 252 252 COUT(4) << "GameStateClient: uncompressing gamestate. id: " << HEADER->id << ", baseid: " << HEADER->base_id << ", datasize: " << HEADER->datasize << ", compsize: " << HEADER->compsize << std::endl; 253 u nsigned int datasize = HEADER->datasize;254 u nsigned int compsize = HEADER->compsize;255 u nsigned int bufsize;253 uint32_t datasize = HEADER->datasize; 254 uint32_t compsize = HEADER->compsize; 255 uint32_t bufsize; 256 256 // assert(compsize<=datasize); 257 257 bufsize = datasize; … … 302 302 //unsigned char *basep = base->getGs()/*, *gs = getGs()*/; 303 303 uint8_t *basep = GAMESTATE_START(base->data_), *gs = GAMESTATE_START(this->data_); 304 u nsigned int of=0; // pointers offset305 u nsigned int dest_length=0;304 uint32_t of=0; // pointers offset 305 uint32_t dest_length=0; 306 306 dest_length=HEADER->datasize; 307 307 if(dest_length==0) … … 334 334 Gamestate* Gamestate::doSelection(unsigned int clientID){ 335 335 assert(data_); 336 std::map<u nsigned int, Synchronisable *>::iterator it;336 std::map<uint32_t, Synchronisable *>::iterator it; 337 337 338 338 // allocate memory for new data … … 347 347 348 348 synchronisableHeader *oldobjectheader, *newobjectheader; 349 u nsigned int objectOffset;349 uint32_t objectOffset; 350 350 351 351 //copy in the zeros … … 353 353 oldobjectheader = (synchronisableHeader*)origdata; 354 354 newobjectheader = (synchronisableHeader*)newdata; 355 u nsigned int objectsize = oldobjectheader->size;355 uint32_t objectsize = oldobjectheader->size; 356 356 assert(it->second->objectID==oldobjectheader->objectID); 357 357 *newobjectheader = *oldobjectheader; … … 382 382 383 383 //preparations 384 std::map<u nsigned int, Synchronisable *>::iterator it;384 std::map<uint32_t, Synchronisable *>::iterator it; 385 385 uint8_t *origdata, *basedata, *destdata, *ndata; 386 u nsigned int objectOffset, streamOffset=0; //data offset387 u nsigned int minsize = (HEADER->datasize < GAMESTATE_HEADER(base->data_)->datasize) ? HEADER->datasize : GAMESTATE_HEADER(base->data_)->datasize;386 uint32_t objectOffset, streamOffset=0; //data offset 387 uint32_t minsize = (HEADER->datasize < GAMESTATE_HEADER(base->data_)->datasize) ? HEADER->datasize : GAMESTATE_HEADER(base->data_)->datasize; 388 388 synchronisableHeader *origheader; 389 389 synchronisableHeader *destheader; … … 402 402 403 403 //copy and partially diff the object header 404 assert(sizeof(synchronisableHeader)==3*sizeof(u nsigned int)+sizeof(bool));404 assert(sizeof(synchronisableHeader)==3*sizeof(uint32_t)+sizeof(bool)); 405 405 *(uint32_t*)destdata = *(uint32_t*)origdata; //size (do not diff) 406 406 *(bool*)(destdata+sizeof(uint32_t)) = sendData; … … 450 450 451 451 //preparations 452 std::map<u nsigned int, Synchronisable *>::iterator it;452 std::map<uint32_t, Synchronisable *>::iterator it; 453 453 uint8_t *origdata, *basedata, *destdata, *ndata; 454 u nsigned int objectOffset, streamOffset=0; //data offset455 u nsigned int minsize = (HEADER->datasize < GAMESTATE_HEADER(base->data_)->datasize) ? HEADER->datasize : GAMESTATE_HEADER(base->data_)->datasize;454 uint32_t objectOffset, streamOffset=0; //data offset 455 uint32_t minsize = (HEADER->datasize < GAMESTATE_HEADER(base->data_)->datasize) ? HEADER->datasize : GAMESTATE_HEADER(base->data_)->datasize; 456 456 synchronisableHeader *origheader; 457 457 synchronisableHeader *destheader; … … 470 470 471 471 //copy and partially diff the object header 472 assert(sizeof(synchronisableHeader)==3*sizeof(u nsigned int)+sizeof(bool));473 *(u nsigned int*)destdata = *(unsigned int*)origdata; //size (do not diff)474 *(bool*)(destdata+sizeof(u nsigned int)) = *(bool*)(origdata+sizeof(unsigned int));475 sendData = *(bool*)(origdata+sizeof(u nsigned int));472 assert(sizeof(synchronisableHeader)==3*sizeof(uint32_t)+sizeof(bool)); 473 *(uint32_t*)destdata = *(uint32_t*)origdata; //size (do not diff) 474 *(bool*)(destdata+sizeof(uint32_t)) = *(bool*)(origdata+sizeof(uint32_t)); 475 sendData = *(bool*)(origdata+sizeof(uint32_t)); 476 476 if(sendData){ 477 *(u nsigned int*)(destdata+sizeof(unsigned int)+sizeof(bool)) = *(unsigned int*)(basedata+sizeof(unsigned int)+sizeof(bool)) ^ *(unsigned int*)(origdata+sizeof(unsigned int)+sizeof(bool)); //objectid (diff it)478 *(u nsigned int*)(destdata+2*sizeof(unsigned int)+sizeof(bool)) = *(unsigned int*)(basedata+2*sizeof(unsigned int)+sizeof(bool)) ^ *(unsigned int*)(origdata+2*sizeof(unsigned int)+sizeof(bool)); //classid (diff it)477 *(uint32_t*)(destdata+sizeof(uint32_t)+sizeof(bool)) = *(uint32_t*)(basedata+sizeof(uint32_t)+sizeof(bool)) ^ *(uint32_t*)(origdata+sizeof(uint32_t)+sizeof(bool)); //objectid (diff it) 478 *(uint32_t*)(destdata+2*sizeof(uint32_t)+sizeof(bool)) = *(uint32_t*)(basedata+2*sizeof(uint32_t)+sizeof(bool)) ^ *(uint32_t*)(origdata+2*sizeof(uint32_t)+sizeof(bool)); //classid (diff it) 479 479 }else{ 480 *(u nsigned int*)(destdata+sizeof(unsigned int)+sizeof(bool)) = 0;481 *(u nsigned int*)(destdata+2*sizeof(unsigned int)+sizeof(bool)) = 0;480 *(uint32_t*)(destdata+sizeof(uint32_t)+sizeof(bool)) = 0; 481 *(uint32_t*)(destdata+2*sizeof(uint32_t)+sizeof(bool)) = 0; 482 482 } 483 483 objectOffset=sizeof(synchronisableHeader); … … 517 517 uint8_t *basep = GAMESTATE_START(base->data_); 518 518 uint8_t *gs = GAMESTATE_START(this->data_); 519 u nsigned int of=0; // pointers offset520 u nsigned int dest_length=0;519 uint32_t of=0; // pointers offset 520 uint32_t dest_length=0; 521 521 dest_length=HEADER->datasize; 522 522 if(dest_length==0) … … 548 548 549 549 550 u nsigned int Gamestate::calcGamestateSize(unsigned int id, uint8_t mode)551 { 552 u nsigned int size=0;550 uint32_t Gamestate::calcGamestateSize(int32_t id, uint8_t mode) 551 { 552 uint32_t size=0; 553 553 // get the start of the Synchronisable list 554 554 ObjectList<Synchronisable>::iterator it; -
code/branches/network64/src/network/packet/Gamestate.h
r2211 r2309 85 85 // Packet functions 86 86 private: 87 virtual u nsigned int getSize() const;87 virtual uint32_t getSize() const; 88 88 virtual bool process(); 89 89 90 90 bool operator ==(packet::Gamestate gs); 91 91 private: 92 u nsigned int calcGamestateSize(unsigned int id, uint8_t mode=0x0);92 uint32_t calcGamestateSize(int32_t id, uint8_t mode=0x0); 93 93 void removeObject(ObjectListIterator<Synchronisable> &it); 94 std::map<u nsigned int, Synchronisable*> dataMap_;94 std::map<uint32_t, Synchronisable*> dataMap_; 95 95 }; 96 96
Note: See TracChangeset
for help on using the changeset viewer.