- Timestamp:
- Nov 4, 2008, 5:12:31 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/network/packet/Gamestate.cc
r2112 r2132 71 71 } 72 72 73 bool Gamestate::collectData(int id, int mode)74 { 75 int tempsize=0, currentsize=0;73 bool Gamestate::collectData(int id, uint8_t mode) 74 { 75 unsigned int tempsize=0, currentsize=0; 76 76 assert(data_==0); 77 int size = calcGamestateSize(id, mode);77 unsigned int size = calcGamestateSize(id, mode); 78 78 79 79 COUT(4) << "G.ST.Man: producing gamestate with id: " << id << std::endl; … … 86 86 } 87 87 88 #ifndef NDEBUG89 std::list<Synchronisable*> slist;90 std::list<Synchronisable*>::iterator iit;91 #endif92 88 //start collect data synchronisable by synchronisable 93 89 uint8_t *mem=data_; … … 98 94 99 95 if(currentsize+tempsize > size){ 96 assert(0); // if we don't use multithreading this part shouldn't be neccessary 100 97 // start allocate additional memory 101 98 COUT(3) << "G.St.Man: need additional memory" << std::endl; … … 110 107 }// stop allocate additional memory 111 108 112 #ifndef NDEBUG113 for(iit=slist.begin(); iit!=slist.end(); iit++)114 assert((*iit)!=*it);115 slist.push_back(*it);116 #endif117 109 118 110 //if(it->doSelection(id)) … … 127 119 //start write gamestate header 128 120 HEADER->packetType = ENUM::Gamestate; 129 assert( *(ENUM::Type *)(data_) == ENUM::Gamestate);130 121 HEADER->datasize = currentsize; 131 122 HEADER->id = id; … … 140 131 } 141 132 142 bool Gamestate::spreadData( int mode)133 bool Gamestate::spreadData(uint8_t mode) 143 134 { 144 135 assert(data_); … … 163 154 bool b = s->updateData(mem, mode); 164 155 assert(b); 165 //if(!s->updateData(mem, mode))166 //return false;167 156 } 168 157 } … … 367 356 assert(it->second->objectID==oldobjectheader->objectID); 368 357 *newobjectheader = *oldobjectheader; 369 objectOffset=sizeof( uint8_t)+sizeof(bool); //skip the size and the availableData variables in the objectheader358 objectOffset=sizeof(synchronisableHeader); //skip the size and the availableData variables in the objectheader 370 359 if(it->second->doSelection(HEADER->id)){ 371 360 newobjectheader->dataAvailable=true; //TODO: probably not neccessary … … 565 554 566 555 567 unsigned int Gamestate::calcGamestateSize(unsigned int id, int mode)568 { 569 int size=0;556 unsigned int Gamestate::calcGamestateSize(unsigned int id, uint8_t mode) 557 { 558 unsigned int size=0; 570 559 // get the start of the Synchronisable list 571 560 ObjectList<Synchronisable>::iterator it;
Note: See TracChangeset
for help on using the changeset viewer.