Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 17, 2007, 1:51:14 PM (17 years ago)
Author:
scheusso
Message:

cmakelists

Location:
code/branches/FICN/src/network
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/FICN/src/network/GameStateManager.cc

    r569 r571  
    164164
    165165GameStateCompressed GameStateManager::compress_(GameState *a) {
     166  COUT(2) << "compressing gamestate" << std::endl;
    166167  int size = a->size;
    167168  uLongf buffer = (uLongf)((a->size + 12)*1.01)+1;
  • code/branches/FICN/src/network/Synchronisable.cc

    r569 r571  
    5959 * @return data containing all variables and their sizes
    6060 */
    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 }
     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// }
    9797/**
    9898 * This function takes all SynchronisableVariables out of the Synchronisable and saves it into a syncData struct
     
    114114  // copy to location
    115115  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){
    117117    //COUT(2) << "size of variable: " << i->size << std::endl;
    118118    //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;
    120121    n+=sizeof(int);
    121122    switch(i->type){
     
    125126        break;
    126127      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);
    128129        n+=((std::string *) i->var)->length()+1;
    129130        break;
  • code/branches/FICN/src/network/Synchronisable.h

    r565 r571  
    5454   
    5555  void registerVar(const void *var, int size, variableType t);
    56   syncData getData();
     56//  syncData getData();
    5757  syncData getData(unsigned char *mem);
    5858  int getSize();
Note: See TracChangeset for help on using the changeset viewer.