Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 8, 2008, 11:53:58 AM (16 years ago)
Author:
scheusso
Message:

some enhanced memory handling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network3/src/network/Client.cc

    r1246 r1248  
    8484    // set server address to localhost
    8585    isConnected=false;
    86     test_once=false;
     86    isSynched_=false;
    8787  }
    8888
     
    9494  Client::Client(std::string address, int port) : client_connection(port, address){
    9595    isConnected=false;
    96     test_once=false;
     96    isSynched_=false;
    9797  }
    9898
     
    104104  Client::Client(const char *address, int port) : client_connection(port, address){
    105105    isConnected=false;
    106     test_once=false;
     106    isSynched_=false;
    107107  }
    108108
     
    229229  */
    230230  void Client::tick(float time){
    231     if(client_connection.isConnected()){
     231    if(client_connection.isConnected() && isSynched_){
    232232      COUT(4) << "popping partial gamestate: " << std::endl;
    233233      GameStateCompressed *gs = gamestate.popPartialGameState();
     
    246246      packet = client_connection.getPacket();
    247247      COUT(5) << "tick packet size " << packet->dataLength << std::endl;
    248       if(!test_once){
    249         elaborate(packet, 0); // ================= i guess we got to change this .... (client_ID is always same = server)
    250       }
     248      elaborate(packet, 0); // ================= i guess we got to change this .... (client_ID is always same = server)
    251249    }
    252250    if(!client_connection.sendPackets())
     
    256254
    257255  void Client::processGamestate( GameStateCompressed *data, int clientID){
    258     if(!test_once){
    259       int id = data->id;
    260       COUT(5) << "received gamestate id: " << data->id << std::endl;
    261       if(gamestate.pushGameState(data)){
    262         client_connection.addPacket(pck_gen.acknowledgement(id));
     256    int id = data->id;
     257    COUT(5) << "received gamestate id: " << data->id << std::endl;
     258    if(gamestate.pushGameState(data)){
     259      if(!isSynched_)
     260        isSynched_=true;
     261      client_connection.addPacket(pck_gen.acknowledgement(id));
    263262        // we do this at the end of a tick
    264 //        if(!client_connection.sendPackets())
    265 //          COUT(2) << "Could not send acknowledgment" << std::endl;
    266       }
    267 //       test_once=true;
     263       if(!client_connection.sendPackets())
     264         COUT(2) << "Could not send acknowledgment" << std::endl;
    268265    }
    269266  }
     
    275272      id->setNetworkID(clid->clid);
    276273    COUT(4) << "Client: received and set network id: " << clid->clid << "; classname: " << clid->message << std::endl;
     274    delete clid;
    277275    return;
    278276  }
     
    280278  void Client::processChat( chat *data){
    281279    COUT(0) << "Server: " << data->message << std::endl;
     280    delete[] data->message;
     281    delete data;
    282282  }
    283283 
     
    286286    clientID_ = w->clientID;
    287287    shipID_ = w->shipID;
     288    delete w;
    288289    return true;
    289290  }
Note: See TracChangeset for help on using the changeset viewer.