Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1355


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

some enhanced enet usage (gamestates are not reliable anymore - we hope to get a latency reduction)

Location:
code/branches/merge/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • code/branches/merge/src/network/ClientInformation.cc

    r1318 r1355  
    5151    preve=0;
    5252    nexte=0;
     53    partialGamestateID_=GAMESTATEID_INITIAL-1;
    5354    this->head_=false;
    5455    synched_=false;
     
    5960    preve=0;
    6061    nexte=0;
     62    partialGamestateID_=GAMESTATEID_INITIAL-1;
    6163    this->head_=head;
    6264    synched_=false;
     
    159161    return true;
    160162  }
     163 
     164  bool ClientInformation::setPartialGamestateID(int id){
     165    boost::recursive_mutex::scoped_lock lock(mutex_);
     166    if(!this)
     167      return false;
     168    partialGamestateID_=id;
     169    return true;
     170  }
    161171
    162172  int ClientInformation::getID() {
     
    203213    if(this)
    204214      return gamestateID_;
     215    else
     216      return -1;
     217  }
     218 
     219  int ClientInformation::getPartialGamestateID() {
     220    boost::recursive_mutex::scoped_lock lock(mutex_);
     221    if(this)
     222      return partialGamestateID_;
    205223    else
    206224      return -1;
  • code/branches/merge/src/network/ClientInformation.h

    r1318 r1355  
    7070    bool setPeer(ENetPeer *peer);
    7171    bool setGamestateID(int id);
     72    bool setPartialGamestateID(int id);
    7273    inline void setShipID(int id){ShipID_=id;}
    7374   
     
    7677    int getID();
    7778    int getGamestateID();
     79    int getPartialGamestateID();
    7880    ENetPeer *getPeer();
    7981    bool getHead();
     
    107109    int clientID_;
    108110    int gamestateID_;
     111    int partialGamestateID_;
    109112    int ShipID_;   // this is the unique objectID
    110113    bool synched_;
  • code/branches/merge/src/network/ConnectionManager.cc

    r1318 r1355  
    193193          addClient(event);
    194194          //this is a workaround to ensure thread safety
    195           /*if(!addFakeConnectRequest(&event))
    196             COUT(3) << "Problem pushing fakeconnectRequest to queue" << std::endl;*/
    197195          COUT(5) << "Con.Man: connection event has occured" << std::endl;
    198196          break;
     
    210208          break;
    211209        case ENET_EVENT_TYPE_NONE:
     210          receiverThread_->yield();
    212211          break;
    213212      }
  • code/branches/merge/src/network/GameStateClient.cc

    r1333 r1355  
    4747    COUT(5) << "this: " << this << std::endl;
    4848    last_diff_=0;
     49    last_gamestate_=GAMESTATEID_INITIAL-1;
    4950  }
    5051
     
    5657    printGameStateMap();
    5758    GameState *gs, *reference;
     59    /*if(compstate->id<last_gamestate_){
     60      // network packets got messed up
     61      COUT(3) << "received an obsolete gamestate" << std::endl;
     62      return false;
     63    }*/
    5864    if(compstate->diffed && compstate->base_id!=GAMESTATEID_INITIAL){
    5965      std::map<int, GameState*>::iterator it = gameStateMap.find(compstate->base_id);
     
    7783        COUT(4) << "adding decoded gs with id: " << gs->id << " diffed from: " << gs->base_id << std::endl;
    7884        last_diff_=gs->base_id;
     85        //last_gamestate_=gs->id;
    7986        return true;
    8087      }else{
     
    149156          Synchronisable *no = dynamic_cast<Synchronisable *>(id->fabricate());
    150157          COUT(4) << "loadsnapshot: classid: " << sync.classID << " objectID: " << sync.objectID << " length: " << sync.length << std::endl;
     158          if(!no){
     159            COUT(2) << "coudl not frabricate classid: " << sync.classID << " objectID: " << sync.objectID << " identifier: " << id << std::endl;
     160            break;
     161          }
    151162          no->objectID=sync.objectID;
    152163          no->classID=sync.classID;
  • code/branches/merge/src/network/GameStateClient.h

    r1264 r1355  
    7171
    7272    int           last_diff_;
     73    int           last_gamestate_;
    7374    std::map<int, GameState *> gameStateMap;
    7475   
  • code/branches/merge/src/network/GameStateManager.cc

    r1299 r1355  
    221221    orxonox::Iterator<Synchronisable> it=orxonox::ObjectList<Synchronisable>::start();
    222222    syncData sync;
     223    /*ClientInformation *client = head_->findClient(clientID);
     224    if(client)
     225      if(client->getPartialGamestateID()>state->id){
     226        COUT(3) << "we received an obsolete partial gamestate" << std::endl;
     227        return false;
     228      }
     229    else;*/
     230        //what should we do now ??
    223231    // loop as long as we have some data ;)
    224232    while(data < state->data+state->size){
     
    268276      ++it;
    269277    }
    270    
     278    //client->setPartialGamestateID(state->id);
    271279    return true;
    272280  }
     
    428436      return;
    429437    int curid = temp->getGamestateID();
     438    if(curid > gamestateID)
     439      // the network packets got messed up
     440      return;
    430441    COUT(4) << "acking gamestate " << gamestateID << " for clientid: " << clientID << " curid: " << curid << std::endl;
    431442    // decrease usage of gamestate and save it
  • code/branches/merge/src/network/PacketManager.h

    r1336 r1355  
    5858    PacketGenerator();
    5959    //call one of this functions out of an instance of PacketGenerator to create a packet
    60     ENetPacket* acknowledgement( int state, int reliable = ENET_PACKET_FLAG_RELIABLE );
     60    ENetPacket* acknowledgement( int state, int reliable = 0 ); // we do not want reliability
    6161    ENetPacket* command( int dataLength, void *data, int reliable = ENET_PACKET_FLAG_RELIABLE );
    6262    ENetPacket* mousem( double x, double y, int reliable = ENET_PACKET_FLAG_RELIABLE );
    6363    ENetPacket* keystrike( char press, int reliable = ENET_PACKET_FLAG_RELIABLE );
    6464    ENetPacket* chatMessage( const char* message, int reliable = ENET_PACKET_FLAG_RELIABLE );
    65     ENetPacket* gstate( GameStateCompressed *states, int reliable = ENET_PACKET_FLAG_RELIABLE );
     65    ENetPacket* gstate( GameStateCompressed *states, int reliable = 0 ); // we do not want reliability of gamestates
    6666    ENetPacket* clid( int classid, std::string classname, int reliable = ENET_PACKET_FLAG_RELIABLE );
    6767    ENetPacket* generateWelcome( int clientID,int shipID, bool allowed, int reliable = ENET_PACKET_FLAG_RELIABLE );
  • code/branches/merge/src/network/Synchronisable.cc

    r1306 r1355  
    156156    if(classID==0)
    157157      COUT(3) << "classid 0 " << this->getIdentifier()->getName() << std::endl;
    158     classID=this->getIdentifier()->getNetworkID();
     158    this->classID=this->getIdentifier()->getNetworkID();
    159159    std::list<synchronisableVariable *>::iterator i;
    160160    syncData retVal;
  • code/branches/merge/src/orxonox/objects/WorldEntity.cc

    r1305 r1355  
    152152      //register staticity
    153153      registerVar( (void*) &(this->bStatic_), sizeof(this->bStatic_), network::DATA, 0x3);
    154       //register acceleration
     154      //register acceleration & momentum
    155155      registerVar( (void*) &(this->getAcceleration().x), sizeof(this->getAcceleration().x), network::DATA, 0x3);
    156156      registerVar( (void*) &(this->getAcceleration().y), sizeof(this->getAcceleration().y), network::DATA, 0x3);
    157157      registerVar( (void*) &(this->getAcceleration().z), sizeof(this->getAcceleration().z), network::DATA, 0x3);
     158      registerVar( (void*) &(this->getMomentum()), sizeof(this->getMomentum()), network::DATA);
    158159    }
    159160
Note: See TracChangeset for help on using the changeset viewer.