Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 5, 2015, 10:47:51 PM (9 years ago)
Author:
landauf
Message:

use range-based for-loop where it makes sense (e.g. ObjectList)

Location:
code/branches/cpp11_v2/src/libraries/network/packet
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v2/src/libraries/network/packet/ClassID.cc

    r10769 r10919  
    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;
     57  for(const auto& mapEntry : IdentifierManager::getInstance().getIdentifierByStringMap()){
     58    id = mapEntry.second;
    6059    if(id == nullptr || !id->hasFactory())
    6160      continue;
  • code/branches/cpp11_v2/src/libraries/network/packet/Gamestate.cc

    r10918 r10919  
    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    }
     
    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_v2/src/libraries/network/packet/ServerInformation.h

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