Changeset 447 in flair-src for trunk/tools
- Timestamp:
- Sep 16, 2021, 2:01:56 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/VrpnLite/src/VrpnLite.cpp
r446 r447 23 23 #include <Quaternion.h> 24 24 #include <string.h> 25 #include <bits/stdc++.h> 25 26 26 27 using namespace std; … … 61 62 ssize_t rcv=dataSocket->RecvMessage(msg,sizeof(msg),dataSocketTimeout,NULL,NULL,&src_id); 62 63 if(rcv>0) { 63 string object=msg;64 uint16_t id;65 memcpy(&id,&msg[rcv- 2],sizeof(id));64 int16_t id; 65 string object=string(msg,rcv-sizeof(id)); 66 memcpy(&id,&msg[rcv-sizeof(id)],sizeof(id)); 66 67 dataSocket->HostToNetwork((char*)&id,sizeof(id)); 67 68 if(src_id==vrpnobjects_list.size()) { 69 vector<VrpnObject*> vect; 70 vrpnobjects_list.push_back(vect); 71 //Printf("add vect %i\n",src_id); 72 } 73 //assume we receive it in the good order 74 if(id==vrpnobjects_list.at(src_id).size()) { 75 Printf("adding object %s with id %i from %i\n",object.c_str(),id,src_id); 76 VrpnObject* vrpnobject = new VrpnObject(object,vrpnclient->GetTabWidget()); 77 vrpnobjects.push_back(vrpnobject); 78 vrpnobjects_list.at(src_id).push_back(vrpnobject); 79 }else { 80 Err("adding object %s failed, expected id %i, got %i\n",object.c_str(),vrpnobjects.size(),id); 68 Printf("src id %i\n",src_id); 69 if(id>0) { //add object 70 if(src_id==vrpnobjects_list.size()) { 71 vector<VrpnObject*> vect; 72 vrpnobjects_list.push_back(vect); 73 //Printf("add vect %i\n",src_id); 74 } 75 //assume we receive it in the good order 76 if(id==vrpnobjects_list.at(src_id).size()+1) {//id 0 is not used as we use positive and negative id for add/remove 77 Printf("adding object %s with id %i from client %i\n",object.c_str(),id,src_id); 78 VrpnObject* vrpnobject = new VrpnObject(object,vrpnclient->GetTabWidget()); 79 vrpnobjects.push_back(vrpnobject); 80 vrpnobjects_list.at(src_id).push_back(vrpnobject); 81 }else { 82 Err("adding object %s failed, expected id %i, got %i\n",object.c_str(),vrpnobjects_list.at(src_id).size()+1,id); 83 } 84 } else { //remove object 85 for (vector<VrpnObject*>::iterator it = vrpnobjects.begin();it < vrpnobjects.end(); it++) { 86 if ((*it)->ObjectName() == object) { 87 Printf("removing object %s with id %i from client %i\n",object.c_str(),-id,src_id); 88 auto iteratorEnd=remove(vrpnobjects_list.at(src_id).begin(), vrpnobjects_list.at(src_id).end(),(*it)); 89 vrpnobjects_list.at(src_id).erase(iteratorEnd, vrpnobjects_list.at(src_id).end()); 90 if(vrpnobjects_list.at(src_id).size()==0) { 91 Printf("not removing empty vrpnobjects_list (need code rewrite\n"); 92 //le src_id va continuer a augmenter cote udtsocket et la comparaison if(src_id==vrpnobjects_list.size()) { 93 //ne va pas marcher; il faut identifier autrement les src 94 //auto iteratorEnd=remove(vrpnobjects_list.begin(), vrpnobjects_list.end(),vrpnobjects_list.at(src_id)); 95 //vrpnobjects_list.erase(iteratorEnd, vrpnobjects_list.end()); 96 } 97 delete (*it); 98 vrpnobjects.erase(it); 99 break; 100 } 101 } 102 81 103 } 82 104 }
Note:
See TracChangeset
for help on using the changeset viewer.