Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 26, 2009, 9:20:57 PM (15 years ago)
Author:
landauf
Message:

merged netp3 branch back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/network/TrafficControl.cc

    r2896 r3084  
    2121 *
    2222 *   Author:
    23  *      Oliver Scheuss <scheusso [at] ee.ethz.ch>, (C) 2008
     23 *      Oliver Scheuss <scheusso [at] ee.ethz.ch>
    2424 *   Co-authors:
    2525 *      ...
     
    9191  void TrafficControl::setConfigValues()
    9292  {
    93     SetConfigValue ( bActive_, true );
    94     SetConfigValue ( targetSize, 5000 );
     93    SetConfigValue ( bActive_, false );
     94    SetConfigValue ( targetSize, 10000 );
    9595  }
    9696
     
    121121
    122122
    123         void TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std::list<obj> *list)
    124         {
    125 //        copiedVector = *list;
     123        void TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std::list<obj>& list)
     124        {
    126125          currentClientID=clientID;
    127126          currentGamestateID=gamestateID;
     
    143142    assert(clientListTemp_.find(clientID) != clientListTemp_.end() );
    144143    assert(clientListPerm_.find(clientID) != clientListPerm_.end() );
    145           assert( clientListTemp_[clientID].find(gamestateID) != clientListTemp_[clientID].end() );
    146 
    147     for(itvec = clientListTemp_[clientID][gamestateID].begin(); itvec != clientListTemp_[clientID][gamestateID].end(); itvec++)
     144    assert( clientListTemp_[clientID].find(gamestateID) != clientListTemp_[clientID].end() );
     145   
     146    // shortcut for maps
     147    std::map<unsigned int, objInfo >& objectListPerm = clientListPerm_[clientID];
     148    std::map<unsigned int, std::list<obj> >& objectListTemp = clientListTemp_[clientID];
     149
     150    for(itvec = objectListTemp[gamestateID].begin(); itvec != objectListTemp[gamestateID].end(); itvec++)
    148151          {
    149       if(clientListPerm_[clientID].find((*itvec).objID) != clientListPerm_[clientID].end()) // check whether the obj already exists in our lists
    150       {
    151         clientListPerm_[clientID][(*itvec).objID].objCurGS = gamestateID;
    152         clientListPerm_[clientID][(*itvec).objID].objValueSched = 0; //set scheduling value back
     152      if(objectListPerm.find((*itvec).objID) != objectListPerm.end()) // check whether the obj already exists in our lists
     153      {
     154        objectListPerm[(*itvec).objID].objCurGS = gamestateID;
     155        objectListPerm[(*itvec).objID].objValueSched = 0; //set scheduling value back
    153156      }
    154157      else
    155158      {
    156159        assert(0);
    157         clientListPerm_[clientID][(*itvec).objID].objCurGS = gamestateID;
    158         clientListPerm_[clientID][(*itvec).objID].objID = (*itvec).objID;
    159         clientListPerm_[clientID][(*itvec).objID].objCreatorID = (*itvec).objCreatorID;
    160         clientListPerm_[clientID][(*itvec).objID].objSize = (*itvec).objSize;
     160        objectListPerm[(*itvec).objID].objCurGS = gamestateID;
     161        objectListPerm[(*itvec).objID].objID = (*itvec).objID;
     162        objectListPerm[(*itvec).objID].objCreatorID = (*itvec).objCreatorID;
     163        objectListPerm[(*itvec).objID].objSize = (*itvec).objSize;
    161164      }
    162165          }
    163166           // remove temporary list (with acked objects) from the map
    164     clientListTemp_[clientID].erase( clientListTemp_[clientID].find(gamestateID) );
     167    objectListTemp.erase( objectListTemp.find(gamestateID) );
    165168        }
    166169
     
    176179        {
    177180          std::map<unsigned int,std::map<unsigned int, objInfo> >::iterator itperm;//iterator clientListPerm over clientIDs
    178 //        itperm = (clientListPerm_).find(clientID);
    179 //        assert(itperm != clientListPerm_.end() );
    180181    unsigned int gsid=GAMESTATEID_INITIAL, gsdiff=currentGamestateID, prioperm=Synchronisable::getSynchronisable(objinf.objID)->getPriority(), priomom=0;
    181182    clientListPerm_[clientID][objinf.objID] = objInfo(objinf.objID, objinf.objCreatorID,gsid,gsdiff, objinf.objSize,prioperm,priomom);
    182 //        itperm->second.insert(std::pair<unsigned int, objInfo>(objid,objinf));
    183 //     permObjPrio_.insert(objid, objinf.objValuePerm);
    184183        }
    185184
     
    188187  * takes the shortened list which will be sent to the gsmanager and puts the *info into clientListTemp
    189188  */
    190   void TrafficControl::updateClientListTemp(std::list<obj> *list)
    191   {
    192     clientListTemp_[currentClientID][currentGamestateID] = std::list<obj>(*list);
     189  void TrafficControl::updateClientListTemp(std::list<obj>& list)
     190  {
     191    clientListTemp_[currentClientID][currentGamestateID] = std::list<obj>(list);
    193192  }
    194193
     
    197196  *takes the current list that has to be returned to the gsmanager and shortens it in criteria of bandwidth of clientID(XY)
    198197  */
    199   void TrafficControl::cut(std::list<obj> *list, unsigned int targetsize)
     198  void TrafficControl::cut(std::list<obj>& list, unsigned int targetsize)
    200199  {
    201200    unsigned int size=0;
    202201    std::list<obj>::iterator itvec, ittemp;
    203     assert(!list->empty());
    204     for(itvec = list->begin(); itvec != list->end();)
     202    assert(!list.empty());
     203    for(itvec = list.begin(); itvec != list.end();)
    205204    {
    206205      assert( (*itvec).objSize < 1000);
     
    213212      {
    214213        clientListPerm_[currentClientID][(*itvec).objID].objValueSched += SCHED_PRIORITY_OFFSET; // NOTE: SCHED_PRIORITY_OFFSET is negative
    215         list->erase(itvec++);
     214        list.erase(itvec, list.end());
     215        break;
    216216      }
    217217//       printList(list, currentClientID);
    218218    }
    219     assert(!list->empty());
     219    assert(!list.empty());
    220220  }
    221221
     
    224224        *evaluateList evaluates whether new obj are there, whether there are things to be updatet and manipulates all this.
    225225        */
    226         void TrafficControl::evaluateList(unsigned int clientID, std::list<obj> *list)
     226        void TrafficControl::evaluateList(unsigned int clientID, std::list<obj>& list)
    227227        {
    228228
     
    232232    //if listToProcess contains new Objects, add them to clientListPerm
    233233    std::list<obj>::iterator itvec;
    234           for( itvec=list->begin(); itvec != list->end(); itvec++)
     234   
     235    std::map<unsigned int, objInfo >& objectListPerm = clientListPerm_[clientID];
     236   
     237          for( itvec=list.begin(); itvec != list.end(); itvec++)
    235238          {
    236             if ( clientListPerm_[clientID].find( (*itvec).objID) != clientListPerm_[clientID].end() )
     239            if ( objectListPerm.find( (*itvec).objID) != objectListPerm.end() )
    237240      {
    238241        // we already have the object in our map
    239242        //obj bleibt in liste und permanente prio wird berechnet
    240         clientListPerm_[clientID][(*itvec).objID].objDiffGS = currentGamestateID - clientListPerm_[clientID][(*itvec).objID].objCurGS;
     243        objectListPerm[(*itvec).objID].objDiffGS = currentGamestateID - objectListPerm[(*itvec).objID].objCurGS;
    241244        continue;//check next objId
    242245      }
     
    254257      //sort copied list according to priorities
    255258      // use boost bind here because we need to pass a memberfunction to stl sort
    256       list->sort(boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
     259//       sort( list.begin(), list.end(), boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
     260      list.sort( boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
     261     
     262//       list.sort(boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
    257263
    258264      //now we check, that the creator of an object always exists on a client
    259265      std::list<obj>::iterator itcreator;
    260       for(itvec = list->begin(); itvec != list->end(); itvec++)
     266      for(itvec = list.begin(); itvec != list.end(); itvec++)
    261267      {
    262268        fixCreatorDependencies(itvec, list, clientID);
     
    266272//       printList(list, clientID);
    267273      cut(list, targetSize);
    268 
    269274      //now sort again after objDataOffset
    270       list->sort(boost::bind(&TrafficControl::dataSort, this, _1, _2) );
     275//       sort(list.begin(), list.end(), boost::bind(&TrafficControl::dataSort, this, _1, _2) );
     276      list.sort( boost::bind(&TrafficControl::dataSort, this, _1, _2) );
    271277    }
    272278    //diese Funktion updateClientList muss noch gemacht werden
     
    275281  }
    276282
    277   void TrafficControl::printList(std::list<obj> *list, unsigned int clientID)
     283  void TrafficControl::printList(std::list<obj>& list, unsigned int clientID)
    278284  {
    279285    std::list<obj>::iterator it;
    280286    COUT(0) << "=========== Objectlist ===========" << endl;
    281     for( it=list->begin(); it!=list->end(); it++)
     287    for( it=list.begin(); it!=list.end(); it++)
    282288      COUT(0) << "ObjectID: " << (*it).objID << " creatorID: " << (*it).objCreatorID << " Priority: " << clientListPerm_[clientID][(*it).objID].objValuePerm + clientListPerm_[clientID][(*it).objID].objValueSched << " size: " << (*it).objSize << endl;
    283289  }
    284290
    285   void TrafficControl::fixCreatorDependencies(std::list<obj>::iterator it1, std::list<obj> *list, unsigned int clientID)
     291  void TrafficControl::fixCreatorDependencies(std::list<obj>::iterator it1, std::list<obj>& list, unsigned int clientID)
    286292  {
    287293    if ( (*it1).objCreatorID == OBJECTID_UNKNOWN )
     
    290296      return;
    291297    std::list<obj>::iterator it2, it3=it1;
    292     for( it2 = ++it3; it2 != list->end(); it2++ )
     298    for( it2 = ++it3; it2 != list.end(); it2++ )
    293299    {
    294300      if( (*it2).objID == (*it1).objCreatorID )
    295301      {
    296         it3 = list->insert(it1, *it2); //insert creator before it1
    297         list->erase(it2);
     302        it3 = list.insert(it1, *it2); //insert creator before it1
     303        list.erase(it2);
    298304//         printList(list, clientID);
    299305        fixCreatorDependencies( it3, list, clientID );
Note: See TracChangeset for help on using the changeset viewer.