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
Location:
code/trunk/src/network
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/network/CMakeLists.txt

    r1735 r1740  
    1717  packet/Gamestate.cc
    1818  packet/Welcome.cc
    19   Host.cc
    2019)
    2120
  • code/trunk/src/network/GamestateHandler.h

    r1735 r1740  
    4343    virtual bool add(packet::Gamestate *gs, int clientID)=0;
    4444    virtual bool ack(int gamestateID, int clientID)=0;
    45    
     45
    4646    static GamestateHandler *instance_;
    47    
    48    
     47
     48
    4949  protected:
    5050    GamestateHandler();
    51     ~GamestateHandler();
    52    
     51    virtual ~GamestateHandler();
     52
    5353  public:
    5454    static bool addGamestate(packet::Gamestate *gs, int clientID){ return instance_->add(gs, clientID); }
  • code/trunk/src/network/GamestateManager.h

    r1735 r1740  
    7070    GamestateManager();
    7171    ~GamestateManager();
    72    
     72
    7373    bool add(packet::Gamestate *gs, int clientID);
    7474    bool processGamestates();
     
    7777
    7878    bool getSnapshot();
    79    
     79
    8080    bool ack(int gamestateID, int clientID);
    8181    void removeClient(ClientInformation *client);
     
    8383    void cleanup(); // "garbage handler"
    8484    bool processGamestate(packet::Gamestate *gs);
    85    
     85
    8686    std::map<int, packet::Gamestate*> gamestateMap; //map gsID to gamestate*
    8787    std::map<int, int> gamestateUsed; // save the number of clients, that use the specific gamestate
  • code/trunk/src/network/Host.h

    r1735 r1740  
    4747    virtual unsigned int shipID()=0;
    4848    virtual int playerID()=0;
    49    
    50    
    51    
     49
     50
     51
    5252  protected:
    5353    Host();
    54     ~Host();
     54    virtual ~Host();
    5555    static Host *instance_;
    56    
     56
    5757  public:
    5858    static bool running(){return instance_!=0;}
  • 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.