Index: code/trunk/src/network/TrafficControl.cc
===================================================================
--- code/trunk/src/network/TrafficControl.cc	(revision 2896)
+++ code/trunk/src/network/TrafficControl.cc	(revision 3084)
@@ -21,5 +21,5 @@
  *
  *   Author:
- *      Oliver Scheuss <scheusso [at] ee.ethz.ch>, (C) 2008
+ *      Oliver Scheuss <scheusso [at] ee.ethz.ch>
  *   Co-authors:
  *      ...
@@ -91,6 +91,6 @@
   void TrafficControl::setConfigValues()
   {
-    SetConfigValue ( bActive_, true );
-    SetConfigValue ( targetSize, 5000 );
+    SetConfigValue ( bActive_, false );
+    SetConfigValue ( targetSize, 10000 );
   }
 
@@ -121,7 +121,6 @@
 
 
-	void TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std::list<obj> *list)
-	{
-// 	  copiedVector = *list;
+	void TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std::list<obj>& list)
+	{
 	  currentClientID=clientID;
 	  currentGamestateID=gamestateID;
@@ -143,24 +142,28 @@
     assert(clientListTemp_.find(clientID) != clientListTemp_.end() );
     assert(clientListPerm_.find(clientID) != clientListPerm_.end() );
-	  assert( clientListTemp_[clientID].find(gamestateID) != clientListTemp_[clientID].end() );
-
-    for(itvec = clientListTemp_[clientID][gamestateID].begin(); itvec != clientListTemp_[clientID][gamestateID].end(); itvec++)
+    assert( clientListTemp_[clientID].find(gamestateID) != clientListTemp_[clientID].end() );
+    
+    // shortcut for maps
+    std::map<unsigned int, objInfo >& objectListPerm = clientListPerm_[clientID];
+    std::map<unsigned int, std::list<obj> >& objectListTemp = clientListTemp_[clientID];
+
+    for(itvec = objectListTemp[gamestateID].begin(); itvec != objectListTemp[gamestateID].end(); itvec++)
 	  {
-      if(clientListPerm_[clientID].find((*itvec).objID) != clientListPerm_[clientID].end()) // check whether the obj already exists in our lists
-      {
-        clientListPerm_[clientID][(*itvec).objID].objCurGS = gamestateID;
-        clientListPerm_[clientID][(*itvec).objID].objValueSched = 0; //set scheduling value back
+      if(objectListPerm.find((*itvec).objID) != objectListPerm.end()) // check whether the obj already exists in our lists
+      {
+        objectListPerm[(*itvec).objID].objCurGS = gamestateID;
+        objectListPerm[(*itvec).objID].objValueSched = 0; //set scheduling value back
       }
       else
       {
         assert(0);
-        clientListPerm_[clientID][(*itvec).objID].objCurGS = gamestateID;
-        clientListPerm_[clientID][(*itvec).objID].objID = (*itvec).objID;
-        clientListPerm_[clientID][(*itvec).objID].objCreatorID = (*itvec).objCreatorID;
-        clientListPerm_[clientID][(*itvec).objID].objSize = (*itvec).objSize;
+        objectListPerm[(*itvec).objID].objCurGS = gamestateID;
+        objectListPerm[(*itvec).objID].objID = (*itvec).objID;
+        objectListPerm[(*itvec).objID].objCreatorID = (*itvec).objCreatorID;
+        objectListPerm[(*itvec).objID].objSize = (*itvec).objSize;
       }
 	  }
 	   // remove temporary list (with acked objects) from the map
-    clientListTemp_[clientID].erase( clientListTemp_[clientID].find(gamestateID) );
+    objectListTemp.erase( objectListTemp.find(gamestateID) );
 	}
 
@@ -176,10 +179,6 @@
 	{
 	  std::map<unsigned int,std::map<unsigned int, objInfo> >::iterator itperm;//iterator clientListPerm over clientIDs
-// 	  itperm = (clientListPerm_).find(clientID);
-// 	  assert(itperm != clientListPerm_.end() );
     unsigned int gsid=GAMESTATEID_INITIAL, gsdiff=currentGamestateID, prioperm=Synchronisable::getSynchronisable(objinf.objID)->getPriority(), priomom=0;
     clientListPerm_[clientID][objinf.objID] = objInfo(objinf.objID, objinf.objCreatorID,gsid,gsdiff, objinf.objSize,prioperm,priomom);
-// 	  itperm->second.insert(std::pair<unsigned int, objInfo>(objid,objinf));
-//     permObjPrio_.insert(objid, objinf.objValuePerm);
 	}
 
@@ -188,7 +187,7 @@
   * takes the shortened list which will be sent to the gsmanager and puts the *info into clientListTemp
   */
-  void TrafficControl::updateClientListTemp(std::list<obj> *list)
-  {
-    clientListTemp_[currentClientID][currentGamestateID] = std::list<obj>(*list);
+  void TrafficControl::updateClientListTemp(std::list<obj>& list)
+  {
+    clientListTemp_[currentClientID][currentGamestateID] = std::list<obj>(list);
   }
 
@@ -197,10 +196,10 @@
   *takes the current list that has to be returned to the gsmanager and shortens it in criteria of bandwidth of clientID(XY)
   */
-  void TrafficControl::cut(std::list<obj> *list, unsigned int targetsize)
+  void TrafficControl::cut(std::list<obj>& list, unsigned int targetsize)
   {
     unsigned int size=0;
     std::list<obj>::iterator itvec, ittemp;
-    assert(!list->empty());
-    for(itvec = list->begin(); itvec != list->end();)
+    assert(!list.empty());
+    for(itvec = list.begin(); itvec != list.end();)
     {
       assert( (*itvec).objSize < 1000);
@@ -213,9 +212,10 @@
       {
         clientListPerm_[currentClientID][(*itvec).objID].objValueSched += SCHED_PRIORITY_OFFSET; // NOTE: SCHED_PRIORITY_OFFSET is negative
-        list->erase(itvec++);
+        list.erase(itvec, list.end());
+        break;
       }
 //       printList(list, currentClientID);
     }
-    assert(!list->empty());
+    assert(!list.empty());
   }
 
@@ -224,5 +224,5 @@
 	*evaluateList evaluates whether new obj are there, whether there are things to be updatet and manipulates all this.
 	*/
-	void TrafficControl::evaluateList(unsigned int clientID, std::list<obj> *list)
+	void TrafficControl::evaluateList(unsigned int clientID, std::list<obj>& list)
 	{
 
@@ -232,11 +232,14 @@
     //if listToProcess contains new Objects, add them to clientListPerm
     std::list<obj>::iterator itvec;
-	  for( itvec=list->begin(); itvec != list->end(); itvec++)
+    
+    std::map<unsigned int, objInfo >& objectListPerm = clientListPerm_[clientID];
+    
+	  for( itvec=list.begin(); itvec != list.end(); itvec++)
 	  {
-	    if ( clientListPerm_[clientID].find( (*itvec).objID) != clientListPerm_[clientID].end() )
+	    if ( objectListPerm.find( (*itvec).objID) != objectListPerm.end() )
       {
         // we already have the object in our map
         //obj bleibt in liste und permanente prio wird berechnet
-        clientListPerm_[clientID][(*itvec).objID].objDiffGS = currentGamestateID - clientListPerm_[clientID][(*itvec).objID].objCurGS;
+        objectListPerm[(*itvec).objID].objDiffGS = currentGamestateID - objectListPerm[(*itvec).objID].objCurGS;
         continue;//check next objId
       }
@@ -254,9 +257,12 @@
       //sort copied list according to priorities
       // use boost bind here because we need to pass a memberfunction to stl sort
-      list->sort(boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
+//       sort( list.begin(), list.end(), boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
+      list.sort( boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
+      
+//       list.sort(boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
 
       //now we check, that the creator of an object always exists on a client
       std::list<obj>::iterator itcreator;
-      for(itvec = list->begin(); itvec != list->end(); itvec++)
+      for(itvec = list.begin(); itvec != list.end(); itvec++)
       {
         fixCreatorDependencies(itvec, list, clientID);
@@ -266,7 +272,7 @@
 //       printList(list, clientID);
       cut(list, targetSize);
-
       //now sort again after objDataOffset
-      list->sort(boost::bind(&TrafficControl::dataSort, this, _1, _2) );
+//       sort(list.begin(), list.end(), boost::bind(&TrafficControl::dataSort, this, _1, _2) );
+      list.sort( boost::bind(&TrafficControl::dataSort, this, _1, _2) );
     }
     //diese Funktion updateClientList muss noch gemacht werden
@@ -275,13 +281,13 @@
   }
 
-  void TrafficControl::printList(std::list<obj> *list, unsigned int clientID)
+  void TrafficControl::printList(std::list<obj>& list, unsigned int clientID)
   {
     std::list<obj>::iterator it;
     COUT(0) << "=========== Objectlist ===========" << endl;
-    for( it=list->begin(); it!=list->end(); it++)
+    for( it=list.begin(); it!=list.end(); it++)
       COUT(0) << "ObjectID: " << (*it).objID << " creatorID: " << (*it).objCreatorID << " Priority: " << clientListPerm_[clientID][(*it).objID].objValuePerm + clientListPerm_[clientID][(*it).objID].objValueSched << " size: " << (*it).objSize << endl;
   }
 
-  void TrafficControl::fixCreatorDependencies(std::list<obj>::iterator it1, std::list<obj> *list, unsigned int clientID)
+  void TrafficControl::fixCreatorDependencies(std::list<obj>::iterator it1, std::list<obj>& list, unsigned int clientID)
   {
     if ( (*it1).objCreatorID == OBJECTID_UNKNOWN )
@@ -290,10 +296,10 @@
       return;
     std::list<obj>::iterator it2, it3=it1;
-    for( it2 = ++it3; it2 != list->end(); it2++ )
+    for( it2 = ++it3; it2 != list.end(); it2++ )
     {
       if( (*it2).objID == (*it1).objCreatorID )
       {
-        it3 = list->insert(it1, *it2); //insert creator before it1
-        list->erase(it2);
+        it3 = list.insert(it1, *it2); //insert creator before it1
+        list.erase(it2);
 //         printList(list, clientID);
         fixCreatorDependencies( it3, list, clientID );
