Changeset 2153 for code/branches/objecthierarchy/src
- Timestamp:
- Nov 7, 2008, 10:50:51 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/network/Synchronisable.cc
r2144 r2153 70 70 objectMode_=0x1; // by default do not send data to server 71 71 if(Host::running() && Host::isServer()) 72 objectID=idCounter++; //this is only needed when running a server 72 { 73 this->objectID = idCounter++; //this is only needed when running a server 74 //add synchronisable to the objectMap 75 objectMap_[this->objectID] = this; 76 } 73 77 else 74 78 objectID=OBJECTID_UNKNOWN; 75 79 classID = (unsigned int)-1; 76 80 syncList = new std::list<synchronisableVariable *>; 81 77 82 78 83 #ifndef NDEBUG … … 118 123 // objectMap_.erase(objectID); 119 124 } 125 std::map<unsigned int, Synchronisable*>::iterator it; 126 it = objectMap_.find(objectID); 127 if (it != objectMap_.end()) 128 objectMap_.erase(it); 120 129 } 121 130 … … 227 236 */ 228 237 Synchronisable* Synchronisable::getSynchronisable(unsigned int objectID){ 238 std::map<unsigned int, Synchronisable*>::iterator it1; 239 it1 = objectMap_.find(objectID); 240 if (it1 != objectMap_.end()) 241 return it1->second; 242 229 243 ObjectList<Synchronisable>::iterator it; 230 244 for(it = ObjectList<Synchronisable>::begin(); it; ++it){ 231 if( it->getObjectID()==objectID ) 232 return *it; 245 if( it->getObjectID()==objectID ){ 246 objectMap_[objectID] = *it; 247 return *it; 248 } 233 249 } 234 250 return NULL; 235 236 // std::map<unsigned int, Synchronisable *>::iterator i = objectMap_.find(objectID);237 // if(i==objectMap_.end())238 // return NULL;239 // assert(i->second->objectID==objectID);240 // return (*i).second;241 251 } 242 252
Note: See TracChangeset
for help on using the changeset viewer.