Changeset 571
- Timestamp:
- Dec 17, 2007, 1:51:14 PM (17 years ago)
- Location:
- code/branches/FICN
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/CMakeLists.txt
r565 r571 49 49 SET(CMAKE_C_FLAGS "$ENV{CFLAGS} -O2 -Wall -g -ggdb") 50 50 #SET(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -O2 -Wall -g -ggdb") 51 SET(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} - Wall -g -ggdb")51 SET(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -O2 -Wall -g -ggdb") 52 52 SET(CMAKE_LD_FLAGS "$ENV{LDFLAGS}") 53 53 -
code/branches/FICN/src/network/GameStateManager.cc
r569 r571 164 164 165 165 GameStateCompressed GameStateManager::compress_(GameState *a) { 166 COUT(2) << "compressing gamestate" << std::endl; 166 167 int size = a->size; 167 168 uLongf buffer = (uLongf)((a->size + 12)*1.01)+1; -
code/branches/FICN/src/network/Synchronisable.cc
r569 r571 59 59 * @return data containing all variables and their sizes 60 60 */ 61 syncData Synchronisable::getData(){62 std::list<synchronisableVariable>::iterator i;63 int totalsize=0;64 //figure out size of data to be allocated65 for(i=syncList.begin(); i!=syncList.end(); i++){66 // increase size (size of variable and size of size of variable ;)67 if(i->type == STRING)68 totalsize+=sizeof(int)+((std::string *)i->var)->length()+1;69 else70 totalsize+=sizeof(int)+i->size;71 }72 syncData retVal;73 retVal.objectID=this->objectID;74 retVal.classID=this->classID;75 retVal.length=totalsize;76 // allocate memory77 retVal.data = (unsigned char *)malloc(totalsize);78 // copy to location79 //CHANGED: REMOVED DECLARATION int n=0 FROM LOOP80 int n=0;81 for(i=syncList.begin(); n<totalsize && i!=syncList.end(); i++){82 std::memcpy(retVal.data+n, (const void*)(i->size), sizeof(int));83 n+=sizeof(int);84 switch(i->type){85 case STRING:86 std::memcpy(retVal.data+n, (const void *)(((std::string *)i->var)->c_str()), ((std::string *)i->var)->length()+1);87 n+=((std::string *)i->var)->length()+1;88 break;89 case DATA:90 std::memcpy(retVal.data+n, ((const void*)i->var), i->size);91 n+=i->size;92 break;93 }94 }95 return retVal;96 }61 // syncData Synchronisable::getData(){ 62 // std::list<synchronisableVariable>::iterator i; 63 // int totalsize=0; 64 // //figure out size of data to be allocated 65 // for(i=syncList.begin(); i!=syncList.end(); i++){ 66 // // increase size (size of variable and size of size of variable ;) 67 // if(i->type == STRING) 68 // totalsize+=sizeof(int)+((std::string *)i->var)->length()+1; 69 // else 70 // totalsize+=sizeof(int)+i->size; 71 // } 72 // syncData retVal; 73 // retVal.objectID=this->objectID; 74 // retVal.classID=this->classID; 75 // retVal.length=totalsize; 76 // // allocate memory 77 // retVal.data = (unsigned char *)malloc(totalsize); 78 // // copy to location 79 // //CHANGED: REMOVED DECLARATION int n=0 FROM LOOP 80 // int n=0; 81 // for(i=syncList.begin(); n<totalsize && i!=syncList.end(); i++){ 82 // std::memcpy(retVal.data+n, (const void*)(i->size), sizeof(int)); 83 // n+=sizeof(int); 84 // switch(i->type){ 85 // case STRING: 86 // std::memcpy(retVal.data+n, (const void *)(((std::string *)i->var)->c_str()), ((std::string *)i->var)->length()+1); 87 // n+=((std::string *)i->var)->length()+1; 88 // break; 89 // case DATA: 90 // std::memcpy(retVal.data+n, ((const void*)i->var), i->size); 91 // n+=i->size; 92 // break; 93 // } 94 // } 95 // return retVal; 96 // } 97 97 /** 98 98 * This function takes all SynchronisableVariables out of the Synchronisable and saves it into a syncData struct … … 114 114 // copy to location 115 115 int n=0; 116 for(i=syncList.begin(); n<datasize && i!=syncList.end(); i++){116 for(i=syncList.begin(); n<datasize && i!=syncList.end(); ++i){ 117 117 //COUT(2) << "size of variable: " << i->size << std::endl; 118 118 //COUT(2) << "size of variable: " << i->size << std::endl; 119 std::memcpy(retVal.data+n, (const void*)(&(i->size)), sizeof(int)); 119 //(std::memcpy(retVal.data+n, (const void*)(&(i->size)), sizeof(int)); 120 *((int *)(retVal.data+n)) = i->size; 120 121 n+=sizeof(int); 121 122 switch(i->type){ … … 125 126 break; 126 127 case STRING: 127 std::memcpy( retVal.data+n, (const void*)(((std::string *)i->var)->c_str()), ((std::string *)i->var)->length()+1);128 std::memcpy( retVal.data+n, (const void*)( ( (std::string *) i->var)->c_str()), ( (std::string *)i->var )->length()+1); 128 129 n+=((std::string *) i->var)->length()+1; 129 130 break; -
code/branches/FICN/src/network/Synchronisable.h
r565 r571 54 54 55 55 void registerVar(const void *var, int size, variableType t); 56 syncData getData();56 // syncData getData(); 57 57 syncData getData(unsigned char *mem); 58 58 int getSize();
Note: See TracChangeset
for help on using the changeset viewer.