Index: code/branches/network5/src/libraries/network/Client.h
===================================================================
--- code/branches/network5/src/libraries/network/Client.h	(revision 7779)
+++ code/branches/network5/src/libraries/network/Client.h	(revision 7780)
@@ -80,4 +80,5 @@
     bool closeConnection();
     void queuePacket(ENetPacket* packet, int clientID, uint8_t channelID);
+    virtual bool sendPacket( packet::Packet* packet ){ return packet->send( static_cast<Host*>(this) ); }
     bool processChat(const std::string& message, unsigned int playerID);
     virtual bool chat(const std::string& message);
Index: code/branches/network5/src/libraries/network/Connection.cc
===================================================================
--- code/branches/network5/src/libraries/network/Connection.cc	(revision 7779)
+++ code/branches/network5/src/libraries/network/Connection.cc	(revision 7780)
@@ -82,4 +82,5 @@
   void Connection::disconnectPeer(ENetPeer *peer)
   {
+    assert(peer);
     outgoingEvent outEvent = { peer, outgoingEventType::disconnectPeer, (ENetPacket*)10, 15 };
     
@@ -91,4 +92,5 @@
   void Connection::addPacket(ENetPacket *packet, ENetPeer *peer, uint8_t channelID)
   {
+    assert(peer);
     outgoingEvent outEvent = { peer, outgoingEventType::sendPacket, packet, channelID };
     
@@ -100,5 +102,5 @@
   void Connection::broadcastPacket(ENetPacket* packet, uint8_t channelID)
   {
-    outgoingEvent outEvent = { 0, outgoingEventType::broadcastPacket, packet, channelID };
+    outgoingEvent outEvent = { (ENetPeer*)15, outgoingEventType::broadcastPacket, packet, channelID };
     
     this->outgoingEventsMutex_->lock();
Index: code/branches/network5/src/libraries/network/GamestateManager.cc
===================================================================
--- code/branches/network5/src/libraries/network/GamestateManager.cc	(revision 7779)
+++ code/branches/network5/src/libraries/network/GamestateManager.cc	(revision 7780)
@@ -110,4 +110,5 @@
       bool b = processGamestate(it->second);
       assert(b);
+      sendAck( it->second->getID(), it->second->getPeerID() );
       delete it->second;
     }
@@ -117,4 +118,19 @@
     NetworkCallbackManager::callCallbacks();
     return true;
+  }
+  
+  bool GamestateManager::sendAck(unsigned int gamestateID, uint32_t peerID)
+  {
+    packet::Acknowledgement *ack = new packet::Acknowledgement(gamestateID, peerID);
+    if( !this->sendPacket(ack))
+    {
+      COUT(3) << "could not ack gamestate: " << gamestateID << std::endl;
+      return false;
+    }
+    else
+    {
+      COUT(5) << "acked a gamestate: " << gamestateID << std::endl;
+      return true;
+    }
   }
 
@@ -173,4 +189,7 @@
       peerGamestates.push_back(0);  // insert an empty gamestate* to change
       finishGamestate( peerID, peerGamestates.back(), baseGamestate, currentGamestate_ );
+      if( peerGamestates.back()==0 )
+        // nothing to send to remove pointer from vector
+        peerGamestates.pop_back();
       //FunctorMember<GamestateManager>* functor =
 //       ExecutorMember<GamestateManager>* executor = createExecutor( createFunctor(&GamestateManager::finishGamestate, this) );
@@ -236,5 +255,6 @@
 
 
-  bool GamestateManager::ackGamestate(unsigned int gamestateID, unsigned int peerID) {
+  bool GamestateManager::ackGamestate(unsigned int gamestateID, unsigned int peerID)
+  {
 //     ClientInformation *temp = ClientInformation::findClient(peerID);
 //     assert(temp);
@@ -255,5 +275,5 @@
     }
 
-    assert(curid==GAMESTATEID_INITIAL || curid<gamestateID);
+    assert(curid==GAMESTATEID_INITIAL || curid<=gamestateID);
     COUT(5) << "acking gamestate " << gamestateID << " for peerID: " << peerID << " curid: " << curid << std::endl;
     std::map<uint32_t, packet::Gamestate*>::iterator it2;
Index: code/branches/network5/src/libraries/network/GamestateManager.h
===================================================================
--- code/branches/network5/src/libraries/network/GamestateManager.h	(revision 7779)
+++ code/branches/network5/src/libraries/network/GamestateManager.h	(revision 7780)
@@ -90,4 +90,5 @@
     
     bool processGamestates();
+    bool sendAck(unsigned int gamestateID, uint32_t peerID);
     bool update();
     std::vector<packet::Gamestate*> getGamestates();
@@ -101,4 +102,6 @@
     void removePeer( uint32_t peerID );
 //     void removeClient(ClientInformation *client);
+  protected:
+    virtual bool sendPacket( packet::Packet* packet ) = 0;
   private:
     bool processGamestate(packet::Gamestate *gs);
Index: code/branches/network5/src/libraries/network/Server.cc
===================================================================
--- code/branches/network5/src/libraries/network/Server.cc	(revision 7779)
+++ code/branches/network5/src/libraries/network/Server.cc	(revision 7780)
@@ -360,4 +360,5 @@
     else
     {
+      GamestateManager::removePeer(client->getID());
       //ServerConnection::disconnectClient( client );
       //ClientConnectionListener::broadcastClientDisconnected( client->getID() ); //this is done in ClientInformation now
Index: code/branches/network5/src/libraries/network/Server.h
===================================================================
--- code/branches/network5/src/libraries/network/Server.h	(revision 7779)
+++ code/branches/network5/src/libraries/network/Server.h	(revision 7780)
@@ -67,4 +67,5 @@
     bool processChat(const std::string& message, unsigned int playerID);
     void queuePacket(ENetPacket *packet, int clientID, uint8_t channelID);
+    virtual bool sendPacket( packet::Packet* packet ){ return packet->send( static_cast<Host*>(this) ); }
     void update(const Clock& time);
     unsigned int getRTT(unsigned int clientID);
Index: code/branches/network5/src/libraries/network/packet/FunctionCalls.cc
===================================================================
--- code/branches/network5/src/libraries/network/packet/FunctionCalls.cc	(revision 7779)
+++ code/branches/network5/src/libraries/network/packet/FunctionCalls.cc	(revision 7780)
@@ -71,5 +71,5 @@
     FunctionCall fctCall;
     fctCall.loadData(temp);
-    if( this->minGamestateID_ > host->getLastProcessedGamestateID(this->getPeerID()) || !fctCall.execute() )
+    if( !fctCall.execute() )
     {
       FunctionCallManager::bufferIncomingFunctionCall( fctCall, minGamestateID_, this->getPeerID() );
Index: code/branches/network5/src/libraries/network/packet/Packet.cc
===================================================================
--- code/branches/network5/src/libraries/network/packet/Packet.cc	(revision 7779)
+++ code/branches/network5/src/libraries/network/packet/Packet.cc	(revision 7780)
@@ -179,4 +179,7 @@
   assert(ClientInformation::findClient(&peer->address)->getID() != static_cast<unsigned int>(-2) || !Host::isServer());
   unsigned int peerID = ClientInformation::findClient(&peer->address)->getID();
+  // HACK
+  if( peerID==static_cast<unsigned int>(-2))
+    peerID = NETWORK_PEER_ID_SERVER;
   Packet *p = 0;
 //   COUT(6) << "packet type: " << *(Type::Value *)&data[_PACKETID] << std::endl;
Index: code/branches/network5/src/orxonox/gametypes/Gametype.cc
===================================================================
--- code/branches/network5/src/orxonox/gametypes/Gametype.cc	(revision 7779)
+++ code/branches/network5/src/orxonox/gametypes/Gametype.cc	(revision 7780)
@@ -171,5 +171,4 @@
     void Gametype::playerEntered(PlayerInfo* player)
     {
-      COUT(0) << "Gametype: playerentered" << endl;
         this->players_[player].state_ = PlayerState::Joined;
     }
@@ -412,5 +411,4 @@
     void Gametype::spawnPlayer(PlayerInfo* player)
     {
-      COUT(0) << "Gametype: spawnPlayer" << endl;
         SpawnPoint* spawnpoint = this->getBestSpawnPoint(player);
         if (spawnpoint)
