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)

File:
1 edited

Legend:

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

    r10769 r10919  
    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
     
    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;
     185      int peerID = mapEntry.first; //get client id
     186
     187      unsigned int lastAckedGamestateID = mapEntry.second.lastAckedGamestateID;
    192188
    193189      packet::Gamestate* baseGamestate=nullptr;
     
    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));
Note: See TracChangeset for help on using the changeset viewer.