Index: code/branches/FICN/src/audio/AudioPrereqs.h
===================================================================
--- code/branches/FICN/src/audio/AudioPrereqs.h	(revision 774)
+++ code/branches/FICN/src/audio/AudioPrereqs.h	(revision 777)
@@ -27,5 +27,5 @@
 
 /**
- @file  OrxonoxPrereq.cc
+ @file  AudioPrereqs.h
  @brief Contains all the necessary forward declarations for all classes, structs and enums.
  */
@@ -59,6 +59,10 @@
 // Forward declarations
 //-----------------------------------------------------------------------
-namespace loader {
-  class LevelAudio;
+namespace audio
+{
+  class AudioBuffer;
+  class AudioManager;
+  class AudioSource;
+  class AudioStream;
 }
 
Index: code/branches/FICN/src/network/Client.cc
===================================================================
--- code/branches/FICN/src/network/Client.cc	(revision 774)
+++ code/branches/FICN/src/network/Client.cc	(revision 777)
@@ -1,28 +1,28 @@
 /*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Oliver Scheuss, (C) 2007
- *   Co-authors:
- *      ...
- *
- */
+*   ORXONOX - the hottest 3D action shooter ever to exist
+*
+*
+*   License notice:
+*
+*   This program is free software; you can redistribute it and/or
+*   modify it under the terms of the GNU General Public License
+*   as published by the Free Software Foundation; either version 2
+*   of the License, or (at your option) any later version.
+*
+*   This program is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with this program; if not, write to the Free Software
+*   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*
+*   Author:
+*      Oliver Scheuss, (C) 2007
+*   Co-authors:
+*      ...
+*
+*/
 
 //
@@ -38,12 +38,13 @@
 //
 
+#include "core/CoreIncludes.h"
 #include "Client.h"
 
-namespace network{
-
-  /**
-   * Constructor for the Client class
-   * initializes the address and the port to default localhost:NETWORK_PORT
-   */
+namespace network
+{
+  /**
+  * Constructor for the Client class
+  * initializes the address and the port to default localhost:NETWORK_PORT
+  */
   Client::Client(): client_connection(NETWORK_PORT,"127.0.0.1"){
     // set server address to localhost
@@ -52,8 +53,8 @@
 
   /**
-   * Constructor for the Client class
-   * @param address the server address
-   * @param port port of the application on the server
-   */
+  * Constructor for the Client class
+  * @param address the server address
+  * @param port port of the application on the server
+  */
   Client::Client(std::string address, int port) : client_connection(port, address){
     isConnected=false;
@@ -61,8 +62,8 @@
 
   /**
-   * Constructor for the Client class
-   * @param address the server address
-   * @param port port of the application on the server
-   */
+  * Constructor for the Client class
+  * @param address the server address
+  * @param port port of the application on the server
+  */
   Client::Client(const char *address, int port) : client_connection(port, address){
     isConnected=false;
@@ -70,7 +71,7 @@
 
   /**
-   * Establish the Connection to the Server
-   * @return true/false
-   */
+  * Establish the Connection to the Server
+  * @return true/false
+  */
   bool Client::establishConnection(){
     isConnected=client_connection.createConnection();
@@ -79,7 +80,7 @@
 
   /**
-   * closes the Connection to the Server
-   * @return true/false
-   */
+  * closes the Connection to the Server
+  * @return true/false
+  */
   bool Client::closeConnection(){
     isConnected=false;
@@ -88,9 +89,9 @@
 
   /**
-   * submits a MouseAction to the server
-   * @param x x Coordinate
-   * @param y y Coordinate
-   * @return true/false
-   */
+  * submits a MouseAction to the server
+  * @param x x Coordinate
+  * @param y y Coordinate
+  * @return true/false
+  */
   bool Client::sendMouse(double x, double y){
     // generate packet and add it to the queue
@@ -98,5 +99,5 @@
       return false;
     if(!client_connection.addPacket(pck_gen.mousem(x, y)))
-        return false;
+      return false;
     // send packets
     return client_connection.sendPackets();
@@ -104,8 +105,8 @@
 
   /**
-   * submits a Keystrike to the server
-   * @param key_code code to submit
-   * @return true/false
-   */
+  * submits a Keystrike to the server
+  * @param key_code code to submit
+  * @return true/false
+  */
   bool Client::sendKeyboard(char key_code){
     // generate packet and add it to queue
@@ -113,5 +114,5 @@
       return false;
     if(!client_connection.addPacket(pck_gen.keystrike(key_code)))
-        return false;
+      return false;
     // send packets
     return client_connection.sendPackets();
@@ -119,8 +120,8 @@
 
   /**
-   * submits a chat message to the server
-   * @param message message to send
-   * @return true/false
-   */
+  * submits a chat message to the server
+  * @param message message to send
+  * @return true/false
+  */
   bool Client::sendChat( std::string message ){
     // generate packet and add it to queue
@@ -134,9 +135,9 @@
 
   /**
-   * Adds a MouseAction to the PacketQueue
-   * @param x x Coordinate
-   * @param y y Coordinate
-   * @return true/false
-   */
+  * Adds a MouseAction to the PacketQueue
+  * @param x x Coordinate
+  * @param y y Coordinate
+  * @return true/false
+  */
   bool Client::addMouse(double x, double y){
     // generate packet and add it to the queue
@@ -148,8 +149,8 @@
 
   /**
-   * Adds a Keystrike to the PacketQueue
-   * @param key_code
-   * @return true/false
-   */
+  * Adds a Keystrike to the PacketQueue
+  * @param key_code
+  * @return true/false
+  */
   bool Client::addKeyboard(char key_code){
     // generate packet and add it to queue
@@ -161,6 +162,6 @@
 
   /**
-   * Sends out all the packets queued by addXXX
-   */
+  * Sends out all the packets queued by addXXX
+  */
   bool Client::sendPackets(){
     if(!isConnected)
@@ -176,6 +177,6 @@
 
   /**
-   * Performs a GameState update
-   */
+  * Performs a GameState update
+  */
   void Client::tick(float time){
     ENetPacket *packet;
Index: code/branches/FICN/src/network/Client.h
===================================================================
--- code/branches/FICN/src/network/Client.h	(revision 774)
+++ code/branches/FICN/src/network/Client.h	(revision 777)
@@ -16,53 +16,51 @@
 #include <string>
 
+#include "NetworkPrereqs.h"
 #include "ClientConnection.h"
 #include "PacketManager.h"
 #include "GameStateClient.h"
-#include "core/CoreIncludes.h"
 //#include "NetworkFrameListener.h"
 
 
-namespace network{
+namespace network
+{
+  /**
+  network::Client *client;
+  * The network/Client class
+  * This class implements all necessary function for the network communication
+  * It is the root class of the network module
+  *
+  */
+  class _NetworkExport Client : PacketDecoder{
+  public:
+    Client();
+    Client(std::string address, int port);
+    Client(const char *address, int port);
 
+    bool establishConnection();
+    bool closeConnection();
 
-  
-/**
-  network::Client *client;
- * The network/Client class
- * This class implements all necessary function for the network communication
- * It is the root class of the network module
- *
- */
-class Client : PacketDecoder{
-  public:
-  Client();
-  Client(std::string address, int port);
-  Client(const char *address, int port);
+    bool sendMouse(double x, double y);
+    bool sendKeyboard(char key_code);
+    bool sendChat( std::string message );
 
-  bool establishConnection();
-  bool closeConnection();
+    bool addMouse(double x, double y);
+    bool addKeyboard(char key_code);
 
-  bool sendMouse(double x, double y);
-  bool sendKeyboard(char key_code);
-  bool sendChat( std::string message );
+    bool sendPackets();
 
-  bool addMouse(double x, double y);
-  bool addKeyboard(char key_code);
-
-  bool sendPackets();
-  
-  void tick(float time);
+    void tick(float time);
 
   private:
-  ClientConnection client_connection;
-  PacketGenerator pck_gen;
-  GameStateClient gamestate;
-  bool isConnected;
-  
-  // implement data processing functions of PacketDecoder
-  void processGamestate( GameStateCompressed *data);
-  void processClassid(classid *clid);
-  void processChat( chat *data);
-};
+    ClientConnection client_connection;
+    PacketGenerator pck_gen;
+    GameStateClient gamestate;
+    bool isConnected;
+
+    // implement data processing functions of PacketDecoder
+    void processGamestate( GameStateCompressed *data);
+    void processClassid(classid *clid);
+    void processChat( chat *data);
+  };
 
 
Index: code/branches/FICN/src/network/ClientConnection.cc
===================================================================
--- code/branches/FICN/src/network/ClientConnection.cc	(revision 774)
+++ code/branches/FICN/src/network/ClientConnection.cc	(revision 777)
@@ -1,28 +1,28 @@
 /*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Oliver Scheuss, (C) 2007
- *   Co-authors:
- *      ...
- *
- */
+*   ORXONOX - the hottest 3D action shooter ever to exist
+*
+*
+*   License notice:
+*
+*   This program is free software; you can redistribute it and/or
+*   modify it under the terms of the GNU General Public License
+*   as published by the Free Software Foundation; either version 2
+*   of the License, or (at your option) any later version.
+*
+*   This program is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with this program; if not, write to the Free Software
+*   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*
+*   Author:
+*      Oliver Scheuss, (C) 2007
+*   Co-authors:
+*      ...
+*
+*/
 
 //
@@ -37,13 +37,17 @@
 //
 
+#include <iostream>
+// boost.thread library for multithreading support
+#include <boost/thread/thread.hpp>
+#include <boost/bind.hpp>
+
+#include "util/Sleep.h"
 #include "ClientConnection.h"
 
-#include "util/Sleep.h"
-
-namespace network{
-
+namespace network
+{
   static boost::thread_group network_threads;
 
-  ClientConnection::ClientConnection(int port, std::string address){
+  ClientConnection::ClientConnection(int port, std::string address) {
     quit=false;
     server=NULL;
@@ -53,5 +57,5 @@
   }
 
-  ClientConnection::ClientConnection(int port, const char *address){
+  ClientConnection::ClientConnection(int port, const char *address) {
     quit=false;
     server=NULL;
@@ -61,5 +65,5 @@
   }
 
-  bool ClientConnection::waitEstablished(int milisec){
+  bool ClientConnection::waitEstablished(int milisec) {
     for(int i=0; i<=milisec && !established; i++)
       usleep(1000);
@@ -69,5 +73,5 @@
 
 
-  ENetPacket *ClientConnection::getPacket(ENetAddress &address){
+  ENetPacket *ClientConnection::getPacket(ENetAddress &address) {
     if(!buffer.isEmpty()) {
       //std::cout << "###BUFFER IS NOT EMPTY###" << std::endl;
@@ -75,18 +79,18 @@
     }
     else{
-        return NULL;
-    }
-  }
-
-  ENetPacket *ClientConnection::getPacket(){
+      return NULL;
+    }
+  }
+
+  ENetPacket *ClientConnection::getPacket() {
     ENetAddress address;
     return getPacket(address);
   }
 
-  bool ClientConnection::queueEmpty(){
+  bool ClientConnection::queueEmpty() {
     return buffer.isEmpty();
   }
 
-  bool ClientConnection::createConnection(){
+  bool ClientConnection::createConnection() {
     network_threads.create_thread(boost::bind(boost::mem_fn(&ClientConnection::receiverThread), this));
     // wait 10 seconds for the connection to be established
@@ -94,5 +98,5 @@
   }
 
-  bool ClientConnection::closeConnection(){
+  bool ClientConnection::closeConnection() {
     quit=true;
     network_threads.join_all();
@@ -102,5 +106,5 @@
 
 
-  bool ClientConnection::addPacket(ENetPacket *packet){
+  bool ClientConnection::addPacket(ENetPacket *packet) {
     if(server==NULL)
       return false;
@@ -110,5 +114,5 @@
   }
 
-  bool ClientConnection::sendPackets(ENetEvent *event){
+  bool ClientConnection::sendPackets(ENetEvent *event) {
     if(server==NULL)
       return false;
@@ -119,5 +123,5 @@
   }
 
-  bool ClientConnection::sendPackets(){
+  bool ClientConnection::sendPackets() {
     ENetEvent event;
     if(server==NULL)
@@ -129,5 +133,5 @@
   }
 
-  void ClientConnection::receiverThread(){
+  void ClientConnection::receiverThread() {
     // what about some error-handling here ?
     enet_initialize();
@@ -170,10 +174,10 @@
 
     if(!disconnectConnection())
-    // if disconnecting failed destroy conn.
+      // if disconnecting failed destroy conn.
       enet_peer_reset(server);
     return;
   }
 
-  bool ClientConnection::disconnectConnection(){
+  bool ClientConnection::disconnectConnection() {
     ENetEvent event;
     enet_peer_disconnect(server, 0);
@@ -181,11 +185,11 @@
       switch (event.type)
       {
-	case ENET_EVENT_TYPE_NONE:
-	case ENET_EVENT_TYPE_CONNECT:
-        case ENET_EVENT_TYPE_RECEIVE:
-          enet_packet_destroy(event.packet);
-          break;
-        case ENET_EVENT_TYPE_DISCONNECT:
-          return true;
+      case ENET_EVENT_TYPE_NONE:
+      case ENET_EVENT_TYPE_CONNECT:
+      case ENET_EVENT_TYPE_RECEIVE:
+        enet_packet_destroy(event.packet);
+        break;
+      case ENET_EVENT_TYPE_DISCONNECT:
+        return true;
       }
     }
@@ -194,5 +198,5 @@
   }
 
-  bool ClientConnection::establishConnection(){
+  bool ClientConnection::establishConnection() {
     ENetEvent event;
     // connect to peer
@@ -210,5 +214,5 @@
   }
 
-  bool ClientConnection::processData(ENetEvent *event){
+  bool ClientConnection::processData(ENetEvent *event) {
     //std::cout << "got packet, pushing to queue" << std::endl;
     // just add packet to the buffer
@@ -217,4 +221,3 @@
   }
 
-
 }
Index: code/branches/FICN/src/network/ClientConnection.h
===================================================================
--- code/branches/FICN/src/network/ClientConnection.h	(revision 774)
+++ code/branches/FICN/src/network/ClientConnection.h	(revision 777)
@@ -13,17 +13,13 @@
 #define _ClientConnection_H__
 
-#include <iostream>
 #include <string>
-// enet library for networking support
 #include <enet/enet.h>
-// boost.thread library for multithreading support
-#include <boost/thread/thread.hpp>
-#include <boost/bind.hpp>
-// headerfile
-#include "ClientConnection.h"
+
+#include "NetworkPrereqs.h"
 #include "PacketBuffer.h"
 
-namespace network{
-  //
+namespace network
+{
+
 #define NETWORK_PORT 55556
 #define NETWORK_CLIENT_MAX_CONNECTIONS 5
@@ -34,5 +30,5 @@
 
   class ClientConnection{
-    public:
+  public:
     ClientConnection(int port, std::string address);
     ClientConnection(int port, const char* address);
@@ -51,5 +47,5 @@
     bool sendPackets(ENetEvent *event);
     bool waitEstablished(int milisec);
-    private:
+  private:
     bool processData(ENetEvent *event);
     // implementation of the listener
Index: code/branches/FICN/src/network/ClientInformation.cc
===================================================================
--- code/branches/FICN/src/network/ClientInformation.cc	(revision 774)
+++ code/branches/FICN/src/network/ClientInformation.cc	(revision 777)
@@ -1,28 +1,28 @@
 /*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      ...
- *   Co-authors:
- *      ...
- *
- */
+*   ORXONOX - the hottest 3D action shooter ever to exist
+*
+*
+*   License notice:
+*
+*   This program is free software; you can redistribute it and/or
+*   modify it under the terms of the GNU General Public License
+*   as published by the Free Software Foundation; either version 2
+*   of the License, or (at your option) any later version.
+*
+*   This program is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with this program; if not, write to the Free Software
+*   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*
+*   Author:
+*      ...
+*   Co-authors:
+*      ...
+*
+*/
 
 //
@@ -37,195 +37,197 @@
 //
 //
+
+#include <iostream> //debug
+
 #include "ClientInformation.h"
 
-namespace network {
-
-ClientInformation::ClientInformation()
+namespace network
 {
-  gamestateID_=GAMESTATEID_INITIAL;
-  preve=0;
-  nexte=0;
-  this->head=false;
-  synched_=false;
+  ClientInformation::ClientInformation() {
+    gamestateID_=GAMESTATEID_INITIAL;
+    preve=0;
+    nexte=0;
+    this->head=false;
+    synched_=false;
+  }
+
+  ClientInformation::ClientInformation(bool head) {
+    gamestateID_=GAMESTATEID_INITIAL;
+    preve=0;
+    nexte=0;
+    this->head=head;
+    synched_=false;
+  }
+
+  // ClientInformation::ClientInformation(ClientInformation *prev) {
+  //   if(prev->next()!=0){
+  //     this->nexte=prev->next();
+  //     this->nexte->setPrev(this);
+  //   }
+  //   else
+  //     this->nexte = 0;
+  //   prev->setNext(this);
+  //   this->preve = pref;
+  // }
+  //
+  // ClientInformation::ClientInformation(ClientInformation *prev, ClientInformation *next){
+  //   this->nexte = next;
+  //   this->preve = prev;
+  //   this->preve->setNext(this);
+  //   this->nexte->setPrev(this);
+  // }
+
+  ClientInformation::~ClientInformation() {
+    if(preve!=0)
+      preve->setNext(this->nexte);
+    if(nexte!=0)
+      nexte->setPrev(this->preve);
+  }
+
+  ClientInformation *ClientInformation::next() {
+    if(this!=0)
+      return this->nexte;
+    else
+      return 0;
+  }
+  ClientInformation *ClientInformation::prev() {
+    if(this!=0)
+      return this->preve;
+    else
+      return 0;
+  }
+
+  bool ClientInformation::setPrev(ClientInformation *prev) {
+    if(!head)
+      this->preve = prev;
+    else
+      return false;
+    return true;
+  }
+
+  bool ClientInformation::setNext(ClientInformation *next) {
+    this->nexte = next;
+    return true;
+  }
+
+  ClientInformation *ClientInformation::insertAfter(ClientInformation *ins) {
+    this->nexte->setPrev(ins);
+    ins->setNext(this->nexte);
+    ins->setPrev(this);
+    this->nexte = ins;
+    return ins;
+  }
+
+  ClientInformation *ClientInformation::insertBefore(ClientInformation *ins){
+    this->prev()->setNext(ins);
+    ins->setPrev(this->preve);
+    this->preve=ins;
+    ins->setNext(this);
+    return ins;
+  }
+
+  void ClientInformation::setID(int clientID){
+    clientID_ = clientID;
+  }
+
+  void ClientInformation::setPeer(ENetPeer *peer){
+    peer_ = peer;
+  }
+
+  void ClientInformation::setGamestateID(int id){
+    gamestateID_=id;
+  }
+
+  int ClientInformation::getID() {
+    return clientID_;
+  }
+
+  ENetPeer *ClientInformation::getPeer() {
+    return peer_;
+  }
+
+  int ClientInformation::getGamestateID() {
+    return gamestateID_;
+  }
+
+  ClientInformation *ClientInformation::insertBack(ClientInformation *ins) {
+    ClientInformation *temp = this;
+    while(temp->next()!=0){
+      temp = temp->next();
+    }
+    temp->setNext(ins);
+    ins->setPrev(temp);
+    return ins;
+  }
+
+  bool ClientInformation::removeClient(int clientID) {
+    ClientInformation *temp = this;
+    while(temp!=0 && temp->getID()!=clientID)
+      temp = temp->next();
+    if(temp==0)
+      return false;
+    delete temp;
+    return true;
+  }
+
+  bool ClientInformation::removeClient(ENetPeer *peer) {
+    ClientInformation *temp = this;
+    while(temp!=0){
+      if(!temp->head)
+        if(temp->getPeer()->address.host==peer->address.host && temp->getPeer()->address.port==peer->address.port)
+          break;
+      temp = temp->next();
+    }
+    if(temp==0)
+      return false;
+    delete temp;
+    return true;
+  }
+
+  /**
+  * This function goes forward through the list and looks for an element with clientID
+  * This function should only be applied to the head of the list
+  * @param clientID id to look for
+  * @return pointer to the element in the list or 0 if the search was unsuccessfull
+  */
+  ClientInformation *ClientInformation::findClient(int clientID, bool look_backwards) {
+    ClientInformation *temp = this;
+    if (temp->head)
+      temp=temp->next();
+    while(temp!=0 && temp->getID()!=clientID){
+      temp = temp->next();
+    }
+    // returns 0 if nothing has been found
+    return temp;
+  }
+
+  /**
+  * This function goes forward through the list and looks for an element with clientID
+  * This function should only be applied to the head of the list
+  * @param peer peer to look for
+  * @return pointer to the element in the list
+  */
+  ClientInformation *ClientInformation::findClient(ENetAddress *address, bool look_backwards) {
+    ClientInformation *temp = this;
+    while(temp!=0){
+      if(temp->head){
+        temp = temp->next();
+        continue;
+      }
+      if(temp->getPeer()->address.host==address->host && temp->getPeer()->address.port == address->port)
+        break;
+      temp = temp->next();
+    }
+    // returns 0 if nothing has been found
+    return temp;
+  }
+
+  void ClientInformation::setSynched(bool s) {
+    synched_=s;
+  }
+
+  bool ClientInformation::getSynched() {
+    return synched_;
+  }
+
 }
-
-ClientInformation::ClientInformation(bool head)
-{
-  gamestateID_=GAMESTATEID_INITIAL;
-  preve=0;
-  nexte=0;
-  this->head=head;
-  synched_=false;
-}
-//
-
-// ClientInformation::ClientInformation(ClientInformation *prev){
-//   if(prev->next()!=0){
-//     this->nexte=prev->next();
-//     this->nexte->setPrev(this);
-//   }
-//   else
-//     this->nexte = 0;
-//   prev->setNext(this);
-//   this->preve = pref;
-// }
-//
-// ClientInformation::ClientInformation(ClientInformation *prev, ClientInformation *next){
-//   this->nexte = next;
-//   this->preve = prev;
-//   this->preve->setNext(this);
-//   this->nexte->setPrev(this);
-// }
-
-ClientInformation::~ClientInformation()
-{
-  if(preve!=0)
-    preve->setNext(this->nexte);
-  if(nexte!=0)
-    nexte->setPrev(this->preve);
-}
-
-ClientInformation *ClientInformation::next(){
-  if(this!=0)
-    return this->nexte;
-  else
-    return 0;
-}
-ClientInformation *ClientInformation::prev(){
-  if(this!=0)
-    return this->preve;
-  else
-    return 0;
-}
-
-bool ClientInformation::setPrev(ClientInformation *prev){
-  if(!head)
-    this->preve = prev;
-  else
-    return false;
-  return true;
-}
-
-bool ClientInformation::setNext(ClientInformation *next){
-  this->nexte = next;
-  return true;
-}
-
-ClientInformation *ClientInformation::insertAfter(ClientInformation *ins){
-  this->nexte->setPrev(ins);
-  ins->setNext(this->nexte);
-  ins->setPrev(this);
-  this->nexte = ins;
-  return ins;
-}
-
-ClientInformation *ClientInformation::insertBefore(ClientInformation *ins){
-  this->prev()->setNext(ins);
-  ins->setPrev(this->preve);
-  this->preve=ins;
-  ins->setNext(this);
-  return ins;
-}
-
-void ClientInformation::setID(int clientID){
-  clientID_ = clientID;
-}
-void ClientInformation::setPeer(ENetPeer *peer){
-  peer_ = peer;
-}
-
-void ClientInformation::setGamestateID(int id){
-  gamestateID_=id;
-}
-
-int ClientInformation::getID(){
-  return clientID_;
-}
-ENetPeer *ClientInformation::getPeer(){
-  return peer_;
-}
-
-int ClientInformation::getGamestateID(){
-  return gamestateID_;
-}
-
-ClientInformation *ClientInformation::insertBack(ClientInformation *ins){
-  ClientInformation *temp = this;
-  while(temp->next()!=0){
-    temp = temp->next();
-  }
-  temp->setNext(ins);
-  ins->setPrev(temp);
-  return ins;
-}
-
-bool ClientInformation::removeClient(int clientID){
-  ClientInformation *temp = this;
-  while(temp!=0 && temp->getID()!=clientID)
-    temp = temp->next();
-  if(temp==0)
-    return false;
-  delete temp;
-  return true;
-}
-
-bool ClientInformation::removeClient(ENetPeer *peer){
-  ClientInformation *temp = this;
-  while(temp!=0){
-    if(!temp->head)
-      if(temp->getPeer()->address.host==peer->address.host && temp->getPeer()->address.port==peer->address.port)
-        break;
-    temp = temp->next();
-  }
-  if(temp==0)
-    return false;
-  delete temp;
-  return true;
-}
-
-/**
- * This function goes forward through the list and looks for an element with clientID
- * This function should only be applied to the head of the list
- * @param clientID id to look for
- * @return pointer to the element in the list or 0 if the search was unsuccessfull
- */
-ClientInformation *ClientInformation::findClient(int clientID, bool look_backwards){
-  ClientInformation *temp = this;
-  if (temp->head)
-    temp=temp->next();
-  while(temp!=0 && temp->getID()!=clientID){
-    temp = temp->next();
-  }
-  // returns 0 if nothing has been found
-  return temp;
-}
-
-/**
- * This function goes forward through the list and looks for an element with clientID
- * This function should only be applied to the head of the list
- * @param peer peer to look for
- * @return pointer to the element in the list
- */
-ClientInformation *ClientInformation::findClient(ENetAddress *address, bool look_backwards){
-  ClientInformation *temp = this;
-  while(temp!=0){
-    if(temp->head){
-      temp = temp->next();
-      continue;
-    }
-    if(temp->getPeer()->address.host==address->host && temp->getPeer()->address.port == address->port)
-      break;
-    temp = temp->next();
-  }
-  // returns 0 if nothing has been found
-  return temp;
-}
-
-void ClientInformation::setSynched(bool s){
-  synched_=s;
-}
-bool ClientInformation::getSynched(){
-  return synched_;
-}
-
-}
Index: code/branches/FICN/src/network/ClientInformation.h
===================================================================
--- code/branches/FICN/src/network/ClientInformation.h	(revision 774)
+++ code/branches/FICN/src/network/ClientInformation.h	(revision 777)
@@ -14,53 +14,54 @@
 
 #include <enet/enet.h>
-#include <iostream> //debug
+
+#include "NetworkPrereqs.h"
 
 #define GAMESTATEID_INITIAL -1
 
-namespace network {
+namespace network
+{
+  /**
+  * This class implements a list for client informations
+  * @author Oliver Scheuss
+  */
+  class ClientInformation{
+  public:
+    ClientInformation();
+    ClientInformation(bool head);
+    //   ClientInformation(ClientInformation *prev, ClientInformation *next);
+    //   ClientInformation(ClientInformation *prev);
+    ~ClientInformation();
+    ClientInformation *next();
+    ClientInformation *prev();
+    bool setNext(ClientInformation *next);
+    bool setPrev(ClientInformation *prev);
+    ClientInformation *insertAfter(ClientInformation *ins);
+    ClientInformation *insertBefore(ClientInformation *ins);
+    ClientInformation *insertBack(ClientInformation *ins);
+    void setID(int clientID);
+    void setPeer(ENetPeer *peer);
+    void setGamestateID(int id);
+    int getID();
+    ENetPeer *getPeer();
+    int getGamestateID();
+    bool removeClient(int clientID);
+    bool removeClient(ENetPeer *peer);
+    ClientInformation *findClient(int clientID, bool look_backwards=false);
+    ClientInformation *findClient(ENetAddress *address, bool look_backwards=false);
 
-/**
- * This class implements a list for client informations
- * @author Oliver Scheuss
-*/
-class ClientInformation{
-public:
-  ClientInformation();
-  ClientInformation(bool head);
-//   ClientInformation(ClientInformation *prev, ClientInformation *next);
-//   ClientInformation(ClientInformation *prev);
-  ~ClientInformation();
-  ClientInformation *next();
-  ClientInformation *prev();
-  bool setNext(ClientInformation *next);
-  bool setPrev(ClientInformation *prev);
-  ClientInformation *insertAfter(ClientInformation *ins);
-  ClientInformation *insertBefore(ClientInformation *ins);
-  ClientInformation *insertBack(ClientInformation *ins);
-  void setID(int clientID);
-  void setPeer(ENetPeer *peer);
-  void setGamestateID(int id);
-  int getID();
-  ENetPeer *getPeer();
-  int getGamestateID();
-  bool removeClient(int clientID);
-  bool removeClient(ENetPeer *peer);
-  ClientInformation *findClient(int clientID, bool look_backwards=false);
-  ClientInformation *findClient(ENetAddress *address, bool look_backwards=false);
-  
-  void setSynched(bool s);
-  bool getSynched();
-  
-  bool head;
-  
-private:
-  ClientInformation *preve;
-  ClientInformation *nexte;
-  //actual information:
-  ENetPeer *peer_;
-  int clientID_;
-  int gamestateID_;
-  bool synched_;
-};
+    void setSynched(bool s);
+    bool getSynched();
+
+    bool head;
+
+  private:
+    ClientInformation *preve;
+    ClientInformation *nexte;
+    //actual information:
+    ENetPeer *peer_;
+    int clientID_;
+    int gamestateID_;
+    bool synched_;
+  };
 
 }
Index: code/branches/FICN/src/network/ConnectionManager.cc
===================================================================
--- code/branches/FICN/src/network/ConnectionManager.cc	(revision 774)
+++ code/branches/FICN/src/network/ConnectionManager.cc	(revision 777)
@@ -1,28 +1,28 @@
 /*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Oliver Scheuss, (C) 2007
- *   Co-authors:
- *      ...
- *
- */
+*   ORXONOX - the hottest 3D action shooter ever to exist
+*
+*
+*   License notice:
+*
+*   This program is free software; you can redistribute it and/or
+*   modify it under the terms of the GNU General Public License
+*   as published by the Free Software Foundation; either version 2
+*   of the License, or (at your option) any later version.
+*
+*   This program is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with this program; if not, write to the Free Software
+*   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*
+*   Author:
+*      Oliver Scheuss, (C) 2007
+*   Co-authors:
+*      ...
+*
+*/
 
 //
@@ -37,8 +37,16 @@
 //
 
+#include <iostream>
+// boost.thread library for multithreading support
+#include <boost/thread/thread.hpp>
+#include <boost/bind.hpp>
+
+#include "core/CoreIncludes.h"
+#include "ClientInformation.h"
 #include "ConnectionManager.h"
 
-namespace std{
-  bool operator< (ENetAddress a, ENetAddress b){
+namespace std
+{
+  bool operator< (ENetAddress a, ENetAddress b) {
     if(a.host <= b.host)
       return true;
@@ -48,9 +56,9 @@
 }
 
-namespace network{
-
+namespace network
+{
   boost::thread_group network_threads;
 
-  ConnectionManager::ConnectionManager(ClientInformation *head){
+  ConnectionManager::ConnectionManager(ClientInformation *head) {
     quit=false;
     bindAddress.host = ENET_HOST_ANY;
@@ -59,5 +67,5 @@
   }
 
-  ConnectionManager::ConnectionManager(int port, std::string address, ClientInformation *head){
+  ConnectionManager::ConnectionManager(int port, std::string address, ClientInformation *head) {
     quit=false;
     enet_address_set_host (& bindAddress, address.c_str());
@@ -66,5 +74,5 @@
   }
 
-  ConnectionManager::ConnectionManager(int port, const char *address, ClientInformation *head){
+  ConnectionManager::ConnectionManager(int port, const char *address, ClientInformation *head) {
     quit=false;
     enet_address_set_host (& bindAddress, address);
@@ -73,12 +81,12 @@
   }
 
-  ENetPacket *ConnectionManager::getPacket(ENetAddress &address){
+  ENetPacket *ConnectionManager::getPacket(ENetAddress &address) {
     if(!buffer.isEmpty())
       return buffer.pop(address);
     else
-        return NULL;
-  }
-
-  ENetPacket *ConnectionManager::getPacket(int &clientID){
+      return NULL;
+  }
+
+  ENetPacket *ConnectionManager::getPacket(int &clientID) {
     ENetAddress address;
     ENetPacket *packet=getPacket(address);
@@ -88,15 +96,15 @@
   }
 
-  bool ConnectionManager::queueEmpty(){
+  bool ConnectionManager::queueEmpty() {
     return buffer.isEmpty();
   }
 
-  void ConnectionManager::createListener(){
+  void ConnectionManager::createListener() {
     network_threads.create_thread(boost::bind(boost::mem_fn(&ConnectionManager::receiverThread), this));
-//     boost::thread thr(boost::bind(boost::mem_fn(&ConnectionManager::receiverThread), this));
+    //     boost::thread thr(boost::bind(boost::mem_fn(&ConnectionManager::receiverThread), this));
     return;
   }
 
-  bool ConnectionManager::quitListener(){
+  bool ConnectionManager::quitListener() {
     quit=true;
     network_threads.join_all();
@@ -104,5 +112,5 @@
   }
 
-  bool ConnectionManager::addPacket(ENetPacket *packet, ENetPeer *peer){
+  bool ConnectionManager::addPacket(ENetPacket *packet, ENetPeer *peer) {
     if(enet_peer_send(peer, head_->findClient(&(peer->address))->getID() , packet)!=0)
       return false;
@@ -110,5 +118,5 @@
   }
 
-  bool ConnectionManager::addPacket(ENetPacket *packet, int clientID){
+  bool ConnectionManager::addPacket(ENetPacket *packet, int clientID) {
     if(enet_peer_send(head_->findClient(clientID)->getPeer(), clientID, packet)!=0)
       return false;
@@ -116,13 +124,13 @@
   }
 
-  bool ConnectionManager::addPacketAll(ENetPacket *packet){
+  bool ConnectionManager::addPacketAll(ENetPacket *packet) {
     for(ClientInformation *i=head_->next(); i!=0; i=i->next()){
       if(enet_peer_send(i->getPeer(), i->getID(), packet)!=0)
-         return false;
-    }
-    return true;
-  }
-
-  bool ConnectionManager::sendPackets(ENetEvent *event){
+        return false;
+    }
+    return true;
+  }
+
+  bool ConnectionManager::sendPackets(ENetEvent *event) {
     if(server==NULL)
       return false;
@@ -133,5 +141,5 @@
   }
 
-  bool ConnectionManager::sendPackets(){
+  bool ConnectionManager::sendPackets() {
     ENetEvent event;
     if(server==NULL)
@@ -143,5 +151,5 @@
   }
 
-  void ConnectionManager::receiverThread(){
+  void ConnectionManager::receiverThread() {
     // what about some error-handling here ?
     enet_initialize();
@@ -164,16 +172,16 @@
         // log handling ================
         case ENET_EVENT_TYPE_CONNECT:
-        addClient(&event);
-        break;
-      case ENET_EVENT_TYPE_RECEIVE:
-        //std::cout << "received data" << std::endl;
-        processData(&event);
-        break;
-      case ENET_EVENT_TYPE_DISCONNECT:
-        // add some error/log handling here
-        clientDisconnect(event.peer);
-        break;
-      case ENET_EVENT_TYPE_NONE:
-        break;
+          addClient(&event);
+          break;
+        case ENET_EVENT_TYPE_RECEIVE:
+          //std::cout << "received data" << std::endl;
+          processData(&event);
+          break;
+        case ENET_EVENT_TYPE_DISCONNECT:
+          // add some error/log handling here
+          clientDisconnect(event.peer);
+          break;
+        case ENET_EVENT_TYPE_NONE:
+          break;
       }
     }
@@ -183,5 +191,5 @@
   }
 
-  void ConnectionManager::disconnectClients(){
+  void ConnectionManager::disconnectClients() {
     ENetEvent event;
     ClientInformation *temp = head_->next();
@@ -194,14 +202,14 @@
       switch (event.type)
       {
-        case ENET_EVENT_TYPE_NONE:
-        case ENET_EVENT_TYPE_CONNECT:
-        case ENET_EVENT_TYPE_RECEIVE:
-          enet_packet_destroy(event.packet);
-          break;
-        case ENET_EVENT_TYPE_DISCONNECT:
-          std::cout << "disconnecting client" << std::endl;
-          delete head_->findClient(&(event.peer->address));
-          temp = temp->next();
-          break;
+      case ENET_EVENT_TYPE_NONE:
+      case ENET_EVENT_TYPE_CONNECT:
+      case ENET_EVENT_TYPE_RECEIVE:
+        enet_packet_destroy(event.packet);
+        break;
+      case ENET_EVENT_TYPE_DISCONNECT:
+        std::cout << "disconnecting client" << std::endl;
+        delete head_->findClient(&(event.peer->address));
+        temp = temp->next();
+        break;
       }
     }
@@ -209,5 +217,5 @@
   }
 
-  bool ConnectionManager::processData(ENetEvent *event){
+  bool ConnectionManager::processData(ENetEvent *event) {
     // just add packet to the buffer
     // this can be extended with some preprocessing
@@ -215,15 +223,13 @@
   }
 
-//   bool ConnectionManager::clientDisconnect(ENetPeer *peer){
-//     return clientDisconnect(*peer);
-//   }
-
-
-
-  bool ConnectionManager::clientDisconnect(ENetPeer *peer){
+  //bool ConnectionManager::clientDisconnect(ENetPeer *peer) {
+  //  return clientDisconnect(*peer);
+  //}
+
+  bool ConnectionManager::clientDisconnect(ENetPeer *peer) {
     return head_->removeClient(peer);
   }
 
-  bool ConnectionManager::addClient(ENetEvent *event){
+  bool ConnectionManager::addClient(ENetEvent *event) {
     ClientInformation *temp = head_->insertBack(new ClientInformation);
     if(temp->prev()->head)
@@ -238,17 +244,17 @@
   }
 
-  int ConnectionManager::getClientID(ENetPeer peer){
+  int ConnectionManager::getClientID(ENetPeer peer) {
     return getClientID(peer.address);
   }
 
-  int ConnectionManager::getClientID(ENetAddress address){
+  int ConnectionManager::getClientID(ENetAddress address) {
     return head_->findClient(&address)->getID();
   }
 
-  ENetPeer *ConnectionManager::getClientPeer(int clientID){
+  ENetPeer *ConnectionManager::getClientPeer(int clientID) {
     return head_->findClient(clientID)->getPeer();
   }
 
-  void ConnectionManager::syncClassid(int clientID){
+  void ConnectionManager::syncClassid(int clientID) {
     int i=0;
     std::string classname;
Index: code/branches/FICN/src/network/ConnectionManager.h
===================================================================
--- code/branches/FICN/src/network/ConnectionManager.h	(revision 774)
+++ code/branches/FICN/src/network/ConnectionManager.h	(revision 777)
@@ -13,23 +13,19 @@
 #define _ConnectionManager_H__
 
-#include <iostream>
 #include <string>
 // enet library for networking support
 #include <enet/enet.h>
-// boost.thread library for multithreading support
-#include <boost/thread/thread.hpp>
-#include <boost/bind.hpp>
-// headerfiles
-#include "ClientInformation.h"
+
+#include "NetworkPrereqs.h"
 #include "PacketBuffer.h"
 #include "PacketManager.h"
-#include "core/CoreIncludes.h"
 
-namespace std{
+namespace std
+{
   bool operator<(ENetAddress a, ENetAddress b);
 }
 
-namespace network{
-  //
+namespace network
+{
 #define NETWORK_PORT 55556
 #define NETWORK_MAX_CONNECTIONS 50
@@ -42,7 +38,7 @@
     ClientList *next;
   };
-  
+
   class ConnectionManager{
-    public:
+  public:
     ConnectionManager(ClientInformation *head);
     ConnectionManager(int port, const char *address, ClientInformation *head);
@@ -71,8 +67,8 @@
     PacketBuffer buffer;
     PacketGenerator packet_gen;
-    
+
     ENetHost *server;
     ENetAddress bindAddress;
-    
+
     bool quit; // quit-variable (communication with threads)
     ClientInformation *head_;
Index: code/branches/FICN/src/network/GameStateClient.cc
===================================================================
--- code/branches/FICN/src/network/GameStateClient.cc	(revision 774)
+++ code/branches/FICN/src/network/GameStateClient.cc	(revision 777)
@@ -1,189 +1,183 @@
 /*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      ...
- *   Co-authors:
- *      ...
- *
- */
+*   ORXONOX - the hottest 3D action shooter ever to exist
+*
+*
+*   License notice:
+*
+*   This program is free software; you can redistribute it and/or
+*   modify it under the terms of the GNU General Public License
+*   as published by the Free Software Foundation; either version 2
+*   of the License, or (at your option) any later version.
+*
+*   This program is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with this program; if not, write to the Free Software
+*   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*
+*   Author:
+*      ...
+*   Co-authors:
+*      ...
+*
+*/
+#include <zlib.h>
 
+#include "core/CoreIncludes.h"
+#include "Synchronisable.h"
 #include "GameStateClient.h"
 
-namespace network {
-
-GameStateClient::GameStateClient()
+namespace network
 {
-}
-
-
-GameStateClient::~GameStateClient()
-{
-}
-
-bool GameStateClient::pushGameState(GameStateCompressed *compstate){
-  if(compstate->diffed)
-    return loadSnapshot(decode(reference, *compstate));
-  else
-    return loadSnapshot(decode(*compstate));
-}
-
-
-/**
- * This function removes a Synchronisable out of the universe
- * @param it iterator of the list pointing to the object
- * @return iterator pointing to the next object in the list
- */
-void GameStateClient::removeObject(orxonox::Iterator<Synchronisable> &it){
-  orxonox::Iterator<Synchronisable> temp=it;
-  ++it;
-  delete  *temp;
-}
-
-/**
- * This function loads a Snapshort of the gamestate into the universe
- * @param state a GameState struct containing the size of the gamestate and a pointer linking to a flat list (returned by getSnapshot)
- */
-bool GameStateClient::loadSnapshot(GameState state)
-{
-  unsigned char *data=state.data;
-  std::cout << "loadSnapshot: loading gs: " << state.id << std::endl;
-  // get the start of the Synchronisable list
-  orxonox::Iterator<Synchronisable> it=orxonox::ObjectList<Synchronisable>::start();
-  syncData sync;
-  // loop as long as we have some data ;)
-  while(data < state.data+state.size){
-    // prepare the syncData struct
-    sync.length = (int)*data;
-    data+=sizeof(int);
-    sync.objectID = (int)*data;
-    data+=sizeof(int);
-    sync.classID = (int)*data;
-    data+=sizeof(int);
-    sync.data = data;
-    data+=sync.length;
-
-    if(it->objectID!=sync.objectID){
-      // bad luck ;)
-      // delete the synchronisable (obviously seems to be deleted on the server)
-      while(it != 0 && it->objectID!=sync.objectID){
-        removeObject(it);
-      }
-      if(it==0){
-        std::cout << "classid: " << sync.classID << ", name: " << ID(sync.classID)->getName() << std::endl;
-        orxonox::BaseObject *no = ID(sync.classID)->fabricate();
-        ((Synchronisable *)no)->objectID=sync.objectID;
-        ((Synchronisable *)no)->classID=sync.classID;
-        it=orxonox::ObjectList<Synchronisable>::end();
-        // update data and create object/entity...
-        if( !(((Synchronisable *)no)->updateData(sync)) && !(((Synchronisable *)no)->create()) )
-          COUT(0) << "We couldn't create/update the object: " << sync.objectID << std::endl;
-        ++it;
-      }
-    } else {
-      // we have our object
-      if(! it->updateData(sync))
-        std::cout << "We couldn't update objectID: " \
-            << sync.objectID << "; classID: " << sync.classID << std::endl;
-    }
-    ++it;
+  GameStateClient::GameStateClient() {
   }
 
-  return true;
-}
+  GameStateClient::~GameStateClient() {
+  }
 
-GameState GameStateClient::diff(GameState a, GameState b){
-  unsigned char *ap = a.data, *bp = b.data;
-  int of=0; // pointers offset
-  int dest_length=0;
-  if(a.size>=b.size)
-    dest_length=a.size;
-  else
-    dest_length=b.size;
-  unsigned char *dp = (unsigned char *)malloc(dest_length*sizeof(unsigned char));
-  while(of<a.size && of<b.size){
-    *(dp+of)=*(ap+of)^*(bp+of); // do the xor
-    ++of;
+  bool GameStateClient::pushGameState(GameStateCompressed *compstate) {
+    if(compstate->diffed)
+      return loadSnapshot(decode(reference, *compstate));
+    else
+      return loadSnapshot(decode(*compstate));
   }
-  if(a.size!=b.size){ // do we have to fill up ?
-    unsigned char n=0;
-    if(a.size<b.size){
-      while(of<dest_length){
-        *(dp+of)=n^*(bp+of);
-        of++;
+
+  /**
+  * This function removes a Synchronisable out of the universe
+  * @param it iterator of the list pointing to the object
+  * @return iterator pointing to the next object in the list
+  */
+  void GameStateClient::removeObject(orxonox::Iterator<Synchronisable> &it) {
+    orxonox::Iterator<Synchronisable> temp=it;
+    ++it;
+    delete  *temp;
+  }
+
+  /**
+  * This function loads a Snapshort of the gamestate into the universe
+  * @param state a GameState struct containing the size of the gamestate and a pointer linking to a flat list (returned by getSnapshot)
+  */
+  bool GameStateClient::loadSnapshot(GameState state) {
+    unsigned char *data=state.data;
+    std::cout << "loadSnapshot: loading gs: " << state.id << std::endl;
+    // get the start of the Synchronisable list
+    orxonox::Iterator<Synchronisable> it=orxonox::ObjectList<Synchronisable>::start();
+    syncData sync;
+    // loop as long as we have some data ;)
+    while(data < state.data+state.size){
+      // prepare the syncData struct
+      sync.length = (int)*data;
+      data+=sizeof(int);
+      sync.objectID = (int)*data;
+      data+=sizeof(int);
+      sync.classID = (int)*data;
+      data+=sizeof(int);
+      sync.data = data;
+      data+=sync.length;
+
+      if(it->objectID!=sync.objectID){
+        // bad luck ;)
+        // delete the synchronisable (obviously seems to be deleted on the server)
+        while(it != 0 && it->objectID!=sync.objectID){
+          removeObject(it);
+        }
+        if(it==0){
+          std::cout << "classid: " << sync.classID << ", name: " << ID(sync.classID)->getName() << std::endl;
+          Synchronisable *no = (Synchronisable*)(ID(sync.classID)->fabricate());
+          no->objectID=sync.objectID;
+          no->classID=sync.classID;
+          it=orxonox::ObjectList<Synchronisable>::end();
+          // update data and create object/entity...
+          if( !no->updateData(sync) && !no->create() )
+            COUT(0) << "We couldn't create/update the object: " << sync.objectID << std::endl;
+          ++it;
+        }
+      } else {
+        // we have our object
+        if(! it->updateData(sync))
+          std::cout << "We couldn't update objectID: " \
+          << sync.objectID << "; classID: " << sync.classID << std::endl;
       }
-    } else{
-      while(of<dest_length){
-        *(dp+of)=*(ap+of)^n;
-        of++;
+      ++it;
+    }
+
+    return true;
+  }
+
+  GameState GameStateClient::diff(GameState a, GameState b) {
+    unsigned char *ap = a.data, *bp = b.data;
+    int of=0; // pointers offset
+    int dest_length=0;
+    if(a.size>=b.size)
+      dest_length=a.size;
+    else
+      dest_length=b.size;
+    unsigned char *dp = (unsigned char *)malloc(dest_length*sizeof(unsigned char));
+    while(of<a.size && of<b.size){
+      *(dp+of)=*(ap+of)^*(bp+of); // do the xor
+      ++of;
+    }
+    if(a.size!=b.size){ // do we have to fill up ?
+      unsigned char n=0;
+      if(a.size<b.size){
+        while(of<dest_length){
+          *(dp+of)=n^*(bp+of);
+          of++;
+        }
+      } else{
+        while(of<dest_length){
+          *(dp+of)=*(ap+of)^n;
+          of++;
+        }
       }
     }
-  }
-  // should be finished now
-  GameState r = {b.id, dest_length, dp};
-  return r;
-}
-
-
-GameState GameStateClient::decompress(GameStateCompressed a){
-  int normsize = a.normsize;
-  int compsize = a.compsize;
-  int bufsize;
-  if(normsize < compsize)
-    bufsize = compsize;
-  else
-    bufsize = normsize;
-  unsigned char* dest = (unsigned char*)malloc( bufsize );
-  int retval;
-  uLongf length=normsize;
-  //std::cout << "gamestateclient" << std::endl;
-  //std::cout << "normsize " << a.normsize << " compsize " << a.compsize << " " << bufsize << std::endl;
-  retval = uncompress( dest, &length, a.data, (uLong)compsize );
-  //std::cout << "length " << length << std::endl;
-  switch ( retval ) {
-    case Z_OK: std::cout << "successfully decompressed" << std::endl; break;
-    case Z_MEM_ERROR: std::cout << "not enough memory available" << std::endl; break;
-    case Z_BUF_ERROR: std::cout << "not enough memory available in the buffer" << std::endl; break;
-    case Z_DATA_ERROR: std::cout << "data corrupted" << std::endl; break;
+    // should be finished now
+    GameState r = {b.id, dest_length, dp};
+    return r;
   }
 
-  GameState gamestate;
-  gamestate.id = a.id;
-  gamestate.size = normsize;
-  gamestate.data = dest;
-  gamestate.diffed = a.diffed;
-  
-  return gamestate;
-}
+  GameState GameStateClient::decompress(GameStateCompressed a) {
+    int normsize = a.normsize;
+    int compsize = a.compsize;
+    int bufsize;
+    if(normsize < compsize)
+      bufsize = compsize;
+    else
+      bufsize = normsize;
+    unsigned char* dest = (unsigned char*)malloc( bufsize );
+    int retval;
+    uLongf length=normsize;
+    //std::cout << "gamestateclient" << std::endl;
+    //std::cout << "normsize " << a.normsize << " compsize " << a.compsize << " " << bufsize << std::endl;
+    retval = uncompress( dest, &length, a.data, (uLong)compsize );
+    //std::cout << "length " << length << std::endl;
+    switch ( retval ) {
+      case Z_OK: std::cout << "successfully decompressed" << std::endl; break;
+      case Z_MEM_ERROR: std::cout << "not enough memory available" << std::endl; break;
+      case Z_BUF_ERROR: std::cout << "not enough memory available in the buffer" << std::endl; break;
+      case Z_DATA_ERROR: std::cout << "data corrupted" << std::endl; break;
+    }
 
+    GameState gamestate;
+    gamestate.id = a.id;
+    gamestate.size = normsize;
+    gamestate.data = dest;
+    gamestate.diffed = a.diffed;
 
-GameState GameStateClient::decode(GameState a, GameStateCompressed x){
-  GameState t = decompress(x);
-  return diff(a, t);
-}
+    return gamestate;
+  }
 
-GameState GameStateClient::decode(GameStateCompressed x){
-  GameState t = decompress(x);
-  return t;
-}
+  GameState GameStateClient::decode(GameState a, GameStateCompressed x) {
+    GameState t = decompress(x);
+    return diff(a, t);
+  }
 
-
+  GameState GameStateClient::decode(GameStateCompressed x) {
+    GameState t = decompress(x);
+    return t;
+  }
 
 }
Index: code/branches/FICN/src/network/GameStateClient.h
===================================================================
--- code/branches/FICN/src/network/GameStateClient.h	(revision 774)
+++ code/branches/FICN/src/network/GameStateClient.h	(revision 777)
@@ -13,27 +13,25 @@
 #define _GameStateClient_H__
 
-#include "zlib.h"
-#include "Synchronisable.h"
-#include "core/CoreIncludes.h"
-#include "core/BaseObject.h"
+#include "NetworkPrereqs.h"
 #include "GameStateManager.h"
 
-namespace network {
+namespace network
+{
+  class GameStateClient
+  {
+  public:
+    GameStateClient();
+    ~GameStateClient();
+    bool pushGameState(GameStateCompressed *compstate);
+  private:
+    bool loadSnapshot(GameState state);
+    GameState diff(GameState a, GameState b);
+    GameState decompress(GameStateCompressed a);
+    GameState decode(GameState a, GameStateCompressed x);
+    GameState decode(GameStateCompressed x);
+    void removeObject(orxonox::Iterator<Synchronisable> &it);
 
-class GameStateClient{
-public:
-  GameStateClient();
-  ~GameStateClient();
-  bool pushGameState(GameStateCompressed *compstate);
-private:
-  bool loadSnapshot(GameState state);
-  GameState diff(GameState a, GameState b);
-  GameState decompress(GameStateCompressed a);
-  GameState decode(GameState a, GameStateCompressed x);
-  GameState decode(GameStateCompressed x);
-  void removeObject(orxonox::Iterator<Synchronisable> &it);
-
-  GameState reference;
-};
+    GameState reference;
+  };
 
 }
Index: code/branches/FICN/src/network/GameStateManager.cc
===================================================================
--- code/branches/FICN/src/network/GameStateManager.cc	(revision 774)
+++ code/branches/FICN/src/network/GameStateManager.cc	(revision 777)
@@ -1,28 +1,28 @@
 /*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Oliver Scheuss, (C) 2007
- *   Co-authors:
- *      ...
- *
- */
+*   ORXONOX - the hottest 3D action shooter ever to exist
+*
+*
+*   License notice:
+*
+*   This program is free software; you can redistribute it and/or
+*   modify it under the terms of the GNU General Public License
+*   as published by the Free Software Foundation; either version 2
+*   of the License, or (at your option) any later version.
+*
+*   This program is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with this program; if not, write to the Free Software
+*   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*
+*   Author:
+*      Oliver Scheuss, (C) 2007
+*   Co-authors:
+*      ...
+*
+*/
 
 //
@@ -37,206 +37,206 @@
 //
 //
+
+#include <utility>
+#include <iostream>
+#include <zlib.h>
+
+#include "core/CoreIncludes.h"
+#include "ClientInformation.h"
+#include "Synchronisable.h"
 #include "GameStateManager.h"
 
-namespace network {
-
-GameStateManager::GameStateManager(ClientInformation *head)
+namespace network
 {
-  id=0;
-  head_=head;
+  GameStateManager::GameStateManager(ClientInformation *head) {
+    id=0;
+    head_=head;
+  }
+
+  GameStateManager::~GameStateManager() {
+  }
+
+  void GameStateManager::update(){
+    reference = getSnapshot(id);
+    gameStateMap.insert(std::pair<int, GameState*>(id, reference));
+    gameStateUsed[id]=0;
+    ++id;
+    return;
+  }
+
+  GameStateCompressed GameStateManager::popGameState(int clientID) {
+    int gID = head_->findClient(clientID)->getGamestateID();
+    std::cout << "popgamestate: sending gstate id: " << id << "diffed from: " << gID << std::endl;
+    if(gID!=GAMESTATEID_INITIAL){
+      GameState *client = gameStateMap[gID];
+      GameState *server = reference;
+      //head_->findClient(clientID)->setGamestateID(id);
+      return encode(client, server);
+    } else {
+      GameState *server = reference;
+      //head_->findClient(clientID)->setGamestateID(id);
+      return encode(server);
+      // return an undiffed gamestate and set appropriate flags
+    }
+  }
+
+  /**
+  * This function goes through the whole list of synchronisables and
+  * saves all the synchronisables to a flat "list".
+  * @return struct of type gamestate containing the size of the whole gamestate and a pointer linking to the flat list
+  */
+  GameState *GameStateManager::getSnapshot(int id)
+  {
+    //the size of the gamestate
+    int totalsize=0;
+    int memsize=1000;
+    //the size of one specific synchronisable
+    int tempsize=0;
+    // get the start of the Synchronisable list
+    orxonox::Iterator<Synchronisable> it;
+    // struct for return value of Synchronisable::getData()
+    syncData sync;
+
+    GameState *retval=new GameState; //return value
+    retval->id=id++;
+    std::cout << "producing gamestate with id: " << retval->id << std::endl;
+    // reserve a little memory and increase it later on
+    //COUT(2) << "mallocing" << std::endl;
+    retval->data = (unsigned char*)malloc(memsize);
+    //COUT(2) << "malloced" << std::endl;
+
+    // offset of memory functions
+    int offset=0;
+    // go through all Synchronisables
+    for(it = orxonox::ObjectList<Synchronisable>::start(); it != 0; ++it){
+      //std::cout << "gamestatemanager: in for loop" << std::endl;
+      //get size of the synchronisable
+      tempsize=it->getSize();
+      //std::cout << "size of temp gamestate: " << tempsize << std::endl;
+      //COUT(2) << "size of synchronisable: " << tempsize << std::endl;
+      // add place for data and 3 ints (length,classid,objectid)
+      totalsize+=tempsize+3*sizeof(int);
+      //std::cout << "totalsize: " << totalsize << std::endl;
+      // allocate additional space
+      if(totalsize+tempsize>memsize){
+        if(tempsize<1000){
+          retval->data = (unsigned char *)realloc((void *)retval->data, totalsize+1000);
+          memsize+=1000;
+        } else {
+          retval->data = (unsigned char *)realloc((void *)retval->data, totalsize+1000);
+          memsize+=tempsize+1000;
+        }
+      }
+
+      // run Synchronisable::getData with offset and additional place for 3 ints in between (for ids and length)
+      sync=it->getData((retval->data)+offset+3*sizeof(int));
+      *(retval->data+offset)=sync.length;
+      *(retval->data+offset+sizeof(int))=sync.objectID;
+      *(retval->data+offset+2*sizeof(int))=sync.classID;
+      // increase data pointer
+      offset+=tempsize+3*sizeof(int);
+    }
+    retval->size=totalsize;
+    return retval;
+  }
+
+  GameStateCompressed GameStateManager::encode(GameState *a, GameState *b) {
+    //GameState r = diff(a,b);
+    //r.diffed = true;
+    GameState r = *b;
+    r.diffed = false;
+    return compress_(&r);
+  }
+
+  GameStateCompressed GameStateManager::encode(GameState *a) {
+    a->diffed=false;
+    return compress_(a);
+  }
+
+  GameState GameStateManager::diff(GameState *a, GameState *b) {
+    unsigned char *ap = a->data, *bp = b->data;
+    int of=0; // pointers offset
+    int dest_length=0;
+    if(a->size>=b->size)
+      dest_length=a->size;
+    else
+      dest_length=b->size;
+    unsigned char *dp = (unsigned char *)malloc(dest_length*sizeof(unsigned char));
+    while(of<a->size && of<b->size){
+      *(dp+of)=*(ap+of)^*(bp+of); // do the xor
+      ++of;
+    }
+    if(a->size!=b->size){ // do we have to fill up ?
+      unsigned char n=0;
+      if(a->size<b->size){
+        while(of<dest_length){
+          *(dp+of)=n^*(bp+of);
+          of++;
+        }
+      } else{
+        while(of<dest_length){
+          *(dp+of)=*(ap+of)^n;
+          of++;
+        }
+      }
+    }
+    // should be finished now
+    GameState r = {b->id, dest_length, dp};
+    return r;
+  }
+
+  GameStateCompressed GameStateManager::compress_(GameState *a) {
+    //COUT(2) << "compressing gamestate" << std::endl;
+    int size = a->size;
+    uLongf buffer = (uLongf)((a->size + 12)*1.01)+1;
+    unsigned char* dest = (unsigned char*)malloc( buffer );
+    int retval;
+    //std::cout << "before ziped " << buffer << std::endl;
+    retval = compress( dest, &buffer, a->data, (uLong)size );
+    //std::cout << "after ziped " << buffer << std::endl;
+
+    switch ( retval ) {
+      case Z_OK: std::cout << "successfully compressed" << std::endl; break;
+      case Z_MEM_ERROR: std::cout << "not enough memory available" << std::endl; break;
+      case Z_BUF_ERROR: std::cout << "not enough memory available in the buffer" << std::endl; break;
+      case Z_DATA_ERROR: std::cout << "decompress: data corrupted" << std::endl; break;
+    }
+
+    GameStateCompressed compressedGamestate;
+    compressedGamestate.compsize = buffer;
+    //std::cout << "compressedGamestate.compsize = buffer; " << buffer << std::endl;
+    compressedGamestate.normsize = size;
+    //std::cout << "compressedGamestate.normsize = size; " << size << std::endl;
+    compressedGamestate.id = a->id;
+    compressedGamestate.data = dest;
+    compressedGamestate.diffed = a->diffed;
+
+    return compressedGamestate;
+  }
+
+  void GameStateManager::ackGameState(int clientID, int gamestateID) {
+    ClientInformation *temp = head_->findClient(clientID);
+    int curid = temp->getID();
+    // decrease usage of gamestate and save it
+    deleteUnusedGameState(curid);
+    //increase gamestateused
+    ++gameStateUsed.find(gamestateID)->second;
+    temp->setGamestateID(gamestateID);
+    /*
+    GameState *old = clientGameState[clientID];
+    deleteUnusedGameState(old);
+    clientGameState[clientID]=idGameState[gamestateID];*/
+  }
+
+  bool GameStateManager::deleteUnusedGameState(int gamestateID) {
+    int used = --(gameStateUsed.find(gamestateID)->second);
+    if(id-gamestateID>KEEP_GAMESTATES && used==0){
+      // delete gamestate
+      delete gameStateMap.find(gamestateID)->second;
+      gameStateMap.erase(gamestateID);
+      return true;
+    }
+    return false;
+  }
+
 }
-
-GameStateManager::~GameStateManager()
-{
-}
-
-void GameStateManager::update(){
-  reference = getSnapshot(id);
-  gameStateMap.insert(std::pair<int, GameState*>(id, reference));
-  gameStateUsed[id]=0;
-  ++id;
-  return;
-}
-
-GameStateCompressed GameStateManager::popGameState(int clientID){
-  int gID = head_->findClient(clientID)->getGamestateID();
-  std::cout << "popgamestate: sending gstate id: " << id << "diffed from: " << gID << std::endl;
-  if(gID!=GAMESTATEID_INITIAL){
-    GameState *client = gameStateMap[gID];
-    GameState *server = reference;
-    //head_->findClient(clientID)->setGamestateID(id);
-    return encode(client, server);
-  } else {
-    GameState *server = reference;
-    //head_->findClient(clientID)->setGamestateID(id);
-    return encode(server);
-    // return an undiffed gamestate and set appropriate flags
-  }
-}
-
-
-
-/**
- * This function goes through the whole list of synchronisables and
- * saves all the synchronisables to a flat "list".
- * @return struct of type gamestate containing the size of the whole gamestate and a pointer linking to the flat list
- */
-GameState *GameStateManager::getSnapshot(int id)
-{
-  //the size of the gamestate
-  int totalsize=0;
-  int memsize=1000;
-  //the size of one specific synchronisable
-  int tempsize=0;
-  // get the start of the Synchronisable list
-  orxonox::Iterator<Synchronisable> it;
-  // struct for return value of Synchronisable::getData()
-  syncData sync;
-
-  GameState *retval=new GameState; //return value
-  retval->id=id++;
-  std::cout << "producing gamestate with id: " << retval->id << std::endl;
-  // reserve a little memory and increase it later on
-  //COUT(2) << "mallocing" << std::endl;
-  retval->data = (unsigned char*)malloc(memsize);
-  //COUT(2) << "malloced" << std::endl;
-
-  // offset of memory functions
-  int offset=0;
-  // go through all Synchronisables
-  for(it = orxonox::ObjectList<Synchronisable>::start(); it != 0; ++it){
-    //std::cout << "gamestatemanager: in for loop" << std::endl;
-    //get size of the synchronisable
-    tempsize=it->getSize();
-    //std::cout << "size of temp gamestate: " << tempsize << std::endl;
-    //COUT(2) << "size of synchronisable: " << tempsize << std::endl;
-    // add place for data and 3 ints (length,classid,objectid)
-    totalsize+=tempsize+3*sizeof(int);
-    //std::cout << "totalsize: " << totalsize << std::endl;
-    // allocate additional space
-    if(totalsize+tempsize>memsize){
-      if(tempsize<1000){
-        retval->data = (unsigned char *)realloc((void *)retval->data, totalsize+1000);
-        memsize+=1000;
-      } else {
-        retval->data = (unsigned char *)realloc((void *)retval->data, totalsize+1000);
-        memsize+=tempsize+1000;
-      }
-    }
-
-    // run Synchronisable::getData with offset and additional place for 3 ints in between (for ids and length)
-    sync=it->getData((retval->data)+offset+3*sizeof(int));
-    *(retval->data+offset)=sync.length;
-    *(retval->data+offset+sizeof(int))=sync.objectID;
-    *(retval->data+offset+2*sizeof(int))=sync.classID;
-    // increase data pointer
-    offset+=tempsize+3*sizeof(int);
-  }
-  retval->size=totalsize;
-  return retval;
-}
-
-
-
-GameStateCompressed GameStateManager::encode(GameState *a, GameState *b){
-  //GameState r = diff(a,b);
-  //r.diffed = true;
-  GameState r = *b;
-  r.diffed = false;
-  return compress_(&r);
-}
-
-GameStateCompressed GameStateManager::encode(GameState *a){
-  a->diffed=false;
-  return compress_(a);
-}
-
-GameState GameStateManager::diff(GameState *a, GameState *b){
-  unsigned char *ap = a->data, *bp = b->data;
-  int of=0; // pointers offset
-  int dest_length=0;
-  if(a->size>=b->size)
-    dest_length=a->size;
-  else
-    dest_length=b->size;
-  unsigned char *dp = (unsigned char *)malloc(dest_length*sizeof(unsigned char));
-  while(of<a->size && of<b->size){
-    *(dp+of)=*(ap+of)^*(bp+of); // do the xor
-    ++of;
-  }
-  if(a->size!=b->size){ // do we have to fill up ?
-    unsigned char n=0;
-    if(a->size<b->size){
-      while(of<dest_length){
-        *(dp+of)=n^*(bp+of);
-        of++;
-      }
-    } else{
-      while(of<dest_length){
-        *(dp+of)=*(ap+of)^n;
-        of++;
-      }
-    }
-  }
-  // should be finished now
-  GameState r = {b->id, dest_length, dp};
-  return r;
-}
-
-GameStateCompressed GameStateManager::compress_(GameState *a) {
-  //COUT(2) << "compressing gamestate" << std::endl;
-  int size = a->size;
-  uLongf buffer = (uLongf)((a->size + 12)*1.01)+1;
-  unsigned char* dest = (unsigned char*)malloc( buffer );
-  int retval;
-  //std::cout << "before ziped " << buffer << std::endl;
-  retval = compress( dest, &buffer, a->data, (uLong)size );
-  //std::cout << "after ziped " << buffer << std::endl;
-
-  switch ( retval ) {
-  case Z_OK: std::cout << "successfully compressed" << std::endl; break;
-  case Z_MEM_ERROR: std::cout << "not enough memory available" << std::endl; break;
-  case Z_BUF_ERROR: std::cout << "not enough memory available in the buffer" << std::endl; break;
-  case Z_DATA_ERROR: std::cout << "decompress: data corrupted" << std::endl; break;
-  }
-
-  GameStateCompressed compressedGamestate;
-  compressedGamestate.compsize = buffer;
-  //std::cout << "compressedGamestate.compsize = buffer; " << buffer << std::endl;
-  compressedGamestate.normsize = size;
-  //std::cout << "compressedGamestate.normsize = size; " << size << std::endl;
-  compressedGamestate.id = a->id;
-  compressedGamestate.data = dest;
-  compressedGamestate.diffed = a->diffed;
-
-  return compressedGamestate;
-}
-
-void GameStateManager::ackGameState(int clientID, int gamestateID){
-  ClientInformation *temp = head_->findClient(clientID);
-  int curid = temp->getID();
-  // decrease usage of gamestate and save it
-  deleteUnusedGameState(curid);
-  //increase gamestateused
-  ++gameStateUsed.find(gamestateID)->second;
-  temp->setGamestateID(gamestateID);
-  /*
-  GameState *old = clientGameState[clientID];
-  deleteUnusedGameState(old);
-  clientGameState[clientID]=idGameState[gamestateID];*/
-}
-
-bool GameStateManager::deleteUnusedGameState(int gamestateID){
-  int used = --(gameStateUsed.find(gamestateID)->second);
-  if(id-gamestateID>KEEP_GAMESTATES && used==0){
-    // delete gamestate
-    delete gameStateMap.find(gamestateID)->second;
-    gameStateMap.erase(gamestateID);
-    return true;
-  }
-  return false;
-}
-
-}
-
-
Index: code/branches/FICN/src/network/GameStateManager.h
===================================================================
--- code/branches/FICN/src/network/GameStateManager.h	(revision 774)
+++ code/branches/FICN/src/network/GameStateManager.h	(revision 777)
@@ -15,52 +15,48 @@
 #include <map>
 
-#include "zlib.h"
-
-#include "ClientInformation.h"
-#include "Synchronisable.h"
-#include "core/CoreIncludes.h"
-#include "core/Iterator.h"
+#include "NetworkPrereqs.h"
 #include "PacketTypes.h"
 
-namespace network {
+namespace network
+{
 
 #define KEEP_GAMESTATES 20
 
-/**
- * This Class implements a manager for gamestates:
- * - creating snapshots of gamestates
- * - writing gamestates to universe
- * - diffing gamestates ?
- * 
- * EN/DECODATION:
- * a: last Gamestate a client has received
- * b: new Gamestate
- * x: diffed and compressed gamestate
- * x=(a^b)
- * b=(a^x)
- * diff(a,diff(a,x))=x (hope this is correct)
- * @author Oliver Scheuss
-*/
-class GameStateManager{
-public:
-  GameStateManager(ClientInformation *head);
-  ~GameStateManager();
-  void update();
-  GameStateCompressed popGameState(int clientID);
-  void ackGameState(int clientID, int gamestateID);
-  int id;
-private:
-  GameState *getSnapshot(int id);
-  GameStateCompressed encode(GameState *a, GameState *b);
-  GameStateCompressed encode(GameState *a);
-  GameState diff(GameState *a, GameState *b);
-  GameStateCompressed compress_(GameState *a);
-  bool deleteUnusedGameState(int gamestateID);
-  
-  std::map<int, GameState*> gameStateMap; //map gsID to gamestate*
-  std::map<int, int> gameStateUsed; // save the number of clients, that use the specific gamestate
-  GameState *reference;
-  ClientInformation *head_;
-};
+  /**
+  * This Class implements a manager for gamestates:
+  * - creating snapshots of gamestates
+  * - writing gamestates to universe
+  * - diffing gamestates ?
+  * 
+  * EN/DECODATION:
+  * a: last Gamestate a client has received
+  * b: new Gamestate
+  * x: diffed and compressed gamestate
+  * x=(a^b)
+  * b=(a^x)
+  * diff(a,diff(a,x))=x (hope this is correct)
+  * @author Oliver Scheuss
+  */
+  class GameStateManager{
+  public:
+    GameStateManager(ClientInformation *head);
+    ~GameStateManager();
+    void update();
+    GameStateCompressed popGameState(int clientID);
+    void ackGameState(int clientID, int gamestateID);
+    int id;
+  private:
+    GameState *getSnapshot(int id);
+    GameStateCompressed encode(GameState *a, GameState *b);
+    GameStateCompressed encode(GameState *a);
+    GameState diff(GameState *a, GameState *b);
+    GameStateCompressed compress_(GameState *a);
+    bool deleteUnusedGameState(int gamestateID);
+
+    std::map<int, GameState*> gameStateMap; //map gsID to gamestate*
+    std::map<int, int> gameStateUsed; // save the number of clients, that use the specific gamestate
+    GameState *reference;
+    ClientInformation *head_;
+  };
 
 }
Index: code/branches/FICN/src/network/NetworkFrameListener.h
===================================================================
--- code/branches/FICN/src/network/NetworkFrameListener.h	(revision 774)
+++ code/branches/FICN/src/network/NetworkFrameListener.h	(revision 777)
@@ -16,30 +16,29 @@
 #include <OgreFrameListener.h>
 
+#include "NetworkPrereqs.h"
 #include "Server.h"
 #include "Client.h"
-//#include <iostream>
-// #include "orxonox/Orxonox.cc"
+
 network::Server *server_g;
 network::Client *client_g;
 
-namespace network{
+namespace network
+{
+  class ServerFrameListener : public Ogre::FrameListener{
+  private:
+    bool frameStarted(const Ogre::FrameEvent &evt){
+      server_g->tick(evt.timeSinceLastFrame);
+      return FrameListener::frameStarted(evt);
+    }
+  };
 
-
-class ServerFrameListener : public Ogre::FrameListener{
-private:
-  bool frameStarted(const Ogre::FrameEvent &evt){
-    server_g->tick(evt.timeSinceLastFrame);
-    return FrameListener::frameStarted(evt);
-  }
-};
-
-class ClientFrameListener : public Ogre::FrameListener{
-private:
-  bool frameStarted(const Ogre::FrameEvent &evt){
-    //std::cout << "framelistener" << std::endl;
-    client_g->tick(evt.timeSinceLastFrame);
-    return FrameListener::frameStarted(evt);
-  }
-};
+  class ClientFrameListener : public Ogre::FrameListener{
+  private:
+    bool frameStarted(const Ogre::FrameEvent &evt){
+      //std::cout << "framelistener" << std::endl;
+      client_g->tick(evt.timeSinceLastFrame);
+      return FrameListener::frameStarted(evt);
+    }
+  };
 
 
Index: code/branches/FICN/src/network/NetworkPrereqs.h
===================================================================
--- code/branches/FICN/src/network/NetworkPrereqs.h	(revision 777)
+++ code/branches/FICN/src/network/NetworkPrereqs.h	(revision 777)
@@ -0,0 +1,90 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file  NetworkPrereqs.h
+ @brief Contains all the necessary forward declarations for all classes, structs and enums.
+ */
+
+#ifndef _NetworkPrereqs_H__
+#define _NetworkPrereqs_H__
+
+#include "orxonox/OrxonoxPlatform.h"
+
+//-----------------------------------------------------------------------
+// Shared library settings
+//-----------------------------------------------------------------------
+#if (ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32) && !defined( NETWORK_STATIC_BUILD )
+#  ifdef NETWORK_SHARED_BUILD
+#    define _NetworkExport __declspec(dllexport)
+#  else
+#    if defined( __MINGW32__ )
+#      define _NetworkExport
+#    else
+#      define _NetworkExport __declspec(dllimport)
+#    endif
+#  endif
+#elif defined ( ORXONOX_GCC_VISIBILITY )
+#  define _NetworkExport  __attribute__ ((visibility("default")))
+#else
+#  define _NetworkExport
+#endif
+
+
+//-----------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------
+namespace network
+{
+  class Client;
+  class ClientConnection;
+  class ClientFrameListener;
+  class ClientInformation;
+  class ConnectionManager;
+  class GameStateClient;
+  class GameStateManager;
+  class PacketBuffer;
+  class PacketDecoder;
+  class PacketGenerator;
+  class Server;
+  class ServerFrameListener;
+  class Synchronisable;
+  struct ack;
+  struct chat;
+  struct classid;
+  struct ClientList;
+  struct GameState;
+  struct GameStateCompressed;
+  struct keyboard;
+  struct mouse;
+  struct PacketEnvelope;
+  struct QueueItem;
+  struct synchData;
+  struct synchronisableVariable;
+}
+
+#endif /* _NetworkPrereqs_H__ */
Index: code/branches/FICN/src/network/PacketBuffer.cc
===================================================================
--- code/branches/FICN/src/network/PacketBuffer.cc	(revision 774)
+++ code/branches/FICN/src/network/PacketBuffer.cc	(revision 777)
@@ -1,28 +1,28 @@
 /*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Oliver Scheuss, (C) 2007
- *   Co-authors:
- *      ...
- *
- */
+*   ORXONOX - the hottest 3D action shooter ever to exist
+*
+*
+*   License notice:
+*
+*   This program is free software; you can redistribute it and/or
+*   modify it under the terms of the GNU General Public License
+*   as published by the Free Software Foundation; either version 2
+*   of the License, or (at your option) any later version.
+*
+*   This program is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with this program; if not, write to the Free Software
+*   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*
+*   Author:
+*      Oliver Scheuss, (C) 2007
+*   Co-authors:
+*      ...
+*
+*/
 
 // C++ PacketBuffer
@@ -30,107 +30,107 @@
 // Author Oliver Scheuss
 
-#ifndef NETWORK_PACKETBUFFER_CC
-#define NETWORK_PACKETBUFFER_CC
+#include <iostream>
+#include <queue>
+#include <string>
+#include <boost/bind.hpp>
+#include <boost/thread/mutex.hpp>
 
-#include <iostream>
 #include "PacketBuffer.h"
 
-namespace network{
+namespace network
+{
+  boost::mutex networkPacketBufferMutex;
 
-   boost::mutex networkPacketBufferMutex;
-
-PacketBuffer::PacketBuffer(){
-  closed=false;
-  first=NULL;
-  last=NULL;
-}
-    //this is needed in order to make the packetbuffer threadsafe
+  PacketBuffer::PacketBuffer() {
+    closed=false;
+    first=NULL;
+    last=NULL;
+  }
+  //this is needed in order to make the packetbuffer threadsafe
 
 
-bool PacketBuffer::push(ENetEvent *ev){
-  boost::mutex::scoped_lock lock(networkPacketBufferMutex);
-  //std::cout << "event size inside packetbuffer " << ev->packet->dataLength << std::endl;
-//   if(closed)
-//     return false;
-  // first element?
-  if(first==NULL){
-    first=new QueueItem;
-    last=first;
-    last->next=NULL;
-    // change this!!!!!!!
-    last->packet = ev->packet;
-    last->address = ev->peer->address;
+  bool PacketBuffer::push(ENetEvent *ev) {
+    boost::mutex::scoped_lock lock(networkPacketBufferMutex);
+    //std::cout << "event size inside packetbuffer " << ev->packet->dataLength << std::endl;
+    //   if(closed)
+    //     return false;
+    // first element?
+    if(first==NULL){
+      first=new QueueItem;
+      last=first;
+      last->next=NULL;
+      // change this!!!!!!!
+      last->packet = ev->packet;
+      last->address = ev->peer->address;
     } else {
-    //insert a new element at the bottom
-    last->next = new QueueItem;
-    last=last->next;
-    // initialize last->next
-    last->next=NULL;
-    // save the packet to the new element
-    last->packet = ev->packet;
-    last->address = ev->peer->address;
-  }
-  return true;
-}
-
-ENetPacket *PacketBuffer::pop(){
-  boost::mutex::scoped_lock lock(networkPacketBufferMutex);
-  //std::cout << "packetbuffer pop" << std::endl;
-  if(first!=NULL /*&& !closed*/){
-    QueueItem *temp = first;
-    // get packet
-    ENetPacket *pck=first->packet;
-    // remove first element
-    first = first->next;
-    delete temp;
-    //std::cout << "pop size of packet " << pck->dataLength << std::endl;
-    return pck;
-  } else{
-    //std::cout << "nothing to return" << std::endl;
-    return NULL;
-  }
-}
-
-ENetPacket *PacketBuffer::pop(ENetAddress &address){
-  boost::mutex::scoped_lock lock(networkPacketBufferMutex);
-  //std::cout << "packetbuffer pop(address)" << std::endl;
-  if(first!=NULL /*&& !closed*/){
-    QueueItem *temp = first;
-    // get packet
-    ENetPacket *pck=first->packet;
-    address = first->address;
-    // remove first element
-    first = first->next;
-    delete temp;
-    //std::cout << "pop(address) size of packet " << pck->dataLength << std::endl;
-    return pck;
-  } else{
-    return NULL;
-  }
-}
-
-bool PacketBuffer::isEmpty(){
-  return (first==NULL);
-}
-
-void PacketBuffer::print(){
-  QueueItem *temp=first;
-  while(temp!=NULL){
-//    std::cout << temp->packet->data << std::endl;
-    temp=temp->next;
+      //insert a new element at the bottom
+      last->next = new QueueItem;
+      last=last->next;
+      // initialize last->next
+      last->next=NULL;
+      // save the packet to the new element
+      last->packet = ev->packet;
+      last->address = ev->peer->address;
+    }
+    return true;
   }
 
-}
+  ENetPacket *PacketBuffer::pop() {
+    boost::mutex::scoped_lock lock(networkPacketBufferMutex);
+    //std::cout << "packetbuffer pop" << std::endl;
+    if(first!=NULL /*&& !closed*/){
+      QueueItem *temp = first;
+      // get packet
+      ENetPacket *pck=first->packet;
+      // remove first element
+      first = first->next;
+      delete temp;
+      //std::cout << "pop size of packet " << pck->dataLength << std::endl;
+      return pck;
+    } else{
+      //std::cout << "nothing to return" << std::endl;
+      return NULL;
+    }
+  }
 
-bool PacketBuffer::isClosed(){
-  return closed;
-}
+  ENetPacket *PacketBuffer::pop(ENetAddress &address) {
+    boost::mutex::scoped_lock lock(networkPacketBufferMutex);
+    //std::cout << "packetbuffer pop(address)" << std::endl;
+    if(first!=NULL /*&& !closed*/){
+      QueueItem *temp = first;
+      // get packet
+      ENetPacket *pck=first->packet;
+      address = first->address;
+      // remove first element
+      first = first->next;
+      delete temp;
+      //std::cout << "pop(address) size of packet " << pck->dataLength << std::endl;
+      return pck;
+    } else{
+      return NULL;
+    }
+  }
 
-void PacketBuffer::setClosed(bool value){
-  closed=value;
-  return;
-}
+  bool PacketBuffer::isEmpty() {
+    return (first==NULL);
+  }
 
-}// namespace network
+  void PacketBuffer::print() {
+    QueueItem *temp=first;
+    while(temp!=NULL){
+      //    std::cout << temp->packet->data << std::endl;
+      temp=temp->next;
+    }
 
-#endif
+  }
+
+  bool PacketBuffer::isClosed() {
+    return closed;
+  }
+
+  void PacketBuffer::setClosed(bool value){
+    closed=value;
+    return;
+  }
+
+} // namespace network
Index: code/branches/FICN/src/network/PacketBuffer.h
===================================================================
--- code/branches/FICN/src/network/PacketBuffer.h	(revision 774)
+++ code/branches/FICN/src/network/PacketBuffer.h	(revision 777)
@@ -14,44 +14,40 @@
 #define _PacketBuffer_H__
 
-#include <queue>
-#include <string>
 #include <enet/enet.h>
-#include <boost/bind.hpp>
-#include <boost/thread/mutex.hpp>
 
+#include "NetworkPrereqs.h"
 
-namespace network{
+namespace network
+{
+  struct PacketEnvelope{
+    int length;
+    int data;
+  };
 
+  struct QueueItem{
+    ENetPacket *packet;
+    ENetAddress address;
+    QueueItem *next;
+  };
 
-struct PacketEnvelope{
-  int length;
-  int data;
-};
+  class PacketBuffer{
+  public:
+    PacketBuffer();
+    bool isEmpty();
+    bool isClosed();
+    void setClosed(bool value);
+    void print();
+    // pops a packet from the queue
+    ENetPacket *pop();
+    ENetPacket *pop(ENetAddress &address);
+    // pushs a packet to the queue
+    bool push(ENetEvent *ev);
 
-struct QueueItem{
-  ENetPacket *packet;
-  ENetAddress address;
-  QueueItem *next;
-};
+  private:
+    QueueItem *first;
+    QueueItem *last;
+    bool closed;
 
-class PacketBuffer{
-public:
-  PacketBuffer();
-  bool isEmpty();
-  bool isClosed();
-  void setClosed(bool value);
-  void print();
-  // pops a packet from the queue
-  ENetPacket *pop();
-  ENetPacket *pop(ENetAddress &address);
-  // pushs a packet to the queue
-  bool push(ENetEvent *ev);
-  
-private:
-  QueueItem *first;
-  QueueItem *last;
-  bool closed;
-  
-};
+  };
 
 } //namespace
Index: code/branches/FICN/src/network/PacketBufferTestExt.cc
===================================================================
--- code/branches/FICN/src/network/PacketBufferTestExt.cc	(revision 774)
+++ code/branches/FICN/src/network/PacketBufferTestExt.cc	(revision 777)
@@ -1,28 +1,28 @@
 /*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      ...
- *   Co-authors:
- *      ...
- *
- */
+*   ORXONOX - the hottest 3D action shooter ever to exist
+*
+*
+*   License notice:
+*
+*   This program is free software; you can redistribute it and/or
+*   modify it under the terms of the GNU General Public License
+*   as published by the Free Software Foundation; either version 2
+*   of the License, or (at your option) any later version.
+*
+*   This program is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with this program; if not, write to the Free Software
+*   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*
+*   Author:
+*      ...
+*   Co-authors:
+*      ...
+*
+*/
 
 #include <string>
@@ -30,16 +30,10 @@
 #include <enet/enet.h>
 #include <boost/thread/thread.hpp>
+
+#include "util/Sleep.h"
 #include "PacketBuffer.h"
 #include "PacketBuffer.cc"
 
-#ifdef WIN32
-#include <windows.h>
-#define usleep(x) Sleep((x)/1000)
-#else
-#include <unistd.h>
-#endif
-
 using namespace network;
-
 
 void write(PacketBuffer *test){
@@ -51,5 +45,5 @@
     std::string temp = "packet ";
     packet = enet_packet_create("packet", strlen("packet ")+1,
-ENET_PACKET_FLAG_RELIABLE);
+      ENET_PACKET_FLAG_RELIABLE);
     std::cout << i << ": pushing " << packet->data << std::endl;
     event.packet=packet;
Index: code/branches/FICN/src/network/PacketDecoder.cc
===================================================================
--- code/branches/FICN/src/network/PacketDecoder.cc	(revision 774)
+++ code/branches/FICN/src/network/PacketDecoder.cc	(revision 777)
@@ -1,257 +1,263 @@
 /*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Dumeni Manatschal, (C) 2007
- *   Co-authors:
- *      ...
- *
- */
+*   ORXONOX - the hottest 3D action shooter ever to exist
+*
+*
+*   License notice:
+*
+*   This program is free software; you can redistribute it and/or
+*   modify it under the terms of the GNU General Public License
+*   as published by the Free Software Foundation; either version 2
+*   of the License, or (at your option) any later version.
+*
+*   This program is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with this program; if not, write to the Free Software
+*   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*
+*   Author:
+*      Dumeni Manatschal, (C) 2007
+*   Co-authors:
+*      ...
+*
+*/
 
 /*
- * Class contains functions to determine and decode incomming packages
- * ->don't read this without the class PacketGenerator, since they belong together
- *
- * Autor: Dumeni Manatschal
- *
+* Class contains functions to determine and decode incomming packages
+* ->don't read this without the class PacketGenerator, since they belong together
+*
+* Autor: Dumeni Manatschal
+*
 */
 
-#include <enet/enet.h>
+#include <iostream>
+
+#include "PacketTypes.h"
 #include "PacketManager.h"
-#include <iostream>
-
-using namespace std;
-using namespace network;
-
-PacketDecoder::PacketDecoder(){}
-
-PacketDecoder::~PacketDecoder(){}
-
-//call this function out of an instance of PacketDecoder
-//it will determine the type id and call the right decode function
-bool PacketDecoder::elaborate( ENetPacket* packet, int clientId )
+
+namespace network
 {
-	int client = clientId;
-	cout << "clientId: " << client << endl; //control cout, not important, just debugging info
-	int id = (int)*packet->data; //the first 4 bytes are always the enet packet id
-	std::cout << "packet id: " << id << std::endl;
-	std::cout << "packet size inside packetdecoder: " << packet->dataLength << std::endl;
-	switch( id ) {
-	case ACK:
-		acknowledgement( packet, clientId );
-		return true;
-		break;
-	case MOUSE:
-		mousem( packet, clientId );
-		return true;
-		break;
-	case KEYBOARD:
-		keystrike( packet, clientId );
-		return true;
-		break;
-	case CHAT:
-		chatMessage( packet, clientId );
-		return true;
-		break;
-	case GAMESTATE:
-		gstate( packet );
-		return true;
-		break;
-    case CLASSID:
-        clid(packet);
-        return true;
-        break;
-	}
-	return false;
+  using namespace std;
+
+  PacketDecoder::PacketDecoder(){}
+
+  PacketDecoder::~PacketDecoder(){}
+
+  //call this function out of an instance of PacketDecoder
+  //it will determine the type id and call the right decode function
+  bool PacketDecoder::elaborate( ENetPacket* packet, int clientId )
+  {
+    int client = clientId;
+    cout << "clientId: " << client << endl; //control cout, not important, just debugging info
+    int id = (int)*packet->data; //the first 4 bytes are always the enet packet id
+    std::cout << "packet id: " << id << std::endl;
+    std::cout << "packet size inside packetdecoder: " << packet->dataLength << std::endl;
+    switch( id ) {
+  case ACK:
+    acknowledgement( packet, clientId );
+    return true;
+    break;
+  case MOUSE:
+    mousem( packet, clientId );
+    return true;
+    break;
+  case KEYBOARD:
+    keystrike( packet, clientId );
+    return true;
+    break;
+  case CHAT:
+    chatMessage( packet, clientId );
+    return true;
+    break;
+  case GAMESTATE:
+    gstate( packet );
+    return true;
+    break;
+  case CLASSID:
+    clid(packet);
+    return true;
+    break;
+    }
+    return false;
+  }
+
+  //following are the decode functions for the data of the packets
+
+  void PacketDecoder::acknowledgement( ENetPacket* packet, int clientId )
+  {
+    ack* a = new ack;
+    *a = *(ack*)packet->data; //press pattern of ack on new data
+
+
+    std::cout << "got ack id: " << a->id << std::endl;
+    processAck( a, clientId ); //debug info
+
+    //clean memory
+    enet_packet_destroy( packet );
+  }
+
+  void PacketDecoder::mousem( ENetPacket* packet, int clientId )
+  {
+    mouse* mouseMove = new mouse;
+    //copy data of packet->data to new struct
+    *mouseMove = *(mouse*)packet->data;
+
+    //clean memory
+    enet_packet_destroy( packet );
+
+    printMouse( mouseMove ); //debug info
+  }
+
+  void PacketDecoder::keystrike( ENetPacket* packet, int clientId )
+  {
+    keyboard* key = new keyboard;
+    *key = *(keyboard*)packet->data; //see above
+
+    //clean memory
+    enet_packet_destroy( packet );
+
+    printKey( key ); //debug info
+
+  }
+
+  void PacketDecoder::chatMessage( ENetPacket* packet, int clientId )
+  {
+    chat* chatting = new chat;
+    chatting->id = (int)*packet->data; //first copy id into new struct
+    //since the chat message is a char*, allocate the memory needed
+    char* reserve = new char[packet->dataLength-4];
+    //copy the transmitted bytestream into the new generated char*,
+    //note the lenght of the message is represented as "packet->dataLength-sizeof( int )"
+    memcpy( &reserve[0], packet->data+sizeof(int), packet->dataLength-sizeof(int) );
+    //put pointer of chatting struct to the begining of the new generated char*
+    chatting->message = reserve;
+
+    //clean memory
+    enet_packet_destroy( packet );
+
+    processChat( chatting, clientId ); //debug info
+  }
+
+  void PacketDecoder::gstate( ENetPacket* packet )
+  {
+    GameStateCompressed* currentState = new GameStateCompressed;
+    //since it's not alowed to use void* for pointer arithmetic
+    unsigned char* data = (unsigned char*)packet->data;
+    //copy the GameStateCompressed id into the struct, which is located at second place data+sizeof( int )
+    //memcpy( (void*)&(currentState->id), (const void*)(data+sizeof( int )), sizeof( int ) );
+    currentState->id = (int)*(data+sizeof(int));
+    std::cout << "id: " << currentState->id << std::endl;
+    //copy the size of the GameStateCompressed compressed data into the new GameStateCompressed struct, located at 3th
+    //position of the data stream, data+2*sizeof( int )
+    memcpy( (void*)&(currentState->compsize), (const void*)(data+2*sizeof( int )), sizeof( int) );
+    //currentState->compsize = (int)*(data+2*sizeof(int));
+    std::cout << "compsize: " << currentState->compsize << std::endl;
+    //size of uncompressed data
+    memcpy( (void*)&(currentState->normsize), (const void*)(data+3*sizeof( int )), sizeof( int ) );
+    //currentState->normsize = (int)*(data+3*sizeof(int));
+    std::cout << "normsize. " << currentState->normsize << std::endl;
+    //since the packetgenerator was changed, due to a new parameter, change this function too
+    memcpy( (void*)&(currentState->diffed), (const void*)(data+4*sizeof(int)), sizeof(bool));
+    //currentState->diffed = (bool)*(data+4*sizeof(int));
+    std::cout << "diffed: " << currentState->diffed << std::endl;
+    //since data is not allocated, because it's just a pointer, allocate it with size of gamestatedatastream
+    currentState->data = (unsigned char*)(malloc( currentState->compsize ));
+    if(currentState->data==NULL)
+      std::cout << "memory leak" << std::endl;
+    //copy the GameStateCompressed data
+    //std::cout << "packet size (enet): " << packet->dataLength << std::endl;
+    //std::cout << "totallen: " << 4*sizeof(int)+sizeof(bool)+currentState->compsize << std::endl;
+    memcpy( (void*)(currentState->data), (const void*)(data+4*sizeof( int ) + sizeof(bool)), currentState->compsize );
+
+    //clean memory
+    enet_packet_destroy( packet );
+    //run processGameStateCompressed
+    //TODO: not yet implemented!
+    processGamestate(currentState);
+  }
+
+  void PacketDecoder::clid( ENetPacket *packet)
+  {
+    classid* cid = new classid;
+    cid->length = ((classid*)(packet->data))->length;
+    cid->id = ((classid *)(packet->data))->id;
+    cid->clid = ((classid *)(packet->data))->clid;
+    cid->message = (const char *)malloc(cid->length);
+    void *data  = (void *)cid->message;
+    memcpy(data, (const void*)(packet->data+3*sizeof(int)), cid->length);
+    std::cout << "classid: " << cid->clid << ", name: " << cid->message << std::endl;
+    enet_packet_destroy( packet );
+    processClassid(cid);
+  }
+
+
+  // now the data processing functions:
+
+  void PacketDecoder::processChat( chat *data, int clientId)
+  {
+    printChat(data, clientId);
+  }
+
+  void PacketDecoder::processGamestate( GameStateCompressed *state )
+  {
+  }
+
+  void PacketDecoder::processClassid( classid *cid)
+  {
+    printClassid(cid);
+    return;
+  }
+
+  void PacketDecoder::processAck( ack *data, int clientID)
+  {
+    printAck(data);
+    return;
+  }
+
+
+  //these are some print functions for test stuff
+
+  void PacketDecoder::printAck( ack* data )
+  {
+    cout << "data id: " << data->id << endl;
+    cout << "data:    " << data->a << endl;
+  }
+
+  void PacketDecoder::printMouse( mouse* data )
+  {
+    cout << "data id: " << data->id << endl;
+    cout << "data:    " << data->x << " " << data->y << endl;
+  }
+
+  void PacketDecoder::printKey( keyboard* data )
+  {
+    cout << "data id: " << data->id << endl;
+    cout << "data:    " << (char)data->press << endl;
+  }
+
+  void PacketDecoder::printChat( chat* data, int clientId )
+  {
+    if(clientId!=CLIENTID_CLIENT)
+      cout << "client: " << clientId << endl;
+    cout << "data id: " << data->id << endl;
+    cout << "data:    " << data->message << endl;
+  }
+
+  void PacketDecoder::printGamestate( GameStateCompressed* data )
+  {
+    cout << "id of GameStateCompressed:   " << data->id << endl;
+    cout << "size of GameStateCompressed: " << data->compsize << endl;
+  }
+
+  void PacketDecoder::printClassid( classid *cid)
+  {
+    cout << "id of classid:    " << cid->id << endl;
+    cout << "size of classid:  " << cid->length << endl;
+    cout << "ID of classid:    " << cid->clid <<endl;
+    cout << "data of classid:  " << cid->message <<endl;
+  }
+
 }
-
-//following are the decode functions for the data of the packets
-
-void PacketDecoder::acknowledgement( ENetPacket* packet, int clientId )
-{
-	ack* a = new ack;
-	*a = *(ack*)packet->data; //press pattern of ack on new data
-
-
-  std::cout << "got ack id: " << a->id << std::endl;
-  processAck( a, clientId ); //debug info
-  
-  //clean memory
-  enet_packet_destroy( packet );
-}
-
-void PacketDecoder::mousem( ENetPacket* packet, int clientId )
-{
-	mouse* mouseMove = new mouse;
-	//copy data of packet->data to new struct
-	*mouseMove = *(mouse*)packet->data;
-
-	//clean memory
-	enet_packet_destroy( packet );
-
-	printMouse( mouseMove ); //debug info
-}
-
-void PacketDecoder::keystrike( ENetPacket* packet, int clientId )
-{
-	keyboard* key = new keyboard;
-	*key = *(keyboard*)packet->data; //see above
-
-	//clean memory
-	enet_packet_destroy( packet );
-
-	printKey( key ); //debug info
-
-}
-
-void PacketDecoder::chatMessage( ENetPacket* packet, int clientId )
-{
-	chat* chatting = new chat;
-	chatting->id = (int)*packet->data; //first copy id into new struct
-	//since the chat message is a char*, allocate the memory needed
-	char* reserve = new char[packet->dataLength-4];
-	//copy the transmitted bytestream into the new generated char*,
-	//note the lenght of the message is represented as "packet->dataLength-sizeof( int )"
-	memcpy( &reserve[0], packet->data+sizeof(int), packet->dataLength-sizeof(int) );
-	//put pointer of chatting struct to the begining of the new generated char*
-	chatting->message = reserve;
-
-	//clean memory
-	enet_packet_destroy( packet );
-
-	processChat( chatting, clientId ); //debug info
-
-}
-
-void PacketDecoder::gstate( ENetPacket* packet )
-{
-	GameStateCompressed* currentState = new GameStateCompressed;
-	//since it's not alowed to use void* for pointer arithmetic
-	unsigned char* data = (unsigned char*)packet->data;
-	//copy the GameStateCompressed id into the struct, which is located at second place data+sizeof( int )
-  	//memcpy( (void*)&(currentState->id), (const void*)(data+sizeof( int )), sizeof( int ) );
-  	currentState->id = (int)*(data+sizeof(int));
- 	 std::cout << "id: " << currentState->id << std::endl;
-	//copy the size of the GameStateCompressed compressed data into the new GameStateCompressed struct, located at 3th
-	//position of the data stream, data+2*sizeof( int )
-	memcpy( (void*)&(currentState->compsize), (const void*)(data+2*sizeof( int )), sizeof( int) );
-  	//currentState->compsize = (int)*(data+2*sizeof(int));
-  	std::cout << "compsize: " << currentState->compsize << std::endl;
-	//size of uncompressed data
-	memcpy( (void*)&(currentState->normsize), (const void*)(data+3*sizeof( int )), sizeof( int ) );
-  	//currentState->normsize = (int)*(data+3*sizeof(int));
-  	std::cout << "normsize. " << currentState->normsize << std::endl;
-	//since the packetgenerator was changed, due to a new parameter, change this function too
-	memcpy( (void*)&(currentState->diffed), (const void*)(data+4*sizeof(int)), sizeof(bool));
-  	//currentState->diffed = (bool)*(data+4*sizeof(int));
-  	std::cout << "diffed: " << currentState->diffed << std::endl;
-	//since data is not allocated, because it's just a pointer, allocate it with size of gamestatedatastream
-	currentState->data = (unsigned char*)(malloc( currentState->compsize ));
-  	if(currentState->data==NULL)
-    		std::cout << "memory leak" << std::endl;
-	//copy the GameStateCompressed data
-  	//std::cout << "packet size (enet): " << packet->dataLength << std::endl;
-  	//std::cout << "totallen: " << 4*sizeof(int)+sizeof(bool)+currentState->compsize << std::endl;
-	memcpy( (void*)(currentState->data), (const void*)(data+4*sizeof( int ) + sizeof(bool)), currentState->compsize );
-
-	//clean memory
-	enet_packet_destroy( packet );
-  	//run processGameStateCompressed
-  	//TODO: not yet implemented!
-  	processGamestate(currentState);
-}
-
-void PacketDecoder::clid( ENetPacket *packet)
-{
-        classid* cid = new classid;
-        cid->length = ((classid*)(packet->data))->length;
-        cid->id = ((classid *)(packet->data))->id;
-        cid->clid = ((classid *)(packet->data))->clid;
-        cid->message = (const char *)malloc(cid->length);
-        void *data  = (void *)cid->message;
-        memcpy(data, (const void*)(packet->data+3*sizeof(int)), cid->length);
-        std::cout << "classid: " << cid->clid << ", name: " << cid->message << std::endl;
-        enet_packet_destroy( packet );
-        processClassid(cid);
-}
-
-
-// now the data processing functions:
-
-void PacketDecoder::processChat( chat *data, int clientId){
-  printChat(data, clientId);
-}
-
-void PacketDecoder::processGamestate( GameStateCompressed *state ){
-  
-}
-
-void PacketDecoder::processClassid( classid *cid){
-  printClassid(cid);
-  return;
-}
-
-void PacketDecoder::processAck( ack *data, int clientID){
-  printAck(data);
-  return;
-}
-
-
-//these are some print functions for test stuff
-
-void PacketDecoder::printAck( ack* data )
-{
-	cout << "data id: " << data->id << endl;
-	cout << "data:    " << data->a << endl;
-}
-
-void PacketDecoder::printMouse( mouse* data )
-{
-	cout << "data id: " << data->id << endl;
-	cout << "data:    " << data->x << " " << data->y << endl;
-}
-
-void PacketDecoder::printKey( keyboard* data )
-{
-	cout << "data id: " << data->id << endl;
-	cout << "data:    " << (char)data->press << endl;
-}
-
-void PacketDecoder::printChat( chat* data, int clientId )
-{
-  if(clientId!=CLIENTID_CLIENT)
-    cout << "client: " << clientId << endl;
-	cout << "data id: " << data->id << endl;
-	cout << "data:    " << data->message << endl;
-}
-
-void PacketDecoder::printGamestate( GameStateCompressed* data )
-{
-	cout << "id of GameStateCompressed:   " << data->id << endl;
-	cout << "size of GameStateCompressed: " << data->compsize << endl;
-}
-
-void PacketDecoder::printClassid( classid *cid)
-{
-        cout << "id of classid:    " << cid->id << endl;
-        cout << "size of classid:  " << cid->length << endl;
-        cout << "ID of classid:    " << cid->clid <<endl;
-        cout << "data of classid:  " << cid->message <<endl;
-}
Index: code/branches/FICN/src/network/PacketGenerator.cc
===================================================================
--- code/branches/FICN/src/network/PacketGenerator.cc	(revision 774)
+++ code/branches/FICN/src/network/PacketGenerator.cc	(revision 777)
@@ -1,39 +1,37 @@
 /*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Dumeni Manatschal, (C) 2007
- *   Co-authors:
- *      ...
- *
- */
+*   ORXONOX - the hottest 3D action shooter ever to exist
+*
+*
+*   License notice:
+*
+*   This program is free software; you can redistribute it and/or
+*   modify it under the terms of the GNU General Public License
+*   as published by the Free Software Foundation; either version 2
+*   of the License, or (at your option) any later version.
+*
+*   This program is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with this program; if not, write to the Free Software
+*   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*
+*   Author:
+*      Dumeni Manatschal, (C) 2007
+*   Co-authors:
+*      ...
+*
+*/
 
 /*
- *Class generates packets that can be send by enet
- * ->don't read this without the class PacketDecoder, since they belong together
- *
- * Autor: Dumeni Manatschal
- *
+* Class generates packets that can be send by enet
+* ->don't read this without the class PacketDecoder, since they belong together
+*
+* Autor: Dumeni Manatschal
+*
 */
 
-#include "PacketManager.h"
-#include <enet/enet.h>
 #include <iostream>
 #include <list>
@@ -41,99 +39,106 @@
 #include <cstring>
 
-using namespace network;
+#include "PacketTypes.h"
+#include "PacketManager.h"
 
-PacketGenerator::PacketGenerator() {}
+namespace network
+{
+  PacketGenerator::PacketGenerator() { }
 
-//following functions create a packet in form of bytestream
+  //following functions create a packet in form of bytestream
 
-ENetPacket* PacketGenerator::acknowledgement( int state, int reliable )
-{
+  ENetPacket* PacketGenerator::acknowledgement( int state, int reliable )
+  {
     std::cout << "generating new acknowledgement, id: " << state << std::endl;
-	ack* ackreq = new ack;
-	ackreq->id = ACK;
-	ackreq->a = state;
+    ack* ackreq = new ack;
+    ackreq->id = ACK;
+    ackreq->a = state;
 
-	ENetPacket *packet = enet_packet_create( ackreq , sizeof( *ackreq ), reliable );
+    ENetPacket *packet = enet_packet_create( ackreq , sizeof( *ackreq ), reliable );
 
-	return packet;
+    return packet;
+  }
+
+  /*### mouseupdates */
+  ENetPacket* PacketGenerator::mousem( double x, double y, int reliable )
+  {
+    std::cout << "generating new mouse" << std::endl;
+    mouse* mousemove = new mouse;
+    mousemove->id = MOUSE;
+    mousemove->x = x;
+    mousemove->y = y;
+
+    ENetPacket *packet = enet_packet_create( mousemove , sizeof( *mousemove ), reliable );
+
+    return packet;
+  }
+
+  /*### keystrikes updates */
+  ENetPacket* PacketGenerator::keystrike( char press, int reliable )
+  {
+    std::cout << "generating new keyboard" << std::endl;
+    keyboard* key = new keyboard;
+    key->id = KEYBOARD;
+    key->press = press;
+
+    ENetPacket *packet = enet_packet_create( key , sizeof( *key ), reliable );
+
+    return packet;
+  }
+
+  /*### chat messages packet */
+  ENetPacket* PacketGenerator::chatMessage( const char* message, int reliable )
+  {
+    int* trans = new int[sizeof(int) + strlen(message) + 1];
+    *trans = CHAT;
+    //be carefull here, don't forget to allocate the space before using it ;-)
+    memcpy( &trans[1], (const void*)message, strlen( message ) + 1);
+    ENetPacket *packet = enet_packet_create( trans , sizeof( int ) + strlen( message ) + 1, reliable );
+
+    return packet;
+  }
+
+  /*### gamestate packet */
+  ENetPacket* PacketGenerator::gstate( GameStateCompressed* states, int reliable )
+  {
+    //std::cout << "packetgenerator" << std::endl;
+    //std::cout << "states->normsize " << states->normsize << std::endl;
+    //std::cout << "states->compsize " << states->compsize << std::endl;
+    int gid = GAMESTATE; //first assign the correct enet id
+    int totalLen = 4*sizeof( int ) + sizeof(bool) + states->compsize; //calculate the total size of the datastream memory
+    //std::cout << "totalLen " << totalLen << std::endl;
+    unsigned char *data = (unsigned char*)malloc( totalLen ); //allocate the memory for datastream
+    memcpy( (void*)(data), (const void*)&gid, sizeof( int ) ); //this is the enet id
+    memcpy( (void*)(data+sizeof(int)), (const void*)&(states->id), sizeof(int) ); //the GameStateCompressed id
+    memcpy( (void*)(data+2*sizeof(int)), (const void*)&(states->compsize), sizeof(int));
+    memcpy( (void*)(data+3*sizeof(int)), (const void*)&(states->normsize), sizeof(int));
+    memcpy( (void*)(data+4*sizeof(int)), (const void*)&(states->diffed), sizeof(bool));
+    /*(int)*(data) = gid;
+    (int)*(data+sizeof(int)) = states->id;
+    //this is the compressed size of the GameStateCompressed data, place at 3th position of the enet datastream
+    (int)*(data+2*sizeof(int)) = states->compsize;
+    //this is the uncompressed size of GameStateCompressed data
+    (int)*(data+3*sizeof(int)) = states->normsize;
+    //since there is a new parameter inside GameStateCompressed, change this function to create packet
+    (bool)*(data+4*sizeof(int)) = states->diffed;*/
+    //place the GameStateCompressed data at the end of the enet datastream
+    memcpy( (void*)(data+4*sizeof( int ) + sizeof(bool)), (const void*)states->data, states->compsize );
+    //create an enet packet with the generated bytestream
+    ENetPacket *packet = enet_packet_create( data , totalLen, reliable );
+    //delete data;
+    return packet;
+  }
+
+  ENetPacket* PacketGenerator::clid( int classid, std::string classname, int reliable )
+  {
+    unsigned char* data = (unsigned char *)malloc(3*sizeof(int)+classname.length()+1);
+    std::cout << "classid: " << classid << ", name: " << classname << std::endl;
+    *(int *)data = CLASSID;
+    *((int *)data+1) = classname.length()+1;
+    *((int *)data+2) = classid;
+    memcpy( (void *)(data+3*sizeof(int)), classname.c_str(), classname.length()+1);
+    ENetPacket *packet = enet_packet_create( data , 3*sizeof(int)+classname.length()+1, reliable );
+    return packet;
+  }
+
 }
-/*### mouseupdates */
-ENetPacket* PacketGenerator::mousem( double x, double y, int reliable )
-{
-	std::cout << "generating new mouse" << std::endl;
-	mouse* mousemove = new mouse;
-	mousemove->id = MOUSE;
-	mousemove->x = x;
-	mousemove->y = y;
-
-	ENetPacket *packet = enet_packet_create( mousemove , sizeof( *mousemove ), reliable );
-
-	return packet;
-}
-/*### keystrikes updates */
-ENetPacket* PacketGenerator::keystrike( char press, int reliable )
-{
-	std::cout << "generating new keyboard" << std::endl;
-	keyboard* key = new keyboard;
-	key->id = KEYBOARD;
-	key->press = press;
-
-	ENetPacket *packet = enet_packet_create( key , sizeof( *key ), reliable );
-
-	return packet;
-}
-/*### chat messages packet */
-ENetPacket* PacketGenerator::chatMessage( const char* message, int reliable )
-{
-	int* trans = new int[sizeof(int) + strlen(message) + 1];
-	*trans = CHAT;
-	//be carefull here, don't forget to allocate the space before using it ;-)
-	memcpy( &trans[1], (const void*)message, strlen( message ) + 1);
-	ENetPacket *packet = enet_packet_create( trans , sizeof( int ) + strlen( message ) + 1, reliable );
-
-	return packet;
-}
-
-/*### gamestate packet */
-ENetPacket* PacketGenerator::gstate( GameStateCompressed* states, int reliable )
-{
-  //std::cout << "packetgenerator" << std::endl;
-  //std::cout << "states->normsize " << states->normsize << std::endl;
-  //std::cout << "states->compsize " << states->compsize << std::endl;
-  int gid = GAMESTATE; //first assign the correct enet id
-  int totalLen = 4*sizeof( int ) + sizeof(bool) + states->compsize; //calculate the total size of the datastream memory
-  //std::cout << "totalLen " << totalLen << std::endl;
-  unsigned char *data = (unsigned char*)malloc( totalLen ); //allocate the memory for datastream
-  memcpy( (void*)(data), (const void*)&gid, sizeof( int ) ); //this is the enet id
-  memcpy( (void*)(data+sizeof(int)), (const void*)&(states->id), sizeof(int) ); //the GameStateCompressed id
-  memcpy( (void*)(data+2*sizeof(int)), (const void*)&(states->compsize), sizeof(int));
-  memcpy( (void*)(data+3*sizeof(int)), (const void*)&(states->normsize), sizeof(int));
-  memcpy( (void*)(data+4*sizeof(int)), (const void*)&(states->diffed), sizeof(bool));
-  /*(int)*(data) = gid;
-  (int)*(data+sizeof(int)) = states->id;
-  //this is the compressed size of the GameStateCompressed data, place at 3th position of the enet datastream
-  (int)*(data+2*sizeof(int)) = states->compsize;
-  //this is the uncompressed size of GameStateCompressed data
-  (int)*(data+3*sizeof(int)) = states->normsize;
-  //since there is a new parameter inside GameStateCompressed, change this function to create packet
-  (bool)*(data+4*sizeof(int)) = states->diffed;*/
-  //place the GameStateCompressed data at the end of the enet datastream
-  memcpy( (void*)(data+4*sizeof( int ) + sizeof(bool)), (const void*)states->data, states->compsize );
-  //create an enet packet with the generated bytestream
-  ENetPacket *packet = enet_packet_create( data , totalLen, reliable );
-  //delete data;
-  return packet;
-}
-
-ENetPacket* PacketGenerator::clid( int classid, std::string classname, int reliable ){
-        unsigned char* data = (unsigned char *)malloc(3*sizeof(int)+classname.length()+1);
-        std::cout << "classid: " << classid << ", name: " << classname << std::endl;
-        *(int *)data = CLASSID;
-        *((int *)data+1) = classname.length()+1;
-        *((int *)data+2) = classid;
-        memcpy( (void *)(data+3*sizeof(int)), classname.c_str(), classname.length()+1);
-        ENetPacket *packet = enet_packet_create( data , 3*sizeof(int)+classname.length()+1, reliable );
-        return packet;
-}
-
-
Index: code/branches/FICN/src/network/PacketManager.h
===================================================================
--- code/branches/FICN/src/network/PacketManager.h	(revision 774)
+++ code/branches/FICN/src/network/PacketManager.h	(revision 777)
@@ -4,79 +4,76 @@
 #include <string>
 #include <enet/enet.h>
-#include "PacketTypes.h"
+
+#include "NetworkPrereqs.h"
 
 #define CLIENTID_CLIENT -1
 
-//enum netowk generaly used to set the type ID of a packet
-namespace network{
-  
-  
+//enum netowk generally used to set the type ID of a packet
+namespace network
+{
+  /*
+  * class to generate packets
+  * 
+  * @autor: Dumeni Manatschal
+  * 
+  */ 
+  class PacketGenerator
+  {
+  public:
+    PacketGenerator();
+    //call one of this functions out of an instance of PacketGenerator to create a packet
+    ENetPacket* acknowledgement( int state, int reliable = ENET_PACKET_FLAG_RELIABLE );
+    ENetPacket* mousem( double x, double y, int reliable = ENET_PACKET_FLAG_RELIABLE );
+    ENetPacket* keystrike( char press, int reliable = ENET_PACKET_FLAG_RELIABLE );
+    ENetPacket* chatMessage( const char* message, int reliable = ENET_PACKET_FLAG_RELIABLE );
+    ENetPacket* gstate( GameStateCompressed *states, int reliable = ENET_PACKET_FLAG_RELIABLE );
+    ENetPacket* clid( int classid, std::string classname, int reliable = ENET_PACKET_FLAG_RELIABLE );
+  private:
+  };
+
+  /*
+  * class used to decode incoming packets
+  * 
+  * @autor: Dumeni Manatschal
+  * 
+  */
+  class _NetworkExport PacketDecoder
+  {
+  public:
+    PacketDecoder();
+    virtual ~PacketDecoder();
+    //call this function to decode, it calls the right decoding function below
+    bool elaborate( ENetPacket* packet, int clientId );
+  protected:
+
+    virtual void processChat( chat *data, int clientId);
+
+
+  private:
 
 
 
-/*
- * class to generate packets
- * 
- * @autor: Dumeni Manatschal
- * 
-*/ 
-class PacketGenerator
-{
-public:
-	PacketGenerator();
-	//call one of this functions out of an instance of PacketGenerator to create a packet
-	ENetPacket* acknowledgement( int state, int reliable = ENET_PACKET_FLAG_RELIABLE );
-	ENetPacket* mousem( double x, double y, int reliable = ENET_PACKET_FLAG_RELIABLE );
-	ENetPacket* keystrike( char press, int reliable = ENET_PACKET_FLAG_RELIABLE );
-  ENetPacket* chatMessage( const char* message, int reliable = ENET_PACKET_FLAG_RELIABLE );
-  ENetPacket* gstate( GameStateCompressed *states, int reliable = ENET_PACKET_FLAG_RELIABLE );
-  ENetPacket* clid( int classid, std::string classname, int reliable = ENET_PACKET_FLAG_RELIABLE );
-private:
-};
+    void acknowledgement( ENetPacket* packet, int clientId = CLIENTID_CLIENT );
+    void mousem( ENetPacket* packet, int clientId = CLIENTID_CLIENT );
+    void keystrike( ENetPacket* packet, int clientId = CLIENTID_CLIENT );
+    void chatMessage( ENetPacket* packet, int clientId = CLIENTID_CLIENT);
+    void gstate( ENetPacket* packet );
+    void clid( ENetPacket *packet);
 
-/*
- * class used to decode incoming packets
- * 
- * @autor: Dumeni Manatschal
- * 
-*/
-class PacketDecoder
-{
-public:
-	PacketDecoder();
-  virtual ~PacketDecoder();
-	//call this function to decode, it calls the right decoding function below
-	bool elaborate( ENetPacket* packet, int clientId );
-protected:
-    
-  virtual void processChat( chat *data, int clientId);
-        
-        
-private:
-        
-        
-	
-  void acknowledgement( ENetPacket* packet, int clientId = CLIENTID_CLIENT );
-  void mousem( ENetPacket* packet, int clientId = CLIENTID_CLIENT );
-  void keystrike( ENetPacket* packet, int clientId = CLIENTID_CLIENT );
-  void chatMessage( ENetPacket* packet, int clientId = CLIENTID_CLIENT);
-  void gstate( ENetPacket* packet );
-  void clid( ENetPacket *packet);
-	
-  //process data
-  //two functions are note yet implemented!
-  virtual void processGamestate(GameStateCompressed *state);
-  virtual void processAck( ack *data, int clientID);
-  void processClassid( classid *cid);
-  //virtual void processAck( ack *data);
-  
-	//print functions
-	void printAck( ack* data );
-	void printMouse( mouse* data );
-	void printKey( keyboard* data );
-	void printChat( chat* data, int clientId );
-	void printGamestate( GameStateCompressed *data );
-  void printClassid( classid *cid);
-};
+    //process data
+    //two functions are note yet implemented!
+    virtual void processGamestate(GameStateCompressed *state);
+    virtual void processAck( ack *data, int clientID);
+    void processClassid( classid *cid);
+    //virtual void processAck( ack *data);
+
+    //print functions
+    void printAck( ack* data );
+    void printMouse( mouse* data );
+    void printKey( keyboard* data );
+    void printChat( chat* data, int clientId );
+    void printGamestate( GameStateCompressed *data );
+    void printClassid( classid *cid);
+  };
 }
 
Index: code/branches/FICN/src/network/PacketTypes.h
===================================================================
--- code/branches/FICN/src/network/PacketTypes.h	(revision 774)
+++ code/branches/FICN/src/network/PacketTypes.h	(revision 777)
@@ -14,20 +14,23 @@
 #define _PacketTypes_H__
 
-namespace network{
-enum packet_id {
-  ACK,
-  MOUSE,
-  KEYBOARD,
-  CHAT,
-  GAMESTATE ,
-  CLASSID
-};
+#include "NetworkPrereqs.h"
+
+namespace network
+{
+  enum packet_id {
+    ACK,
+    MOUSE,
+    KEYBOARD,
+    CHAT,
+    GAMESTATE ,
+    CLASSID
+  };
 
 
   /**
-   * This struct defines a gamestate:
-   * size: total size of the data in *data
-   * data: pointer to the data allocated in the memory
-   */
+  * This struct defines a gamestate:
+  * size: total size of the data in *data
+  * data: pointer to the data allocated in the memory
+  */
   struct GameState{
     int id;
@@ -39,9 +42,9 @@
 
   /**
-   * this struct defines a gamestate:
-   * compsize is the size of the compressed data
-   * normsize is the size of the uncompressed data
-   * data are the gamestates
-   */
+  * this struct defines a gamestate:
+  * compsize is the size of the compressed data
+  * normsize is the size of the uncompressed data
+  * data are the gamestates
+  */
   struct GameStateCompressed{
     int id;
@@ -76,6 +79,6 @@
     char press;
   };
-	//only in this class, not PacketGenerator, used as pattern to put incoming
-	//bytes inside
+  //only in this class, not PacketGenerator, used as pattern to put incoming
+  //bytes inside
   struct chat {
     int id;
Index: code/branches/FICN/src/network/Server.cc
===================================================================
--- code/branches/FICN/src/network/Server.cc	(revision 774)
+++ code/branches/FICN/src/network/Server.cc	(revision 777)
@@ -11,14 +11,21 @@
 //
 
+#include <iostream>
 
+#include "ConnectionManager.h"
+#include "PacketTypes.h"
+#include "GameStateManager.h"
+#include "ClientInformation.h"
+//#include "NetworkFrameListener.h"
 #include "Server.h"
 
-namespace network{
 
+namespace network
+{
   /**
-   * Constructor for default values (bindaddress is set to ENET_HOST_ANY
-   *
-   */
-  Server::Server(){
+  * Constructor for default values (bindaddress is set to ENET_HOST_ANY
+  *
+  */
+  Server::Server() {
     packet_gen = PacketGenerator();
     clients = new ClientInformation(true);
@@ -28,9 +35,9 @@
 
   /**
-   * Constructor
-   * @param port Port to listen on
-   * @param bindAddress Address to listen on
-   */
-  Server::Server(int port, std::string bindAddress){
+  * Constructor
+  * @param port Port to listen on
+  * @param bindAddress Address to listen on
+  */
+  Server::Server(int port, std::string bindAddress) {
     packet_gen = PacketGenerator();
     clients = new ClientInformation();
@@ -40,9 +47,9 @@
 
   /**
-   * Constructor
-   * @param port Port to listen on
-   * @param bindAddress Address to listen on
-   */
-  Server::Server(int port, const char *bindAddress){
+  * Constructor
+  * @param port Port to listen on
+  * @param bindAddress Address to listen on
+  */
+  Server::Server(int port, const char *bindAddress) {
     packet_gen = PacketGenerator();
     clients = new ClientInformation();
@@ -52,7 +59,7 @@
 
   /**
-   * This function opens the server by creating the listener thread
-   */
-  void Server::open(){
+  * This function opens the server by creating the listener thread
+  */
+  void Server::open() {
     connection->createListener();
     return;
@@ -60,7 +67,7 @@
 
   /**
-   * This function closes the server
-   */
-  void Server::close(){
+  * This function closes the server
+  */
+  void Server::close() {
     connection->quitListener();
     return;
@@ -68,9 +75,9 @@
 
   /**
-   * This function sends out a message to all clients
-   * @param msg message
-   * @return true/false
-   */
-  bool Server::sendMSG(std::string msg){
+  * This function sends out a message to all clients
+  * @param msg message
+  * @return true/false
+  */
+  bool Server::sendMSG(std::string msg) {
     ENetPacket *packet = packet_gen.chatMessage(msg.c_str());
     //std::cout <<"adding packets" << std::endl;
@@ -79,10 +86,11 @@
     return connection->sendPackets();
   }
+
   /**
-   * This function sends out a message to all clients
-   * @param msg message
-   * @return true/false
-   */
-  bool Server::sendMSG(const char *msg){
+  * This function sends out a message to all clients
+  * @param msg message
+  * @return true/false
+  */
+  bool Server::sendMSG(const char *msg) {
     ENetPacket *packet = packet_gen.chatMessage(msg);
     std::cout <<"adding Packets" << std::endl;
@@ -90,6 +98,6 @@
     //std::cout <<"added packets" << std::endl;
     if (connection->sendPackets()){
-	std::cout << "Sucessfully" << std::endl;
-	return true;
+      std::cout << "Sucessfully" << std::endl;
+      return true;
     }
     return false;
@@ -97,9 +105,9 @@
 
   /**
-   * Run this function once every tick
-   * calls processQueue and updateGamestate
-   * @param time time since last tick
-   */
-  void Server::tick(float time){
+  * Run this function once every tick
+  * calls processQueue and updateGamestate
+  * @param time time since last tick
+  */
+  void Server::tick(float time) {
     processQueue();
     updateGamestate();
@@ -108,7 +116,7 @@
 
   /**
-   * processes all the packets waiting in the queue
-   */
-  void Server::processQueue(){
+  * processes all the packets waiting in the queue
+  */
+  void Server::processQueue() {
     ENetPacket *packet;
     int clientID=-1;
@@ -121,7 +129,7 @@
 
   /**
-   * takes a new snapshot of the gamestate and sends it to the clients
-   */
-  void Server::updateGamestate(){
+  * takes a new snapshot of the gamestate and sends it to the clients
+  */
+  void Server::updateGamestate() {
     gamestates->update();
     //std::cout << "updated gamestate, sending it" << std::endl;
@@ -131,7 +139,7 @@
 
   /**
-   * sends the gamestate
-   */
-  bool Server::sendGameState(){
+  * sends the gamestate
+  */
+  bool Server::sendGameState() {
     std::cout << "starting gamestate" << std::endl;
     ClientInformation *temp = clients;
@@ -160,9 +168,9 @@
     if(added)
       return connection->sendPackets();
-    else return false;
-    //return true;
+    else
+      return false;
   }
 
-  void Server::processAck( ack *data, int clientID){
+  void Server::processAck( ack *data, int clientID) {
     clients->findClient(clientID)->setGamestateID(data->a);
   }
Index: code/branches/FICN/src/network/Server.h
===================================================================
--- code/branches/FICN/src/network/Server.h	(revision 774)
+++ code/branches/FICN/src/network/Server.h	(revision 777)
@@ -16,22 +16,15 @@
 #include <string>
 
-#include "ConnectionManager.h"
 #include "PacketManager.h"
-#include "PacketTypes.h"
-#include "GameStateManager.h"
-#include "ClientInformation.h"
-//#include "enet/enet.h"
-//#include "NetworkFrameListener.h"
+#include "NetworkPrereqs.h"
 
-
-namespace network{
-
-  
+namespace network
+{
   /**
-   * This class is the root class of the network module for a server.
-   * It implements all functions necessary for a Server
-   */
-  class Server : public PacketDecoder{
-    public:
+  * This class is the root class of the network module for a server.
+  * It implements all functions necessary for a Server
+  */
+  class _NetworkExport Server : public PacketDecoder{
+  public:
     Server();
     Server(int port, std::string bindAddress);
@@ -42,8 +35,8 @@
     bool sendMSG(const char *msg);
     void tick(float time);
-    protected:
+  protected:
     void processQueue();
     void updateGamestate();
-    private:
+  private:
     bool sendGameState();
     void processAck( ack *data, int clientID);
@@ -51,8 +44,8 @@
     GameStateManager *gamestates;
     PacketGenerator packet_gen;
-    
+
     ClientInformation *clients;
   };
- 
+
 
 
Index: code/branches/FICN/src/network/Synchronisable.cc
===================================================================
--- code/branches/FICN/src/network/Synchronisable.cc	(revision 774)
+++ code/branches/FICN/src/network/Synchronisable.cc	(revision 777)
@@ -10,114 +10,111 @@
 //
 
+#include <string>
+#include <iostream>
+
 #include "Synchronisable.h"
-#include "core/CoreIncludes.h"
 
+namespace network
+{
+  /**
+  * Constructor:
+  * calls registarAllVariables, that has to be implemented by the inheriting classID
+  */
+  Synchronisable::Synchronisable(){
+    RegisterRootObject(Synchronisable);
+    static int idCounter=0;
+    datasize=0;
+    objectID=idCounter++;
+    //registerAllVariables();
+  }
 
-namespace network {
+  Synchronisable::~Synchronisable(){
+  }
 
-/**
- * Constructor:
- * calls registarAllVariables, that has to be implemented by the inheriting classID
- */
-Synchronisable::Synchronisable()
-{
-  RegisterRootObject(Synchronisable);
-  static int idCounter=0;
-  datasize=0;
-  objectID=idCounter++;
-  //registerAllVariables();
-}
+  /**
+  * This function is used to register a variable to be synchronized
+  * also counts the total datasize needed to save the variables
+  * @param var pointer to the variable
+  * @param size size of the datatype the variable consists of
+  */
+  void Synchronisable::registerVar(const void *var, int size, variableType t){
+    // create temporary synch.Var struct
+    synchronisableVariable temp={size, var, t};
+    // increase datasize
+    datasize+=sizeof(int)+size;
+    // push temp to syncList (at the bottom)
+    syncList.push_back(temp);
+  }
 
-
-Synchronisable::~Synchronisable()
-{
-
-}
-
-/**
- * This function is used to register a variable to be synchronized
- * also counts the total datasize needed to save the variables
- * @param var pointer to the variable
- * @param size size of the datatype the variable consists of
- */
-void Synchronisable::registerVar(const void *var, int size, variableType t){
-  // create temporary synch.Var struct
-  synchronisableVariable temp={size, var, t};
-  // increase datasize
-  datasize+=sizeof(int)+size;
-  // push temp to syncList (at the bottom)
-  syncList.push_back(temp);
-}
-
-/**
- * note: only use this function for debug use, because it's inefficient (in order to produce a gamestate, you have to copy the whole data again to another memory location after this process)
- * This function takes all SynchronisableVariables out of the Synchronisable and saves it into a syncData struct
- * structure of the bitstream:
- * (var1_size,var1,var2_size,var2,...)
- * varx_size: size = sizeof(int)
- * varx: size = varx_size
- * @return data containing all variables and their sizes
- */
-// syncData Synchronisable::getData(){
-//   std::list<synchronisableVariable>::iterator i;
-//   int totalsize=0;
-//   //figure out size of data to be allocated
-//   for(i=syncList.begin(); i!=syncList.end(); i++){
-//     // increase size (size of variable and size of size of variable ;)
-//     if(i->type == STRING)
-//       totalsize+=sizeof(int)+((std::string *)i->var)->length()+1;
-//     else
-//       totalsize+=sizeof(int)+i->size;
-//   }
-//   syncData retVal;
-//   retVal.objectID=this->objectID;
-//   retVal.classID=this->classID;
-//   retVal.length=totalsize;
-//   // allocate memory
-//   retVal.data = (unsigned char *)malloc(totalsize);
-//   // copy to location
-//   //CHANGED: REMOVED DECLARATION int n=0 FROM LOOP
-//   int n=0;
-//   for(i=syncList.begin(); n<totalsize && i!=syncList.end(); i++){
-//     std::memcpy(retVal.data+n, (const void*)(i->size), sizeof(int));
-//     n+=sizeof(int);
-//     switch(i->type){
-//     case STRING:
-//       std::memcpy(retVal.data+n, (const void *)(((std::string *)i->var)->c_str()), ((std::string *)i->var)->length()+1);
-//       n+=((std::string *)i->var)->length()+1;
-//       break;
-//     case DATA:
-//       std::memcpy(retVal.data+n, ((const void*)i->var), i->size);
-//       n+=i->size;
-//       break;
-//     }
-//   }
-//   return retVal;
-// }
-/**
- * This function takes all SynchronisableVariables out of the Synchronisable and saves it into a syncData struct
- * Difference to the above function:
- * takes a pointer to already allocated memory (must have at least getSize bytes length)
- * structure of the bitstream:
- * (var1_size,var1,var2_size,var2,...)
- * varx_size: size = sizeof(int)
- * varx: size = varx_size
- * @return data containing all variables and their sizes
- */
-syncData Synchronisable::getData(unsigned char *mem){
-  std::list<synchronisableVariable>::iterator i;
-  syncData retVal;
-  retVal.objectID=this->objectID;
-  retVal.classID=this->classID;
-  retVal.length=getSize();
-  retVal.data=mem;
-  // copy to location
-  int n=0;
-  for(i=syncList.begin(); n<datasize && i!=syncList.end(); ++i){
-    //COUT(2) << "size of variable: " << i->size << std::endl;
-    //(std::memcpy(retVal.data+n, (const void*)(&(i->size)), sizeof(int));
-    memcpy( (void *)(retVal.data+n), (const void*)&(i->size), sizeof(int) );
-    n+=sizeof(int);
-    switch(i->type){
+  /**
+  * note: only use this function for debug use, because it's inefficient (in order to produce a gamestate, you have to copy the whole data again to another memory location after this process)
+  * This function takes all SynchronisableVariables out of the Synchronisable and saves it into a syncData struct
+  * structure of the bitstream:
+  * (var1_size,var1,var2_size,var2,...)
+  * varx_size: size = sizeof(int)
+  * varx: size = varx_size
+  * @return data containing all variables and their sizes
+  */
+  // syncData Synchronisable::getData(){
+  //   std::list<synchronisableVariable>::iterator i;
+  //   int totalsize=0;
+  //   //figure out size of data to be allocated
+  //   for(i=syncList.begin(); i!=syncList.end(); i++){
+  //     // increase size (size of variable and size of size of variable ;)
+  //     if(i->type == STRING)
+  //       totalsize+=sizeof(int)+((std::string *)i->var)->length()+1;
+  //     else
+  //       totalsize+=sizeof(int)+i->size;
+  //   }
+  //   syncData retVal;
+  //   retVal.objectID=this->objectID;
+  //   retVal.classID=this->classID;
+  //   retVal.length=totalsize;
+  //   // allocate memory
+  //   retVal.data = (unsigned char *)malloc(totalsize);
+  //   // copy to location
+  //   //CHANGED: REMOVED DECLARATION int n=0 FROM LOOP
+  //   int n=0;
+  //   for(i=syncList.begin(); n<totalsize && i!=syncList.end(); i++){
+  //     std::memcpy(retVal.data+n, (const void*)(i->size), sizeof(int));
+  //     n+=sizeof(int);
+  //     switch(i->type){
+  //     case STRING:
+  //       std::memcpy(retVal.data+n, (const void *)(((std::string *)i->var)->c_str()), ((std::string *)i->var)->length()+1);
+  //       n+=((std::string *)i->var)->length()+1;
+  //       break;
+  //     case DATA:
+  //       std::memcpy(retVal.data+n, ((const void*)i->var), i->size);
+  //       n+=i->size;
+  //       break;
+  //     }
+  //   }
+  //   return retVal;
+  // }
+  /**
+  * This function takes all SynchronisableVariables out of the Synchronisable and saves it into a syncData struct
+  * Difference to the above function:
+  * takes a pointer to already allocated memory (must have at least getSize bytes length)
+  * structure of the bitstream:
+  * (var1_size,var1,var2_size,var2,...)
+  * varx_size: size = sizeof(int)
+  * varx: size = varx_size
+  * @return data containing all variables and their sizes
+  */
+  syncData Synchronisable::getData(unsigned char *mem){
+    std::list<synchronisableVariable>::iterator i;
+    syncData retVal;
+    retVal.objectID=this->objectID;
+    retVal.classID=this->classID;
+    retVal.length=getSize();
+    retVal.data=mem;
+    // copy to location
+    int n=0;
+    for(i=syncList.begin(); n<datasize && i!=syncList.end(); ++i){
+      //COUT(2) << "size of variable: " << i->size << std::endl;
+      //(std::memcpy(retVal.data+n, (const void*)(&(i->size)), sizeof(int));
+      memcpy( (void *)(retVal.data+n), (const void*)&(i->size), sizeof(int) );
+      n+=sizeof(int);
+      switch(i->type){
       case DATA:
         std::memcpy( (void *)(retVal.data+n), (const void*)(i->var), i->size);
@@ -128,20 +125,20 @@
         n+=((std::string *) i->var)->length()+1;
         break;
+      }
     }
+    return retVal;
   }
-  return retVal;
-}
 
-/**
- * This function takes a syncData struct and takes it to update the variables
- * @param vars data of the variables
- * @return true/false
- */
-bool Synchronisable::updateData(syncData vars){
-  unsigned char *data=vars.data;
-  std::list<synchronisableVariable>::iterator i;
-  for(i=syncList.begin(); i!=syncList.end(); i++){
-    if((int)*data==i->size || i->type==STRING){
-      switch(i->type){
+  /**
+  * This function takes a syncData struct and takes it to update the variables
+  * @param vars data of the variables
+  * @return true/false
+  */
+  bool Synchronisable::updateData(syncData vars){
+    unsigned char *data=vars.data;
+    std::list<synchronisableVariable>::iterator i;
+    for(i=syncList.begin(); i!=syncList.end(); i++){
+      if((int)*data==i->size || i->type==STRING){
+        switch(i->type){
       case DATA:
         data+=sizeof(int);
@@ -155,20 +152,20 @@
         data += i->size;
         break;
-      }
-    } else
-      return false; //there was some problem with registerVar
+        }
+      } else
+        return false; //there was some problem with registerVar
+    }
+    return true;
   }
-  return true;
-}
 
-/**
- * This function returns the total amount of bytes needed by getData to save the whole content of the variables
- * @return amount of bytes
- */
-int Synchronisable::getSize(){
-  int tsize=0;
-  std::list<synchronisableVariable>::iterator i;
-  for(i=syncList.begin(); i!=syncList.end(); i++){
-    switch(i->type){
+  /**
+  * This function returns the total amount of bytes needed by getData to save the whole content of the variables
+  * @return amount of bytes
+  */
+  int Synchronisable::getSize(){
+    int tsize=0;
+    std::list<synchronisableVariable>::iterator i;
+    for(i=syncList.begin(); i!=syncList.end(); i++){
+      switch(i->type){
     case DATA:
       tsize+=sizeof(int);
@@ -179,8 +176,8 @@
       tsize+=((std::string *)i->var)->length()+1;
       break;
+      }
     }
+    return tsize;
   }
-  return tsize;
-}
 
 }
Index: code/branches/FICN/src/network/Synchronisable.h
===================================================================
--- code/branches/FICN/src/network/Synchronisable.h	(revision 774)
+++ code/branches/FICN/src/network/Synchronisable.h	(revision 777)
@@ -14,58 +14,57 @@
 
 #include <list>
-#include <iostream>
-#include <string>
 
+#include "NetworkPrereqs.h"
 #include "core/CoreIncludes.h"
-#include "core/OrxonoxClass.h"
 
-namespace network {
+namespace network
+{
+  enum variableType{
+    DATA,
+    STRING,
+  };
 
-enum variableType{
-  DATA,
-  STRING,
-};
-  
-struct syncData{
-  int length;
-  int objectID;
-  int classID;
-  unsigned char *data;
-};
+  struct syncData{
+    int length;
+    int objectID;
+    int classID;
+    unsigned char *data;
+  };
 
-typedef struct synchronisableVariable{
-  int size;
-  const void *var;
-  variableType type;
-}SYNCVAR;
+  typedef struct synchronisableVariable{
+    int size;
+    const void *var;
+    variableType type;
+  }SYNCVAR;
 
-  
-/**
- * This class is the base class of all the Objects in the universe that need to be synchronised over the network
- * Every class, that inherits from this class has to link the DATA THAT NEEDS TO BE SYNCHRONISED into the linked list. Additionally it also has to provide a Constructor, that takes exactly the variables in this linked list.
- * @author Oliver Scheuss
-*/
-class Synchronisable : virtual public orxonox::OrxonoxClass{
-public:
 
-  virtual ~Synchronisable();
-  int objectID;
-  int classID;
-    
-  void registerVar(const void *var, int size, variableType t);
-//  syncData getData();
-  syncData getData(unsigned char *mem);
-  int getSize();
-  bool updateData(syncData vars);
-  void registerAllVariables();
-  virtual bool create()=0;
-protected:
-  Synchronisable();
-private:
-/*  bool removeObject(Iterator<Synchronisable> it);*/
-  
-  std::list<SYNCVAR> syncList;
-  int datasize;
-};
+  /**
+  * This class is the base class of all the Objects in the universe that need to be synchronised over the network
+  * Every class, that inherits from this class has to link the DATA THAT NEEDS TO BE SYNCHRONISED into the linked list. Additionally it also has to provide a Constructor, that takes exactly the variables in this linked list.
+  * @author Oliver Scheuss
+  */
+  class _NetworkExport Synchronisable : virtual public orxonox::OrxonoxClass{
+  public:
+
+    virtual ~Synchronisable();
+    int objectID;
+    int classID;
+
+    void registerVar(const void *var, int size, variableType t);
+    //  syncData getData();
+    syncData getData(unsigned char *mem);
+    int getSize();
+    bool updateData(syncData vars);
+    void registerAllVariables();
+    virtual bool create()=0;
+  protected:
+    Synchronisable();
+  private:
+    /*  bool removeObject(Iterator<Synchronisable> it);*/
+
+    std::list<SYNCVAR> syncList;
+    int datasize;
+  };
+  ExportAbstractClass(Synchronisable, Network);
 
 }
Index: code/branches/FICN/src/network/dummyclient.cc
===================================================================
--- code/branches/FICN/src/network/dummyclient.cc	(revision 774)
+++ code/branches/FICN/src/network/dummyclient.cc	(revision 777)
@@ -1,28 +1,28 @@
 /*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Oliver Scheuss, (C) 2007
- *   Co-authors:
- *      ...
- *
- */
+*   ORXONOX - the hottest 3D action shooter ever to exist
+*
+*
+*   License notice:
+*
+*   This program is free software; you can redistribute it and/or
+*   modify it under the terms of the GNU General Public License
+*   as published by the Free Software Foundation; either version 2
+*   of the License, or (at your option) any later version.
+*
+*   This program is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with this program; if not, write to the Free Software
+*   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*
+*   Author:
+*      Oliver Scheuss, (C) 2007
+*   Co-authors:
+*      ...
+*
+*/
 
 //o
@@ -34,13 +34,7 @@
 #include <string>
 #include <enet/enet.h>
+
+#include "util/Sleep.h"
 #include "PacketManager.h"
-
-#ifdef WIN32
-#include <windows.h>
-#define usleep(x) Sleep((x)/1000)
-#else
-#include <unistd.h>
-#endif
-
 
 using namespace std;
@@ -66,5 +60,5 @@
   address.port = 55556;
 
-        // create client object
+  // create client object
   client = enet_host_create(NULL, 2, 0, 0);
 
@@ -73,5 +67,5 @@
     exit(EXIT_FAILURE);
   }
-        // connect peer
+  // connect peer
   peer = enet_host_connect(client, &address, 2);
   if(peer==NULL){
@@ -79,5 +73,5 @@
     exit(EXIT_FAILURE);
   }
-        // wait 5 seconds for the connection attempt to succeed
+  // wait 5 seconds for the connection attempt to succeed
   if(enet_host_service(client, &event, 5000) > 0 && event.type == ENET_EVENT_TYPE_CONNECT){
     cout << "Connection to " << str << " succeeded." << endl;
@@ -91,10 +85,10 @@
 
   for(int i=0; i<10; i++){
-        // weihnachtsmann bringt packete
+    // weihnachtsmann bringt packete
     //ENetPacket *packet = enet_packet_create ("packet1234", strlen("packet1234") + 1, ENET_PACKET_FLAG_RELIABLE);
-        // extend the packet and append the string foo to it
-        // send packet to peer on channel id 0
+    // extend the packet and append the string foo to it
+    // send packet to peer on channel id 0
     enet_peer_send(peer, 1, pck.chatMessage("test2"));
-        // keep the timeout very small for low delay
+    // keep the timeout very small for low delay
     if(enet_host_service(client, &event, 1)==0){
       cout << "successfully sent: " << event.type << endl;
@@ -105,20 +99,20 @@
   }
 
-        // now disconnect
-//   enet_peer_disconnect (peer);
+  // now disconnect
+  //   enet_peer_disconnect (peer);
   enet_peer_disconnect (peer, 0);
-        // 3 seconds timeout
+  // 3 seconds timeout
   while(enet_host_service(client, &event, 3000) > 0){
     switch (event.type)
     {
-      case ENET_EVENT_TYPE_RECEIVE:
-        enet_packet_destroy(event.packet);
-        break;
-      case ENET_EVENT_TYPE_DISCONNECT:
-        puts("Disconnection succeeded.");
-        return 0;
+    case ENET_EVENT_TYPE_RECEIVE:
+      enet_packet_destroy(event.packet);
+      break;
+    case ENET_EVENT_TYPE_DISCONNECT:
+      puts("Disconnection succeeded.");
+      return 0;
     }
   }
-        // if disconnect failed
+  // if disconnect failed
   enet_peer_reset(peer);
 
Index: code/branches/FICN/src/network/dummyclient2.cc
===================================================================
--- code/branches/FICN/src/network/dummyclient2.cc	(revision 774)
+++ code/branches/FICN/src/network/dummyclient2.cc	(revision 777)
@@ -1,28 +1,28 @@
 /*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Oliver Scheuss, (C) 2007
- *   Co-authors:
- *      ...
- *
- */
+*   ORXONOX - the hottest 3D action shooter ever to exist
+*
+*
+*   License notice:
+*
+*   This program is free software; you can redistribute it and/or
+*   modify it under the terms of the GNU General Public License
+*   as published by the Free Software Foundation; either version 2
+*   of the License, or (at your option) any later version.
+*
+*   This program is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with this program; if not, write to the Free Software
+*   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*
+*   Author:
+*      Oliver Scheuss, (C) 2007
+*   Co-authors:
+*      ...
+*
+*/
 
 //
@@ -34,13 +34,8 @@
 #include <string>
 #include <enet/enet.h>
+
+#include "util/Sleep.h"
 #include "PacketManager.h"
 #include "ClientConnection.h"
-
-#ifdef WIN32
-#include <windows.h>
-#define usleep(x) Sleep((x)/1000)
-#else
-#include <unistd.h>
-#endif
 
 using namespace network;
@@ -71,9 +66,9 @@
 
   for(int i=0; i<10; i++){
-        // weihnachtsmann bringt packete
-        // extend the packet and append the string foo to it
-        // send packet to peer on channel id 0
+    // weihnachtsmann bringt packete
+    // extend the packet and append the string foo to it
+    // send packet to peer on channel id 0
     client.addPacket(pck.chatMessage("test"));
-        // keep the timeout very small for low delay
+    // keep the timeout very small for low delay
     if(client.sendPackets(&event)){
       std::cout << "successfully sent: " << event.type << std::endl;
@@ -81,8 +76,8 @@
       std::cout << "failed sending" << std::endl;
     }
-//    usleep(1000000);
+    //    usleep(1000000);
   }
   usleep(1000000);
-        // now disconnect
+  // now disconnect
   if(client.closeConnection())
     std::cout << "Connection successfully closed" << std::endl;
@@ -90,5 +85,5 @@
     std::cout << "Connection closing failed" << std::endl;
 
-        // 3 seconds timeout
+  // 3 seconds timeout
   return 0;
 }
Index: code/branches/FICN/src/network/dummyclient3.cc
===================================================================
--- code/branches/FICN/src/network/dummyclient3.cc	(revision 774)
+++ code/branches/FICN/src/network/dummyclient3.cc	(revision 777)
@@ -1,13 +1,8 @@
 #include <iostream>
 #include <string>
+
+#include "util/Sleep.h"
 #include "PacketManager.h"
 #include "Client.h"
-
-#ifdef WIN32
-#include <windows.h>
-#define usleep(x) Sleep((x)/1000)
-#else
-#include <unistd.h>
-#endif
 
 using namespace network;
@@ -26,20 +21,20 @@
   Client client( str, PORT );
   if ( client.establishConnection() )
-          std::cout << "connection established" << std::endl;
+    std::cout << "connection established" << std::endl;
   else std::cout << "problems establishing connection" << std::endl;
   char message[10000];
   char signs[] = "abcdefghijklmnopqrstuvwxy";
   while (true) {
-          client.tick(0);
-	  
-          std::cout << "your message2: ";
-	  for ( int i=0; i<9999; i++ ) {
-	    message[i] = signs[0];
- 	  }
-	  message[9999] = 'z';
-	  std::string str( message );
-	  client.sendChat( str );
-          std::cout << str << std::endl;
-	  std::cin.get(); std::cin.get();
+    client.tick(0);
+
+    std::cout << "your message2: ";
+    for ( int i=0; i<9999; i++ ) {
+      message[i] = signs[0];
+    }
+    message[9999] = 'z';
+    std::string str( message );
+    client.sendChat( str );
+    std::cout << str << std::endl;
+    std::cin.get(); std::cin.get();
   }
 
@@ -49,5 +44,5 @@
 
 void listener(){
-	
+
   const int PORT = 55556;
   std::cout << "Enter address of the server xxx.xxx.xxx.xxx (enter for localhost)" << std::endl;
@@ -60,10 +55,10 @@
   Client client( str, PORT );
   if ( client.establishConnection() )
-          std::cout << "connection established" << std::endl;
+    std::cout << "connection established" << std::endl;
   else std::cout << "problems establishing connection" << std::endl;
 
   while (true) {
-          client.tick(0);
-          usleep(100);
+    client.tick(0);
+    usleep(100);
   }
 
Index: code/branches/FICN/src/network/dummyserver.cc
===================================================================
--- code/branches/FICN/src/network/dummyserver.cc	(revision 774)
+++ code/branches/FICN/src/network/dummyserver.cc	(revision 777)
@@ -1,28 +1,28 @@
 /*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Oliver Scheuss, (C) 2007
- *   Co-authors:
- *      ...
- *
- */
+*   ORXONOX - the hottest 3D action shooter ever to exist
+*
+*
+*   License notice:
+*
+*   This program is free software; you can redistribute it and/or
+*   modify it under the terms of the GNU General Public License
+*   as published by the Free Software Foundation; either version 2
+*   of the License, or (at your option) any later version.
+*
+*   This program is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with this program; if not, write to the Free Software
+*   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*
+*   Author:
+*      Oliver Scheuss, (C) 2007
+*   Co-authors:
+*      ...
+*
+*/
 
 //
@@ -31,18 +31,11 @@
 // Author: Oliver Scheuss
 
-
 #include <iostream>
 #include <enet/enet.h>
+
+#include "util/Sleep.h"
 #include "ConnectionManager.h"
 #include "PacketManager.h"
 #include "ClientInformation.h"
-
-#ifdef WIN32
-#include <windows.h>
-#define usleep(x) Sleep((x)/1000)
-#else
-#include <unistd.h>
-#endif
-
 
 using namespace network;
@@ -59,5 +52,5 @@
   while(!quit){
     if(server.queueEmpty())
-// Warning: usleep(100) is Sleep(100/1000) = Sleep(0), which is nothing!
+      // Warning: usleep(100) is Sleep(100/1000) = Sleep(0), which is nothing!
       usleep(1);
     else{
Index: code/branches/FICN/src/network/dummyserver3.cc
===================================================================
--- code/branches/FICN/src/network/dummyserver3.cc	(revision 774)
+++ code/branches/FICN/src/network/dummyserver3.cc	(revision 777)
@@ -1,51 +1,46 @@
 #include <iostream>
+
+#include "util/Sleep.h"
 #include "PacketManager.h"
 //#include "PacketTypes.h"
 #include "Server.h"
 
-#ifdef WIN32
-#include <windows.h>
-#define usleep(x) Sleep((x)/1000)
-#else
-#include <unistd.h>
-#endif
+namespace network
+{
 
-namespace network{
-  
-class dummyserver3 : public Server{
+  class dummyserver3 : public Server
+  {
   public:
-  dummyserver3();
-  ~dummyserver3();
-  void loop();
+    dummyserver3();
+    ~dummyserver3();
+    void loop();
   private:
-  void tick();
-  void processChat( chat *data, int clientId);
-  
-  
-  
-};
+    void tick();
+    void processChat( chat *data, int clientId);
 
-dummyserver3::dummyserver3(){
-}
-dummyserver3::~dummyserver3(){
-}
 
-void dummyserver3::loop(){
-  open();
-  while(true){
-    tick();
-    usleep(100);
+  };
+
+  dummyserver3::dummyserver3(){
   }
-}
+  dummyserver3::~dummyserver3(){
+  }
 
-void dummyserver3::processChat( chat *data, int clientId){
-  std::cout << "Client " << clientId << " sent: " << data->message << std::endl;
-  sendMSG(data->message);
-}
+  void dummyserver3::loop(){
+    open();
+    while(true){
+      tick();
+      usleep(100);
+    }
+  }
 
-void dummyserver3::tick(){
-  processQueue();
-}
+  void dummyserver3::processChat( chat *data, int clientId){
+    std::cout << "Client " << clientId << " sent: " << data->message << std::endl;
+    sendMSG(data->message);
+  }
 
+  void dummyserver3::tick(){
+    processQueue();
+  }
 
 }
Index: code/branches/FICN/src/orxonox/Orxonox.h
===================================================================
--- code/branches/FICN/src/orxonox/Orxonox.h	(revision 774)
+++ code/branches/FICN/src/orxonox/Orxonox.h	(revision 777)
@@ -15,4 +15,5 @@
 #include "OrxonoxPrereqs.h"
 #include "loader/LoaderPrereqs.h"
+#include "audio/AudioPrereqs.h"
 
 #include "GraphicsEngine.h"
Index: code/branches/FICN/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- code/branches/FICN/src/orxonox/OrxonoxPrereqs.h	(revision 774)
+++ code/branches/FICN/src/orxonox/OrxonoxPrereqs.h	(revision 777)
@@ -27,5 +27,5 @@
 
 /**
- @file  OrxonoxPrereq.h
+ @file  OrxonoxPrereqs.h
  @brief Contains all the necessary forward declarations for all classes and structs.
  */
@@ -94,39 +94,4 @@
 }
 
-namespace audio {
-  class AudioBuffer;
-  class AudioManager;
-  class AudioSource;
-  class AudioStream;
-}
-
-namespace network {
-  class Client;
-  class ClientConnection;
-  class ClientFrameListener;
-  class ClientInformation;
-  class ConnectionManager;
-  class GameStateClient;
-  class GameStateManager;
-  class PacketBuffer;
-  class PacketDecoder;
-  class PacketGenerator;
-  class Server;
-  class ServerFrameListener;
-  class Synchronisable;
-  struct ack;
-  struct chat;
-  struct classid;
-  struct ClientList;
-  struct GameState;
-  struct GameStateCompressed;
-  struct keyboard;
-  struct mouse;
-  struct PacketEnvelope;
-  struct QueueItem;
-  struct synchData;
-  struct synchronisableVariable;
-
-}
 
 #endif /* _OrxonoxPrereqs_H__ */
