Index: code/branches/bugger/src/network/GamestateManager.cc
===================================================================
--- code/branches/bugger/src/network/GamestateManager.cc	(revision 2531)
+++ code/branches/bugger/src/network/GamestateManager.cc	(revision 2532)
@@ -57,7 +57,9 @@
   GamestateManager::GamestateManager() {
     id_=0;
+    trafficControl_ = new TrafficControl();
   }
 
   GamestateManager::~GamestateManager() {
+    delete trafficControl_;
   }
 
@@ -185,4 +187,5 @@
     }
     temp->setGamestateID(gamestateID);
+    TrafficControl::processAck(clientID, gamestateID);
     return true;
   }
Index: code/branches/bugger/src/network/GamestateManager.h
===================================================================
--- code/branches/bugger/src/network/GamestateManager.h	(revision 2531)
+++ code/branches/bugger/src/network/GamestateManager.h	(revision 2532)
@@ -43,4 +43,5 @@
 #include "NetworkPrereqs.h"
 #include "GamestateHandler.h"
+#include "TrafficControl.h"
 #include <map>
 
@@ -89,4 +90,5 @@
     std::map<unsigned int, packet::Gamestate*> gamestateQueue;
     packet::Gamestate *reference;
+    TrafficControl *trafficControl_;
     unsigned int id_;
   };
Index: code/branches/bugger/src/network/TrafficControl.cc
===================================================================
--- code/branches/bugger/src/network/TrafficControl.cc	(revision 2531)
+++ code/branches/bugger/src/network/TrafficControl.cc	(revision 2532)
@@ -30,4 +30,5 @@
 
 #include "synchronisable/Synchronisable.h"
+#include "core/ConfigValueIncludes.h"
 
 #include <cassert>
@@ -67,7 +68,9 @@
 	TrafficControl::TrafficControl()
 	{
+    RegisterRootObject(TrafficControl);
 	  assert(instance_==0);
 	  instance_=this;
-    targetSize = 1000;//5000bytes
+//     targetSize = 2500;//5000bytes
+    SetConfigValue ( targetSize, 28000./25. );
 	}
 	
@@ -127,6 +130,12 @@
 	  return;
 	}
-	
-	void TrafficControl::processAck(unsigned int clientID, unsigned int gamestateID)
+  
+  TrafficControl *TrafficControl::getInstance()
+  {
+    assert(instance_);
+    return instance_;
+  }
+	
+	void TrafficControl::ack(unsigned int clientID, unsigned int gamestateID)
 	{
 	  std::list<obj>::iterator itvec;  // iterator to iterate through the acked objects
@@ -141,8 +150,10 @@
       if(clientListPerm_[clientID].find((*itvec).objID) != clientListPerm_[clientID].end()) // check whether the obj already exists in our lists
       {
-        clientListPerm_[clientID][(*itvec).objID].objID = gamestateID;
+        clientListPerm_[clientID][(*itvec).objID].objCurGS = gamestateID;
+        clientListPerm_[clientID][(*itvec).objID].objValueSched = 0; //set scheduling value back
       }
       else
       {
+        assert(0);
         clientListPerm_[clientID][(*itvec).objID].objCurGS = gamestateID;
         clientListPerm_[clientID][(*itvec).objID].objID = (*itvec).objID;
@@ -225,5 +236,5 @@
 //     for(itvec = list.begin(); itvec!=list.end(), itvec++)
 //     {
-//       ittempgs.insert(itvec);
+//       ittempgs.insert(itvec);static
 //     }
   }
@@ -236,19 +247,25 @@
   {
     unsigned int size=0;
-    std::list<obj>::iterator itvec;
+    std::list<obj>::iterator itvec, ittemp;
     assert(!list->empty());
-    itvec = list->begin();
-    for(itvec = list->begin(); itvec != list->end() && size<targetsize; itvec++)
+    for(itvec = list->begin(); itvec != list->end();)
     {
       assert( (*itvec).objSize < 1000);
-      if ( size + (*itvec).objSize < targetsize )
-      {
+//       COUT(0) << "==targetsize==  " << targetsize << endl;
+      if ( ( size + (*itvec).objSize ) < targetsize )
+      {
+//         COUT(0) << "no cut" << endl;
         size += (*itvec).objSize;//objSize is given in bytes
+        ++itvec;
       }
       else
       {
-        clientListPerm_[currentClientID][(*itvec).objID].objValueSched -= SCHED_PRIORITY_OFFSET;
+//         COUT(0) << "cut" << endl;
+        clientListPerm_[currentClientID][(*itvec).objID].objValueSched += SCHED_PRIORITY_OFFSET; // NOTE: SCHED_PRIORITY_OFFSET is negative
+//         ittemp = itvec;
         list->erase(itvec++);
-      }
+//         itvec = ittemp;
+      }
+//       printList(list, currentClientID);
     }
     assert(!list->empty());
@@ -339,5 +356,5 @@
     
     //now we check, that the creator of an object always exists on a client
-    printList(list, clientID);
+//     printList(list, clientID);
     std::list<obj>::iterator itcreator;
     for(itvec = list->begin(); itvec != list->end(); itvec++)
@@ -348,5 +365,5 @@
     //now the cutting, work the same obj out in processobjectlist and copiedlist, compression rate muss noch festgelegt werden. 
     cut(list, targetSize);
-    printList(list, clientID);
+//     printList(list, clientID);
     //diese Funktion updateClientList muss noch gemacht werden
     updateClientListTemp(list);
@@ -359,5 +376,5 @@
     COUT(0) << "=========== Objectlist ===========" << endl;
     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 << endl;
+      COUT(0) << "ObjectID: " << (*it).objID << " creatorID: " << (*it).objCreatorID << " Priority: " << clientListPerm_[clientID][(*it).objID].objValuePerm + clientListPerm_[clientID][(*it).objID].objValueSched << " size: " << (*it).objSize << endl;
   }
   
Index: code/branches/bugger/src/network/TrafficControl.h
===================================================================
--- code/branches/bugger/src/network/TrafficControl.h	(revision 2531)
+++ code/branches/bugger/src/network/TrafficControl.h	(revision 2532)
@@ -37,4 +37,5 @@
 #include <algorithm>
 #include "util/Integers.h"
+#include "core/OrxonoxClass.h"
 
 namespace orxonox {
@@ -52,6 +53,6 @@
       uint32_t objDiffGS;//difference between current and latest GameState
       uint32_t objSize;
-      unsigned int objValuePerm;
-      unsigned int objValueSched;
+      int objValuePerm;
+      int objValueSched;
       objInfo(uint32_t ID, uint32_t creatorID, int32_t curGsID, int32_t diffGsID, uint32_t size, unsigned int prioperm, unsigned int priosched);
       objInfo();
@@ -78,5 +79,5 @@
 *
 */
-class TrafficControl{
+class TrafficControl : public OrxonoxClass{
   private:
 
@@ -139,4 +140,5 @@
     */
     void evaluateList(unsigned int clientID, std::list<obj> *list);//done    
+    void ack(unsigned int clientID, unsigned int gamestateID);  // this function gets called when the server receives an ack from the client
 
   protected:
@@ -152,7 +154,9 @@
     *Elements of struct i are therefore: *list[i].objID
     */
+    static TrafficControl *getInstance();
     void processObjectList(unsigned int clientID, unsigned int gamestateID, std::list<obj>* list); //gets a pointer to the list (containing objectIDs) and sorts it
     //done
-    void processAck(unsigned int clientID, unsigned int gamestateID);	// this function gets called when the server receives an ack from the client
+    static void processAck(unsigned int clientID, unsigned int gamestateID)
+    { return instance_->ack(clientID, gamestateID); }
     //done
     void deleteObject(unsigned int objectID);				// this function gets called when an object has been deleted (in order to clean up lists and maps)
Index: code/branches/bugger/src/network/packet/Gamestate.cc
===================================================================
--- code/branches/bugger/src/network/packet/Gamestate.cc	(revision 2531)
+++ code/branches/bugger/src/network/packet/Gamestate.cc	(revision 2532)
@@ -50,6 +50,4 @@
 
 #define PACKET_FLAG_GAMESTATE  ENET_PACKET_FLAG_RELIABLE
-  
-TrafficControl Gamestate::trafficControl_;
 
 Gamestate::Gamestate()
@@ -362,5 +360,5 @@
 
   //call TrafficControl
-  trafficControl_.processObjectList( clientID, HEADER->id, &dataMap_ );
+  TrafficControl::getInstance()->processObjectList( clientID, HEADER->id, &dataMap_ );
   
   //copy in the zeros
Index: code/branches/bugger/src/network/packet/Gamestate.h
===================================================================
--- code/branches/bugger/src/network/packet/Gamestate.h	(revision 2531)
+++ code/branches/bugger/src/network/packet/Gamestate.h	(revision 2532)
@@ -95,5 +95,5 @@
     void removeObject(ObjectListIterator<Synchronisable> &it);
     std::list<obj> dataMap_;
-    static TrafficControl trafficControl_;
+//     static TrafficControl *trafficControl_;
 };
 
