Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 7, 2008, 4:39:42 PM (16 years ago)
Author:
scheusso
Message:

different enhancements in input/network handling and synchronisation

File:
1 edited

Legend:

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

    r1233 r1245  
    8484    // set server address to localhost
    8585    isConnected=false;
     86    test_once=false;
    8687  }
    8788
     
    9394  Client::Client(std::string address, int port) : client_connection(port, address){
    9495    isConnected=false;
     96    test_once=false;
    9597  }
    9698
     
    102104  Client::Client(const char *address, int port) : client_connection(port, address){
    103105    isConnected=false;
     106    test_once=false;
    104107  }
    105108
     
    226229  */
    227230  void Client::tick(float time){
     231    if(client_connection.isConnected()){
     232      COUT(4) << "popping partial gamestate: " << std::endl;
     233      GameStateCompressed *gs = gamestate.popPartialGameState();
     234      if(gs){
     235        COUT(4) << "client tick: sending gs " << gs << std::endl;
     236        if(client_connection.addPacket(pck_gen.gstate(gs)))
     237          if(!client_connection.sendPackets())
     238            COUT(3) << "Problem sending partial gamestate" << std::endl;
     239        // now delete it to save memory
     240        delete [] gs->data;
     241        delete gs;
     242      }
     243    }
    228244    ENetPacket *packet;
    229245    // stop if the packet queue is empty
     
    231247      packet = client_connection.getPacket();
    232248      COUT(5) << "tick packet size " << packet->dataLength << std::endl;
    233       elaborate(packet, 0); // ================= i guess we got to change this .... (client_ID is always same = server)
     249      if(!test_once){
     250        elaborate(packet, 0); // ================= i guess we got to change this .... (client_ID is always same = server)
     251      }
    234252    }
    235253    return;
    236254  }
    237255
    238   void Client::processGamestate( GameStateCompressed *data){
    239     int id = data->id;
    240     COUT(5) << "received gamestate id: " << data->id << std::endl;
    241     if(gamestate.pushGameState(data)){
    242       client_connection.addPacket(pck_gen.acknowledgement(id));
    243       if(!client_connection.sendPackets())
    244         COUT(2) << "Could not send acknowledgment" << std::endl;
     256  void Client::processGamestate( GameStateCompressed *data, int clientID){
     257    if(!test_once){
     258      int id = data->id;
     259      COUT(5) << "received gamestate id: " << data->id << std::endl;
     260      if(gamestate.pushGameState(data)){
     261        client_connection.addPacket(pck_gen.acknowledgement(id));
     262        if(!client_connection.sendPackets())
     263          COUT(2) << "Could not send acknowledgment" << std::endl;
     264      }
     265//       test_once=true;
    245266    }
    246267  }
     
    263284    clientID_ = w->clientID;
    264285    shipID_ = w->shipID;
    265    
     286    return true;
    266287  }
    267288
Note: See TracChangeset for help on using the changeset viewer.