Changeset 1901 for code/branches/network/src/network/Synchronisable.cc
- Timestamp:
- Oct 12, 2008, 12:15:30 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/network/Synchronisable.cc
r1834 r1901 64 64 Synchronisable::Synchronisable(){ 65 65 RegisterRootObject(Synchronisable); 66 static u nsigned int idCounter=0;66 static uint32_t idCounter=0; 67 67 objectFrequency_=1; 68 68 objectMode_=0x1; // by default do not send data to server 69 69 objectID=idCounter++; 70 // COUT(3) << " bump +++" << objectID << " | " << &objectMap_ << std::endl;71 70 syncList = new std::list<synchronisableVariable *>; 72 71 } … … 81 80 for(std::list<synchronisableVariable *>::iterator it = syncList->begin(); it!=syncList->end(); it++) 82 81 delete (*it)->callback; 82 deletedObjects_.push(objectID); 83 // COUT(3) << "destruct synchronisable +++" << objectID << " | " << classID << std::endl; 83 84 // COUT(3) << " bump ---" << objectID << " | " << &objectMap_ << std::endl; 84 85 // assert(objectMap_[objectID]->objectID==objectID); … … 94 95 bool Synchronisable::create(){ 95 96 this->classID = this->getIdentifier()->getNetworkID(); 96 COUT(4) << "creating synchronisable: setting classid from " << this->getIdentifier()->getName() << " to: " << classID << std::endl; 97 97 // COUT(4) << "creating synchronisable: setting classid from " << this->getIdentifier()->getName() << " to: " << classID << std::endl; 98 99 // COUT(3) << "construct synchronisable +++" << objectID << " | " << classID << std::endl; 98 100 // objectMap_[objectID]=this; 99 101 // assert(objectMap_[objectID]==this); … … 121 123 * @return pointer to the newly created synchronisable 122 124 */ 123 Synchronisable *Synchronisable::fabricate(u nsigned char*& mem, int mode)125 Synchronisable *Synchronisable::fabricate(uint8_t*& mem, int mode) 124 126 { 125 127 synchronisableHeader *header = (synchronisableHeader *)mem; 128 129 COUT(3) << "fabricating object with id: " << header->objectID << std::endl; 126 130 127 131 orxonox::Identifier* id = GetIdentifier(header->classID); … … 134 138 COUT(3) << "fabricate objectID: " << no->objectID << " classID: " << no->classID << std::endl; 135 139 // update data and create object/entity... 136 assert(no->updateData(mem, mode)); 137 assert( no->create() ); 140 bool b = no->updateData(mem, mode); 141 assert(b); 142 b = no->create(); 143 assert(b); 138 144 return no; 139 145 } … … 146 152 */ 147 153 bool Synchronisable::deleteObject(unsigned int objectID){ 148 assert(getSynchronisable(objectID)); 154 // assert(getSynchronisable(objectID)); 155 if(!getSynchronisable(objectID)) 156 return false; 149 157 assert(getSynchronisable(objectID)->objectID==objectID); 150 158 // delete objectMap_[objectID]; … … 222 230 * @return true: if !isMyTick or if everything was successfully saved 223 231 */ 224 bool Synchronisable::getData(u nsigned char*& mem, unsigned int id, int mode){232 bool Synchronisable::getData(uint8_t*& mem, unsigned int id, int mode){ 225 233 //if this tick is we dont synchronise, then abort now 226 234 if(!isMyTick(id)) … … 232 240 if(classID==0) 233 241 COUT(3) << "classid 0 " << this->getIdentifier()->getName() << std::endl; 234 this->classID=this->getIdentifier()->getNetworkID(); // TODO: correct this 242 assert(this->classID==this->getIdentifier()->getNetworkID()); 243 // this->classID=this->getIdentifier()->getNetworkID(); // TODO: correct this 235 244 std::list<synchronisableVariable *>::iterator i; 236 245 unsigned int size; … … 283 292 * @return true/false 284 293 */ 285 bool Synchronisable::updateData(u nsigned char*& mem, int mode){294 bool Synchronisable::updateData(uint8_t*& mem, int mode){ 286 295 if(mode==0x0) 287 296 mode=state_; … … 291 300 return false; 292 301 } 293 u nsigned char*data=mem;302 uint8_t *data=mem; 294 303 // start extract header 295 304 synchronisableHeader *syncHeader = (synchronisableHeader *)mem; … … 322 331 break; 323 332 case STRING: 324 (*i)->size = *( int *)mem;333 (*i)->size = *(uint32_t *)mem; 325 334 COUT(5) << "string size: " << (*i)->size << std::endl; 326 335 mem+=sizeof(int); … … 346 355 * @return amount of bytes 347 356 */ 348 int Synchronisable::getSize(unsigned int id, int mode){357 uint32_t Synchronisable::getSize(unsigned int id, int mode){ 349 358 if(!isMyTick(id)) 350 359 return 0; … … 388 397 * @param mem pointer to the bytestream 389 398 */ 390 bool Synchronisable::isMyData(u nsigned char* mem)399 bool Synchronisable::isMyData(uint8_t* mem) 391 400 { 392 401 synchronisableHeader *header = (synchronisableHeader *)mem;
Note: See TracChangeset
for help on using the changeset viewer.