Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 17, 2016, 10:29:21 PM (8 years ago)
Author:
landauf
Message:

merged branch cpp11_v3 back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/network/Host.cc

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