Index: /code/branches/network/src/network/CMakeLists.txt
===================================================================
--- /code/branches/network/src/network/CMakeLists.txt	(revision 1704)
+++ /code/branches/network/src/network/CMakeLists.txt	(revision 1705)
@@ -4,9 +4,8 @@
   ClientInformation.cc
   ConnectionManager.cc
-  GameStateManager.cc
-  GameStateClient.cc
+  GamestateManager.cc
+  GamestateClient.cc
+  GamestateHandler.cc
   PacketBuffer.cc
-  PacketDecoder.cc
-  PacketGenerator.cc
   Server.cc
   Synchronisable.cc
@@ -17,4 +16,5 @@
   packet/Acknowledgement.cc
   packet/Gamestate.cc
+  packet/Welcome.cc
   Host.cc
 )
Index: /code/branches/network/src/network/Client.cc
===================================================================
--- /code/branches/network/src/network/Client.cc	(revision 1704)
+++ /code/branches/network/src/network/Client.cc	(revision 1705)
@@ -45,4 +45,5 @@
 #include "core/ConsoleCommand.h"
 #include "packet/Packet.h"
+#include "packet/Acknowledgement.h"
 
 namespace network
@@ -127,4 +128,5 @@
     return p->send();
   }
+  
 
   /**
@@ -137,8 +139,8 @@
     if(!isConnected)
       return false;
-    return client_connection.addPacket(pck_gen.chatMessage( message.c_str() ));
+    packet::Packet p(new packet::Chat(message, clientID_));
+    return p.send();
       //return client_connection.sendPackets();
     // send packets
-    return false;
   }
 
@@ -150,12 +152,11 @@
     if(client_connection.isConnected() && isSynched_){
       COUT(4) << "popping partial gamestate: " << std::endl;
-      GameStateCompressed *gs = gamestate.popPartialGameState();
+      packet::Gamestate *gs = gamestate.getGamestate();
       if(gs){
         COUT(4) << "client tick: sending gs " << gs << std::endl;
-        ENetPacket *packet = pck_gen.gstate(gs);
-        if( packet == NULL || !client_connection.addPacket(packet))
+        packet::Packet p(gs);
+        if( !p.send() )
           COUT(3) << "Problem adding partial gamestate to queue" << std::endl;
         // now delete it to save memory
-        delete[] gs->data;
         delete gs;
       }
@@ -166,10 +167,12 @@
       event = client_connection.getEvent();
       COUT(5) << "tick packet size " << event->packet->dataLength << std::endl;
-      elaborate(event->packet, 0); // ================= i guess we got to change this .... (client_ID is always same = server)
+      packet::Packet packet(event->packet, event->peer);
+      assert(packet.getPacketContent()->process());
     }
-    int gameStateID = gamestate.processGameState();
+    int gameStateID = gamestate.processGamestates();
     if(gameStateID==GAMESTATEID_INITIAL)
       if(gameStateFailure_){
-        if(!client_connection.addPacket(pck_gen.acknowledgement(GAMESTATEID_INITIAL)))
+        packet::Packet packet(new packet::Acknowledgement(GAMESTATEID_INITIAL, 0));
+        if(!packet.send())
           COUT(3) << "could not (negatively) ack gamestate" << std::endl;
         else 
@@ -183,47 +186,11 @@
         isSynched_=true;
       gameStateFailure_=false;
-      if(!client_connection.addPacket(pck_gen.acknowledgement(gameStateID)))
+      packet::Packet packet(new packet::Acknowledgement(gameStateID, 0));
+      if(!packet.send())
         COUT(3) << "could not ack gamestate" << std::endl;
     }// otherwise we had no gamestate to load
     gamestate.cleanup();
-    /*if(!client_connection.sendPackets())
-      COUT(3) << "Problem sending packets to server" << std::endl;*/
     return;
   }
 
-  void Client::processGamestate( GameStateCompressed *data, int clientID){
-    COUT(5) << "received gamestate id: " << data->id << std::endl;
-    gamestate.addGameState(data);
-  }
-
-  void Client::processClassid(classid *clid){
-    orxonox::Identifier *id;
-    id=ID(std::string(clid->message));
-    if(id!=NULL)
-      id->setNetworkID(clid->clid);
-    COUT(4) << "Client: received and set network id: " << clid->clid << "; classname: " << clid->message << std::endl;
-    COUT(4) << "id(classid)->getName " << ID((unsigned int)clid->clid)->getName() << std::endl;
-    delete clid;
-    return;
-  }
-  
-  bool Client::ackGamestateID(int gamestateID, int clientID){
-    return true;
-    //TODO: maybe change this (not needed at the moment)
-  }
-
-//   void Client::processChat( chat *data, int clientId){
-//     COUT(1) << data->message << std::endl;
-//     delete[] data->message;
-//     delete data;
-//   }
-  
-  bool Client::processWelcome( welcome *w ){
-    COUT(4) << "processing welcome message" << std::endl;
-    clientID_ = w->clientID;
-    shipID_ = w->shipID;
-    delete w;
-    return true;
-  }
-
 }
Index: /code/branches/network/src/network/Client.h
===================================================================
--- /code/branches/network/src/network/Client.h	(revision 1704)
+++ /code/branches/network/src/network/Client.h	(revision 1705)
@@ -49,6 +49,5 @@
 #include "packet/Chat.h"
 #include "ClientConnection.h"
-#include "PacketManager.h"
-#include "GameStateClient.h"
+#include "GamestateClient.h"
 //#include "NetworkFrameListener.h"
 
@@ -64,5 +63,5 @@
   *
   */
-  class _NetworkExport Client : PacketDecoder, public Host{
+  class _NetworkExport Client : public Host{
   public:
     Client();
@@ -81,5 +80,7 @@
     unsigned int shipID(){return shipID_;}
     int playerID(){return clientID_;}
-
+    static void setShipID( unsigned int shipID){ dynamic_cast<Client *>(instance_)->shipID_=shipID; }
+    static void setClientID( unsigned int clientID){ dynamic_cast<Client *>(instance_)->clientID_=clientID; }
+    
     void tick(float time);
 
@@ -87,6 +88,5 @@
     
     ClientConnection client_connection;
-    PacketGenerator pck_gen;
-    GameStateClient gamestate;
+    GamestateClient gamestate;
     bool isConnected;
     bool isSynched_;
@@ -95,9 +95,5 @@
     
     // implement data processing functions of PacketDecoder
-    void processGamestate( GameStateCompressed *data, int clientID);
-    void processClassid(classid *clid);
-    bool ackGamestateID(int gamestateID, int clientID);
 //     void processChat( chat *data, int clientId );
-    bool processWelcome( welcome *w );
     int clientID_;     // this is the id the server gave to us
     int shipID_;
Index: /code/branches/network/src/network/ClientInformation.cc
===================================================================
--- /code/branches/network/src/network/ClientInformation.cc	(revision 1704)
+++ /code/branches/network/src/network/ClientInformation.cc	(revision 1705)
@@ -123,5 +123,5 @@
   }
 
-  bool ClientInformation::setGameStateID(int id){
+  bool ClientInformation::setGamestateID(int id){
     if(!this)
       return false;
Index: /code/branches/network/src/network/ClientInformation.h
===================================================================
--- /code/branches/network/src/network/ClientInformation.h	(revision 1704)
+++ /code/branches/network/src/network/ClientInformation.h	(revision 1705)
@@ -70,5 +70,5 @@
     void setID(int clientID);
     bool setPeer(ENetPeer *peer);
-    bool setGameStateID(int id);
+    bool setGamestateID(int id);
     bool setPartialGamestateID(int id);
     inline void setShipID(unsigned int id){ShipID_=id;}
Index: /code/branches/network/src/network/ConnectionManager.cc
===================================================================
--- /code/branches/network/src/network/ConnectionManager.cc	(revision 1704)
+++ /code/branches/network/src/network/ConnectionManager.cc	(revision 1705)
@@ -51,4 +51,5 @@
 #include "ConnectionManager.h"
 #include "Synchronisable.h"
+#include "packet/ClassID.h"
 
 namespace std
@@ -75,5 +76,5 @@
     bindAddress.port = NETWORK_PORT;
   }
-  boost::recursive_mutex ConnectionManager::enet_mutex_;
+  boost::recursive_mutex ConnectionManager::enet_mutex;
   
 //   ConnectionManager::ConnectionManager(ClientInformation *head) : receiverThread_(0) {
@@ -172,5 +173,5 @@
   
   bool ConnectionManager::addPacket(ENetPacket *packet, ENetPeer *peer) {
-    boost::recursive_mutex::scoped_lock lock(instance_->enet_mutex_);
+    boost::recursive_mutex::scoped_lock lock(instance_->enet_mutex);
     if(enet_peer_send(peer, NETWORK_DEFAULT_CHANNEL, packet)!=0)
       return false;
@@ -190,5 +191,5 @@
     if(!instance_)
       return false;
-    boost::recursive_mutex::scoped_lock lock(instance_->enet_mutex_);
+    boost::recursive_mutex::scoped_lock lock(instance_->enet_mutex);
     for(ClientInformation *i=ClientInformation::getBegin()->next(); i!=0; i=i->next()){
       COUT(3) << "adding broadcast packet for client: " << i->getID() << std::endl;
@@ -203,5 +204,5 @@
     if(server==NULL || !instance_)
       return false;
-    boost::recursive_mutex::scoped_lock lock(enet_mutex_);
+    boost::recursive_mutex::scoped_lock lock(enet_mutex);
     enet_host_flush(server);
     lock.unlock();
@@ -214,5 +215,5 @@
     atexit(enet_deinitialize);
     { //scope of the mutex
-      boost::recursive_mutex::scoped_lock lock(enet_mutex_);
+      boost::recursive_mutex::scoped_lock lock(enet_mutex);
       enet_initialize();
       server = enet_host_create(&bindAddress, NETWORK_MAX_CONNECTIONS, 0, 0);
@@ -228,5 +229,5 @@
     while(!quit){
       { //mutex scope
-        boost::recursive_mutex::scoped_lock lock(enet_mutex_);
+        boost::recursive_mutex::scoped_lock lock(enet_mutex);
         if(enet_host_service(server, event, NETWORK_WAIT_TIMEOUT)<0){
           // we should never reach this point
@@ -270,5 +271,5 @@
     // if we're finishied, destroy server
     {
-      boost::recursive_mutex::scoped_lock lock(enet_mutex_);
+      boost::recursive_mutex::scoped_lock lock(enet_mutex);
       enet_host_destroy(server);
       lock.unlock();
@@ -284,5 +285,5 @@
     while(temp!=0){
       {
-        boost::recursive_mutex::scoped_lock lock(enet_mutex_);
+        boost::recursive_mutex::scoped_lock lock(enet_mutex);
         enet_peer_disconnect(temp->getPeer(), 0);
         lock.unlock();
@@ -292,5 +293,5 @@
     //bugfix: might be the reason why server crashes when clients disconnects
     temp = ClientInformation::getBegin()->next();
-    boost::recursive_mutex::scoped_lock lock(enet_mutex_);
+    boost::recursive_mutex::scoped_lock lock(enet_mutex);
     while( temp!=0 && enet_host_service(server, &event, NETWORK_WAIT_TIMEOUT) >= 0){
       switch (event.type)
@@ -337,4 +338,7 @@
     std::string classname;
     orxonox::Identifier *id;
+    packet::Packet packet;
+    packet.setClientID(clientID);
+    packet::ClassID *classid;
     std::map<std::string, orxonox::Identifier*>::const_iterator it = orxonox::Factory::getFactoryBegin();
     while(it != orxonox::Factory::getFactoryEnd()){
@@ -348,9 +352,13 @@
       COUT(4) << "Con.Man:syncClassid:\tnetwork_id: " << network_id << ", classname: " << classname << std::endl;
 
-      while(!addPacket(packet_gen.clid( (int)network_id, classname ), clientID) && failures < 10){
+      classid = new packet::ClassID(network_id, classname);
+      packet.setPacketContent(classid);
+      while(!packet.send() && failures < 10){
         failures++;
       }
+      delete classid;
       ++it;
     }
+    packet.setPacketContent(0);
     //sendPackets();
     COUT(4) << "syncClassid:\tall synchClassID packets have been sent" << std::endl;
@@ -370,15 +378,8 @@
   }
   
-  bool ConnectionManager::sendWelcome(int clientID, int shipID, bool allowed){
-    if(addPacket(packet_gen.generateWelcome(clientID, shipID, allowed),clientID)){
-      //sendPackets();
-      return true;
-    }else
-      return false;
-  }
   
   void ConnectionManager::disconnectClient(ClientInformation *client){
     {
-      boost::recursive_mutex::scoped_lock lock(enet_mutex_);
+      boost::recursive_mutex::scoped_lock lock(enet_mutex);
       enet_peer_disconnect(client->getPeer(), 0);
       lock.unlock();
@@ -387,12 +388,4 @@
   }
   
-  bool ConnectionManager::addFakeConnectRequest(ENetEvent *ev){
-    ENetEvent event;
-    event.peer=ev->peer;
-    event.packet = packet_gen.generateConnectRequest();
-    return buffer.push(&event);
-  }
-  
-  
 
 }
Index: /code/branches/network/src/network/ConnectionManager.h
===================================================================
--- /code/branches/network/src/network/ConnectionManager.h	(revision 1704)
+++ /code/branches/network/src/network/ConnectionManager.h	(revision 1705)
@@ -51,5 +51,4 @@
 
 #include "PacketBuffer.h"
-#include "PacketManager.h"
 #include "packet/Packet.h"
 
@@ -73,5 +72,6 @@
 
   class ConnectionManager{
-  public:
+    public:
+    static boost::recursive_mutex enet_mutex;
     ConnectionManager();
     //ConnectionManager(ClientInformation *head);
@@ -95,5 +95,4 @@
     void disconnectClient(ClientInformation *client);
     void syncClassid(int clientID);
-    bool sendWelcome(int clientID, int shipID, bool allowed);
 
   private:
@@ -109,7 +108,5 @@
     //bool createShip(ClientInformation *client);
     bool removeShip(ClientInformation *client);
-    bool addFakeConnectRequest(ENetEvent *ev);
     PacketBuffer buffer;
-    PacketGenerator packet_gen;
 
     ENetHost *server;
@@ -119,5 +116,4 @@
 
     boost::thread *receiverThread_;
-    static boost::recursive_mutex enet_mutex_;
     static ConnectionManager *instance_;
 
Index: de/branches/network/src/network/GameStateManager.cc
===================================================================
--- /code/branches/network/src/network/GameStateManager.cc	(revision 1704)
+++ 	(revision )
@@ -1,528 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   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++ Implementation: GameStateManager
-//
-// Description:
-//
-//
-// Author:  Oliver Scheuss, (C) 2007
-//
-// Copyright: See COPYING file that comes with this distribution
-//
-//
-
-#include "GameStateManager.h"
-
-#include <utility>
-#include <iostream>
-#include <zlib.h>
-#include <assert.h>
-
-#include "core/CoreIncludes.h"
-#include "core/BaseObject.h"
-#include "ClientInformation.h"
-#include "Synchronisable.h"
-
-namespace network
-{
-  GameStateManager::GameStateManager() {
-    id_=0;
-  }
-
-  GameStateManager::~GameStateManager() {
-  }
-
-  void GameStateManager::update(){
-    cleanup();
-    reference = getSnapshot();
-    COUT(4) << "inserting gamestate: " << reference << std::endl;
-    gameStateMap.insert(std::pair<int, GameState*>(id_, reference));
-    gameStateUsed[id_]=0;
-    printGameStates();
-    return;
-  }
-  
-  void GameStateManager::addGameState(GameStateCompressed *gs, int clientID){
-    if(!gs)
-      return;
-    std::map<int, GameStateCompressed*>::iterator it = gameStateQueue.find(clientID);
-    if(it!=gameStateQueue.end()){
-      // delete obsolete gamestate
-      delete[] it->second->data;
-      delete it->second;
-    }
-    gameStateQueue[clientID] = gs;
-    return;
-  }
-  
-  void GameStateManager::processGameStates(){
-    std::map<int, GameStateCompressed*>::iterator it;
-    // now push only the most recent gamestates we received (ignore obsolete ones)
-    for(it = gameStateQueue.begin(); it!=gameStateQueue.end(); it++){
-      pushGameState(it->second, it->first);
-    }
-    // now clear the queue
-    gameStateQueue.clear();
-  }
-  
-  
-  /**
-   * this function is used to keep the memory usage low
-   * it tries to delete all the unused gamestates
-   * 
-   * 
-   */
-  void GameStateManager::cleanup(){
-    std::map<int,int>::iterator it = gameStateUsed.begin();
-    while(it!=gameStateUsed.end()){
-      if((id_-(*it).first)<KEEP_GAMESTATES)
-        break;
-      if( (*it).second <= 0 ){
-        COUT(5) << "GameStateManager: deleting gamestate with id: " << (*it).first << ", uses: " << (*it).second << std::endl;
-        std::map<int, GameState *>::iterator tempit = gameStateMap.find((*it).first);
-        if( tempit != gameStateMap.end() ){
-          GameState *temp = tempit->second;
-          if(temp){
-            delete[] gameStateMap[(*it).first]->data;
-            delete gameStateMap[(*it).first];
-            gameStateMap.erase((*it).first);
-          }
-        }
-        gameStateUsed.erase(it++);
-        continue;
-      }/*else if(id_-it->first<=KEEP_GAMESTATES){  //as soon as we got a used gamestate break here because we could use newer gamestates in future but only if we do not exceed KEEP_GAMESTATES # of gamestates in cache
-        COUT(4) << "breaking " << std::endl;
-        break;
-      }*/
-      it++;
-    }
-  }
-
-  GameStateCompressed *GameStateManager::popGameState(int clientID) {
-    //why are we searching the same client's gamestate id as we searched in
-    //Server::sendGameState?
-    int gID = ClientInformation::findClient(clientID)->getGamestateID();
-    COUT(4) << "G.St.Man: popgamestate: sending gstate_id: " << id_ << " diffed from: " << gID << std::endl;
-//     COUT(3) << "gamestatemap: " << &gameStateMap << std::endl;
-    //chose wheather the next gamestate is the first or not
-    if(gID != GAMESTATEID_INITIAL){
-      // TODO something with the gamestatemap is wrong
-      GameState *client=NULL;
-      std::map<int, GameState*>::iterator it = gameStateMap.find(gID);
-      if(it!=gameStateMap.end())
-        client = it->second;
-      GameState *server = reference;
-      //COUT(4) << "client: " << client << " server: " << server << " gamestatemap: " << &gameStateMap << " size: " << server->size << std::endl;
-      COUT(4) << "client: " << (client!=0 ? client->id : (int)client) << " server: " << server->id << " gamestatemap: " << &gameStateMap << " size: " << server->size << std::endl;
-      if(client)
-        return encode(client, server);
-      else
-        return encode(server);
-    } else {
-      COUT(4) << "we got a GAMESTATEID_INITIAL for clientID: " << clientID << std::endl;
-      GameState *server = reference;
-//       ackGameState(clientID, reference->id);
-      return encode(server);
-      // return an undiffed gamestate and set appropriate flags
-    }
-  }
-  
-  bool GameStateManager::pushGameState( GameStateCompressed *gs, int clientID ){
-    GameState *ugs = decompress(gs);
-    delete[] gs->data;
-    delete gs;
-    bool result = loadPartialSnapshot(ugs, clientID);
-    delete[] ugs->data;
-    delete ugs;
-    return result;
-  }
-
-  /**
-  * 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()
-  {
-    //std::cout << "begin getSnapshot" << std::endl;
-    //the size of the gamestate
-    int totalsize=0;
-    int memsize=0;
-    //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_;
-    COUT(4) << "G.ST.Man: producing gamestate with id: " << retval->id << std::endl;
-    // offset of memory functions
-    int offset=0, size=0;
-    // get total size of gamestate
-    for(it = orxonox::ObjectList<Synchronisable>::start(); it; ++it){
-      size+=it->getSize(); // size of the actual data of the synchronisable
-      size+=3*sizeof(int); // size of datasize, classID and objectID
-    }
-    //retval->data = (unsigned char*)malloc(size);
-    if(size==0)
-      return NULL;
-    retval->data = new unsigned char[size];
-    if(!retval->data){
-      COUT(2) << "GameStateManager: could not allocate memory" << std::endl;
-      return NULL;
-    }
-    memsize=size;
-    // go through all Synchronisables
-    for(it = orxonox::ObjectList<Synchronisable>::start(); it; ++it){
-      //get size of the synchronisable
-      tempsize=it->getSize();
-      // add place for data and 3 ints (length,classid,objectid)
-      totalsize+=tempsize+3*sizeof(int);
-      // allocate+tempsize additional space
-      if(totalsize > size){
-        COUT(3) << "G.St.Man: need additional memory" << std::endl;
-//         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;
-//         }
-//         COUT(5) << "G.St.Man: additional space allocation finished" << std::endl;
-      }
-
-      // 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));
-      memcpy(retval->data+offset, (void *)&(sync.length), sizeof(int));
-      memcpy(retval->data+offset+sizeof(int), (void *)&(sync.objectID), sizeof(int));
-      memcpy(retval->data+offset+2*sizeof(int), (void *)&(sync.classID), sizeof(int));
-      // increase data pointer
-      offset+=tempsize+3*sizeof(int);
-    }
-    retval->size=totalsize;
-    //#### bugfix
-    retval->diffed = false;
-    retval->complete = true;
-    //std::cout << "end snapShot" << std::endl;
-    COUT(5) << "G.ST.Man: Gamestate size: " << totalsize << std::endl;
-    COUT(5) << "G.ST.Man: 'estimated' Gamestate size: " << size << std::endl;
-    return retval;
-  }
-
-  bool GameStateManager::loadPartialSnapshot(GameState *state, int clientID){
-    if(!state)
-      return false;
-    unsigned char *data=state->data;
-    COUT(4) << "loadSnapshot: loading gs: " << state->id << std::endl;
-    // get the start of the Synchronisable list
-    orxonox::Iterator<Synchronisable> it=orxonox::ObjectList<Synchronisable>::start();
-    syncData sync;
-    /*ClientInformation *client = head_->findClient(clientID);
-    if(client)
-      if(client->getPartialGamestateID()>state->id){
-        COUT(3) << "we received an obsolete partial gamestate" << std::endl;
-        return false;
-      }
-    else;*/
-        //what should we do now ??
-    // 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;
-      if(sync.classID == 0) // TODO: remove this
-        COUT(3) << "received a classid 0" << std::endl;
-      data+=sizeof(int);
-      sync.data = data;
-      data+=sync.length;
-      COUT(5) << "objectID: " << sync.objectID << " classID: " << sync.classID << std::endl;
-      while(it && it->objectID!=sync.objectID)
-        ++it;
-
-
-      if(!it){
-        // the objectaber ich glaub die  does not exist yet
-        COUT(4) << "loadsnapshot: creating new object " << std::endl;
-        //COUT(4) << "loadSnapshot:\tclassid: " << sync.classID << ", name: " << ID((unsigned int) sync.classID)->getName() << std::endl;
-        orxonox::Identifier* id = ID((unsigned int)sync.classID);
-        if(!id){
-          COUT(4) << "We could not identify a new object; classid: " << sync.classID << std::endl;
-          continue;
-        }
-        Synchronisable *no = dynamic_cast<Synchronisable *>(id->fabricate());
-        COUT(4) << "loadpartialsnapshot (generating new object): classid: " << sync.classID << " objectID: " << sync.objectID << " length: " << sync.length << std::endl;
-        no->objectID=sync.objectID;
-        no->classID=sync.classID;
-        it=orxonox::ObjectList<Synchronisable>::end();
-        // update data and create object/entity...
-        if( !no->updateData(sync) )
-          COUT(1) << "We couldn't update the object: " << sync.objectID << std::endl;
-        if( !no->create() )
-          COUT(1) << "We couldn't manifest (create() ) the object: " << sync.objectID << std::endl;
-      }else{
-        // we have our object
-        COUT(4) << "loadpartialsnapshot: we found the appropriate object" << std::endl;
-        if(checkAccess(clientID, sync.objectID)){
-          if(! it->updateData(sync))
-            COUT(1) << "We couldn't update objectID: " \
-              << sync.objectID << "; classID: " << sync.classID << std::endl;
-        }else
-          COUT(4) << "loadPartialSnapshot: no access to change objectID: " << sync.objectID << std::endl;
-      }
-      ++it;
-    }
-    //client->setPartialGamestateID(state->id);
-    return true;
-  }
-  
-  
-  //##### ADDED FOR TESTING PURPOSE #####
-  GameStateCompressed* GameStateManager::testCompress( GameState* g ) {
-    return compress_( g );
-  }
-
-  GameState* GameStateManager::testDiff( GameState* a, GameState* b ) {
-    return diff( a, b );
-  }
-  //##### END TESTING PURPOSE #####
-
-  GameStateCompressed *GameStateManager::encode(GameState *a, GameState *b) {
-    COUT(5) << "G.St.Man: this will be a DIFFED gamestate" << std::endl;
-    GameState *r = diff(a,b);
-    GameStateCompressed *c = compress_(r);
-    delete[] r->data;
-    delete r;
-    return c;
-  }
-
-  GameStateCompressed *GameStateManager::encode(GameState *a) {
-    COUT(5) << "G.St.Man: encoding gamestate (compress)" << std::endl;
-    a->base_id=GAMESTATEID_INITIAL;
-    return compress_(a);
-    /*GameStateCompressed *g = new GameStateCompressed;
-    g->base_id = a->base_id;
-    g->id = a->id;
-    g->diffed = a->diffed;
-    g->data = a->data;
-    g->normsize = a->size;
-    g->compsize = a->size;
-    return g;*/
-  }
-
-  GameState *GameStateManager::diff(GameState *alt, GameState *neu) {
-    unsigned char *ap = alt->data, *bp = neu->data;
-    int of=0; // pointers offset
-    int dest_length=0;
-    /*if(alt->size>neu->size)
-      dest_length=alt->size;
-    else*/
-      dest_length=neu->size;
-    if(dest_length==0)
-      return NULL;
-    //unsigned char *dp = (unsigned char *)malloc(dest_length*sizeof(unsigned char));
-    unsigned char *dp = new unsigned char[dest_length*sizeof(unsigned char)];
-    while(of<alt->size && of<neu->size){
-      *(dp+of)=*(ap+of)^*(bp+of); // do the xor
-      ++of;
-    }
-    if(alt->size!=neu->size){ // do we have to fill up ?
-      unsigned char n=0;
-      if(alt->size<neu->size){
-        while(of<dest_length){
-          *(dp+of)=n^*(bp+of);
-          of++;
-        }
-      } /*else{
-        while(of<dest_length){
-          *(dp+of)=*(ap+of)^n;
-          of++;
-        }
-      }*/
-    }
-
-    GameState *r = new GameState;
-    r->id = neu->id;
-    r->size = dest_length;
-    r->diffed = true;
-    r->base_id = alt->id;
-    r->data = dp;
-    r->complete = true;
-    return r;
-  }
-
-  GameStateCompressed *GameStateManager::compress_(GameState *a) {
-    //COUT(4) << "G.St.Man: compressing gamestate" << std::endl;
-
-    //COUT(4) << "G.St.Man: a: id: " << a->id << " base_id: " << a->base_id << " size: " << a->size << " diffed: " << a->diffed << std::endl;
-    int size = a->size;
-
-    uLongf buffer = (uLongf)((a->size + 12)*1.01)+1;
-    //COUT(4) << "size: " << size << ", buffer: " << buffer << std::endl;
-    //unsigned char* dest = (unsigned char*)malloc( buffer );
-    if(buffer==0)
-      return NULL;
-    unsigned char *dest = new unsigned char[buffer];
-    //COUT(4) << "dest: " << dest << std::endl;
-    int retval;
-    //std::cout << "before ziped " << buffer << std::endl;
-    retval = compress( dest, &buffer, a->data, (uLong)size );
-    //COUT(4) << "bloablabla aft3er compress" << std::endl;
-    //std::cout << "after ziped " << buffer << std::endl;
-
-    switch ( retval ) {
-      case Z_OK: COUT(5) << "G.St.Man: compress: successfully compressed" << std::endl; break;
-      case Z_MEM_ERROR: COUT(1) << "G.St.Man: compress: not enough memory available in gamestate.compress" << std::endl; 
-      return NULL;
-      case Z_BUF_ERROR: COUT(2) << "G.St.Man: compress: not enough memory available in the buffer in gamestate.compress" << std::endl;
-      return NULL;
-      case Z_DATA_ERROR: COUT(2) << "G.St.Man: compress: data corrupted in gamestate.compress" << std::endl;
-      return NULL;
-    }
-
-    GameStateCompressed *compressedGamestate = new GameStateCompressed;
-    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;
-    compressedGamestate->complete = a->complete;
-    compressedGamestate->base_id = a->base_id;
-    //COUT(5) << "G.St.Man: saved compressed data in GameStateCompressed:" << std::endl;
-    return compressedGamestate;
-  }
-  
-  GameState *GameStateManager::decompress(GameStateCompressed *a) {
-    //COUT(4) << "GameStateClient: uncompressing gamestate. id: " << a->id << ", baseid: " << a->base_id << ", normsize: " << a->normsize << ", compsize: " << a->compsize << std::endl;
-    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 );
-    if(bufsize==0)
-      return NULL;
-    unsigned char *dest = new unsigned char[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: COUT(5) << "successfully decompressed" << std::endl; break;
-      case Z_MEM_ERROR: COUT(1) << "not enough memory available" << std::endl; return NULL;
-      case Z_BUF_ERROR: COUT(2) << "not enough memory available in the buffer" << std::endl; return NULL;
-      case Z_DATA_ERROR: COUT(2) << "data corrupted (zlib)" << std::endl; return NULL;
-    }
-
-    GameState *gamestate = new GameState;
-    gamestate->id = a->id;
-    gamestate->size = normsize;
-    gamestate->data = dest;
-    gamestate->base_id = a->base_id;
-    gamestate->diffed = a->diffed;
-    gamestate->complete = a->complete;
-
-
-    return gamestate;
-  }
-  
-
-  void GameStateManager::ackGameState(int clientID, int gamestateID) {
-    ClientInformation *temp = ClientInformation::findClient(clientID);
-    if(temp==0)
-      return;
-    int curid = temp->getGamestateID();
-    
-    if(gamestateID == GAMESTATEID_INITIAL){
-      temp->setGameStateID(GAMESTATEID_INITIAL);
-      if(curid!=GAMESTATEID_INITIAL){
-        assert(gameStateUsed.find(curid)!=gameStateUsed.end());
-        --(gameStateUsed.find(curid)->second);
-      }
-      return;
-    }
-    if(curid > gamestateID)
-      // the network packets got messed up 
-      return;
-    COUT(4) << "acking gamestate " << gamestateID << " for clientid: " << clientID << " curid: " << curid << std::endl;
-    // decrease usage of gamestate and save it
-//     deleteUnusedGameState(curid);
-    //increase gamestateused
-    std::map<int, int>::iterator it = gameStateUsed.find(curid);
-    if(curid!=GAMESTATEID_INITIAL){
-      if(it!=gameStateUsed.end())
-        --(it->second);
-    }
-    it = gameStateUsed.find(gamestateID);
-    if(it!=gameStateUsed.end()){
-      ++(it->second);
-      temp->setGameStateID(gamestateID);
-    }
-    /*
-    GameState *old = clientGameState[clientID];
-    deleteUnusedGameState(old);
-    clientGameState[clientID]=idGameState[gamestateID];*/
-  }
-
-  bool GameStateManager::printGameStates() {
-    std::map<int, GameState*>::iterator it;
-    COUT(4) << "gamestates: ";
-    for(it = gameStateMap.begin(); it!=gameStateMap.end(); it++){
-      COUT(4) << (*it).first << ":" << (*it).second << " | ";
-    }
-    COUT(4) << std::endl;
-    return true;
-  }
-  
-  bool GameStateManager::checkAccess(int clientID, int objectID){
-    // currently we only check, wheter the object is the clients spaceship
-//     return head_->findClient(objectID)->getShipID()==objectID;
-    return true; // TODO: change this
-  }
-  
-  void GameStateManager::removeClient(ClientInformation* client){
-    if(!client)
-      return;
-    if(client->getGamestateID()>=0)
-      gameStateUsed[client->getGamestateID()]--;
-    ClientInformation::removeClient(client->getID());
-  }
-
-}
Index: de/branches/network/src/network/GameStateManager.h
===================================================================
--- /code/branches/network/src/network/GameStateManager.h	(revision 1704)
+++ 	(revision )
@@ -1,112 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   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++ Interface: GameStateManager
-//
-// Description:
-//
-//
-// Author:  Oliver Scheuss, (C) 2007
-//
-// Copyright: See COPYING file that comes with this distribution
-//
-//
-#ifndef _GameStateManager_H__
-#define _GameStateManager_H__
-
-#include "NetworkPrereqs.h"
-
-#include <map>
-
-#include "PacketTypes.h"
-
-namespace network
-{
-
-#define KEEP_GAMESTATES 10
-
-  /**
-  * 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();
-    ~GameStateManager();
-    
-    void addGameState(GameStateCompressed *gs, int clientID);
-    void processGameStates();
-    
-    void update();
-    GameStateCompressed *popGameState(int clientID);
-    void ackGameState(int clientID, int gamestateID);
-    void removeClient(ClientInformation *client);
-    private:
-    bool pushGameState(GameStateCompressed *gs, int clientID);
-    void cleanup(); // "garbage handler"
-    GameState *getSnapshot();
-    bool loadPartialSnapshot(GameState *state, int clientID);
-    GameStateCompressed *encode(GameState *a, GameState *b);
-    GameStateCompressed *encode(GameState *a);
-    GameState *diff(GameState *alt, GameState *neu);
-    GameStateCompressed *compress_(GameState *a);
-    GameState *decompress(GameStateCompressed *a);
-    bool printGameStates();
-    bool checkAccess(int clientID, int objectID);
-
-    std::map<int, GameState*> gameStateMap; //map gsID to gamestate*
-    std::map<int, int> gameStateUsed; // save the number of clients, that use the specific gamestate
-    std::map<int, GameStateCompressed*> gameStateQueue;
-    GameState *reference;
-    int id_;
-    
-    
-    
-    
-  public:
-    //#### ADDED FOR TESTING PURPOSE ####
-    GameStateCompressed* testCompress( GameState* g );
-    GameState* testDiff( GameState* a, GameState* b );
-  //#### END TESTING PURPOSE ####
-  };
-
-}
-
-#endif /* _GameStateManager_H__ */
Index: /code/branches/network/src/network/GamestateManager.cc
===================================================================
--- /code/branches/network/src/network/GamestateManager.cc	(revision 1705)
+++ /code/branches/network/src/network/GamestateManager.cc	(revision 1705)
@@ -0,0 +1,200 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   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++ Implementation: GameStateManager
+//
+// Description:
+//
+//
+// Author:  Oliver Scheuss, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#include "GamestateManager.h"
+
+#include <utility>
+#include <iostream>
+#include <zlib.h>
+#include <assert.h>
+
+#include "core/CoreIncludes.h"
+#include "core/BaseObject.h"
+#include "ClientInformation.h"
+#include "Synchronisable.h"
+
+namespace network
+{
+  GamestateManager::GamestateManager() {
+    id_=0;
+  }
+
+  GamestateManager::~GamestateManager() {
+  }
+
+  bool GamestateManager::update(){
+    cleanup();
+    getSnapshot();
+    return true;
+  }
+  
+  bool GamestateManager::add(packet::Gamestate *gs, int clientID){
+    assert(gs);
+    std::map<int, packet::Gamestate*>::iterator it = gamestateQueue.find(clientID);
+    if(it!=gamestateQueue.end()){
+      // delete obsolete gamestate
+      delete it->second;
+    }
+    gamestateQueue[clientID] = gs;
+    return true;
+  }
+  
+  bool GamestateManager::processGamestates(){
+    std::map<int, packet::Gamestate*>::iterator it;
+    // now push only the most recent gamestates we received (ignore obsolete ones)
+    for(it = gamestateQueue.begin(); it!=gamestateQueue.end(); it++){
+      it->second->spreadData();
+      delete it->second;
+    }
+    // now clear the queue
+    gamestateQueue.clear();
+    return true;
+  }
+  
+  
+  bool GamestateManager::getSnapshot(){
+    reference = new packet::Gamestate();
+    reference->collectData(++id_);
+    COUT(4) << "inserting gamestate: " << reference << std::endl;
+    gamestateMap.insert(std::pair<int, packet::Gamestate*>(id_, reference));
+    gamestateUsed[id_]=0;
+    return true;
+  }
+  
+  /**
+   * this function is used to keep the memory usage low
+   * it tries to delete all the unused gamestates
+   * 
+   * 
+   */
+  void GamestateManager::cleanup(){
+    std::map<int,int>::iterator it = gamestateUsed.begin();
+    while(it!=gamestateUsed.end()){
+      if((id_-(*it).first)<KEEP_GAMESTATES)
+        break;
+      if( (*it).second <= 0 ){
+        COUT(5) << "GameStateManager: deleting gamestate with id: " << (*it).first << ", uses: " << (*it).second << std::endl;
+        std::map<int, packet::Gamestate *>::iterator tempit = gamestateMap.find((*it).first);
+        if( tempit != gamestateMap.end() ){
+          packet::Gamestate *temp = tempit->second;
+          if(temp){
+            delete gamestateMap[(*it).first];
+            gamestateMap.erase((*it).first);
+          }
+        }
+        gamestateUsed.erase(it++);
+        continue;
+      }
+      it++;
+    }
+  }
+
+  packet::Gamestate *GamestateManager::popGameState(int clientID) {
+    //why are we searching the same client's gamestate id as we searched in
+    //Server::sendGameState?
+    int gID = ClientInformation::findClient(clientID)->getGamestateID();
+    COUT(4) << "G.St.Man: popgamestate: sending gstate_id: " << id_ << " diffed from: " << gID << std::endl;
+//     COUT(3) << "gamestatemap: " << &gameStateMap << std::endl;
+    //chose wheather the next gamestate is the first or not
+    if(gID != GAMESTATEID_INITIAL){
+      // TODO something with the gamestatemap is wrong
+      packet::Gamestate *client=NULL;
+      std::map<int, packet::Gamestate*>::iterator it = gamestateMap.find(gID);
+      if(it!=gamestateMap.end())
+        client = it->second;
+      packet::Gamestate *gs;
+      if(client)
+        gs = reference->diff(client);
+      else
+        gs = new packet::Gamestate(*reference);
+      gs->compressData();
+      return gs;
+    } else {
+      COUT(4) << "we got a GAMESTATEID_INITIAL for clientID: " << clientID << std::endl;
+//       ackGameState(clientID, reference->id);
+      return new packet::Gamestate(*reference);
+      // return an undiffed gamestate and set appropriate flags
+    }
+  }
+  
+  
+  bool GamestateManager::ack(int gamestateID, int clientID) {
+    ClientInformation *temp = ClientInformation::findClient(clientID);
+    if(temp==0)
+      return false;
+    int curid = temp->getGamestateID();
+    
+    if(gamestateID == GAMESTATEID_INITIAL){
+      temp->setGamestateID(GAMESTATEID_INITIAL);
+      if(curid!=GAMESTATEID_INITIAL){
+        assert(gamestateUsed.find(curid)!=gamestateUsed.end());
+        --(gamestateUsed.find(curid)->second);
+      }
+      return false;
+    }
+    if(curid > gamestateID)
+      // the network packets got messed up 
+      return true;
+    COUT(4) << "acking gamestate " << gamestateID << " for clientid: " << clientID << " curid: " << curid << std::endl;
+    // decrease usage of gamestate and save it
+//     deleteUnusedGameState(curid);
+    //increase gamestateused
+    std::map<int, int>::iterator it = gamestateUsed.find(curid);
+    if(curid!=GAMESTATEID_INITIAL){
+      if(it!=gamestateUsed.end())
+        --(it->second);
+    }
+    it = gamestateUsed.find(gamestateID);
+    if(it!=gamestateUsed.end()){
+      ++(it->second);
+      temp->setGamestateID(gamestateID);
+    }
+    return true;
+  }
+
+  void GamestateManager::removeClient(ClientInformation* client){
+    if(!client)
+      return;
+    if(client->getGamestateID()>=0)
+      gamestateUsed[client->getGamestateID()]--;
+    ClientInformation::removeClient(client->getID());
+  }
+
+}
Index: /code/branches/network/src/network/GamestateManager.h
===================================================================
--- /code/branches/network/src/network/GamestateManager.h	(revision 1705)
+++ /code/branches/network/src/network/GamestateManager.h	(revision 1705)
@@ -0,0 +1,94 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   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++ Interface: GamestateManager
+//
+// Description:
+//
+//
+// Author:  Oliver Scheuss, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef _GamestateManager_H__
+#define _GamestateManager_H__
+
+#include "NetworkPrereqs.h"
+#include "GamestateHandler.h"
+#include <map>
+
+#include "packet/Gamestate.h"
+
+namespace network
+{
+
+#define KEEP_GAMESTATES 10
+
+  /**
+  * 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 GamestateHandler{
+  public:
+    GamestateManager();
+    ~GamestateManager();
+    
+    bool add(packet::Gamestate *gs, int clientID);
+    bool processGamestates();
+    bool update();
+    packet::Gamestate *popGameState(int clientID);
+
+    bool getSnapshot();
+    
+    bool ack(int gamestateID, int clientID);
+    void removeClient(ClientInformation *client);
+    private:
+    void cleanup(); // "garbage handler"
+
+    std::map<int, packet::Gamestate*> gamestateMap; //map gsID to gamestate*
+    std::map<int, int> gamestateUsed; // save the number of clients, that use the specific gamestate
+    std::map<int, packet::Gamestate*> gamestateQueue;
+    packet::Gamestate *reference;
+    int id_;
+  };
+
+}
+
+#endif /* _GameStateManager_H__ */
Index: /code/branches/network/src/network/Host.cc
===================================================================
--- /code/branches/network/src/network/Host.cc	(revision 1704)
+++ /code/branches/network/src/network/Host.cc	(revision 1705)
@@ -54,7 +54,3 @@
 }
 
-bool Host::ackGamestate(int gamestateID, int clientID){
-  return instance_->ackGamestateID(gamestateID, clientID);
-}
-
 }//namespace network
Index: /code/branches/network/src/network/Host.h
===================================================================
--- /code/branches/network/src/network/Host.h	(revision 1704)
+++ /code/branches/network/src/network/Host.h	(revision 1705)
@@ -31,4 +31,5 @@
 #include <string>
 
+#include "NetworkPrereqs.h"
 #include "packet/Chat.h"
 
@@ -44,9 +45,7 @@
     virtual bool sendChat(packet::Chat *chat)=0;
     virtual bool queuePacket(ENetPacket *packet, int clientID)=0;
-    virtual bool ackGamestateID(int gamestateID, int clientID)=0;
     virtual unsigned int shipID()=0;
     virtual int playerID()=0;
     
-    static Host *instance_;
     
     
@@ -54,4 +53,5 @@
     Host();
     ~Host();
+    static Host *instance_;
     
   public:
@@ -62,5 +62,6 @@
     static int getPlayerID();
     static unsigned int getShipID();
-    static bool ackGamestate(int gamestateID, int clientID);
+    
+    // packet process functions
 };
 
Index: /code/branches/network/src/network/NetworkPrereqs.h
===================================================================
--- /code/branches/network/src/network/NetworkPrereqs.h	(revision 1704)
+++ /code/branches/network/src/network/NetworkPrereqs.h	(revision 1705)
@@ -66,26 +66,24 @@
   class ClientInformation;
   class ConnectionManager;
-  class GameStateClient;
-  class GameStateManager;
+  class GamestateClient;
+  class GamestateManager;
+  class GamestateHandler;
   class PacketBuffer;
-  class PacketDecoder;
-  class PacketGenerator;
   class Server;
   class ServerFrameListener;
   class Synchronisable;
-  struct ack;
-  struct chat;
-  struct classid;
-  struct welcome;
-  struct connectRequest;
   struct ClientList;
-  struct GameState;
-  struct GameStateCompressed;
-  struct keyboard;
-  struct mouse;
   struct PacketEnvelope;
   struct QueueItem;
   struct syncData;
   struct synchronisableVariable;
+  namespace packet{
+    class Gamestate;
+    class Packet;
+    class PacketContent;
+    class Acknowledgement;
+    class ClassID;
+    class Welcome;
+  }
 }
 
Index: de/branches/network/src/network/PacketDecoder.cc
===================================================================
--- /code/branches/network/src/network/PacketDecoder.cc	(revision 1704)
+++ 	(revision )
@@ -1,307 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   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
-*
-*/
-
-#include "PacketTypes.h"
-#include "PacketManager.h"
-
-#include <iostream>
-
-#include "core/Debug.h"
-
-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 )
-  {
-    COUT(5) << "PacketDecoder: clientId: " << clientId << std::endl; //control cout, not important, just debugging info
-    int id = (int)*packet->data; //the first 4 bytes are always the enet packet id
-    COUT(5) << "PacketDecoder: packet id: " << id << std::endl;
-    //COUT(5) << "packet size inside packetdecoder: " << packet->dataLength << std::endl;
-
-    if ( packet == NULL ) {
-      COUT(4) << "PacketDecoder: no packets->packetbuffer queue is empty" << std::endl;
-      return false;
-    }
-    switch( id ) {
-    case ACK:
-      acknowledgement( packet, clientId );
-      return true;
-    case COMMAND:
-      return command( packet, clientId );
-    case CHAT:
-      chatMessage( packet, clientId );
-      return true;
-    case GAMESTATE:
-      gstate( packet, clientId );
-      return true;
-    case CLASSID:
-      clid(packet);
-      return true;
-    case WELCOME:
-      return decodeWelcome( packet, clientId );
-    case CONNECT:
-      return decodeConnectRequest( packet, clientId );
-    }
-    return false;
-  }
-
-  bool PacketDecoder::testAndRemoveCRC(ENetPacket *packet){
-    uint32_t submittetcrc;
-    int dataLength = packet->dataLength;
-    // get the submittet crc code
-    memcpy(&submittetcrc, &packet->data[dataLength-sizeof(uint32_t)], sizeof(uint32_t));
-    unsigned char *data = packet->data;
-    uint32_t crc32=calcCRC(data, packet->dataLength-sizeof(uint32_t));
-    // now append the crc to the packet data
-    if(crc32==submittetcrc){
-      dataLength-=sizeof(uint32_t);
-      enet_packet_resize(packet, dataLength);
-      return true;
-    }
-    COUT(3) << "gamestate crc: " << crc32 << std::endl;
-    COUT(3) << "submitted crc: " << submittetcrc << std::endl;
-    return false;
-  }
-
-  // ATTENTION: TODO watch, that arguments we pass over to the processFunction gets deleted in THE PROCESSXXX function
-
-  //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
-
-
-    COUT(4) << "PacketDecoder: got ack id: " << a->a << std::endl;
-    processAck( a, clientId ); //debug info
-    //clean memory
-    enet_packet_destroy( packet );
-  }
-
-  bool PacketDecoder::command( ENetPacket* packet, int clientId ){
-    int length = *(int*)((unsigned char *)packet->data+sizeof(int));
-    if(length<=0)
-      return false;
-    void *data = (void *)new unsigned char[length];
-    memcpy(data, (void *)(packet->data+2*sizeof(int)), length);
-    enet_packet_destroy( packet );
-    return true;
-  }
-
-  void PacketDecoder::chatMessage( ENetPacket* packet, int clientId )
-  {
-    chat* chatting = new chat;
-    if(packet->dataLength==4)
-      return;
-    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, int clientID )
-  {
-//    if(!testAndRemoveCRC(packet)){
-//     COUT(3) << "crc test of gamestate failed - dropping packet" << std::endl;
-//      return;
-//    }
-    GameStateCompressed* currentState = NULL;
-    currentState = new GameStateCompressed;
-    if(currentState == NULL){
-      COUT(3) << "PacketDecoder: could not generate new GameStateCompressed" << std::endl;
-      return;
-    }
-    //copy the GameStateCompressed id into the struct, which is located at second place data+sizeof( int )
-    memcpy( (void*)&(currentState->id), (const void*)(packet->data+1*sizeof( int )), sizeof( int) );
-    COUT(5) << "PacketDecoder: received gs 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*)(packet->data+2*sizeof( int )), sizeof( int) );
-    //size of uncompressed data
-    memcpy( (void*)&(currentState->normsize), (const void*)(packet->data+3*sizeof( int )), sizeof( int ) );
-    memcpy( (void*)&(currentState->base_id), (const void*)(packet->data+4*sizeof( int )), sizeof( int ) );
-    //since the packetgenerator was changed, due to a new parameter, change this function too
-    memcpy( (void*)&(currentState->diffed), (const void*)(packet->data+5*sizeof(int)), sizeof(bool));
-    memcpy( (void*)&(currentState->complete), (const void*)(packet->data+5*sizeof(int)+sizeof(bool)), sizeof(bool));
-    //since data is not allocated, because it's just a pointer, allocate it with size of gamestatedatastream
-    if(currentState->compsize==0)
-    {
-      COUT(2) << "PacketDecoder: compsize is 0" << std::endl;
-    }
-//     currentState->data = (unsigned char*)(malloc( currentState->compsize ));
-    if(currentState->compsize==0)
-      return;
-    currentState->data = new unsigned char[currentState->compsize];
-    if(currentState->data==NULL)
-    {
-      COUT(2) << "PacketDecoder: Gamestatepacket-decoder: memory leak" << std::endl;
-    }
-    //copy the GameStateCompressed data
-    memcpy( (void*)(currentState->data), (const void*)(packet->data+5*sizeof( int ) + 2*sizeof(bool)), currentState->compsize );
-
-    //clean memory
-    enet_packet_destroy( packet );
-    processGamestate(currentState, clientID);
-  }
-
-  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;
-    if(cid->length==0)
-      return;
-//     cid->message = (const char *)malloc(cid->length);
-    cid->message = new char[cid->length];
-    void *data  = (void *)cid->message;
-    memcpy(data, (const void*)(packet->data+3*sizeof(int)), cid->length);
-    COUT(4) << "PacketDecoder: classid: " << cid->clid << ", name: " << cid->message << std::endl;
-    enet_packet_destroy( packet );
-    processClassid(cid);
-  }
-
-
-  bool PacketDecoder::decodeWelcome( ENetPacket* packet, int clientID ){
-    welcome *w = new welcome;
-    w->allowed = ((welcome *)(packet->data))->allowed;
-    w->shipID = ((welcome *)(packet->data))->shipID;
-    w->clientID = ((welcome *)(packet->data))->clientID;
-    w->id = ((welcome *)(packet->data))->id;
-    enet_packet_destroy( packet );
-    return processWelcome(w);
-  }
-
-  bool PacketDecoder::decodeConnectRequest( ENetPacket *packet, int clientID ){
-    connectRequest *con = new connectRequest;
-    con->id = ((connectRequest *)(packet->data))->id;
-    enet_packet_destroy( packet );
-    return processConnectRequest(con, clientID );
-  }
-
-
-  // now the data processing functions:
-
-  void PacketDecoder::processChat( chat *data, int clientId)
-  {
-    printChat(data, clientId);
-    delete[] data->message;
-    delete data;
-  }
-
-  void PacketDecoder::processGamestate( GameStateCompressed *state, int clientID )
-  {
-    COUT(3) << "PacketDecoder-process: processing Gamestate" << std::endl;
-    //printGamestate( state );
-//     delete[] state->data;
-//     delete state;
-  }
-
-  void PacketDecoder::processClassid( classid *cid)
-  {
-    printClassid(cid);
-    delete cid;
-    return;
-  }
-
-  void PacketDecoder::processAck( ack *data, int clientID)
-  {
-    printAck(data);
-    delete data;
-    return;
-  }
-
-  bool PacketDecoder::processWelcome( welcome *w ){
-    delete w;
-    return true;
-  }
-
-  bool PacketDecoder::processConnectRequest( connectRequest *con, int clientID ){
-    COUT(3) << "packetdecoder: processing connectRequest" << std::endl;
-    delete con;
-    return true;
-  }
-
-  //these are some print functions for test stuff
-
-  void PacketDecoder::printAck( ack* data )
-  {
-    COUT(5) << "data id: " << data->id << std::endl;
-    COUT(5) << "data:    " << data->a << std::endl;
-  }
-
-
-  void PacketDecoder::printChat( chat* data, int clientId )
-  {
-    if(clientId!=CLIENTID_CLIENT)
-    {
-      COUT(5) << "client: " << clientId << std::endl;
-    }
-    COUT(5) << "data id: " << data->id << std::endl;
-    COUT(5) << "data:    " << data->message << std::endl;
-  }
-
-  void PacketDecoder::printGamestate( GameStateCompressed* data )
-  {
-    COUT(5) << "id of GameStateCompressed:   " << data->id << std::endl;
-    COUT(5) << "size of GameStateCompressed: " << data->compsize << std::endl;
-  }
-
-  void PacketDecoder::printClassid( classid *cid)
-  {
-    COUT(5) << "id of classid:    " << cid->id << std::endl;
-    COUT(5) << "size of classid:  " << cid->length << std::endl;
-    COUT(5) << "ID of classid:    " << cid->clid << std::endl;
-    COUT(5) << "data of classid:  " << cid->message << std::endl;
-  }
-
-}
Index: de/branches/network/src/network/PacketGenerator.cc
===================================================================
--- /code/branches/network/src/network/PacketGenerator.cc	(revision 1704)
+++ 	(revision )
@@ -1,201 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   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
-*
-*/
-
-#include "PacketManager.h"
-#include "PacketTypes.h"
-
-#include <iostream>
-#include <list>
-#include <string>
-#include <cstring>
-
-
-namespace network
-{
-  void calcCRCBit(uint32_t &crc32, int bit){
-    int hbit;
- 
-    hbit=(crc32 & 0x80000000) ? 1 : 0;
-    if (hbit != bit)
-      crc32=(crc32<<1) ^ NETWORK_CRC32POLY;
-    else
-      crc32=crc32<<1;
-  }
-  
-  uint32_t calcCRC(unsigned char *data, unsigned int dataLength){
-    uint32_t crc32=0;
-    for(unsigned int i=0; i<dataLength; i++){
-      calcCRCBit(crc32, (data[i]&0x1)>>0); // 1st bit
-      calcCRCBit(crc32, (data[i]&0x2)>>1); // 2nd bit
-      calcCRCBit(crc32, (data[i]&0x3)>>2); // 3rd bit
-      calcCRCBit(crc32, (data[i]&0x4)>>3); // 4th bit
-      calcCRCBit(crc32, (data[i]&0x5)>>4); // 5th bit
-      calcCRCBit(crc32, (data[i]&0x6)>>5); // 6th bit
-      calcCRCBit(crc32, (data[i]&0x7)>>6); // 7th bit
-      calcCRCBit(crc32, (data[i]&0x8)>>7); // 8th bit
-    }
-    return crc32;
-  }
-  
-  PacketGenerator::PacketGenerator() { }
-
-  //following functions create a packet in form of bytestream
-
-  ENetPacket* PacketGenerator::acknowledgement( int state, int reliable )
-  {
-    COUT(4) << "PacketGenerator: generating new acknowledgement, id: " << state << std::endl;
-    
-    ENetPacket *packet = enet_packet_create( NULL , sizeof( ack ), reliable );
-    ack* ackreq = (ack *)packet->data;
-    ackreq->id = ACK;
-    ackreq->a = state;
-    //delete ackreq;
-    return packet;
-  }
-  
-  ENetPacket* command( int dataLength, void *data, int reliable = ENET_PACKET_FLAG_RELIABLE )
-  {
-    if(dataLength==0)
-      return NULL;
-    unsigned char *stream = new unsigned char[dataLength + 2*sizeof(int)];
-    if(!stream)
-      return NULL;
-    packet_id a = COMMAND;
-    memcpy(stream, (void*)&a, sizeof(int));
-    memcpy((unsigned char *)stream+sizeof(int), (void*)&dataLength, sizeof(int));
-    memcpy((unsigned char *)stream+2*sizeof(int), data, dataLength);
-    ENetPacket *packet = enet_packet_create(stream, dataLength+2*sizeof(int), reliable);
-    delete[] stream; // TODO: we could also tell enet not to copy the data, but to use the exisiting memory
-    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 );
-    delete[] trans;
-    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 = 5*sizeof( int ) + 2*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
-    if(totalLen==0)
-      return NULL;
-    ENetPacket *packet = enet_packet_create( NULL , totalLen+sizeof(uint32_t), reliable );
-    //unsigned char *data = new unsigned char[totalLen];
-    unsigned char *data = packet->data;
-    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->base_id), sizeof(int));
-    memcpy( (void*)(data+5*sizeof(int)), (const void*)&(states->diffed), sizeof(bool));
-    //place the GameStateCompressed data at the end of the enet datastream
-    memcpy( (void*)(data+5*sizeof( int ) + sizeof(bool)), (const void*)&(states->complete), sizeof(bool) );
-    memcpy( (void*)(data+5*sizeof( int ) + 2*sizeof(bool)), (const void*)states->data, states->compsize );
-    
-    //create an enet packet with the generated bytestream
-    COUT(4) << "PacketGenerator generating totalLen " << totalLen << std::endl;
-    //delete[] data;
-//    if(!addCRC(packet))
-//      COUT(3) << "could not add crc to gamestate packet" << std::endl;
-    return packet;
-  }
-
-  ENetPacket* PacketGenerator::clid( int classid, std::string classname, int reliable )
-  {
-    //unsigned char* data = (unsigned char *)malloc(3*sizeof(int)+classname.length()+1);
-    if(classname.length()==0)
-      return NULL;
-    unsigned char *data = new unsigned char[3*sizeof(int)+classname.length()+1];
-    std::cout << "PacketGenerator: 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 );
-    delete[] data;
-    return packet;
-  }
-  
-  ENetPacket* PacketGenerator::generateWelcome( int clientID,int shipID, bool allowed , int reliable ){
-    welcome *wc = new welcome;
-    wc->id = WELCOME;
-    wc->clientID = clientID;
-    wc->shipID = shipID;
-    wc->allowed = true;
-    ENetPacket *packet = enet_packet_create( wc, sizeof(welcome), reliable);
-    delete wc;
-    return packet;
-  }
-  
-  ENetPacket* PacketGenerator::generateConnectRequest( int reliable ){
-    connectRequest *con = new connectRequest;
-    con->id=CONNECT;
-    ENetPacket *packet = enet_packet_create( con, sizeof(connectRequest), reliable);
-    delete con;
-    return packet;
-  }
-  
-  
-  bool PacketGenerator::addCRC( ENetPacket *packet){
-    unsigned char *data = packet->data;
-    uint32_t crc32=calcCRC(data, packet->dataLength-sizeof(uint32_t));
-    // now append the crc to the packet data
-    int oldlength = packet->dataLength-sizeof(uint32_t);
-    //if(enet_packet_resize(packet, packet->dataLength+sizeof(uint32_t))==0){
-      memcpy(&packet->data[oldlength], &crc32, sizeof(uint32_t));
-      return true;
-    //}else{
-     // COUT(3) << "could not add crc to gamestate" << std::endl;
-     // return false;
-    //}
-  }
-
-}
Index: de/branches/network/src/network/PacketManager.h
===================================================================
--- /code/branches/network/src/network/PacketManager.h	(revision 1704)
+++ 	(revision )
@@ -1,117 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   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:
- *      ...
- *
- */
-
-#ifndef _PacketManager_H__
-#define _PacketManager_H__
-
-#include "NetworkPrereqs.h"
-
-#include <string>
-#include <enet/enet.h>
-
-#include "core/CoreIncludes.h"
-
-#define CLIENTID_CLIENT -1
-#define NETWORK_CRC32POLY 0x04C11DB7 /* CRC-32 Polynom */
-
-//enum netowk generally used to set the type ID of a packet
-namespace network
-{
-  /*
-  * class to generate packets
-  *
-  * @autor: Dumeni Manatschal
-  *
-  */
-  //void calcCRC(uint32_t &crc32, int bit);
-  uint32_t calcCRC(unsigned char *data, unsigned int dataLength);
-  
-  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 = 0 ); // we do not want reliability
-    ENetPacket* command( int dataLength, void *data, int reliable = ENET_PACKET_FLAG_RELIABLE );
-    ENetPacket* chatMessage( const char* message, int reliable = ENET_PACKET_FLAG_RELIABLE );
-    ENetPacket* gstate( GameStateCompressed *states, int reliable = 0 ); // we do not want reliability of gamestates
-    ENetPacket* clid( int classid, std::string classname, int reliable = ENET_PACKET_FLAG_RELIABLE );
-    ENetPacket* generateWelcome( int clientID,int shipID, bool allowed, int reliable = ENET_PACKET_FLAG_RELIABLE );
-    ENetPacket* generateConnectRequest( int reliable = ENET_PACKET_FLAG_RELIABLE );
-  private:
-    bool addCRC( ENetPacket *packet);
-  };
-
-  /*
-  * 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:
-    bool testAndRemoveCRC(ENetPacket *packet);
-
-
-    void acknowledgement( ENetPacket* packet, int clientId = CLIENTID_CLIENT );
-    bool command( ENetPacket* packet, int clientId );
-    void chatMessage( ENetPacket* packet, int clientId = CLIENTID_CLIENT );
-    void gstate( ENetPacket* packet, int clientID = CLIENTID_CLIENT );
-    void clid( ENetPacket *packet);
-    bool decodeWelcome( ENetPacket* packet, int clientID = CLIENTID_CLIENT );
-    bool decodeConnectRequest( ENetPacket *packet, int clientID = CLIENTID_CLIENT );
-
-    //process data
-    //two functions are note yet implemented!
-    virtual void processGamestate(GameStateCompressed *state, int clientID);
-    virtual void processAck( ack *data, int clientID);
-    virtual void processClassid( classid *cid);
-    virtual bool processWelcome( welcome *w );
-    virtual bool processConnectRequest( connectRequest *con, int clientID );
-    //virtual void processAck( ack *data);
-
-    //print functions
-    void printAck( ack* data );
-    void printChat( chat* data, int clientId );
-    void printGamestate( GameStateCompressed *data );
-    void printClassid( classid *cid);
-  };
-}
-
-#endif /* _PacketManager_H__ */
Index: de/branches/network/src/network/PacketTypes.h
===================================================================
--- /code/branches/network/src/network/PacketTypes.h	(revision 1704)
+++ 	(revision )
@@ -1,123 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   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:
- *      ...
- *
- */
-
-//
-// C++ Interface: PacketTypes
-//
-// Description:
-//
-//
-// Author:  <>, (C) 2007
-//
-// Copyright: See COPYING file that comes with this distribution
-//
-//
-
-#ifndef _PacketTypes_H__
-#define _PacketTypes_H__
-
-#include "NetworkPrereqs.h"
-
-namespace network
-{
-  enum packet_id {
-    ACK,
-    COMMAND,
-    CHAT,
-    GAMESTATE ,
-    CLASSID,
-    WELCOME,
-    CONNECT,
-  };
-
-
-  /**
-  * 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;
-    int size;                       //!< total size of data
-    // new ---- change functions
-    int base_id;                    // if gamestate is diffed this is the id of the old gamestate (base)
-    bool diffed;
-    bool complete;                  // this determines, wheter all objects are in this gamestate (server) or only few objects (client)
-    unsigned char *data;            //!< pointer to data
-  };
-
-  /**
-  * 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;
-    int compsize;                   //!< size of compressed data
-    int normsize;                   //!< size of uncompressed data
-    // new ----- change functions
-    int base_id;                  // if gamestate is diffed this is the id of the old gamestate (base)
-    bool diffed;
-    bool complete;                  // this determines, wheter all objects are in this gamestate (server) or only few objects (client)
-    unsigned char *data;            //!< gamestate data
-  };
-
-  struct classid{
-    int id;
-    int length;
-    int clid;
-    const char *message;
-  };
-
-
-  struct ack {
-    int id;
-    int a;
-  };
-
-  //only in this class, not PacketGenerator, used as pattern to put incoming
-  //bytes inside
-  struct chat {
-    int id;
-    const char* message;
-  };
-
-  struct welcome {
-    int id;
-    int clientID;
-    int shipID;
-    bool allowed;
-  };
-  
-  struct connectRequest{
-    int id;
-  };
-}
-
-#endif /* _PacketTypes_H__ */
Index: /code/branches/network/src/network/Server.cc
===================================================================
--- /code/branches/network/src/network/Server.cc	(revision 1704)
+++ /code/branches/network/src/network/Server.cc	(revision 1705)
@@ -45,6 +45,5 @@
 
 #include "ConnectionManager.h"
-#include "PacketTypes.h"
-#include "GameStateManager.h"
+#include "GamestateManager.h"
 #include "ClientInformation.h"
 #include "util/Sleep.h"
@@ -53,4 +52,5 @@
 #include "packet/Chat.h"
 #include "packet/Packet.h"
+#include "packet/Welcome.h"
 
 namespace network
@@ -65,14 +65,12 @@
   Server::Server() {
     timeSinceLastUpdate_=0;
-    packet_gen = PacketGenerator();
     connection = new ConnectionManager();
-    gamestates = new GameStateManager();
+    gamestates_ = new GamestateManager();
   }
   
   Server::Server(int port){
     timeSinceLastUpdate_=0;
-    packet_gen = PacketGenerator();
     connection = new ConnectionManager(port);
-    gamestates = new GameStateManager();
+    gamestates_ = new GamestateManager();
   }
 
@@ -84,7 +82,6 @@
   Server::Server(int port, std::string bindAddress) {
     timeSinceLastUpdate_=0;
-    packet_gen = PacketGenerator();
     connection = new ConnectionManager(port, bindAddress);
-    gamestates = new GameStateManager();
+    gamestates_ = new GamestateManager();
   }
 
@@ -96,7 +93,6 @@
   Server::Server(int port, const char *bindAddress) {
     timeSinceLastUpdate_=0;
-    packet_gen = PacketGenerator();
     connection = new ConnectionManager(port, bindAddress);
-    gamestates = new GameStateManager();
+    gamestates_ = new GamestateManager();
   }
 
@@ -173,5 +169,5 @@
       timeSinceLastUpdate_=(float)((int)(timeSinceLastUpdate_*NETWORK_FREQUENCY))/timeSinceLastUpdate_;
 //      timeSinceLastUpdate_-=1./NETWORK_FREQUENCY;
-      gamestates->processGameStates();
+      gamestates_->processGamestates();
       updateGamestate();
     }
@@ -191,5 +187,4 @@
   void Server::processQueue() {
     ENetEvent *event;
-    int clientID=-1;
     while(!connection->queueEmpty()){
       //std::cout << "Client " << clientID << " sent: " << std::endl;
@@ -209,9 +204,6 @@
         break;
       case ENET_EVENT_TYPE_RECEIVE:
-        if(ClientInformation::findClient(&event->peer->address)){
-          clientID = ClientInformation::findClient(&event->peer->address)->getID();
-          if( !elaborate(event->packet, clientID) ) 
-            COUT(3) << "Server: could not elaborate" << std::endl;
-        }
+        if(!processPacket(event->packet, event->peer))
+          COUT(3) << "processing incoming packet failed" << std::endl;
         break;
       default:
@@ -227,5 +219,5 @@
   */
   void Server::updateGamestate() {
-    gamestates->update();
+    gamestates_->update();
     COUT(5) << "Server: one gamestate update complete, goig to sendGameState" << std::endl;
     //std::cout << "updated gamestate, sending it" << std::endl;
@@ -236,4 +228,9 @@
   }
 
+  bool Server::processPacket( ENetPacket *packet, ENetPeer *peer ){
+    packet::Packet p = packet::Packet(packet, peer);
+    return p.getPacketContent()->process();
+  }
+  
   /**
   * sends the gamestate
@@ -257,5 +254,5 @@
       int cid = temp->getID(); //get client id
       COUT(5) << "Server: got acked (gamestate) ID from clientlist: " << gid << std::endl;
-      GameStateCompressed *gs = gamestates->popGameState(cid);
+      packet::Gamestate *gs = gamestates_->popGameState(cid);
       if(gs==NULL){
         COUT(2) << "Server: could not generate gamestate (NULL from compress)" << std::endl;
@@ -263,8 +260,7 @@
       }
       //std::cout << "adding gamestate" << std::endl;
-      ENetPacket *packet = packet_gen.gstate(gs);
-      if(!packet)
-	continue;
-      if ( !(connection->addPacket(packet, cid)) ){
+      packet::Packet packet(gs);
+      packet.setClientID(cid);
+      if ( !packet.send() ){
         COUT(3) << "Server: packet with client id (cid): " << cid << " not sended: " << temp->getFailures() << std::endl; 
         temp->addFailure();
@@ -277,5 +273,4 @@
       temp=temp->next();
       // now delete gamestate
-      delete[] gs->data;
       delete gs;
     }
@@ -286,32 +281,4 @@
     //COUT(5) << "Server: had no gamestates to send" << std::endl;
     return true;
-  }
-
-  void Server::processAck( ack *data, int clientID) {
-    COUT(4) << "Server: processing ack from client: " << clientID << "; ack-id: " << data->a << std::endl;
-    gamestates->ackGameState(clientID, data->a);
-    delete data;
-  }
-  
-  bool Server::processConnectRequest( connectRequest *con, int clientID ){
-    //(COUT(3) << "processing connectRequest " << std::endl;
-    //connection->addPacket(packet_gen.gstate(gamestates->popGameState(clientID)) , clientID);
-    //createClient(clientID);
-    delete con;
-    return true;
-  }
-  
-  bool Server::ackGamestateID(int gamestateID, int clientID){
-    gamestates->ackGameState(clientID, gamestateID);
-    return true;
-  }
-  
-  void Server::processGamestate( GameStateCompressed *data, int clientID){
-    COUT(4) << "processing partial gamestate from client " << clientID << std::endl;
-    gamestates->addGameState(data, clientID);
-        /*COUT(3) << "Could not push gamestate\t\t\t\t=====" << std::endl;
-    else
-      if(clients->findClient(clientID))
-        clients->findClient(clientID)->resetFailures();*/
   }
   
@@ -359,5 +326,6 @@
     temp->setSynched(true);
     COUT(3) << "sending welcome" << std::endl;
-    connection->sendWelcome(temp->getID(), temp->getShipID(), true);
+    packet::Packet packet(new packet::Welcome(temp->getID(), temp->getShipID()));
+    assert(packet.send());
     return true;
   }
@@ -421,5 +389,5 @@
   void Server::disconnectClient( ClientInformation *client){
     connection->disconnectClient(client);
-    gamestates->removeClient(client);
+    gamestates_->removeClient(client);
   }
   
Index: /code/branches/network/src/network/Server.h
===================================================================
--- /code/branches/network/src/network/Server.h	(revision 1704)
+++ /code/branches/network/src/network/Server.h	(revision 1705)
@@ -47,7 +47,5 @@
 
 #include "Host.h"
-#include "PacketManager.h"
-
-
+#include "GamestateManager.h"
 
 namespace network
@@ -59,5 +57,5 @@
   * It implements all functions necessary for a Server
   */
-  class _NetworkExport Server : public PacketDecoder, public Host{
+  class _NetworkExport Server : public Host{
   public:
     Server();
@@ -85,15 +83,11 @@
     void disconnectClient(int clientID);
     void disconnectClient( ClientInformation *client);
+    bool processPacket( ENetPacket *packet, ENetPeer *peer );
     bool sendGameState();
-    void processAck( ack *data, int clientID);
-    bool processConnectRequest( connectRequest *con, int clientID );
-    void processGamestate( GameStateCompressed *data, int clientID);
     
-    bool ackGamestateID(int gamestateID, int clientID);
     
     //void processChat( chat *data, int clientId);
     ConnectionManager *connection;
-    GameStateManager *gamestates;
-    PacketGenerator packet_gen;
+    GamestateManager *gamestates_;
 
     
Index: /code/branches/network/src/network/packet/Acknowledgement.cc
===================================================================
--- /code/branches/network/src/network/packet/Acknowledgement.cc	(revision 1704)
+++ /code/branches/network/src/network/packet/Acknowledgement.cc	(revision 1705)
@@ -2,4 +2,5 @@
 #include "Packet.h"
 #include "network/Host.h"
+#include "network/GamestateHandler.h"
 
 namespace network {
@@ -21,5 +22,5 @@
 
 Acknowledgement::Acknowledgement( unsigned char *data, int clientID )
-  : PacketContent(data)
+  : PacketContent(data, clientID)
 {
   clientID_=clientID;
@@ -39,5 +40,5 @@
 
 bool Acknowledgement::process(){
-  return Host::ackGamestate(data_[_ACKID], clientID_);
+  return GamestateHandler::ackGamestate(data_[_ACKID], clientID_);
 }
 
Index: /code/branches/network/src/network/packet/Acknowledgement.h
===================================================================
--- /code/branches/network/src/network/packet/Acknowledgement.h	(revision 1704)
+++ /code/branches/network/src/network/packet/Acknowledgement.h	(revision 1705)
@@ -50,5 +50,4 @@
   unsigned int getAckID();
 private:
-  int clientID_;
 };
 
Index: /code/branches/network/src/network/packet/Chat.cc
===================================================================
--- /code/branches/network/src/network/packet/Chat.cc	(revision 1704)
+++ /code/branches/network/src/network/packet/Chat.cc	(revision 1705)
@@ -23,8 +23,7 @@
 
 Chat::Chat( unsigned char *data, int clientID )
-  : PacketContent(data)
+  : PacketContent(data, clientID)
 {
   messageLength_ = *(unsigned int *)&data[ _MESSAGELENGTH ];
-  clientID_ = clientID;
 }
 
Index: /code/branches/network/src/network/packet/ClassID.cc
===================================================================
--- /code/branches/network/src/network/packet/ClassID.cc	(revision 1704)
+++ /code/branches/network/src/network/packet/ClassID.cc	(revision 1705)
@@ -3,5 +3,5 @@
 #include "core/CoreIncludes.h"
 #include <string>
-
+#include <assert.h>
 
 namespace network {
@@ -19,4 +19,5 @@
   flags_ = flags_ | PACKET_FLAGS_CLASSID;
   classNameLength_=className.length()+1;
+  assert(getSize());
   data_=new unsigned char[ getSize() ];
   if(!data_)
@@ -28,6 +29,6 @@
 }
 
-ClassID::ClassID( unsigned char *data )
-  : PacketContent(data)
+ClassID::ClassID( unsigned char *data, int clientID )
+  : PacketContent(data, clientID)
 {
   memcpy( (void *)&classNameLength_, &data[ sizeof(ENUM::Type) + sizeof(int) ], sizeof(classNameLength_) );
Index: /code/branches/network/src/network/packet/ClassID.h
===================================================================
--- /code/branches/network/src/network/packet/ClassID.h	(revision 1704)
+++ /code/branches/network/src/network/packet/ClassID.h	(revision 1705)
@@ -43,5 +43,5 @@
 public:
   ClassID( unsigned int classID, std::string className );
-  ClassID( unsigned char* data );
+  ClassID( unsigned char* data, int clientID );
   ~ClassID();
   
Index: /code/branches/network/src/network/packet/Gamestate.cc
===================================================================
--- /code/branches/network/src/network/packet/Gamestate.cc	(revision 1704)
+++ /code/branches/network/src/network/packet/Gamestate.cc	(revision 1705)
@@ -1,5 +1,5 @@
 #include "Gamestate.h"
 #include "network/ClientInformation.h"
-
+#include "network/GamestateHandler.h"
 
 #include <zlib.h>
@@ -21,6 +21,6 @@
 }
 
-Gamestate::Gamestate(unsigned char *data, bool compressed):
-    PacketContent(data)
+Gamestate::Gamestate(unsigned char *data, bool compressed, int clientID):
+    PacketContent(data, clientID)
 {
   compressed_ = compressed;
@@ -133,4 +133,8 @@
 }
 
+int Gamestate::getID(){
+  return HEADER->id;
+}
+
 unsigned char *Gamestate::getData()
 {
@@ -146,6 +150,4 @@
   {
     return HEADER->normsize+sizeof(GamestateHeader);
-    //assert(bs_);
-    //return bs_->getSize();
   }
 }
@@ -153,6 +155,5 @@
 bool Gamestate::process()
 {
-  //FIXME: TODO: implement this function
-  return true;
+  return GamestateHandler::addGamestate(this, getClientID());
 }
 
@@ -182,5 +183,4 @@
   *GAMESTATE_HEADER(ndata) = *HEADER;
   //delete old data
-//  delete bs_;
   delete[] data_;
   //save new data
@@ -250,5 +250,5 @@
   }
 
-  Gamestate *g = new Gamestate(ndata, false);
+  Gamestate *g = new Gamestate(ndata, false, 0);
   return g;
 }
@@ -282,5 +282,5 @@
   }
   
-  Gamestate *g = new Gamestate(ndata, false);
+  Gamestate *g = new Gamestate(ndata, false, 0);
   return g;
 }
Index: /code/branches/network/src/network/packet/Gamestate.h
===================================================================
--- /code/branches/network/src/network/packet/Gamestate.h	(revision 1704)
+++ /code/branches/network/src/network/packet/Gamestate.h	(revision 1705)
@@ -54,5 +54,5 @@
   public:
     Gamestate();
-    Gamestate(unsigned char *data, bool compressed);
+    Gamestate(unsigned char *data, bool compressed, int clientID);
     
     ~Gamestate();
@@ -60,4 +60,9 @@
     bool collectData(int id, int mode=0x0);
     bool spreadData(int mode=0x0);
+    int getID();
+    Gamestate *diff(Gamestate *base);
+    Gamestate *undiff(Gamestate *base);
+    bool compressData();
+    bool decompressData();
     
     // PacketContent functions
@@ -68,10 +73,5 @@
     
   private:
-    bool compressData();
-    bool decompressData();
-    Gamestate *diff(Gamestate *base);
-    Gamestate *undiff(Gamestate *base);
     unsigned int calcGamestateSize(int mode=0x0);
-    //unsigned char *getGs(){ return bs_->getData(); }
     void removeObject(orxonox::Iterator<Synchronisable> &it);
 
Index: /code/branches/network/src/network/packet/Packet.cc
===================================================================
--- /code/branches/network/src/network/packet/Packet.cc	(revision 1704)
+++ /code/branches/network/src/network/packet/Packet.cc	(revision 1705)
@@ -10,5 +10,5 @@
 #include "ClassID.h"
 #include "network/Host.h"
-//#include "Gamestate.h"
+#include "core/CoreIncludes.h"
 
 namespace network{
@@ -39,4 +39,6 @@
   clientID_ = ClientInformation::findClient(&peer->address)->getID();
   packetContent_ = createPacketContent(packet);
+  delete packet;
+  delete peer;
 }
 
@@ -49,14 +51,23 @@
 }
 
+void Packet::setPacketContent(PacketContent *content){
+  packetContent_ = content;
+  if(enetPacket_){
+    enet_packet_destroy(enetPacket_);
+    enetPacket_=0;
+  }
+}
 
 bool Packet::send(){
-  if(!packetDirection_ == ENUM::Outgoing || !packetDirection_ == ENUM::Bidirectional )
+  if(packetDirection_ != ENUM::Outgoing && packetDirection_ != ENUM::Bidirectional )
     return false;
   if(!enetPacket_){
     if(!packetContent_)
       return false;
+    COUT(3) << "creating packet with data: " << packetContent_->getData() << " size: " << packetContent_->getSize() << " and flags: " << packetContent_->getFlags() << std::endl;
     enetPacket_ = enet_packet_create(packetContent_->getData(), packetContent_->getSize(), packetContent_->getFlags());
   }
   network::Host::addPacket( enetPacket_, clientID_);
+  enetPacket_ = 0; // otherwise we have a double free because enet already handles the deallocation of the packet
   return true;
 }
@@ -73,5 +84,5 @@
       break;
     case ENUM::ClassID:
-      packetContent_ = new ClassID( data );
+      packetContent_ = new ClassID( data, clientID_ );
       break;
     case ENUM::Gamestate:
Index: /code/branches/network/src/network/packet/Packet.h
===================================================================
--- /code/branches/network/src/network/packet/Packet.h	(revision 1704)
+++ /code/branches/network/src/network/packet/Packet.h	(revision 1705)
@@ -47,5 +47,6 @@
     Gamestate,
     ClassID,
-    Chat
+    Chat,
+    Welcome
   };
 }
@@ -65,5 +66,5 @@
     
     void setClientID( int id ){ clientID_ = id; }
-    void setPacketContent(PacketContent *content){ packetContent_=content; }
+    void setPacketContent(PacketContent *content);
     
     bool send();
Index: /code/branches/network/src/network/packet/PacketContent.h
===================================================================
--- /code/branches/network/src/network/packet/PacketContent.h	(revision 1704)
+++ /code/branches/network/src/network/packet/PacketContent.h	(revision 1705)
@@ -47,4 +47,5 @@
     virtual unsigned char *getData()=0;
     virtual unsigned int getSize() const =0;
+    int getClientID(){return clientID_;}
     virtual bool process()=0;
     enet_uint32 getFlags(){ return flags_; }
@@ -53,6 +54,6 @@
         { flags_ = PACKET_FLAG_DEFAULT;
         data_=0; }
-    PacketContent( unsigned char *data )
-        { flags_ = PACKET_FLAG_DEFAULT; data_=data; }
+    PacketContent( unsigned char *data, int clientID )
+        { flags_ = PACKET_FLAG_DEFAULT; data_=data; clientID_=clientID; }
     PacketContent(const PacketContent& p){
       flags_=p.flags_;
@@ -66,4 +67,5 @@
     enet_uint32 flags_;
     unsigned char *data_;
+    int clientID_;
   private:
 };
Index: /code/branches/network/src/network/packet/Welcome.cc
===================================================================
--- /code/branches/network/src/network/packet/Welcome.cc	(revision 1705)
+++ /code/branches/network/src/network/packet/Welcome.cc	(revision 1705)
@@ -0,0 +1,50 @@
+#include "Welcome.h"
+#include "Packet.h"
+
+namespace network {
+namespace packet {
+
+#define PACKET_FLAGS_CLASSID  ENET_PACKET_FLAG_RELIABLE
+#define _PACKETID             0
+#define _CLIENTID             _PACKETID + sizeof(ENUM::Type)
+#define _SHIPID               _CLIENTID + sizeof(unsigned int)
+  
+  Welcome::Welcome( unsigned int clientID, unsigned int shipID )
+ : PacketContent()
+{
+  flags_ = flags_ | PACKET_FLAGS_CLASSID;
+  data_=new unsigned char[ getSize() ];
+  if(!data_)
+    return;
+  *(packet::ENUM::Type *)&data_[ _PACKETID ] = packet::ENUM::Welcome;
+  *(unsigned int *)&data_[ _CLIENTID ] = clientID;
+  *(unsigned int *)&data_[ _SHIPID ] = shipID;
+}
+
+Welcome::Welcome( unsigned char *data, int clientID )
+  : PacketContent(data, clientID)
+{
+}
+
+Welcome::~Welcome()
+{
+}
+
+unsigned char *Welcome::getData(){
+  return data_;
+}
+
+unsigned int Welcome::getSize() const{
+  return sizeof(network::packet::ENUM::Type) + 2*sizeof(unsigned int);
+}
+
+bool Welcome::process(){
+  unsigned int shipID, clientID;
+  clientID = *(unsigned int *)&data_[ _CLIENTID ];
+  shipID = *(unsigned int *)&data_[ _SHIPID ];
+  return true;
+}
+
+
+} //namespace packet
+}//namespace network
Index: /code/branches/network/src/network/packet/Welcome.h
===================================================================
--- /code/branches/network/src/network/packet/Welcome.h	(revision 1705)
+++ /code/branches/network/src/network/packet/Welcome.h	(revision 1705)
@@ -0,0 +1,56 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   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 <scheusso [at] ee.ethz.ch>, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+#ifndef NETWORKWELCOME_H
+#define NETWORKWELCOME_H
+
+#include "PacketContent.h"
+
+namespace network {
+namespace packet {
+
+/**
+	@author 
+*/
+class Welcome : public PacketContent
+{
+public:
+  Welcome( unsigned int clientID, unsigned int shipID );
+  Welcome( unsigned char* data, int clientID );
+  ~Welcome();
+  
+  unsigned char *getData();
+  inline unsigned int getSize() const;
+  bool process();
+  
+private:
+};
+
+} //namespace packet
+} //namespace network
+
+#endif
