Changeset 1856 for code/trunk/src/network/Synchronisable.cc
- Timestamp:
- Sep 29, 2008, 4:15:03 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/network/Synchronisable.cc
r1837 r1856 83 83 } 84 84 85 85 86 86 void Synchronisable::setClient(bool b){ 87 87 if(b) // client … … 90 90 state_=0x1; 91 91 } 92 92 93 93 bool Synchronisable::fabricate(unsigned char*& mem, int mode) 94 94 { … … 97 97 objectID = *(unsigned int*)(mem+sizeof(unsigned int)); 98 98 classID = *(unsigned int*)(mem+2*sizeof(unsigned int)); 99 99 100 100 if(size==3*sizeof(unsigned int)){ //not our turn, dont do anything 101 101 mem+=3*sizeof(unsigned int); 102 102 return true; 103 103 } 104 105 orxonox::Identifier* id = GetIdentifier(classID);104 105 orxonox::Identifier* id = ClassByID(classID); 106 106 if(!id){ 107 107 COUT(3) << "We could not identify a new object; classid: " << classID << " uint: " << (unsigned int)classID << " objectID: " << objectID << " size: " << size << std::endl; … … 149 149 syncList->push_back(temp); 150 150 } 151 151 152 152 /** 153 153 * This function takes all SynchronisableVariables out of the Synchronisable and saves it into a syncData struct … … 171 171 unsigned int size; 172 172 size=getSize2(id, mode); 173 173 174 174 // start copy header 175 175 memcpy(mem, &size, sizeof(unsigned int)); … … 181 181 tempsize+=12; 182 182 // end copy header 183 183 184 184 //if this tick is we dont synchronise, then abort now 185 185 if(!isMyTick(id)) 186 186 return true; 187 187 188 188 COUT(5) << "Synchronisable getting data from objectID: " << objectID << " classID: " << classID << " length: " << size << std::endl; 189 189 // copy to location … … 215 215 } 216 216 217 217 218 218 /** 219 219 * This function takes a syncData struct and takes it to update the variables … … 230 230 return false; 231 231 } 232 232 233 233 // start extract header 234 234 unsigned int objectID, classID, size; … … 245 245 return true; 246 246 //assert(0); 247 247 248 248 COUT(5) << "Synchronisable: objectID " << objectID << ", classID " << classID << " size: " << size << " synchronising data" << std::endl; 249 249 for(i=syncList->begin(); i!=syncList->end() && mem <= data+size; i++){ … … 317 317 return sizeof(synchronisableHeader) + getSize( id, mode ); 318 318 } 319 320 /** 321 * 322 * @param id 323 * @return 319 320 /** 321 * 322 * @param id 323 * @return 324 324 */ 325 325 bool Synchronisable::isMyTick(unsigned int id){ … … 327 327 return ( id==0 || id%objectFrequency_==objectID%objectFrequency_ ) && ((objectMode_&state_)!=0); 328 328 } 329 329 330 330 bool Synchronisable::isMyData(unsigned char* mem) 331 331 { … … 337 337 classID = *(int *)mem; 338 338 mem+=sizeof(classID); 339 339 340 340 assert(classID == this->classID); 341 341 return (objectID == this->objectID); 342 342 } 343 343 344 344 void Synchronisable::setObjectMode(int mode){ 345 345 assert(mode==0x1 || mode==0x2 || mode==0x3);
Note: See TracChangeset
for help on using the changeset viewer.