Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 9, 2008, 4:25:52 AM (16 years ago)
Author:
landauf
Message:

merged core3 back to trunk

Location:
code/trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/network/ClientConnection.cc

    r1534 r1747  
    4545
    4646#include "util/Sleep.h"
    47 #include "core/Debug.h"
     47#include "util/Debug.h"
    4848
    4949namespace network
     
    9191    return getPacket(address);
    9292  }*/
    93  
     93
    9494  ENetEvent *ClientConnection::getEvent(){
    9595    if(!buffer.isEmpty())
  • code/trunk/src/network/ConnectionManager.cc

    r1735 r1747  
    4545#include "core/CoreIncludes.h"
    4646#include "core/BaseObject.h"
     47#include "core/Iterator.h"
    4748#include "objects/SpaceShip.h"
    4849#include "util/Math.h"
     
    6667{
    6768  //boost::thread_group network_threads;
    68  
     69
    6970  ConnectionManager *ConnectionManager::instance_=0;
    70  
     71
    7172  ConnectionManager::ConnectionManager():receiverThread_(0){
    7273    assert(instance_==0);
     
    7778  }
    7879  boost::recursive_mutex ConnectionManager::enet_mutex;
    79  
     80
    8081//   ConnectionManager::ConnectionManager(ClientInformation *head) : receiverThread_(0) {
    8182//     assert(instance_==0);
     
    8586//     bindAddress.port = NETWORK_PORT;
    8687//   }
    87  
     88
    8889  ConnectionManager::ConnectionManager(int port){
    8990    assert(instance_==0);
     
    109110    bindAddress.port = NETWORK_PORT;
    110111  }
    111  
     112
    112113  ConnectionManager::~ConnectionManager(){
    113114    instance_=0;
     
    135136    return packet;
    136137  }*/
    137  
     138
    138139  ENetEvent *ConnectionManager::getEvent(){
    139140    if(!buffer.isEmpty())
     
    160161    return true;
    161162  }
    162  
     163
    163164//   bool ConnectionManager::addPacket(Packet::Packet *packet){
    164165//     ClientInformation *temp = instance_->head_->findClient(packet->getClientID());
     
    170171//     //  TODO: finish implementation
    171172//   }
    172 //   
    173  
     173//
     174
    174175  bool ConnectionManager::addPacket(ENetPacket *packet, ENetPeer *peer) {
    175176    boost::recursive_mutex::scoped_lock lock(instance_->enet_mutex);
     
    276277    }
    277278  }
    278  
     279
    279280  //### added some bugfixes here, but we cannot test them because
    280281  //### the server crashes everytime because of some gamestates
     
    335336
    336337  /**
    337    * 
    338    * @param clientID 
     338   *
     339   * @param clientID
    339340   */
    340341  void ConnectionManager::syncClassid(unsigned int clientID) {
     
    364365  }
    365366
    366  
    367  
     367
     368
    368369  bool ConnectionManager::removeShip(ClientInformation *client){
    369370    unsigned int id=client->getShipID();
    370     orxonox::Iterator<orxonox::SpaceShip> it;
    371     for(it = orxonox::ObjectList<orxonox::SpaceShip>::start(); it; ++it){
     371    orxonox::ObjectList<orxonox::SpaceShip>::iterator it;
     372    for(it = orxonox::ObjectList<orxonox::SpaceShip>::begin(); it; ++it){
    372373      if(it->objectID!=id)
    373374        continue;
     
    376377    return true;
    377378  }
    378  
    379  
     379
     380
    380381  void ConnectionManager::disconnectClient(ClientInformation *client){
    381382    {
     
    386387    removeShip(client);
    387388  }
    388  
     389
    389390
    390391}
  • code/trunk/src/network/GamestateClient.cc

    r1735 r1747  
    3333#include "core/CoreIncludes.h"
    3434#include "core/BaseObject.h"
     35#include "core/Iterator.h"
    3536#include "Synchronisable.h"
    3637
     
    6869    return true;
    6970  }
    70  
     71
    7172  int GamestateClient::processGamestates(){
    7273    if(tempGamestate_==NULL)
     
    8990  * @return iterator pointing to the next object in the list
    9091  */
    91   void GamestateClient::removeObject(orxonox::Iterator<Synchronisable> &it) {
    92     orxonox::Iterator<Synchronisable> temp=it;
     92  void GamestateClient::removeObject(orxonox::ObjectList<Synchronisable>::iterator &it) {
     93    orxonox::ObjectList<Synchronisable>::iterator temp=it;
    9394    ++it;
    9495    delete  *temp;
  • code/trunk/src/network/GamestateClient.h

    r1735 r1747  
    4242
    4343#include <map>
    44 // 
     44//
    4545#include "NetworkPrereqs.h"
    4646#include "core/CorePrereqs.h"
     
    5858    GamestateClient();
    5959    ~GamestateClient();
    60    
     60
    6161    bool add(packet::Gamestate *gs, int clientID);
    6262    bool ack(int gamestateID, int clientID);
    63    
     63
    6464    int processGamestates();
    6565    packet::Gamestate *getGamestate();
     
    6767  private:
    6868    bool processGamestate(packet::Gamestate *gs);
    69     void removeObject(orxonox::Iterator<Synchronisable> &it);
     69    void removeObject(orxonox::ObjectListIterator<Synchronisable> &it);
    7070    void printGamestateMap();
    7171    bool saveShipCache();
     
    7878    orxonox::SpaceShip *myShip_;
    7979    unsigned char *shipCache_;
    80    
     80
    8181  };
    8282
  • code/trunk/src/network/Server.cc

    r1735 r1747  
    5050#include "objects/SpaceShip.h"
    5151#include "core/ConsoleCommand.h"
     52#include "core/Iterator.h"
    5253#include "packet/Chat.h"
    5354#include "packet/Packet.h"
     
    5859  #define MAX_FAILURES 20;
    5960  #define NETWORK_FREQUENCY 30
    60  
     61
    6162  /**
    6263  * Constructor for default values (bindaddress is set to ENET_HOST_ANY
     
    6869    gamestates_ = new GamestateManager();
    6970  }
    70  
     71
    7172  Server::Server(int port){
    7273    timeSinceLastUpdate_=0;
     
    123124    return message->process();
    124125  }
    125  
     126
    126127  /**
    127128  * This function sends out a message to all clients
     
    175176    return;
    176177  }
    177  
     178
    178179  bool Server::queuePacket(ENetPacket *packet, int clientID){
    179180    return connection->addPacket(packet, clientID);
     
    230231    return p->process();
    231232  }
    232  
     233
    233234  /**
    234235  * sends the gamestate
     
    261262      assert(gs->compressData());
    262263      if ( !gs->send() ){
    263         COUT(3) << "Server: packet with client id (cid): " << cid << " not sended: " << temp->getFailures() << std::endl; 
     264        COUT(3) << "Server: packet with client id (cid): " << cid << " not sended: " << temp->getFailures() << std::endl;
    264265        temp->addFailure();
    265266      }else
     
    276277    return true;
    277278  }
    278  
     279
    279280//   void Server::processChat( chat *data, int clientId){
    280281//     char *message = new char [strlen(data->message)+10+1];
     
    286287//     delete data;
    287288//   }
    288  
     289
    289290  bool Server::addClient(ENetEvent *event){
    290291    ClientInformation *temp = ClientInformation::insertBack(new ClientInformation);
     
    303304    return createClient(temp->getID());
    304305  }
    305  
     306
    306307  bool Server::createClient(int clientID){
    307308    ClientInformation *temp = ClientInformation::findClient(clientID);
     
    325326    return true;
    326327  }
    327  
     328
    328329  bool Server::createShip(ClientInformation *client){
    329330    if(!client)
     
    351352    no->create();
    352353    no->setBacksync(true);
    353    
     354
    354355    return true;
    355356  }
    356  
     357
    357358  bool Server::disconnectClient(ENetEvent *event){
    358359    COUT(4) << "removing client from list" << std::endl;
    359360    //return removeClient(head_->findClient(&(peer->address))->getID());
    360    
     361
    361362    //boost::recursive_mutex::scoped_lock lock(head_->mutex_);
    362     orxonox::Iterator<orxonox::SpaceShip> it = orxonox::ObjectList<orxonox::SpaceShip>::start();
     363    orxonox::ObjectList<orxonox::SpaceShip>::iterator it = orxonox::ObjectList<orxonox::SpaceShip>::begin();
    363364    ClientInformation *client = ClientInformation::findClient(&event->peer->address);
    364365    if(!client)
     
    369370        continue;
    370371      }
    371       orxonox::Iterator<orxonox::SpaceShip> temp=it;
     372      orxonox::ObjectList<orxonox::SpaceShip>::iterator temp=it;
    372373      ++it;
    373374      delete  *temp;
     
    386387    gamestates_->removeClient(client);
    387388  }
    388  
     389
    389390}
  • code/trunk/src/network/Synchronisable.h

    r1735 r1747  
    9292    Synchronisable();
    9393  private:
    94     /*  bool removeObject(Iterator<Synchronisable> it);*/
     94    /*  bool removeObject(ObjectList<Synchronisable>::iterator it);*/
    9595
    9696    std::list<synchronisableVariable *> *syncList;
  • code/trunk/src/network/packet/Gamestate.cc

    r1740 r1747  
    3030#include "network/ClientInformation.h"
    3131#include "network/GamestateHandler.h"
     32#include "core/Iterator.h"
    3233
    3334#include <zlib.h>
     
    7980  unsigned char *mem=data_;
    8081  mem+=sizeof(GamestateHeader);
    81   orxonox::Iterator<Synchronisable> it;
    82   for(it = orxonox::ObjectList<Synchronisable>::start(); it; ++it){
     82  orxonox::ObjectList<Synchronisable>::iterator it;
     83  for(it = orxonox::ObjectList<Synchronisable>::begin(); it; ++it){
    8384    tempsize=it->getSize2(mode);
    8485
     
    8687      // start allocate additional memory
    8788      COUT(3) << "G.St.Man: need additional memory" << std::endl;
    88       orxonox::Iterator<Synchronisable> temp = it;
     89      orxonox::ObjectList<Synchronisable>::iterator temp = it;
    8990      int addsize=tempsize;
    9091      while(++temp)
     
    124125  unsigned char *mem=data_+sizeof(GamestateHeader);
    125126    // get the start of the Synchronisable list
    126   orxonox::Iterator<Synchronisable> it=orxonox::ObjectList<Synchronisable>::start();
     127  orxonox::ObjectList<Synchronisable>::iterator it=orxonox::ObjectList<Synchronisable>::begin();
    127128
    128129  while(mem < data_+sizeof(GamestateHeader)+HEADER->normsize){
     
    318319  int size=0;
    319320    // get the start of the Synchronisable list
    320   orxonox::Iterator<Synchronisable> it;
     321  orxonox::ObjectList<Synchronisable>::iterator it;
    321322    // get total size of gamestate
    322   for(it = orxonox::ObjectList<Synchronisable>::start(); it; ++it)
     323  for(it = orxonox::ObjectList<Synchronisable>::begin(); it; ++it)
    323324    size+=it->getSize2(mode); // size of the actual data of the synchronisable
    324325//  size+=sizeof(GamestateHeader);
     
    331332 * @return iterator pointing to the next object in the list
    332333 */
    333   void Gamestate::removeObject(orxonox::Iterator<Synchronisable> &it) {
    334     orxonox::Iterator<Synchronisable> temp=it;
     334  void Gamestate::removeObject(orxonox::ObjectList<Synchronisable>::iterator &it) {
     335    orxonox::ObjectList<Synchronisable>::iterator temp=it;
    335336    ++it;
    336337    delete  *temp;
  • code/trunk/src/network/packet/Gamestate.h

    r1735 r1747  
    3838
    3939namespace packet {
    40  
     40
    4141struct GamestateHeader{
    4242  ENUM::Type packetType;
     
    5151
    5252/**
    53         @author 
     53        @author
    5454*/
    5555class Gamestate: public Packet{
     
    5757    Gamestate();
    5858    Gamestate(unsigned char *data, int clientID);
    59    
     59
    6060    ~Gamestate();
    61    
     61
    6262    bool collectData(int id, int mode=0x0);
    6363    bool spreadData(int mode=0x0);
     
    6969    bool compressData();
    7070    bool decompressData();
    71    
     71
    7272    // Packet functions
    7373    virtual unsigned int getSize() const;
    7474    virtual bool process();
    7575
    76    
     76
    7777  private:
    7878    unsigned int calcGamestateSize(int mode=0x0);
    79     void removeObject(orxonox::Iterator<Synchronisable> &it);
     79    void removeObject(orxonox::ObjectListIterator<Synchronisable> &it);
    8080
    81    
     81
    8282    //Bytestream *bs_;
    8383    //GamestateHeader *header_;
Note: See TracChangeset for help on using the changeset viewer.