Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 10, 2016, 1:54:11 PM (8 years ago)
Author:
landauf
Message:

merged branch cpp11_v2 into cpp11_v3

Location:
code/branches/cpp11_v3
Files:
49 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v3

  • code/branches/cpp11_v3/src/libraries/network/Client.cc

    r10624 r11054  
    161161        {
    162162          std::vector<packet::Gamestate*> gamestates = GamestateManager::getGamestates();
    163           std::vector<packet::Gamestate*>::iterator it;
    164           for( it = gamestates.begin(); it != gamestates.end(); ++it )
     163          for( packet::Gamestate* gamestate : gamestates )
    165164          {
    166             (*it)->send( static_cast<Host*>(this) );
     165            gamestate->send( static_cast<Host*>(this) );
    167166          }
    168167        }
  • code/branches/cpp11_v3/src/libraries/network/Client.h

    r8858 r11054  
    7676    static Client* getInstance(){ return singletonPtr_s; } // tolua_export
    7777
    78     bool establishConnection();
     78    virtual bool establishConnection() override;
    7979    void setDestination( const std::string& serverAddress, unsigned int port ); // tolua_export
    80     bool closeConnection();
    81     void queuePacket(ENetPacket* packet, int clientID, uint8_t channelID);
    82     virtual bool sendPacket( packet::Packet* packet ){ return packet->send( static_cast<Host*>(this) ); }
    83     virtual void doSendChat(const std::string& message, unsigned int sourceID, unsigned int targetID);
    84     virtual void doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID);
    85     virtual void printRTT();
     80    virtual bool closeConnection() override;
     81    virtual void queuePacket(ENetPacket* packet, int clientID, uint8_t channelID) override;
     82    virtual bool sendPacket( packet::Packet* packet ) override{ return packet->send( static_cast<Host*>(this) ); }
     83    virtual void doSendChat(const std::string& message, unsigned int sourceID, unsigned int targetID) override;
     84    virtual void doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID) override;
     85    virtual void printRTT() override;
    8686
    8787    void update(const Clock& time);
    8888  protected:
    89     virtual void connectionClosed();
     89    virtual void connectionClosed() override;
    9090  private:
    9191    Client(const Client& copy); // not used
    92     virtual bool isServer_(){return false;}
    93     void processPacket(packet::Packet* packet);
     92    virtual bool isServer_() override{return false;}
     93    virtual void processPacket(packet::Packet* packet) override;
    9494
    9595    static Client* singletonPtr_s;
  • code/branches/cpp11_v3/src/libraries/network/ClientConnection.cc

    r8858 r11054  
    4444    Connection(NETWORK_PEER_ID_SERVER),
    4545    established_(false),
    46     server_(NULL)
     46    server_(nullptr)
    4747  {
    4848    this->serverAddress_ = new ENetAddress();
     
    7272
    7373    // create host
    74     this->host_ = enet_host_create(NULL, NETWORK_CLIENT_MAX_CONNECTIONS, NETWORK_CHANNEL_COUNT, 0, 0);
     74    this->host_ = enet_host_create(nullptr, NETWORK_CLIENT_MAX_CONNECTIONS, NETWORK_CHANNEL_COUNT, 0, 0);
    7575   
    76     if ( this->host_ == NULL )
     76    if ( this->host_ == nullptr )
    7777    {
    78       orxout(internal_error, context::network) << "ClientConnection: host_ == NULL" << endl;
     78      orxout(internal_error, context::network) << "ClientConnection: host_ == nullptr" << endl;
    7979      // error handling
    8080      return false;
     
    9393
    9494    this->server_ = enet_host_connect(this->host_, serverAddress_, NETWORK_CHANNEL_COUNT, 0);
    95     if ( this->server_==NULL )
     95    if ( this->server_==nullptr )
    9696    {
    97       orxout(internal_error, context::network) << "ClientConnection: server_ == NULL" << endl;
     97      orxout(internal_error, context::network) << "ClientConnection: server_ == nullptr" << endl;
    9898      // error handling
    9999      return false;
  • code/branches/cpp11_v3/src/libraries/network/ClientConnection.h

    r8327 r11054  
    5757    uint32_t getRTT();
    5858  private:
    59     virtual void addPeer(uint32_t peerID);
    60     virtual void removePeer(uint32_t peerID);
     59    virtual void addPeer(uint32_t peerID) override;
     60    virtual void removePeer(uint32_t peerID) override;
    6161
    6262    bool disconnectConnection();
  • code/branches/cpp11_v3/src/libraries/network/ClientConnectionListener.cc

    r10624 r11054  
    4444    void ClientConnectionListener::broadcastClientConnected(unsigned int clientID)
    4545    {
    46         for (ObjectList<ClientConnectionListener>::iterator it = ObjectList<ClientConnectionListener>::begin(); it != ObjectList<ClientConnectionListener>::end(); ++it)
    47             it->clientConnected(clientID);
     46        for (ClientConnectionListener* listener : ObjectList<ClientConnectionListener>())
     47            listener->clientConnected(clientID);
    4848    }
    4949
    5050    void ClientConnectionListener::broadcastClientDisconnected(unsigned int clientID)
    5151    {
    52         for (ObjectList<ClientConnectionListener>::iterator it = ObjectList<ClientConnectionListener>::begin(); it != ObjectList<ClientConnectionListener>::end(); ++it)
    53             it->clientDisconnected(clientID);
     52        for (ClientConnectionListener* listener : ObjectList<ClientConnectionListener>())
     53            listener->clientDisconnected(clientID);
    5454    }
    5555
  • code/branches/cpp11_v3/src/libraries/network/Connection.cc

    r8858 r11054  
    4646
    4747  Connection::Connection(uint32_t firstPeerID):
    48     host_(0), bCommunicationThreadRunning_(false), nextPeerID_(firstPeerID)
     48    host_(nullptr), bCommunicationThreadRunning_(false), nextPeerID_(firstPeerID)
    4949  {
    5050    enet_initialize();
     
    8181  {
    8282//     this->overallMutex_->lock();
    83     outgoingEvent outEvent = { peerID, outgoingEventType::disconnectPeer, 0, 0 };
     83    outgoingEvent outEvent = { peerID, outgoingEventType::disconnectPeer, nullptr, 0 };
    8484   
    8585    this->outgoingEventsMutex_->lock();
     
    9191  void Connection::disconnectPeers()
    9292  {
    93     outgoingEvent outEvent = { 0, outgoingEventType::disconnectPeers, 0, 0 };
     93    outgoingEvent outEvent = { 0, outgoingEventType::disconnectPeers, nullptr, 0 };
    9494   
    9595    this->outgoingEventsMutex_->lock();
     
    237237  void Connection::disconnectPeersInternal()
    238238  {
    239     std::map<uint32_t, ENetPeer*>::iterator it;
    240     for( it=this->peerMap_.begin(); it!=this->peerMap_.end(); ++it )
    241     {
    242       enet_peer_disconnect(it->second, 0);
     239    for( const auto& mapEntry : this->peerMap_ )
     240    {
     241      enet_peer_disconnect(mapEntry.second, 0);
    243242    }
    244243    uint32_t iterations = NETWORK_DISCONNECT_TIMEOUT/NETWORK_WAIT_TIMEOUT;
     
    323322   
    324323    // create new peerEvent and return it
    325     incomingEvent inEvent = { peerID, incomingEventType::peerConnect, 0 };
     324    incomingEvent inEvent = { peerID, incomingEventType::peerConnect, nullptr };
    326325    return inEvent;
    327326  }
     
    338337   
    339338    // create new peerEvent and return it
    340     incomingEvent inEvent = { peerID, incomingEventType::peerDisconnect, 0 };
     339    incomingEvent inEvent = { peerID, incomingEventType::peerDisconnect, nullptr };
    341340    return inEvent;
    342341  }
  • code/branches/cpp11_v3/src/libraries/network/Connection.h

    r8327 r11054  
    4646#include <map>
    4747#include <enet/enet.h>
    48 #include <boost/concept_check.hpp>
    4948
    5049namespace boost
  • code/branches/cpp11_v3/src/libraries/network/FunctionCall.cc

    r10624 r11054  
    4848bool FunctionCall::execute(){
    4949  NetworkFunctionBase* fct = NetworkFunctionManager::getInstance().getFunctionByNetworkId( this->functionID_ );
    50   assert( fct != NULL );
     50  assert( fct != nullptr );
    5151  assert( this->nrOfArguments_==this->arguments_.size() );
    5252  switch(this->nrOfArguments_)
     
    119119  for( unsigned int i=0; i<this->nrOfArguments_; ++i )
    120120  {
    121     this->arguments_.push_back(MultiType());
     121    this->arguments_.emplace_back();
    122122    this->arguments_.back().importData(mem);
    123123  }
     
    131131  *(uint32_t*)(mem+2*sizeof(uint32_t)) = this->objectID_;
    132132  mem += 3*sizeof(uint32_t);
    133   for( std::vector<MultiType>::iterator it = this->arguments_.begin(); it!=this->arguments_.end(); ++it )
     133  for(const MultiType& argument : this->arguments_)
    134134  {
    135     it->exportData( mem );
     135    argument.exportData( mem );
    136136  }
    137137}
  • code/branches/cpp11_v3/src/libraries/network/FunctionCallManager.cc

    r10624 r11054  
    3737
    3838std::map<uint32_t, packet::FunctionCalls*> FunctionCallManager::sPeerMap_;
    39 std::vector<std::pair<FunctionCall, std::pair<uint32_t, uint32_t> > > FunctionCallManager::sIncomingFunctionCallBuffer_;
     39std::vector<std::pair<FunctionCall, std::pair<uint32_t, uint32_t>>> FunctionCallManager::sIncomingFunctionCallBuffer_;
    4040
    4141
     
    5454void FunctionCallManager::sendCalls(orxonox::Host* host)
    5555{
    56   std::map<uint32_t, packet::FunctionCalls*>::iterator it;
    57   for (it = FunctionCallManager::sPeerMap_.begin(); it != FunctionCallManager::sPeerMap_.end(); ++it )
     56  for (const auto& mapEntry : FunctionCallManager::sPeerMap_ )
    5857  {
    5958    assert(!FunctionCallManager::sPeerMap_.empty());
    60     it->second->send(host);
     59    mapEntry.second->send(host);
    6160  }
    6261  FunctionCallManager::sPeerMap_.clear();
     
    6564void FunctionCallManager::bufferIncomingFunctionCall(const orxonox::FunctionCall& fctCall, uint32_t minGamestateID, uint32_t peerID)
    6665{
    67   FunctionCallManager::sIncomingFunctionCallBuffer_.push_back( std::make_pair(fctCall, std::make_pair(minGamestateID, peerID)));
     66  FunctionCallManager::sIncomingFunctionCallBuffer_.emplace_back(fctCall, std::make_pair(minGamestateID, peerID));
    6867}
    6968
    7069void FunctionCallManager::processBufferedFunctionCalls()
    7170{
    72   std::vector<std::pair<FunctionCall, std::pair<uint32_t, uint32_t> > >::iterator it = FunctionCallManager::sIncomingFunctionCallBuffer_.begin();
     71  std::vector<std::pair<FunctionCall, std::pair<uint32_t, uint32_t>>>::iterator it = FunctionCallManager::sIncomingFunctionCallBuffer_.begin();
    7372  while( it!=FunctionCallManager::sIncomingFunctionCallBuffer_.end() )
    7473  {
  • code/branches/cpp11_v3/src/libraries/network/FunctionCallManager.h

    r10624 r11054  
    5454
    5555  static std::map<uint32_t, packet::FunctionCalls*>                           sPeerMap_;
    56   static std::vector<std::pair<FunctionCall,std::pair<uint32_t, uint32_t> > > sIncomingFunctionCallBuffer_;
     56  static std::vector<std::pair<FunctionCall,std::pair<uint32_t, uint32_t>>> sIncomingFunctionCallBuffer_;
    5757protected:
    5858  FunctionCallManager();
  • code/branches/cpp11_v3/src/libraries/network/GamestateHandler.cc

    r7801 r11054  
    3232namespace orxonox {
    3333
    34 // GamestateHandler *GamestateHandler::instance_=0;
     34// GamestateHandler *GamestateHandler::instance_=nullptr;
    3535
    3636GamestateHandler::GamestateHandler()
  • code/branches/cpp11_v3/src/libraries/network/GamestateManager.cc

    r8858 r11054  
    6060{
    6161  GamestateManager::GamestateManager() :
    62   currentGamestate_(0), id_(0)
     62  currentGamestate_(nullptr), id_(0)
    6363  {
    6464//     trafficControl_ = new TrafficControl();
     
    7070  {
    7171    if( this->currentGamestate_ )
    72         delete this->currentGamestate_;std::map<unsigned int, packet::Gamestate*>::iterator it;
    73     for( it = gamestateQueue.begin(); it != gamestateQueue.end(); ++it )
    74       delete it->second;
    75     std::map<uint32_t, peerInfo>::iterator peerIt;
    76     std::map<uint32_t, packet::Gamestate*>::iterator gamestateIt;
    77     for( peerIt = peerMap_.begin(); peerIt != peerMap_.end(); ++peerIt )
    78     {
    79       for( gamestateIt = peerIt->second.gamestates.begin(); gamestateIt != peerIt->second.gamestates.end(); ++gamestateIt )
    80         delete gamestateIt->second;
     72        delete this->currentGamestate_;
     73    for( const auto& mapEntry : gamestateQueue )
     74      delete mapEntry.second;
     75    for( const auto& mapEntryPeer : peerMap_ )
     76    {
     77      for( const auto& mapEntryGamestate : mapEntryPeer.second.gamestates )
     78        delete mapEntryGamestate.second;
    8179    }
    8280//     this->trafficControl_->destroy();
     
    107105    if( this->gamestateQueue.empty() )
    108106        return true;
    109     std::map<unsigned int, packet::Gamestate*>::iterator it;
    110107    // now push only the most recent gamestates we received (ignore obsolete ones)
    111     for(it = gamestateQueue.begin(); it!=gamestateQueue.end(); it++)
    112     {
    113       OrxVerify(processGamestate(it->second), "ERROR: could not process Gamestate");
    114       sendAck( it->second->getID(), it->second->getPeerID() );
    115       delete it->second;
     108    for(const auto& mapEntry : gamestateQueue)
     109    {
     110      OrxVerify(processGamestate(mapEntry.second), "ERROR: could not process Gamestate");
     111      sendAck( mapEntry.second->getID(), mapEntry.second->getPeerID() );
     112      delete mapEntry.second;
    116113    }
    117114    // now clear the queue
     
    140137
    141138  bool GamestateManager::getSnapshot(){
    142     if ( currentGamestate_ != 0 )
     139    if ( currentGamestate_ != nullptr )
    143140      delete currentGamestate_;
    144141    uint8_t gsMode;
     
    165162    { //we have no data to send
    166163      delete currentGamestate_;
    167       currentGamestate_=0;
     164      currentGamestate_=nullptr;
    168165      return false;
    169166    }
     
    177174    std::vector<packet::Gamestate*> peerGamestates;
    178175   
    179     std::map<uint32_t, peerInfo>::iterator peerIt;
    180     for( peerIt=peerMap_.begin(); peerIt!=peerMap_.end(); ++peerIt )
    181     {
    182       if( !peerIt->second.isSynched )
     176    for( const auto& mapEntry : peerMap_ )
     177    {
     178      if( !mapEntry.second.isSynched )
    183179      {
    184180        orxout(verbose_more, context::network) << "Server: not sending gamestate" << endl;
    185181        continue;
    186182      }
    187       orxout(verbose_more, context::network) << "client id: " << peerIt->first << endl;
     183      orxout(verbose_more, context::network) << "client id: " << mapEntry.first << endl;
    188184      orxout(verbose_more, context::network) << "Server: doing gamestate gamestate preparation" << endl;
    189       int peerID = peerIt->first; //get client id
    190 
    191       unsigned int lastAckedGamestateID = peerIt->second.lastAckedGamestateID;
    192 
    193       packet::Gamestate* baseGamestate=0;
     185      int peerID = mapEntry.first; //get client id
     186
     187      unsigned int lastAckedGamestateID = mapEntry.second.lastAckedGamestateID;
     188
     189      packet::Gamestate* baseGamestate=nullptr;
    194190      if(lastAckedGamestateID != GAMESTATEID_INITIAL)
    195191      {
     
    200196      }
    201197
    202       peerGamestates.push_back(0);  // insert an empty gamestate* to be changed
     198      peerGamestates.push_back(nullptr);  // insert an empty gamestate* to be changed
    203199      finishGamestate( peerID, peerGamestates.back(), baseGamestate, currentGamestate_ );
    204       if( peerGamestates.back()==0 )
     200      if( peerGamestates.back()==nullptr )
    205201        // nothing to send to remove pointer from vector
    206202        peerGamestates.pop_back();
     
    243239      {
    244240        delete diffed1;
    245         destgamestate = 0;
     241        destgamestate = nullptr;
    246242        return;
    247243      }
     
    340336  {
    341337    assert(peerMap_.find(peerID)!=peerMap_.end());
    342     std::map<uint32_t, packet::Gamestate*>::iterator peerIt;
    343     for( peerIt = peerMap_[peerID].gamestates.begin(); peerIt!=peerMap_[peerID].gamestates.end(); ++peerIt )
    344     {
    345       delete peerIt->second;
     338    for( const auto& mapEntry : peerMap_[peerID].gamestates )
     339    {
     340      delete mapEntry.second;
    346341    }
    347342    peerMap_.erase(peerMap_.find(peerID));
     
    351346//   void GamestateManager::removeClient(ClientInformation* client){
    352347//     assert(client);
    353 //     std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> >::iterator clientMap = gamestateMap_.find(client->getID());
     348//     std::map<unsigned int, std::map<unsigned int, packet::Gamestate*>>::iterator clientMap = gamestateMap_.find(client->getID());
    354349//     // first delete all remained gamestates
    355350//     std::map<unsigned int, packet::Gamestate*>::iterator it;
  • code/branches/cpp11_v3/src/libraries/network/GamestateManager.h

    r10622 r11054  
    4747#include "core/CorePrereqs.h"
    4848#include "packet/Gamestate.h"
    49 #include <boost/concept_check.hpp>
    5049
    5150namespace orxonox
     
    8483    ~GamestateManager();
    8584
    86     virtual bool      addGamestate(packet::Gamestate *gs, unsigned int peerID);
    87     virtual bool      ackGamestate(unsigned int gamestateID, unsigned int peerID);
    88     virtual uint32_t  getLastReceivedGamestateID( unsigned int peerID );
    89     virtual uint32_t  getCurrentGamestateID(){ if( currentGamestate_) return currentGamestate_->getID(); else return GAMESTATEID_INITIAL; }
     85    virtual bool      addGamestate(packet::Gamestate *gs, unsigned int peerID) override;
     86    virtual bool      ackGamestate(unsigned int gamestateID, unsigned int peerID) override;
     87    virtual uint32_t  getLastReceivedGamestateID( unsigned int peerID ) override;
     88    virtual uint32_t  getCurrentGamestateID() override{ if( currentGamestate_) return currentGamestate_->getID(); else return GAMESTATEID_INITIAL; }
    9089
    9190    bool processGamestates();
     
    108107    bool processGamestate(packet::Gamestate *gs);
    109108
    110 //     std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> > gamestateMap_;
     109//     std::map<unsigned int, std::map<unsigned int, packet::Gamestate*>> gamestateMap_;
    111110    std::map<unsigned int, packet::Gamestate*> gamestateQueue;
    112111//     std::map<unsigned int, uint32_t> lastProcessedGamestateID_;
  • code/branches/cpp11_v3/src/libraries/network/Host.cc

    r10624 r11054  
    4444  SetConsoleCommand(__CC_printRTT_group, __CC_printRTT_name, &Host::printRTT);
    4545
    46   // Host*               Host::instance_=0;
     46  // Host*               Host::instance_=nullptr;
    4747  uint32_t            Host::clientID_s=0;
    4848//   uint32_t            Host::shipID_s=-1;
     
    5454  Host::Host()
    5555  {
    56   //   assert(instance_==0);
     56  //   assert(instance_==nullptr);
    5757    instances_s.push_back(this);
    5858    ModifyConsoleCommand(__CC_printRTT_group, __CC_printRTT_name).setObject(this);
     
    6262
    6363  /**
    64   * @brief Destructor: resets the instance pointer to 0
     64  * @brief Destructor: resets the instance pointer to nullptr
    6565  */
    6666  Host::~Host()
     
    6868    assert( std::find( instances_s.begin(), instances_s.end(), this )!=instances_s.end() );
    6969    instances_s.erase(std::find( instances_s.begin(), instances_s.end(), this ));
    70     ModifyConsoleCommand(__CC_printRTT_group, __CC_printRTT_name).setObject(0);
     70    ModifyConsoleCommand(__CC_printRTT_group, __CC_printRTT_name).setObject(nullptr);
    7171  }
    7272
     
    8080  void Host::addPacket(ENetPacket *packet, int clientID, uint8_t channelID)
    8181  {
    82     for( std::vector<Host*>::iterator it = instances_s.begin(); it!=instances_s.end(); ++it )
     82    for(Host* host : instances_s)
    8383    {
    84       if( (*it)->isActive() )
     84      if( host->isActive() )
    8585      {
    86         (*it)->queuePacket(packet, clientID, channelID);
     86        host->queuePacket(packet, clientID, channelID);
    8787      }
    8888    }
     
    9797  void Host::sendChat(const std::string& message, unsigned int sourceID, unsigned int targetID)
    9898  {
    99     for( std::vector<Host*>::iterator it = instances_s.begin(); it!=instances_s.end(); ++it )
    100       if( (*it)->isActive() )
    101         (*it)->doSendChat(message, sourceID, targetID);
     99    for(Host* host : instances_s)
     100      if( host->isActive() )
     101        host->doSendChat(message, sourceID, targetID);
    102102  }
    103103
     
    107107  void Host::doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID)
    108108  {
    109     for (ObjectList<NetworkChatListener>::iterator it = ObjectList<NetworkChatListener>::begin(); it != ObjectList<NetworkChatListener>::end(); ++it)
    110       it->incomingChat(message, sourceID);
     109    for (NetworkChatListener* listener : ObjectList<NetworkChatListener>())
     110      listener->incomingChat(message, sourceID);
    111111  }
    112112
     
    114114  bool Host::isServer()
    115115  {
    116     for (std::vector<Host*>::iterator it=instances_s.begin(); it!=instances_s.end(); ++it )
     116    for (Host* host : instances_s)
    117117    {
    118       if( (*it)->isActive() )
     118      if( host->isActive() )
    119119      {
    120         if( (*it)->isServer_() )
     120        if( host->isServer_() )
    121121          return true;
    122122      }
     
    135135        ++it;
    136136    }
    137     return 0;
     137    return nullptr;
    138138  }
    139139
  • code/branches/cpp11_v3/src/libraries/network/LANDiscoverable.cc

    r11009 r11054  
    4646  RegisterClassNoArgs(LANDiscoverable);
    4747
    48   LANDiscoverable::LANDiscoverable() : bActive_(false), host_(0)
     48  LANDiscoverable::LANDiscoverable() : bActive_(false), host_(nullptr)
    4949  {
    5050    /* register object in orxonox */
     
    8282      bindAddress.host = ENET_HOST_ANY;
    8383      bindAddress.port = LAN_DISCOVERY_PORT;
    84       assert( this->host_ == 0 );
     84      assert( this->host_ == nullptr );
    8585      this->host_ = enet_host_create( &bindAddress, 10, 0, 0, 0 );
    86       if ( this->host_ == NULL )
    87           orxout(internal_error, context::network) << "LANDiscoverable: host_ == NULL" << endl;
     86      if ( this->host_ == nullptr )
     87          orxout(internal_error, context::network) << "LANDiscoverable: host_ == nullptr" << endl;
    8888    }
    8989    else
    9090    {
    9191      enet_host_destroy( this->host_ );
    92       this->host_ = 0;
     92      this->host_ = nullptr;
    9393    }
    9494      this->bActive_ = bActive;
  • code/branches/cpp11_v3/src/libraries/network/LANDiscovery.cc

    r10624 r11054  
    4242  LANDiscovery::LANDiscovery()
    4343  {
    44     this->host_ = enet_host_create(NULL, 10, 0, 0, 0 );
    45     if ( this->host_ == NULL )
    46         orxout(internal_error, context::network) << "LANDiscovery: host_ == NULL" << endl;
     44    this->host_ = enet_host_create(nullptr, 10, 0, 0, 0 );
     45    if ( this->host_ == nullptr )
     46        orxout(internal_error, context::network) << "LANDiscovery: host_ == nullptr" << endl;
    4747  }
    4848
    4949  LANDiscovery::~LANDiscovery()
    5050  {
    51     if (this->host_ != NULL)
     51    if (this->host_ != nullptr)
    5252      enet_host_destroy(this->host_);
    5353  }
     
    6565    address.host = ENET_HOST_BROADCAST;
    6666    peer = enet_host_connect(this->host_, &address, 0, 0);
    67     if (peer == NULL)
     67    if (peer == nullptr)
    6868        orxout(internal_error, context::network) << "Could not send LAN discovery to IPv4 Broadcast." << endl;
    6969
     
    7171    enet_address_set_host(&address, "ff02::1"); // TODO: use a multicast group
    7272    peer = enet_host_connect(this->host_, &address, 0, 0);
    73     if (peer == NULL)
     73    if (peer == nullptr)
    7474        orxout(internal_error, context::network) << "Could not send LAN discovery to IPv6 Multicast." << endl;
    7575
  • code/branches/cpp11_v3/src/libraries/network/MasterServer.cc

    r10624 r11054  
    4343
    4444  /* forward declaration so the linker doesn't complain */
    45   MasterServer *MasterServer::instance = NULL;
     45  MasterServer *MasterServer::instance = nullptr;
    4646
    4747  /* command: list servers */
     
    4949  MasterServer::listServers( void )
    5050  {
    51     /* get an iterator */
    52     std::list<ServerListElem>::iterator i;
    53 
    5451    /* print list header */
    5552    orxout(user_info) << "List of connected servers" << std::endl;
    5653
    5754    /* loop through list elements */
    58     for( i = MasterServer::getInstance()->mainlist.serverlist.begin();
    59       i != MasterServer::getInstance()->mainlist.serverlist.end(); ++i )
     55    for( const ServerListElem& elem : MasterServer::getInstance()->mainlist.serverlist )
    6056    {
    61       orxout(user_info) << "  " << (*i).ServerInfo.getServerIP() << std::endl;
     57      orxout(user_info) << "  " << elem.ServerInfo.getServerIP() << std::endl;
    6258    }
    6359
     
    112108  MasterServer::helper_sendlist( ENetEvent *event )
    113109  {
    114     /* get an iterator */
    115     std::list<ServerListElem>::iterator i;
    116 
    117110    /* packet holder */
    118111    ENetPacket *reply;
    119112
    120113    /* loop through list elements */
    121     for( i = mainlist.serverlist.begin(); i
    122         != mainlist.serverlist.end(); ++i )
     114    for( const ServerListElem& elem : mainlist.serverlist )
    123115    {
    124116      /* send this particular server */
    125117      /* build reply string */
    126       int packetlen = MSPROTO_SERVERLIST_ITEM_LEN + 1 + (*i).ServerInfo.getServerIP().length() + 1 + (*i).ServerInfo.getServerName().length() + 1 + sizeof((*i).ServerInfo.getClientNumber()) + 1;
     118      int packetlen = MSPROTO_SERVERLIST_ITEM_LEN + 1 + elem.ServerInfo.getServerIP().length() + 1 + elem.ServerInfo.getServerName().length() + 1 + sizeof(elem.ServerInfo.getClientNumber()) + 1;
    127119      char *tosend = (char *)calloc(packetlen ,1 );
    128120      if( !tosend )
     
    131123      }
    132124      sprintf( tosend, "%s %s %s %u", MSPROTO_SERVERLIST_ITEM,
    133           (*i).ServerInfo.getServerIP().c_str(), (*i).ServerInfo.getServerName().c_str(), (*i).ServerInfo.getClientNumber());
     125          elem.ServerInfo.getServerIP().c_str(), elem.ServerInfo.getServerName().c_str(), elem.ServerInfo.getClientNumber());
    134126
    135127      /* create packet from it */
     
    167159  MasterServer::helper_cleanupServers( void )
    168160  {
    169     /* get an iterator */
    170     std::list<ServerListElem>::iterator i;
    171 
    172161    if( mainlist.serverlist.size() == 0 )
    173162      return;
    174163
    175164    /* loop through list elements */
    176     for( i = mainlist.serverlist.begin(); i
    177         != mainlist.serverlist.end(); ++i )
     165    for( const ServerListElem& elem : mainlist.serverlist )
    178166    { /* see if we have a disconnected peer */
    179       if( (*i).peer &&
    180          ((*i).peer->state == ENET_PEER_STATE_DISCONNECTED ||
    181           (*i).peer->state == ENET_PEER_STATE_ZOMBIE ))
     167      if( elem.peer &&
     168         (elem.peer->state == ENET_PEER_STATE_DISCONNECTED ||
     169          elem.peer->state == ENET_PEER_STATE_ZOMBIE ))
    182170      {
    183171        /* Remove it from the list */
    184         orxout(internal_warning) << (char*)(*i).peer->data << " timed out.\n";
    185         mainlist.delServerByName( (*i).ServerInfo.getServerName() );
     172        orxout(internal_warning) << (char*)elem.peer->data << " timed out.\n";
     173        mainlist.delServerByName( elem.ServerInfo.getServerName() );
    186174
    187175        /* stop iterating, we manipulated the list */
     
    345333    /***** ENTER MAIN LOOP *****/
    346334    ENetEvent *event = (ENetEvent *)calloc(sizeof(ENetEvent), sizeof(char));
    347     if( event == NULL )
     335    if( event == nullptr )
    348336    {
    349337      orxout(user_error, context::master_server) << "Could not create ENetEvent structure, exiting." << endl;
  • code/branches/cpp11_v3/src/libraries/network/MasterServerComm.cc

    r8858 r11054  
    5454
    5555    /* initiate the client */
    56     this->client = enet_host_create( NULL /* create a client host */,
     56    this->client = enet_host_create( nullptr /* create a client host */,
    5757        1,
    5858        2, /* allow up 2 channels to be used, 0 and 1 */
     
    6161
    6262    /* see if it worked */
    63     if (this->client == NULL)
     63    if (this->client == nullptr)
    6464    { orxout(internal_error, context::master_server) << "An error occurred while trying to create an "
    6565        << "ENet client host." << endl;
     
    8585    this->peer = enet_host_connect(this->client, &this->address, 2, 0);   
    8686
    87     if( this->peer == NULL )
     87    if( this->peer == nullptr )
    8888    { orxout(internal_error, context::master_server) << "No available peers for initiating an ENet"
    8989        << " connection." << endl;
     
    157157
    158158    /* address buffer */
    159     char *addrconv = NULL;
     159    char *addrconv = nullptr;
    160160    int retval = 0;
    161161
     
    193193
    194194          /* call the supplied callback, if any. */
    195           if( listener != NULL )
     195          if( listener != nullptr )
    196196            retval = listener->rhandler( addrconv, &(this->event) );
    197197
  • code/branches/cpp11_v3/src/libraries/network/NetworkFunction.h

    r10624 r11054  
    4545
    4646#if defined(ORXONOX_COMPILER_GCC) && defined(ORXONOX_ARCH_32)
    47 static const unsigned int MAX_FUNCTION_POINTER_SIZE = 8;
     47static constexpr unsigned int MAX_FUNCTION_POINTER_SIZE = 8;
    4848#else
    49 static const unsigned int MAX_FUNCTION_POINTER_SIZE = 16;
     49static constexpr unsigned int MAX_FUNCTION_POINTER_SIZE = 16;
    5050#endif //ORXONOX_COMPILER_GCC
    51 static const unsigned int MAX_FUNCTION_POINTER_INTS = (MAX_FUNCTION_POINTER_SIZE-1)/4+1;
     51static constexpr unsigned int MAX_FUNCTION_POINTER_INTS = (MAX_FUNCTION_POINTER_SIZE-1)/4+1;
    5252
    5353struct _NetworkExport NetworkFunctionPointer {
     
    114114
    115115    // ignore the objectID because its a static function
    116     virtual bool call(uint32_t objectID){ (*this->functor_)(); return true; }
    117     virtual bool call(uint32_t objectID, const MultiType& mt1){ (*this->functor_)(mt1); return true; }
    118     virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2){ (*this->functor_)(mt1, mt2); return true; }
    119     virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3){ (*this->functor_)(mt1, mt2, mt3); return true; }
    120     virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4){ (*this->functor_)(mt1, mt2, mt3, mt4); return true; }
    121     virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5){ (*this->functor_)(mt1, mt2, mt3, mt4, mt5); return true; }
     116    virtual bool call(uint32_t objectID) override{ (*this->functor_)(); return true; }
     117    virtual bool call(uint32_t objectID, const MultiType& mt1) override{ (*this->functor_)(mt1); return true; }
     118    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2) override{ (*this->functor_)(mt1, mt2); return true; }
     119    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3) override{ (*this->functor_)(mt1, mt2, mt3); return true; }
     120    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4) override{ (*this->functor_)(mt1, mt2, mt3, mt4); return true; }
     121    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5) override{ (*this->functor_)(mt1, mt2, mt3, mt4, mt5); return true; }
    122122
    123123  private:
     
    142142    { }
    143143
    144     inline bool call(uint32_t objectID)
    145     {
    146       if ( Synchronisable::getSynchronisable(objectID)!=0 )
     144    virtual inline bool call(uint32_t objectID) override
     145    {
     146      if ( Synchronisable::getSynchronisable(objectID)!=nullptr )
    147147      {
    148148        (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)));
     
    152152        return false;
    153153    }
    154     inline bool call(uint32_t objectID, const MultiType& mt1)
    155     {
    156       if ( Synchronisable::getSynchronisable(objectID)!=0 )
     154    virtual inline bool call(uint32_t objectID, const MultiType& mt1) override
     155    {
     156      if ( Synchronisable::getSynchronisable(objectID)!=nullptr )
    157157      {
    158158        (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1);
     
    162162        return false;
    163163    }
    164     inline bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2)
    165     {
    166       if ( Synchronisable::getSynchronisable(objectID)!=0 )
     164    virtual inline bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2) override
     165    {
     166      if ( Synchronisable::getSynchronisable(objectID)!=nullptr )
    167167      {
    168168        (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2);
     
    172172        return false;
    173173    }
    174     inline bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
    175     {
    176       if ( Synchronisable::getSynchronisable(objectID)!=0 )
     174    virtual inline bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3) override
     175    {
     176      if ( Synchronisable::getSynchronisable(objectID)!=nullptr )
    177177      {
    178178        (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3);
     
    182182        return false;
    183183    }
    184     inline bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
    185     {
    186       if ( Synchronisable::getSynchronisable(objectID)!=0 )
     184    virtual inline bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4) override
     185    {
     186      if ( Synchronisable::getSynchronisable(objectID)!=nullptr )
    187187      {
    188188        (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3, mt4);
     
    192192        return false;
    193193    }
    194     inline bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
    195     {
    196       if ( Synchronisable::getSynchronisable(objectID)!=0 )
     194    virtual inline bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5) override
     195    {
     196      if ( Synchronisable::getSynchronisable(objectID)!=nullptr )
    197197      {
    198198        (*this->functor_)(orxonox_cast<T*>(Synchronisable::getSynchronisable(objectID)), mt1, mt2, mt3, mt4, mt5);
  • code/branches/cpp11_v3/src/libraries/network/NetworkFunctionIncludes.h

    r11052 r11054  
    3333
    3434#include <boost/preprocessor/cat.hpp>
    35 #include <boost/static_assert.hpp>
    3635
    3736#include "NetworkFunction.h"
     
    5756            ~StaticallyInitializedNetworkFunction() { delete function_; }
    5857
    59             virtual void load();
    60             virtual void unload();
     58            virtual void load() override;
     59            virtual void unload() override;
    6160
    6261            inline NetworkFunctionBase& getFunction()
     
    7271    inline NetworkFunctionBase* registerStaticNetworkFunctionFct(PT ptr, const std::string& name)
    7372    {
    74         BOOST_STATIC_ASSERT(sizeof(PT) <= sizeof(NetworkFunctionPointer)); // if this fails your compiler uses bigger pointers for static functions than defined above
     73        static_assert(sizeof(PT) <= sizeof(NetworkFunctionPointer), "check pointer size"); // if this fails your compiler uses bigger pointers for static functions than defined above
    7574        NetworkFunctionPointer destptr;
    7675        copyPtr(ptr, destptr);
     
    8180    inline NetworkFunctionBase* registerMemberNetworkFunctionFct(PT ptr, const std::string& name)
    8281    {
    83         BOOST_STATIC_ASSERT(sizeof(PT) <= sizeof(NetworkFunctionPointer)); // if this fails your compiler uses bigger pointers for a specific kind of member functions than defined above
     82        static_assert(sizeof(PT) <= sizeof(NetworkFunctionPointer), "check pointer size"); // if this fails your compiler uses bigger pointers for a specific kind of member functions than defined above
    8483        NetworkFunctionPointer destptr;
    8584        copyPtr(ptr, destptr);
  • code/branches/cpp11_v3/src/libraries/network/NetworkFunctionManager.cc

    r11052 r11054  
    3232namespace orxonox
    3333{
    34     NetworkFunctionManager* NetworkFunctionManager::singletonPtr_s = 0;
     34    NetworkFunctionManager* NetworkFunctionManager::singletonPtr_s = nullptr;
    3535
    3636    void NetworkFunctionManager::registerFunction(NetworkFunctionBase* function)
     
    7171            return it->second;
    7272        else
    73             return NULL;
     73            return nullptr;
    7474    }
    7575
  • code/branches/cpp11_v3/src/libraries/network/NetworkPrereqs.h

    r10624 r11054  
    6767namespace orxonox
    6868{
    69   static const unsigned int GAMESTATEID_INITIAL       = static_cast<unsigned int>(-1);
     69  static constexpr unsigned int GAMESTATEID_INITIAL       = static_cast<unsigned int>(-1);
    7070  extern const char* LAN_DISCOVERY_MESSAGE;
    7171  extern const char* LAN_DISCOVERY_ACK;
    72   static const unsigned int LAN_DISCOVERY_PORT          = 55558;
    73   static const unsigned int NETWORK_PEER_ID_SERVER      = 0;
    74   static const unsigned int NETWORK_PEER_ID_BROADCAST   = static_cast<unsigned int>(-1);
    75   static const unsigned int NETWORK_PEER_ID_UNKNOWN     = static_cast<unsigned int>(-2);
    76   static const unsigned int NETWORK_CHANNEL_DEFAULT     = 0;
    77   static const unsigned int NETWORK_CHANNEL_UNRELIABLE  = 1;
    78   static const unsigned int NETWORK_CHANNEL_COUNT       = 2;
     72  static constexpr unsigned int LAN_DISCOVERY_PORT          = 55558;
     73  static constexpr unsigned int NETWORK_PEER_ID_SERVER      = 0;
     74  static constexpr unsigned int NETWORK_PEER_ID_BROADCAST   = static_cast<unsigned int>(-1);
     75  static constexpr unsigned int NETWORK_PEER_ID_UNKNOWN     = static_cast<unsigned int>(-2);
     76  static constexpr unsigned int NETWORK_CHANNEL_DEFAULT     = 0;
     77  static constexpr unsigned int NETWORK_CHANNEL_UNRELIABLE  = 1;
     78  static constexpr unsigned int NETWORK_CHANNEL_COUNT       = 2;
    7979}
    8080
  • code/branches/cpp11_v3/src/libraries/network/NetworkStaticInitializationHandler.h

    r10624 r11054  
    3939    {
    4040        public:
    41             virtual void setupHandler();
    42             virtual void shutdownHandler();
     41            virtual void setupHandler() override;
     42            virtual void shutdownHandler() override;
    4343
    44             virtual void loadModule(ModuleInstance* module);
    45             virtual void unloadModule(ModuleInstance* module);
     44            virtual void loadModule(ModuleInstance* module) override;
     45            virtual void unloadModule(ModuleInstance* module) override;
    4646    };
    4747}
  • code/branches/cpp11_v3/src/libraries/network/PeerList.cc

    r10622 r11054  
    4141  PeerList::addPeer( ENetPeer *toadd )
    4242  { /* error correction */
    43     if( toadd == NULL )
     43    if( toadd == nullptr )
    4444    { orxout(internal_error, context::master_server) << "PeerList::addPeer: empty peer given." << endl;
    4545      return -1;
     
    6565  bool
    6666  PeerList::remPeerByAddr( ENetAddress addr )
    67   { /* get an iterator */
    68     std::list<ENetPeer *>::iterator i;
    69 
     67  {
    7068    /* loop through list elements */
    71     for( i = peerlist.begin(); i != peerlist.end(); ++i )
    72       if( !sub_compAddr((*i)->address, addr ) )
     69    for( ENetPeer* peer : peerlist )
     70      if( !sub_compAddr(peer->address, addr ) )
    7371      { /* found this name, remove and quit */
    74         this->peerlist.remove( *i );
     72        this->peerlist.remove( peer );
    7573        return true;
    7674      }
     
    8280  ENetPeer *
    8381  PeerList::findPeerByAddr( ENetAddress addr )
    84   { /* get an iterator */
    85     std::list<ENetPeer *>::iterator i;
    86 
     82  {
    8783    /* loop through list elements */
    88     for( i = peerlist.begin(); i != peerlist.end(); ++i )
    89       if( !sub_compAddr((*i)->address, addr ) )
     84    for( ENetPeer* peer : peerlist )
     85      if( !sub_compAddr(peer->address, addr ) )
    9086        /* found this name, remove and quit */
    91         return *i;
     87        return peer;
    9288
    9389    /* not found */
    94     return NULL;
     90    return nullptr;
    9591  }
    9692
  • code/branches/cpp11_v3/src/libraries/network/Server.cc

    r10622 r11054  
    194194  void Server::printRTT()
    195195  {
    196 //     for( ClientInformation* temp=ClientInformation::getBegin(); temp!=0; temp=temp->next() )
     196//     for( ClientInformation* temp=ClientInformation::getBegin(); temp!=nullptr; temp=temp->next() )
    197197//       orxout(message) << "Round trip time to client with ID: " << temp->getID() << " is " << temp->getRTT() << " ms" << endl;
    198198  }
     
    232232  {
    233233    std::vector<packet::Gamestate*> gamestates = GamestateManager::getGamestates();
    234     std::vector<packet::Gamestate*>::iterator it;
    235     for( it = gamestates.begin(); it != gamestates.end(); ++it )
     234    for( packet::Gamestate* gamestate : gamestates )
    236235    {
    237       (*it)->send(static_cast<Host*>(this));
     236      gamestate->send(static_cast<Host*>(this));
    238237    }
    239238    return true;
     
    244243  {
    245244//     ClientInformation *temp = ClientInformation::getBegin();
    246 //     if( temp == NULL )
     245//     if( temp == nullptr )
    247246      //no client connected
    248247    if( this->clientIDs_.size()==0 )
     
    255254    }
    256255//     orxout(verbose, context::network) << "sending DeleteObjects" << endl;
    257 //     while(temp != NULL){
     256//     while(temp != nullptr){
    258257//       if( !(temp->getSynched()) )
    259258//       {
     
    434433      return true;
    435434
    436     std::vector<uint32_t>::iterator it;
    437     for( it=this->clientIDs_.begin(); it!=this->clientIDs_.end(); ++it )
    438       if( *it == targetID )
     435    for( uint32_t id : this->clientIDs_ )
     436      if( id == targetID )
    439437        return true;
    440438
  • code/branches/cpp11_v3/src/libraries/network/Server.h

    r10622 r11054  
    6161    void open();
    6262    void close();
    63     void queuePacket(ENetPacket *packet, int clientID, uint8_t channelID);
    64     virtual bool sendPacket( packet::Packet* packet ){ return packet->send( static_cast<Host*>(this) ); }
     63    virtual void queuePacket(ENetPacket *packet, int clientID, uint8_t channelID) override;
     64    virtual bool sendPacket( packet::Packet* packet ) override{ return packet->send( static_cast<Host*>(this) ); }
    6565    void update(const Clock& time);
    6666    unsigned int getRTT(unsigned int clientID);
    67     virtual void printRTT();
     67    virtual void printRTT() override;
    6868    float getPacketLoss(unsigned int clientID);
    6969    int getClientCount() { return this->clientIDs_.size();}
     
    7373    void updateGamestate();
    7474  private:
    75     virtual bool isServer_(){return true;}
     75    virtual bool isServer_() override{return true;}
    7676    unsigned int playerID(){return 0;}
    7777
    78     void addPeer(uint32_t peerID);
    79     void removePeer(uint32_t peerID);
    80     void processPacket(packet::Packet* packet);
     78    virtual void addPeer(uint32_t peerID) override;
     79    virtual void removePeer(uint32_t peerID) override;
     80    virtual void processPacket(packet::Packet* packet) override;
    8181
    8282    bool createClient(int clientID);
     
    8585    bool sendObjectDeletes();
    8686    bool isValidTarget(unsigned int targetID);
    87     virtual void doSendChat(const std::string& message, unsigned int sourceID, unsigned int targetID);
    88     virtual void doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID);
     87    virtual void doSendChat(const std::string& message, unsigned int sourceID, unsigned int targetID) override;
     88    virtual void doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID) override;
    8989    void syncClassid(unsigned int clientID);
    9090
  • code/branches/cpp11_v3/src/libraries/network/ServerConnection.cc

    r8858 r11054  
    7373    this->host_ = enet_host_create(this->bindAddress_, NETWORK_MAX_CONNECTIONS, NETWORK_CHANNEL_COUNT, 0, 0);
    7474   
    75     if ( this->host_ == NULL )
     75    if ( this->host_ == nullptr )
    7676    {
    77         orxout(internal_error, context::network) << "ServerConnection: host_ == NULL" << endl;
     77        orxout(internal_error, context::network) << "ServerConnection: host_ == nullptr" << endl;
    7878        return false;
    7979    }
  • code/branches/cpp11_v3/src/libraries/network/TrafficControl.cc

    r9667 r11054  
    3030
    3131#include <cassert>
    32 #include <boost/bind.hpp>
     32#include <functional>
    3333
    3434#include "core/CoreIncludes.h"
     
    3838namespace orxonox {
    3939
    40   static const unsigned int SCHED_PRIORITY_OFFSET = static_cast<unsigned int>(-1);
     40  static constexpr unsigned int SCHED_PRIORITY_OFFSET = static_cast<unsigned int>(-1);
     41  namespace arg = std::placeholders;
    4142
    4243  objInfo::objInfo(uint32_t ID, uint32_t creatorID, int32_t curGsID, int32_t diffGsID, uint32_t size, unsigned int prioperm, unsigned int priosched)
     
    6465*Initializing protected members
    6566*/
    66     TrafficControl *TrafficControl::instance_=0;
     67    TrafficControl *TrafficControl::instance_=nullptr;
    6768
    6869    /**
     
    7273    {
    7374    RegisterObject(TrafficControl);
    74       assert(instance_==0);
     75      assert(instance_==nullptr);
    7576      instance_=this;
    7677    this->setConfigValues();
     
    7879
    7980    /**
    80     * @brief Destructor: resets the instance pointer to 0
     81    * @brief Destructor: resets the instance pointer to nullptr
    8182    */
    8283    TrafficControl::~TrafficControl()
    8384    {
    84       instance_=0;
     85      instance_=nullptr;
    8586    }
    8687
     
    148149    // shortcut for maps
    149150    std::map<unsigned int, objInfo >& objectListPerm = clientListPerm_[clientID];
    150     std::map<unsigned int, std::list<obj> >& objectListTemp = clientListTemp_[clientID];
     151    std::map<unsigned int, std::list<obj>>& objectListTemp = clientListTemp_[clientID];
    151152
    152153    for(itvec = objectListTemp[gamestateID].begin(); itvec != objectListTemp[gamestateID].end(); itvec++)
     
    180181    void TrafficControl::insertinClientListPerm(unsigned int clientID, obj objinf)
    181182    {
    182       std::map<unsigned int,std::map<unsigned int, objInfo> >::iterator itperm;//iterator clientListPerm over clientIDs
     183      std::map<unsigned int,std::map<unsigned int, objInfo>>::iterator itperm;//iterator clientListPerm over clientIDs
    183184    unsigned int gsid=GAMESTATEID_INITIAL, gsdiff=currentGamestateID, prioperm=Synchronisable::getSynchronisable(objinf.objID)->getPriority(), priomom=0;
    184185    clientListPerm_[clientID][objinf.objID] = objInfo(objinf.objID, objinf.objCreatorID,gsid,gsdiff, objinf.objSize,prioperm,priomom);
     
    258259
    259260      //sort copied list according to priorities
    260       // use boost bind here because we need to pass a memberfunction to stl sort
    261 //       sort( list.begin(), list.end(), boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
    262       list.sort( boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
    263 
    264 //       list.sort(boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
     261      // use std::bind here because we need to pass a memberfunction to stl sort
     262//       sort( list.begin(), list.end(), std::bind(&TrafficControl::prioritySort, this, clientID, arg::_1, arg::_2) );
     263      list.sort( std::bind(&TrafficControl::prioritySort, this, clientID, arg::_1, arg::_2) );
     264
     265//       list.sort(std::bind(&TrafficControl::prioritySort, this, clientID, arg::_1, arg::_2) );
    265266
    266267      //now we check, that the creator of an object always exists on a client
     
    275276      cut(list, targetSize);
    276277      //now sort again after objDataOffset
    277 //       sort(list.begin(), list.end(), boost::bind(&TrafficControl::dataSort, this, _1, _2) );
    278       list.sort( boost::bind(&TrafficControl::dataSort, this, _1, _2) );
     278//       sort(list.begin(), list.end(), std::bind(&TrafficControl::dataSort, this, arg::_1, arg::_2) );
     279      list.sort( std::bind(&TrafficControl::dataSort, this, arg::_1, arg::_2) );
    279280
    280281      //diese Funktion updateClientList muss noch gemacht werden
  • code/branches/cpp11_v3/src/libraries/network/TrafficControl.h

    r6746 r11054  
    8282    *permanent client list: contains client ids, object ids and objectInfos (in this order)
    8383    */
    84     std::map<unsigned int, std::map<unsigned int, objInfo > > clientListPerm_;
     84    std::map<unsigned int, std::map<unsigned int, objInfo >> clientListPerm_;
    8585    //has to be created with constructor and then needs to be updated by evaluateList().
    8686
     
    8888    *temporary client list: contains client ids, gamestate ids and object ids (in this order)
    8989    */
    90     std::map<unsigned int, std::map<unsigned int, std::list<obj> > > clientListTemp_;
     90    std::map<unsigned int, std::map<unsigned int, std::list<obj>>> clientListTemp_;
    9191
    9292    /**updateReferenceList
     
    109109
    110110    //ClientConnectionListener functions
    111     virtual void clientConnected(unsigned int clientID){};
    112     virtual void clientDisconnected(unsigned int clientID);
     111    virtual void clientConnected(unsigned int clientID) override{};
     112    virtual void clientDisconnected(unsigned int clientID) override;
    113113
    114114
  • code/branches/cpp11_v3/src/libraries/network/packet/Acknowledgement.h

    r7801 r11054  
    4646  ~Acknowledgement();
    4747
    48   inline unsigned int getSize() const;
    49   virtual bool process(orxonox::Host* host);
     48  virtual inline unsigned int getSize() const override;
     49  virtual bool process(orxonox::Host* host) override;
    5050
    5151  unsigned int getAckID();
  • code/branches/cpp11_v3/src/libraries/network/packet/Chat.h

    r8858 r11054  
    4949
    5050  /* get size of packet */
    51   inline unsigned int getSize() const;
     51  virtual inline unsigned int getSize() const override;
    5252
    5353  /* process chat message packet and remove it afterwards */
    54   virtual bool process(orxonox::Host* host);
     54  virtual bool process(orxonox::Host* host) override;
    5555
    5656  /* Get the length of the message (not the full size of the packet) */
  • code/branches/cpp11_v3/src/libraries/network/packet/ClassID.cc

    r9667 r11054  
    5252  uint32_t network_id;
    5353  flags_ = flags_ | PACKET_FLAGS_CLASSID;
    54   std::queue<std::pair<uint32_t, std::string> > tempQueue;
     54  std::queue<std::pair<uint32_t, std::string>> tempQueue;
    5555
    5656  //calculate total needed size (for all strings and integers)
    57   std::map<std::string, Identifier*>::const_iterator it = IdentifierManager::getInstance().getIdentifierByStringMap().begin();
    58   for(;it != IdentifierManager::getInstance().getIdentifierByStringMap().end();++it){
    59     id = it->second;
    60     if(id == NULL || !id->hasFactory())
     57  for(const auto& mapEntry : IdentifierManager::getInstance().getIdentifierByStringMap()){
     58    id = mapEntry.second;
     59    if(id == nullptr || !id->hasFactory())
    6160      continue;
    6261    const std::string& classname = id->getName();
     
    144143    id=ClassByString( std::string((const char*)classname) );
    145144    orxout(internal_info, context::packets) << "processing classid: " << networkID << " name: " << classname << " id: " << id << endl;
    146     if(id==NULL){
     145    if(id==nullptr){
    147146      orxout(user_error, context::packets) << "Received a bad classname" << endl;
    148147      abort();
  • code/branches/cpp11_v3/src/libraries/network/packet/ClassID.h

    r7801 r11054  
    4747  ~ClassID();
    4848
    49   uint32_t getSize() const;
    50   virtual bool process(orxonox::Host* host);
     49  virtual uint32_t getSize() const override;
     50  virtual bool process(orxonox::Host* host) override;
    5151
    5252private:
  • code/branches/cpp11_v3/src/libraries/network/packet/DeleteObjects.h

    r7801 r11054  
    4848  bool fetchIDs();
    4949
    50   inline unsigned int getSize() const;
    51   virtual bool process(orxonox::Host* host);
     50  virtual inline unsigned int getSize() const override;
     51  virtual bool process(orxonox::Host* host) override;
    5252
    5353private:
  • code/branches/cpp11_v3/src/libraries/network/packet/FunctionCalls.h

    r10624 r11054  
    5252  ~FunctionCalls();
    5353
    54   inline unsigned int getSize() const
     54  virtual inline unsigned int getSize() const override
    5555    { assert(!this->isDataENetAllocated()); return currentSize_; }
    56   virtual bool process(orxonox::Host* host);
     56  virtual bool process(orxonox::Host* host) override;
    5757
    5858  void addCall( uint32_t networkID, uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5);
    59   virtual bool send(orxonox::Host* host);
     59  virtual bool send(orxonox::Host* host) override;
    6060private:
    6161  std::queue<orxonox::FunctionCall> functionCalls_;
  • code/branches/cpp11_v3/src/libraries/network/packet/FunctionIDs.cc

    r10624 r11054  
    5353  uint32_t networkID;
    5454  flags_ = flags_ | PACKET_FLAGS_FUNCTIONIDS;
    55   std::queue<std::pair<uint32_t, std::string> > tempQueue;
     55  std::queue<std::pair<uint32_t, std::string>> tempQueue;
    5656
    5757  //calculate total needed size (for all strings and integers)
  • code/branches/cpp11_v3/src/libraries/network/packet/FunctionIDs.h

    r7801 r11054  
    4747  ~FunctionIDs();
    4848
    49   virtual uint32_t getSize() const;
    50   virtual bool process(orxonox::Host* host);
     49  virtual uint32_t getSize() const override;
     50  virtual bool process(orxonox::Host* host) override;
    5151
    5252private:
  • code/branches/cpp11_v3/src/libraries/network/packet/Gamestate.cc

    r9667 r11054  
    106106{
    107107  uint32_t tempsize=0, currentsize=0;
    108   assert(data_==0);
     108  assert(data_==nullptr);
    109109  uint32_t size = calcGamestateSize(id, mode);
    110110
     
    126126  mem += GamestateHeader::getSize();
    127127  ObjectList<Synchronisable>::iterator it;
    128   for(it = ObjectList<Synchronisable>::begin(); it; ++it)
     128  for(it = ObjectList<Synchronisable>().begin(); it; ++it)
    129129  {
    130130
     
    133133    tempsize = it->getData(mem, this->sizes_, id, mode);
    134134    if ( tempsize != 0 )
    135       dataVector_.push_back( obj(it->getObjectID(), it->getContextID(), tempsize, mem-data_) );
     135      dataVector_.emplace_back(it->getObjectID(), it->getContextID(), tempsize, mem-data_);
    136136
    137137#ifndef NDEBUG
     
    213213  {
    214214    std::list<uint32_t> v1;
    215     ObjectList<Synchronisable>::iterator it;
    216     for (it = ObjectList<Synchronisable>::begin(); it != ObjectList<Synchronisable>::end(); ++it)
    217     {
    218       if (it->getObjectID() == OBJECTID_UNKNOWN)
    219       {
    220         if (it->objectMode_ != 0x0)
     215    for (Synchronisable* synchronisable : ObjectList<Synchronisable>())
     216    {
     217      if (synchronisable->getObjectID() == OBJECTID_UNKNOWN)
     218      {
     219        if (synchronisable->objectMode_ != 0x0)
    221220        {
    222221          orxout(user_error, context::packets) << "Found object with OBJECTID_UNKNOWN on the client with objectMode != 0x0!" << endl;
    223222          orxout(user_error, context::packets) << "Possible reason for this error: Client created a synchronized object without the Server's approval." << endl;
    224           orxout(user_error, context::packets) << "Objects class: " << it->getIdentifier()->getName() << endl;
     223          orxout(user_error, context::packets) << "Objects class: " << synchronisable->getIdentifier()->getName() << endl;
    225224          assert(false);
    226225        }
     
    228227      else
    229228      {
    230         std::list<uint32_t>::iterator it2;
    231         for (it2 = v1.begin(); it2 != v1.end(); ++it2)
     229        for (uint32_t id : v1)
    232230        {
    233           if (it->getObjectID() == *it2)
     231          if (synchronisable->getObjectID() == id)
    234232          {
    235233            orxout(user_error, context::packets) << "Found duplicate objectIDs on the client!" << endl
     
    239237          }
    240238        }
    241         v1.push_back(it->getObjectID());
     239        v1.push_back(synchronisable->getObjectID());
    242240      }
    243241    }
     
    608606
    609607  if(dest_length==0)
    610     return NULL;
     608    return nullptr;
    611609
    612610  uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+GamestateHeader::getSize()];
     
    645643
    646644  if(dest_length==0)
    647     return NULL;
     645    return nullptr;
    648646
    649647  uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+GamestateHeader::getSize()];
     
    762760  uint32_t size = 0;
    763761  uint32_t nrOfVariables = 0;
    764     // get the start of the Synchronisable list
    765   ObjectList<Synchronisable>::iterator it;
    766762    // get total size of gamestate
    767   for(it = ObjectList<Synchronisable>::begin(); it; ++it){
    768     size+=it->getSize(id, mode); // size of the actual data of the synchronisable
    769     nrOfVariables += it->getNrOfVariables();
     763  for(Synchronisable* synchronisable : ObjectList<Synchronisable>()){
     764    size+=synchronisable->getSize(id, mode); // size of the actual data of the synchronisable
     765    nrOfVariables += synchronisable->getNrOfVariables();
    770766  }
    771767//   orxout() << "allocating " << nrOfVariables << " ints" << endl;
  • code/branches/cpp11_v3/src/libraries/network/packet/Gamestate.h

    r7801 r11054  
    4848{
    4949   
    50 static const uint8_t GAMESTATE_MODE_SERVER = 0x1;
    51 static const uint8_t GAMESTATE_MODE_CLIENT = 0x2;
     50static constexpr uint8_t GAMESTATE_MODE_SERVER = 0x1;
     51static constexpr uint8_t GAMESTATE_MODE_CLIENT = 0x2;
    5252
    5353class _NetworkExport GamestateHeader
    5454{
    5555  public:
    56     GamestateHeader(){ data_=0; }
     56    GamestateHeader(){ data_=nullptr; }
    5757    GamestateHeader(uint8_t* data)
    5858      { assert(data); data_ = data; *(uint32_t*)data_ = Type::Gamestate; }
     
    138138//     void rawDiff( uint8_t* newdata, uint8_t* data, uint8_t* basedata, uint32_t datalength, uint32_t baselength);
    139139//     inline uint32_t findObject( const SynchronisableHeader& header, uint8_t* mem, uint32_t dataLength, uint32_t startPosition = 0 );
    140     virtual uint32_t getSize() const;
    141     virtual bool process(orxonox::Host* host);
     140    virtual uint32_t getSize() const override;
     141    virtual bool process(orxonox::Host* host) override;
    142142    uint32_t calcGamestateSize(uint32_t id, uint8_t mode=0x0);
    143143//     inline void diffObject( uint8_t*& newData, uint8_t*& origData, uint8_t*& baseData, SynchronisableHeader& objectHeader, std::vector<uint32_t>::iterator& sizes );
  • code/branches/cpp11_v3/src/libraries/network/packet/Packet.cc

    r8858 r11054  
    3434#define WIN32_LEAN_AND_MEAN
    3535#include <enet/enet.h>
    36 #include <boost/static_assert.hpp>
    3736#include <boost/thread/mutex.hpp>
    3837
     
    5453
    5554// Make sure we assume the right values
    56 BOOST_STATIC_ASSERT(static_cast<int>(PacketFlag::Reliable)    == static_cast<int>(ENET_PACKET_FLAG_RELIABLE));
    57 BOOST_STATIC_ASSERT(static_cast<int>(PacketFlag::Unsequenced) == static_cast<int>(ENET_PACKET_FLAG_UNSEQUENCED));
    58 BOOST_STATIC_ASSERT(static_cast<int>(PacketFlag::NoAllocate)  == static_cast<int>(ENET_PACKET_FLAG_NO_ALLOCATE));
     55static_assert(static_cast<int>(PacketFlag::Reliable)    == static_cast<int>(ENET_PACKET_FLAG_RELIABLE),    "check enum");
     56static_assert(static_cast<int>(PacketFlag::Unsequenced) == static_cast<int>(ENET_PACKET_FLAG_UNSEQUENCED), "check enum");
     57static_assert(static_cast<int>(PacketFlag::NoAllocate)  == static_cast<int>(ENET_PACKET_FLAG_NO_ALLOCATE), "check enum");
    5958
    6059#define PACKET_FLAG_DEFAULT PacketFlag::NoAllocate
     
    6968  packetDirection_ = Direction::Outgoing;
    7069  peerID_=0;
    71   data_=0;
    72   enetPacket_=0;
     70  data_=nullptr;
     71  enetPacket_=nullptr;
    7372  bDataENetAllocated_ = false;
    7473}
     
    8079  peerID_=peerID;
    8180  data_=data;
    82   enetPacket_=0;
     81  enetPacket_=nullptr;
    8382  bDataENetAllocated_ = false;
    8483}
     
    9594    memcpy(data_, p.data_, p.getSize());
    9695  }else
    97     data_=0;
     96    data_=nullptr;
    9897  bDataENetAllocated_ = p.bDataENetAllocated_;
    9998}
     
    122121  // Destroy the ENetPacket if necessary.
    123122  // Note: For the case ENet used the callback to destroy the packet, we have already set
    124   // enetPacket_ to NULL to avoid destroying it again.
     123  // enetPacket_ to nullptr to avoid destroying it again.
    125124  if (this->enetPacket_)
    126125  {
     
    175174#endif
    176175//  ENetPacket *temp = enetPacket_;
    177 //  enetPacket_ = 0; // otherwise we have a double free because enet already handles the deallocation of the packet
     176//  enetPacket_ = nullptr; // otherwise we have a double free because enet already handles the deallocation of the packet
    178177  if( this->flags_ & PacketFlag::Reliable )
    179178    host->addPacket( enetPacket_, peerID_, NETWORK_CHANNEL_DEFAULT);
     
    191190//   if( peerID==static_cast<unsigned int>(-2))
    192191//     peerID = NETWORK_PEER_ID_SERVER;
    193   Packet *p = 0;
     192  Packet *p = nullptr;
    194193//   orxout(verbose_ultra, context::packets) << "packet type: " << *(Type::Value *)&data[_PACKETID] << endl;
    195194  switch( *(Type::Value *)(data + _PACKETID) )
     
    251250  assert(it != packetMap_.end());
    252251  // Make sure we don't delete it again in the destructor
    253   it->second->enetPacket_ = 0;
     252  it->second->enetPacket_ = nullptr;
    254253  delete it->second;
    255254  packetMap_.erase(it);
  • code/branches/cpp11_v3/src/libraries/network/packet/ServerInformation.cc

    r10622 r11054  
    8787  } // namespace packet
    8888
    89   std::ostream& operator<<(std::ostream& out, const ENetAddress& address)
    90   {
    91       char addr[64];
    92       if (!enet_address_get_host_ip(&address, addr, 64))
    93           out << addr;
    94       return out;
    95   }
    9689} // namespace orxonox
     90
     91std::ostream& operator<<(std::ostream& out, const ENetAddress& address)
     92{
     93    char addr[64];
     94    if (!enet_address_get_host_ip(&address, addr, 64))
     95        out << addr;
     96    return out;
     97}
  • code/branches/cpp11_v3/src/libraries/network/packet/ServerInformation.h

    r10622 r11054  
    5050        void          send( ENetPeer* peer );
    5151        void          setServerName(std::string name) { this->serverName_ = name; }
    52         std::string   getServerName() { return this->serverName_; }
     52        std::string   getServerName() const { return this->serverName_; }
    5353        void          setServerIP( std::string IP ) { this->serverIP_ = IP; }
    54         std::string   getServerIP() { return this->serverIP_; }
     54        std::string   getServerIP() const { return this->serverIP_; }
    5555        void          setClientNumber( int clientNumber ) { this->clientNumber_ = clientNumber; }
    56         int           getClientNumber() { return this->clientNumber_; }
    57         uint32_t      getServerRTT() { return this->serverRTT_; }
     56        int           getClientNumber() const { return this->clientNumber_; }
     57        uint32_t      getServerRTT() const { return this->serverRTT_; }
    5858
    5959      private:
     
    6666  }
    6767
    68   _NetworkExport std::ostream& operator<<(std::ostream& out, const ENetAddress& address);
    6968}
    7069
     70_NetworkExport std::ostream& operator<<(std::ostream& out, const ENetAddress& address);
     71
    7172#endif // SERVERINFORMATION_H
  • code/branches/cpp11_v3/src/libraries/network/packet/Welcome.h

    r8706 r11054  
    4545  virtual ~Welcome();
    4646
    47   uint8_t *getData();
    48   inline unsigned int getSize() const;
    49   virtual bool process(orxonox::Host* host);
     47  virtual uint8_t *getData() override;
     48  virtual inline unsigned int getSize() const override;
     49  virtual bool process(orxonox::Host* host) override;
    5050
    5151private:
  • code/branches/cpp11_v3/src/libraries/network/synchronisable/NetworkCallback.h

    r6417 r11054  
    5353      NetworkCallback(T* object, void (T::*function) (void)) : object_(object), function_(function) {}
    5454      virtual ~NetworkCallback() {}
    55       virtual void call()
     55      virtual void call() override
    5656        { (this->object_->*function_)(); }
    5757
     
    6868      NetworkCallbackNotify() {}
    6969      virtual ~NetworkCallbackNotify() {}
    70       virtual void call()
     70      virtual void call() override
    7171        { (this->object_->*function_)( this->oldValue_ ); }
    7272      void setOldValue(const U& value){ this->oldValue_ = value; }
  • code/branches/cpp11_v3/src/libraries/network/synchronisable/Serialise.h

    r10624 r11054  
    9090    {
    9191//         *const_cast<typename Loki::TypeTraits<T*>::UnqualifiedType*>(&variable) = dynamic_cast<T*>(variable->getSynchronisable( *(uint32_t*)(mem) ));
    92         *const_cast<typename Loki::TypeTraits<StrongPtr<T> >::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem)));
     92        *const_cast<typename Loki::TypeTraits<StrongPtr<T>>::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem)));
    9393        mem += returnSize( variable );
    9494    }
     
    125125    {
    126126        //         *const_cast<typename Loki::TypeTraits<T*>::UnqualifiedType*>(&variable) = dynamic_cast<T*>(variable->getSynchronisable( *(uint32_t*)(mem) ));
    127         *const_cast<typename Loki::TypeTraits<WeakPtr<T> >::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem)));
     127        *const_cast<typename Loki::TypeTraits<WeakPtr<T>>::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem)));
    128128        mem += returnSize( variable );
    129129    }
  • code/branches/cpp11_v3/src/libraries/network/synchronisable/Synchronisable.cc

    r10624 r11054  
    8888    }
    8989    // delete all Synchronisable Variables from syncList_ ( which are also in stringList_ )
    90     for(std::vector<SynchronisableVariableBase*>::iterator it = syncList_.begin(); it!=syncList_.end(); it++)
    91       delete (*it);
     90    for(SynchronisableVariableBase* variable : syncList_)
     91      delete variable;
    9292    syncList_.clear();
    9393    stringList_.clear();
     
    105105  uint32_t Synchronisable::findContextID(Context* context)
    106106  {
    107       if (context == NULL)
     107      if (context == nullptr)
    108108          return OBJECTID_UNKNOWN;
    109109
    110110      Synchronisable* synchronisableContext = orxonox_cast<Synchronisable*>(context);
    111       if (synchronisableContext != NULL)
     111      if (synchronisableContext != nullptr)
    112112          return synchronisableContext->getObjectID();
    113113      else
     
    140140    {
    141141      mem += header.getDataSize() + header.getSize();
    142       return 0;
     142      return nullptr;
    143143    }
    144144//     assert( !header.isDiffed() );
     
    156156    }
    157157    assert(id);
    158     Context* context = 0;
     158    Context* context = nullptr;
    159159    if (header.getContextID() != OBJECTID_UNKNOWN)
    160160    {
     
    164164        mem += header.getDataSize()+SynchronisableHeader::getSize(); //.TODO: this suckz.... remove size from header
    165165        assert(0); // TODO: uncomment this if we have a clean objecthierarchy (with destruction of children of objects) ^^
    166         return 0;
     166        return nullptr;
    167167      }
    168168      else
     
    172172      context = Context::getRootContext();
    173173
    174     assert(getSynchronisable(header.getObjectID())==0);   //make sure no object with this id exists
     174    assert(getSynchronisable(header.getObjectID())==nullptr);   //make sure no object with this id exists
    175175    BaseObject *bo = orxonox_cast<BaseObject*>(id->fabricate(context));
    176176    assert(bo);
     
    226226      return it1->second;
    227227    // if the objects not in the map it should'nt exist at all anymore
    228     return NULL;
     228    return nullptr;
    229229  }
    230230
     
    266266    assert(this->classID_==this->getIdentifier()->getNetworkID());
    267267    assert(this->objectID_!=OBJECTID_UNKNOWN);
    268     std::vector<SynchronisableVariableBase*>::iterator i;
    269268
    270269    // start copy header
     
    276275//     orxout(verbose, context::network) << "objectid: " << this->objectID_ << ":";
    277276    // copy to location
    278     for(i=syncList_.begin(); i!=syncList_.end(); ++i)
    279     {
    280       uint32_t varsize = (*i)->getData( mem, mode );
     277    for(SynchronisableVariableBase* variable : syncList_)
     278    {
     279      uint32_t varsize = variable->getData( mem, mode );
    281280//       orxout(verbose, context::network) << " " << varsize;
    282281      tempsize += varsize;
     
    348347      assert( this->getContextID() == syncHeader2.getContextID() );
    349348      mem += SynchronisableHeader::getSize();
    350       std::vector<SynchronisableVariableBase *>::iterator i;
    351       for(i=syncList_.begin(); i!=syncList_.end(); ++i)
     349      for(SynchronisableVariableBase* variable : syncList_)
    352350      {
    353351        assert( mem <= data+syncHeader2.getDataSize()+SynchronisableHeader::getSize() ); // always make sure we don't exceed the datasize in our stream
    354         (*i)->putData( mem, mode, forceCallback );
     352        variable->putData( mem, mode, forceCallback );
    355353      }
    356354      assert(mem == data+syncHeaderLight.getDataSize()+SynchronisableHeader::getSize() );
     
    388386    assert( mode==state_ );
    389387    tsize += this->dataSize_;
    390     std::vector<SynchronisableVariableBase*>::iterator i;
    391     for(i=stringList_.begin(); i!=stringList_.end(); ++i)
    392     {
    393       tsize += (*i)->getSize( mode );
     388    for(SynchronisableVariableBase* variable : stringList_)
     389    {
     390      tsize += variable->getSize( mode );
    394391    }
    395392    return tsize;
  • code/branches/cpp11_v3/src/libraries/network/synchronisable/Synchronisable.h

    r9667 r11054  
    171171  protected:
    172172    Synchronisable(Context* context);
    173     template <class T> void registerVariable(T& variable, uint8_t mode=0x1, NetworkCallbackBase *cb=0, bool bidirectional=false);
    174     template <class T> void registerVariable(std::set<T>& variable, uint8_t mode=0x1, NetworkCallbackBase *cb=0, bool bidirectional=false);
     173    template <class T> void registerVariable(T& variable, uint8_t mode=0x1, NetworkCallbackBase *cb=nullptr, bool bidirectional=false);
     174    template <class T> void registerVariable(std::set<T>& variable, uint8_t mode=0x1, NetworkCallbackBase *cb=nullptr, bool bidirectional=false);
    175175    template <class T> void unregisterVariable(T& var);
    176176
     
    242242    SynchronisableVariableBase* sv;
    243243    if (bidirectional)
    244       sv = new SynchronisableVariableBidirectional<std::set<T> >(variable, mode, cb);
     244      sv = new SynchronisableVariableBidirectional<std::set<T>>(variable, mode, cb);
    245245    else
    246       sv = new SynchronisableVariable<std::set<T> >(variable, mode, cb);
     246      sv = new SynchronisableVariable<std::set<T>>(variable, mode, cb);
    247247    syncList_.push_back(sv);
    248248    stringList_.push_back(sv);
     
    250250
    251251  template <> _NetworkExport void Synchronisable::registerVariable( std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional);
    252 //   template <class T> _NetworkExport void Synchronisable::registerVariable<std::set<T> >( std::set<T>& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional);
     252//   template <class T> _NetworkExport void Synchronisable::registerVariable<std::set<T>>( std::set<T>& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional);
    253253  template <> _NetworkExport void Synchronisable::unregisterVariable( std::string& variable );
    254254
  • code/branches/cpp11_v3/src/libraries/network/synchronisable/SynchronisableVariable.h

    r10624 r11054  
    7171  {
    7272    public:
    73       SynchronisableVariable(T& variable, uint8_t syncDirection=VariableDirection::ToClient, NetworkCallbackBase *cb=0);
     73      SynchronisableVariable(T& variable, uint8_t syncDirection=VariableDirection::ToClient, NetworkCallbackBase *cb=nullptr);
    7474      virtual ~SynchronisableVariable();
    7575
    76       virtual inline uint8_t getMode(){ return mode_; }
    77       virtual inline uint32_t getData(uint8_t*& mem, uint8_t mode);
    78       virtual inline void putData(uint8_t*& mem, uint8_t mode, bool forceCallback = false);
    79       virtual inline uint32_t getSize(uint8_t mode);
    80       virtual inline void* getReference(){ return static_cast<void*>(const_cast<typename Loki::TypeTraits<T>::UnqualifiedType*>(&this->variable_)); }
     76      virtual inline uint8_t getMode() override{ return mode_; }
     77      virtual inline uint32_t getData(uint8_t*& mem, uint8_t mode) override;
     78      virtual inline void putData(uint8_t*& mem, uint8_t mode, bool forceCallback = false) override;
     79      virtual inline uint32_t getSize(uint8_t mode) override;
     80      virtual inline void* getReference() override{ return static_cast<void*>(const_cast<typename Loki::TypeTraits<T>::UnqualifiedType*>(&this->variable_)); }
    8181    protected:
    8282      T&                       variable_;
     
    8989  {
    9090    public:
    91       SynchronisableVariableBidirectional(T& variable, uint8_t master=Bidirectionality::ServerMaster, NetworkCallbackBase *cb=0);
     91      SynchronisableVariableBidirectional(T& variable, uint8_t master=Bidirectionality::ServerMaster, NetworkCallbackBase *cb=nullptr);
    9292      virtual ~SynchronisableVariableBidirectional();
    9393
Note: See TracChangeset for help on using the changeset viewer.