Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 8, 2008, 2:48:48 AM (16 years ago)
Author:
landauf
Message:

removed 3 warnings:

  • Host.cc was twice in CMakeLists.txt
  • virtual destructors for Host and GamestateHandler
  • returning false instead of NULL in Gamestate.cc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/network/packet/Gamestate.cc

    r1735 r1740  
    3939
    4040namespace packet {
    41  
     41
    4242
    4343#define GAMESTATE_START(data) data + sizeof(GamestateHeader)
    4444#define GAMESTATE_HEADER(data) ((GamestateHeader *)data)
    4545#define HEADER GAMESTATE_HEADER(data_)
    46  
     46
    4747Gamestate::Gamestate()
    4848{
     
    6464  assert(data_==0 /*&& bs_==0*/);
    6565  int size = calcGamestateSize(mode);
    66  
     66
    6767  COUT(4) << "G.ST.Man: producing gamestate with id: " << id << std::endl;
    6868    //retval->data = (unsigned char*)malloc(size);
     
    8282  for(it = orxonox::ObjectList<Synchronisable>::start(); it; ++it){
    8383    tempsize=it->getSize2(mode);
    84    
     84
    8585    if(currentsize+tempsize > size){
    8686      // start allocate additional memory
     
    101101    currentsize+=tempsize;
    102102  }
    103  
    104  
     103
     104
    105105  //start write gamestate header
    106106  HEADER->packetType = ENUM::Gamestate;
    107   assert( *(ENUM::Type *)(data_) == ENUM::Gamestate); 
     107  assert( *(ENUM::Type *)(data_) == ENUM::Gamestate);
    108108  HEADER->normsize = currentsize;
    109109  HEADER->id = id;
     
    112112  HEADER->compressed = false;
    113113  //stop write gamestate header
    114  
     114
    115115  COUT(5) << "G.ST.Man: Gamestate size: " << currentsize << std::endl;
    116116  COUT(5) << "G.ST.Man: 'estimated' (and corrected) Gamestate size: " << size << std::endl;
     
    125125    // get the start of the Synchronisable list
    126126  orxonox::Iterator<Synchronisable> it=orxonox::ObjectList<Synchronisable>::start();
    127  
     127
    128128  while(mem < data_+sizeof(GamestateHeader)+HEADER->normsize){
    129129      // extract synchronisable header
     
    144144        it=orxonox::ObjectList<Synchronisable>::end();
    145145      }
    146     } else 
     146    } else
    147147    {
    148148        // we have our object
     
    185185  if(buffer==0)
    186186    return false;
    187  
     187
    188188  unsigned char *ndata = new unsigned char[buffer+sizeof(GamestateHeader)];
    189189  unsigned char *dest = GAMESTATE_START(ndata);
     
    192192  switch ( retval ) {
    193193    case Z_OK: COUT(5) << "G.St.Man: compress: successfully compressed" << std::endl; break;
    194     case Z_MEM_ERROR: COUT(1) << "G.St.Man: compress: not enough memory available in gamestate.compress" << std::endl; 
     194    case Z_MEM_ERROR: COUT(1) << "G.St.Man: compress: not enough memory available in gamestate.compress" << std::endl;
    195195    return false;
    196196    case Z_BUF_ERROR: COUT(2) << "G.St.Man: compress: not enough memory available in the buffer in gamestate.compress" << std::endl;
     
    224224    bufsize = normsize;
    225225  if(bufsize==0)
    226     return NULL;
     226    return false;
    227227  unsigned char *ndata = new unsigned char[bufsize + sizeof(GamestateHeader)];
    228228  unsigned char *dest = ndata + sizeof(GamestateHeader);
     
    236236    case Z_DATA_ERROR: COUT(2) << "data corrupted (zlib)" << std::endl; return false;
    237237  }
    238  
     238
    239239  HEADER->compressed = false;
    240240  //copy over the header
     
    245245  data_ = ndata;
    246246  //bs_ = new Bytestream(getGs(), GAMESTATE_HEADER->normsize);
    247  
     247
    248248  return true;
    249249}
     
    340340    return HEADER->diffed;
    341341  }
    342  
     342
    343343  int Gamestate::getBaseID(){
    344344    return HEADER->base_id;
Note: See TracChangeset for help on using the changeset viewer.