Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 9, 2008, 4:35:38 AM (16 years ago)
Author:
landauf
Message:

big change in ObjectList: separated the class into a non-template base and a template wrapper for the base. this also changes the Iterator, there is now a non-template IteratorBase. this brings much more flexibility, like iterating through all objects of a given identifier without knowing the type. however this needs a dynamic_cast, which isn't quite optimal, but I think there are much worser things than that out there. ;)

there isn't much you have to know about this, except there is no more ObjectList<myClass>::start() function but a ObjectList<myClass>::begin() to be more STLish. another thing: ObjectList<myClass>::end() points now to the element _after_ the last element, so it's possible to iterate in a for-loop until (it != ObjectList<myClass>::end()). the reason is the same as above. however, (it) as a boolean still works perfectly fine.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core3/src/network/Server.cc

    r1556 r1574  
    5757  #define MAX_FAILURES 20;
    5858  #define NETWORK_FREQUENCY 30
    59  
     59
    6060  Server *Server::instance_=0;
    61  
     61
    6262  Server *Server::createSingleton(){
    6363    if(!instance_)
     
    8080    return instance_;
    8181  }
    82  
     82
    8383  Server *Server::getSingleton(){
    8484    return instance_;
    8585  }
    86  
    87  
     86
     87
    8888  /**
    8989  * Constructor for default values (bindaddress is set to ENET_HOST_ANY
     
    9797    gamestates = new GameStateManager(clients);
    9898  }
    99  
     99
    100100  Server::Server(int port){
    101101    timeSinceLastUpdate_=0;
     
    217217        if(clients->findClient(&event->peer->address)){
    218218          clientID = clients->findClient(&event->peer->address)->getID();
    219           if( !elaborate(event->packet, clientID) ) 
     219          if( !elaborate(event->packet, clientID) )
    220220            COUT(3) << "Server: could not elaborate" << std::endl;
    221221        }
     
    276276        continue;
    277277      if ( !(connection->addPacket(packet, cid)) ){
    278         COUT(3) << "Server: packet with client id (cid): " << cid << " not sended: " << temp->getFailures() << std::endl; 
     278        COUT(3) << "Server: packet with client id (cid): " << cid << " not sended: " << temp->getFailures() << std::endl;
    279279        temp->addFailure();
    280280        /*if(temp->getFailures() > 0 )
     
    302302    delete data;
    303303  }
    304  
     304
    305305  bool Server::processConnectRequest( connectRequest *con, int clientID ){
    306306    //(COUT(3) << "processing connectRequest " << std::endl;
     
    310310    return true;
    311311  }
    312  
     312
    313313  void Server::processGamestate( GameStateCompressed *data, int clientID){
    314314    COUT(4) << "processing partial gamestate from client " << clientID << std::endl;
     
    319319        clients->findClient(clientID)->resetFailures();*/
    320320  }
    321  
     321
    322322  void Server::processChat( chat *data, int clientId){
    323323    char *message = new char [strlen(data->message)+10+1];
     
    329329    delete data;
    330330  }
    331  
     331
    332332  bool Server::addClient(ENetEvent *event){
    333333    ClientInformation *temp = clients->insertBack(new ClientInformation);
     
    346346    return createClient(temp->getID());
    347347  }
    348  
     348
    349349  bool Server::createClient(int clientID){
    350350    ClientInformation *temp = clients->findClient(clientID);
     
    366366    return true;
    367367  }
    368  
     368
    369369  bool Server::createShip(ClientInformation *client){
    370370    if(!client)
     
    390390    no->classID = id->getNetworkID();
    391391    no->create();
    392    
     392
    393393    client->setShipID(no->objectID);
    394394    return true;
    395395  }
    396  
     396
    397397  bool Server::disconnectClient(ENetEvent *event){
    398398    COUT(4) << "removing client from list" << std::endl;
    399399    //return removeClient(head_->findClient(&(peer->address))->getID());
    400    
     400
    401401    //boost::recursive_mutex::scoped_lock lock(head_->mutex_);
    402     orxonox::Iterator<orxonox::SpaceShip> it = orxonox::ObjectList<orxonox::SpaceShip>::start();
     402    orxonox::Iterator<orxonox::SpaceShip> it = orxonox::ObjectList<orxonox::SpaceShip>::begin();
    403403    ClientInformation *client = clients->findClient(&event->peer->address);
    404404    if(!client)
     
    426426    gamestates->removeClient(client);
    427427  }
    428  
     428
    429429}
Note: See TracChangeset for help on using the changeset viewer.