Changeset 1087 for code/branches/network
- Timestamp:
- Apr 17, 2008, 1:06:49 PM (17 years ago)
- Location:
- code/branches/network/src/network
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/network/GameStateClient.cc
r1083 r1087 117 117 it=orxonox::ObjectList<Synchronisable>::end(); 118 118 // update data and create object/entity... 119 if( !no->updateData(sync) && !no->create() ) 120 COUT(1) << "We couldn't create/update the object: " << sync.objectID << std::endl; 119 if( !no->updateData(sync) ) 120 COUT(1) << "We couldn't update the object: " << sync.objectID << std::endl; 121 if( !no->create() ) 122 COUT(1) << "We couldn't manifest (create() ) the object: " << sync.objectID << std::endl; 121 123 } 122 124 } else { -
code/branches/network/src/network/Synchronisable.cc
r1082 r1087 118 118 retVal.data=mem; 119 119 // copy to location 120 int n=0; 120 int n=0; //offset 121 121 for(i=syncList->begin(); n<datasize && i!=syncList->end(); ++i){ 122 122 //(std::memcpy(retVal.data+n, (const void*)(&(i->size)), sizeof(int)); … … 129 129 break; 130 130 case STRING: 131 std::memcpy( retVal.data+n, (const void*)( ( (std::string *) (*i)->var)->c_str()), ( (std::string *)(*i)->var )->length()+1);132 n+=( (std::string *) (*i)->var)->length()+1;131 std::memcpy( retVal.data+n, (const void*)( ( (std::string *) (*i)->var)->c_str()), (*i)->size); 132 n+=(*i)->size; 133 133 break; 134 134 } … … 149 149 return false; 150 150 } 151 COUT(5) << "Synchronisable: synchronising data" << std::endl; 152 i=syncList->begin(); 153 COUT(5) << "element size: " << (*syncList->begin())->size << std::endl; 154 COUT(5) << "*i.size" << (*i)->size << std::endl; 155 for(; i!=syncList->end(); i++){ 151 COUT(5) << "Synchronisable: objectID " << objectID << ", classID " << classID << " synchronising data" << std::endl; 152 for(i=syncList->begin(); i!=syncList->end(); i++){ 153 COUT(5) << "element size: " << (*i)->size << " type: " << (*i)->type << std::endl; 156 154 if(*(int *)data==(*i)->size || (*i)->type==STRING){ 157 155 switch((*i)->type){ 158 case DATA:159 data+=sizeof(int);160 memcpy((void*)(*i)->var, data, (*i)->size);161 data+=(*i)->size;162 break;163 case STRING:164 (*i)->size = *(int *)data;165 data+=sizeof(int);166 *((std::string *)((*i)->var)) = std::string((const char*)data);167 data += (*i)->size;168 break;156 case DATA: 157 data+=sizeof(int); 158 memcpy((void*)(*i)->var, data, (*i)->size); 159 data+=(*i)->size; 160 break; 161 case STRING: 162 (*i)->size = *(int *)data; 163 data+=sizeof(int); 164 *((std::string *)((*i)->var)) = std::string((const char*)data); 165 data += (*i)->size; 166 break; 169 167 } 170 168 } else … … 189 187 case STRING: 190 188 tsize+=sizeof(int); 191 tsize+=((std::string *)(*i)->var)->length()+1; 189 (*i)->size=((std::string *)(*i)->var)->length()+1; 190 tsize+=(*i)->size; 192 191 break; 193 192 }
Note: See TracChangeset
for help on using the changeset viewer.