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:
15 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v3

  • 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:
Note: See TracChangeset for help on using the changeset viewer.