Index: code/branches/FICN/src/network/ConnectionManager.cc
===================================================================
--- code/branches/FICN/src/network/ConnectionManager.cc	(revision 379)
+++ code/branches/FICN/src/network/ConnectionManager.cc	(revision 380)
@@ -16,11 +16,6 @@
   boost::thread_group network_threads;
 
-  void test(){
-    return;
-  }
-
   ConnectionManager::ConnectionManager(){
     quit=false;
-    client=NULL;
     bindAddress.host = ENET_HOST_ANY;
     bindAddress.port = NETWORK_PORT;
@@ -29,5 +24,4 @@
   ConnectionManager::ConnectionManager(int port, std::string address){
     quit=false;
-    client=NULL;
     enet_address_set_host (& bindAddress, address.c_str());
     bindAddress.port = NETWORK_PORT;
@@ -36,5 +30,4 @@
   ConnectionManager::ConnectionManager(int port, const char *address){
     quit=false;
-    client=NULL;
     enet_address_set_host (& bindAddress, address);
     bindAddress.port = NETWORK_PORT;
@@ -47,4 +40,11 @@
         return NULL;
   }
+  
+  ENetPacket *ConnectionManager::getPacket(int &clientID){
+    ENetAddress address;
+    ENetPacket *packet=getPacket(address);
+    clientID=clientMap.find(address)->second;
+    return packet;
+  }
 
   bool ConnectionManager::queueEmpty(){
@@ -65,36 +65,22 @@
 
   bool ConnectionManager::addPacket(ENetPacket *packet, ENetPeer *peer){
-    if(client==NULL)
-      return false;
-    ClientList *temp=client;
-    while(peer->host != temp->event->peer->host){
-      temp=temp->next;
-      if(temp==NULL)
-        return false;
-    }
-    if(enet_peer_send(temp->event->peer, temp->ID, packet)!=0)
-      return false;
-    return true;
-  }
-
-  bool ConnectionManager::addPacket(ENetPacket *packet, int ID){
-    if(client==NULL)
-      return false;
-    ClientList *temp=client;
-    while(ID != temp->ID){
-      temp=temp->next;
-      if(temp==NULL)
-        return false;
-    }
-    if(enet_peer_send(temp->event->peer, temp->ID, packet)!=0)
-      return false;
-    else
-      return true;
-  }
-
+    if(clientVector.size()==0)
+      return false;
+    if(enet_peer_send(peer, clientMap.find(peer->address)->second , packet)!=0)
+      return false;
+    return true;
+  }
+  
+  bool ConnectionManager::addPacket(ENetPacket *packet, int clientID){
+    if(clientVector.size()==0)
+      return false;
+    if(enet_peer_send(&(peerMap.find(clientVector[clientID])->second), clientID, packet)!=0)
+      return false;
+    return true;
+  }
+  
   bool ConnectionManager::addPacketAll(ENetPacket *packet){
-    ClientList *temp=client;
-    while(temp!=NULL){
-      if(enet_peer_send(temp->event->peer, temp->ID, packet)!=0)
+    for(int i=0; i<clientVector.size(); i++){
+      if(enet_peer_send(&(peerMap.find(clientVector[i])->second), i, packet)!=0)
          return false;
     }
@@ -163,7 +149,6 @@
     bool disconnected=false;
     ENetEvent event;
-    ClientList *temp=client;
-    while(temp!=NULL){
-      enet_peer_disconnect(temp->event->peer, 0);
+    for(int i=0; i<clientVector.size(); i++){
+      enet_peer_disconnect(&(peerMap.find(clientVector[i])->second), 0);
       while( !disconnected && enet_host_service(server, &event, NETWORK_WAIT_TIMEOUT) > 0){
         switch (event.type)
@@ -179,5 +164,4 @@
         }
       }
-      temp = temp->next;
       disconnected=false;
     }
@@ -192,55 +176,34 @@
 
   bool ConnectionManager::clientDisconnect(ENetPeer *peer){
-    ClientList *temp=client;
-    // do we have to remove the first item ?
-    if(temp->event->peer->host==peer->host){
-      if(temp->next==NULL){
-        client=NULL;
-      } else{
-        client=temp->next;
-      }
-      delete temp;
-      return true;
-    } else {
-      while(temp->next!=NULL){
-        if(temp->next->event->peer->host==peer->host){
-          // do a correct relink and delete the disconnected client
-          ClientList *temp2=temp->next;
-          temp->next=temp2->next;
-          delete temp2;
-          return true;
-        } else
-          //otherwise keep on searching ;)
-          temp=temp->next;
-      }
-    }
-    return false;
+    return clientDisconnect(*peer);
+  }
+  
+  bool ConnectionManager::clientDisconnect(ENetPeer peer){
+    std::map<ENetAddress, int>::iterator it;
+    it=clientMap.find(peer.address);
+    clientVector.erase(clientVector.begin()+it->second);
+    clientMap.erase(it);
+    peerMap.erase(peerMap.find(peer.address));
+    return true;
   }
 
   bool ConnectionManager::addClient(ENetEvent *event){
-
-    // first client?
-    if(client==NULL){
-      client =new ClientList;
-      client->ID=1;
-      client->next=NULL;
-      client->event = event;
-    } else {
-      // otherwise add a new element to clientlist
-      ClientList *temp = client;
-      int i=1;
-      while(temp->next != NULL){
-        temp=temp->next;
-        i++;
-      }
-      temp->next=new ClientList;
-      temp=temp->next;
-      temp->ID=i+1;
-      temp->event=event;
-      temp->next=NULL;
-    }
-    return true;
-  }
-
-
+    clientVector.push_back((event->peer->address));
+    clientMap[event->peer->address]=clientVector.size()-1;
+    peerMap[event->peer->address]=*(event->peer);
+    return true;
+  }
+  
+  int ConnectionManager::getClientID(ENetPeer peer){
+    return clientMap.find(peer.address)->second;
+  }
+  
+  int ConnectionManager::getClientID(ENetAddress address){
+    return clientMap.find(address)->second;
+  }
+  
+  ENetPeer ConnectionManager::getClientPeer(int clientID){
+    return peerMap.find(clientVector[clientID])->second;
+  }
+  
 }
Index: code/branches/FICN/src/network/ConnectionManager.h
===================================================================
--- code/branches/FICN/src/network/ConnectionManager.h	(revision 379)
+++ code/branches/FICN/src/network/ConnectionManager.h	(revision 380)
@@ -15,4 +15,6 @@
 #include <iostream>
 #include <string>
+#include <map>
+#include <vector>
 // enet library for networking support
 #include <enet/enet.h>
@@ -20,5 +22,5 @@
 #include <boost/thread/thread.hpp>
 #include <boost/bind.hpp>
-// headerfile
+// headerfiles
 #include "ConnectionManager.h"
 #include "PacketBuffer.h"
@@ -30,9 +32,4 @@
 #define NETWORK_WAIT_TIMEOUT 5000
 #define NETWORK_SEND_WAIT 5
-  //just some defines to make life easier ;)
-// #define ENetEvent std::ENetEvent
-// #define ENetHost std::ENetHost
-// #define ENetAddress std::ENetAddress
-// #define ENetPeer std::ENetPeer
 
   struct ClientList{
@@ -48,36 +45,32 @@
     ConnectionManager(int port, std::string address);
     ENetPacket *getPacket(ENetAddress &address); // thread1
-    // check wheter the packet queue is empty
+    ENetPacket *getPacket(int &clientID);
     bool queueEmpty();
-    // create a new listener thread
     void createListener();
     bool quitListener();
-    // add a packet to queue for a specific client peer
     bool addPacket(ENetPacket *packet, ENetPeer *peer);
-    // add ad packet to queue for a specific client ID
     bool addPacket(ENetPacket *packet, int ID);
-    // add a packet to queue for all clients
     bool addPacketAll(ENetPacket *packet);
-    // send out all queued packets
     bool sendPackets(ENetEvent *event);
     bool sendPackets();
     private:
     bool clientDisconnect(ENetPeer *peer);
+    bool clientDisconnect(ENetPeer peer);
     bool processData(ENetEvent *event);
     bool addClient(ENetEvent *event);
-    // implementation of the listener
-    void receiverThread(); //thread2
+    void receiverThread();
     void disconnectClients();
-    //packetbuffer
+    int getClientID(ENetPeer peer);
+    int getClientID(ENetAddress address);
+    ENetPeer getClientPeer(int clientID);
     PacketBuffer buffer;
-    // enet stuff
+    
     ENetHost *server;
     ENetAddress bindAddress;
-    // quit-variable (communication with threads)
-    bool quit;
-    // clientlist
-    ClientList *client;
-//     thread group
-//     boost::thread_group threads;
+    
+    bool quit; // quit-variable (communication with threads)
+    std::map<ENetAddress, int> clientMap;
+    std::map<ENetAddress, ENetPeer> peerMap;
+    std::vector<ENetAddress> clientVector;
   };
 
Index: code/branches/FICN/src/network/Server.cc
===================================================================
--- code/branches/FICN/src/network/Server.cc	(revision 379)
+++ code/branches/FICN/src/network/Server.cc	(revision 380)
@@ -85,5 +85,28 @@
   }
   
+  /**
+   * Run this function once every tick
+   * calls processQueue and updateGamestate
+   */
   void Server::tick(){
+    processQueue();
+    updateGamestate();
+    return;
+  }
+  
+  /**
+   * processes all the packets waiting in the queue
+   */
+  void Server::processQueue(){
+    ENetPacket *packet;
+    while(!connection.queueEmpty()){
+      packet = connection.getPacket()
+    }
+  }
+  
+  /**
+   * takes a new snapshot of the gamestate and sends it to the clients
+   */
+  void Server::updateGamestate(){
   }
   
Index: code/branches/FICN/src/network/Server.h
===================================================================
--- code/branches/FICN/src/network/Server.h	(revision 379)
+++ code/branches/FICN/src/network/Server.h	(revision 380)
@@ -40,5 +40,7 @@
     GameStateManager gamestates;
     PacketGenerator packet_gen;
-
+    
+    void processQueue();
+    void updateGamestate();
   };
 
