Index: code/trunk/src/network/Client.cc
===================================================================
--- code/trunk/src/network/Client.cc	(revision 1359)
+++ code/trunk/src/network/Client.cc	(revision 1360)
@@ -120,7 +120,7 @@
     isConnected=client_connection.createConnection();
     if(isConnected){
-      COUT(4) << "sending connectrequest" << std::endl;
-      client_connection.addPacket(pck_gen.generateConnectRequest());
-      client_connection.sendPackets();
+      COUT(3) << "sending connectrequest" << std::endl;
+      if(!client_connection.addPacket(pck_gen.generateConnectRequest()) || !client_connection.sendPackets())
+        COUT(1) << "could not create connection" << std::endl;
     }else
       COUT(1) << "could not create connection" << std::endl;
@@ -229,4 +229,5 @@
   */
   void Client::tick(float time){
+//     COUT(3) << ".";
     if(client_connection.isConnected() && isSynched_){
       COUT(4) << "popping partial gamestate: " << std::endl;
@@ -260,8 +261,9 @@
       if(!isSynched_)
         isSynched_=true;
-      client_connection.addPacket(pck_gen.acknowledgement(id));
+      if(!client_connection.addPacket(pck_gen.acknowledgement(id)))
+        return;
         // we do this at the end of a tick
-       if(!client_connection.sendPackets())
-         COUT(2) << "Could not send acknowledgment" << std::endl;
+      if(!client_connection.sendPackets())
+        COUT(2) << "Could not send acknowledgment" << std::endl;
     }
   }
Index: code/trunk/src/network/ClientInformation.cc
===================================================================
--- code/trunk/src/network/ClientInformation.cc	(revision 1359)
+++ code/trunk/src/network/ClientInformation.cc	(revision 1360)
@@ -45,9 +45,12 @@
 namespace network
 {
+  boost::recursive_mutex ClientInformation::mutex_;
+  
   ClientInformation::ClientInformation() {
     gamestateID_=GAMESTATEID_INITIAL;
     preve=0;
     nexte=0;
-    this->head=false;
+    partialGamestateID_=GAMESTATEID_INITIAL-1;
+    this->head_=false;
     synched_=false;
   }
@@ -57,5 +60,6 @@
     preve=0;
     nexte=0;
-    this->head=head;
+    partialGamestateID_=GAMESTATEID_INITIAL-1;
+    this->head_=head;
     synched_=false;
   }
@@ -80,4 +84,5 @@
 
   ClientInformation::~ClientInformation() {
+    boost::recursive_mutex::scoped_lock lock(mutex_);
     if(preve!=0)
       preve->setNext(this->nexte);
@@ -87,4 +92,5 @@
 
   ClientInformation *ClientInformation::next() {
+    boost::recursive_mutex::scoped_lock lock(mutex_);
     if(this!=0)
       return this->nexte;
@@ -93,4 +99,5 @@
   }
   ClientInformation *ClientInformation::prev() {
+    boost::recursive_mutex::scoped_lock lock(mutex_);
     if(this!=0)
       return this->preve;
@@ -100,5 +107,6 @@
 
   bool ClientInformation::setPrev(ClientInformation *prev) {
-    if(!head)
+    boost::recursive_mutex::scoped_lock lock(mutex_);
+    if(!head_)
       this->preve = prev;
     else
@@ -108,4 +116,5 @@
 
   bool ClientInformation::setNext(ClientInformation *next) {
+    boost::recursive_mutex::scoped_lock lock(mutex_);
     this->nexte = next;
     return true;
@@ -113,4 +122,5 @@
 
   ClientInformation *ClientInformation::insertAfter(ClientInformation *ins) {
+    boost::recursive_mutex::scoped_lock lock(mutex_);
     this->nexte->setPrev(ins);
     ins->setNext(this->nexte);
@@ -121,4 +131,7 @@
 
   ClientInformation *ClientInformation::insertBefore(ClientInformation *ins){
+    boost::recursive_mutex::scoped_lock lock(mutex_);
+    if(!this)
+      return NULL;
     this->prev()->setNext(ins);
     ins->setPrev(this->preve);
@@ -129,28 +142,91 @@
 
   void ClientInformation::setID(int clientID){
+    boost::recursive_mutex::scoped_lock lock(mutex_);
     clientID_ = clientID;
   }
 
-  void ClientInformation::setPeer(ENetPeer *peer){
+  bool ClientInformation::setPeer(ENetPeer *peer){
+    boost::recursive_mutex::scoped_lock lock(mutex_);
+    if(!this)
+      return false;
     peer_ = peer;
-  }
-
-  void ClientInformation::setGamestateID(int id){
+    return true;
+  }
+
+  bool ClientInformation::setGamestateID(int id){
+    boost::recursive_mutex::scoped_lock lock(mutex_);
+    if(!this)
+      return false;
     gamestateID_=id;
+    return true;
+  }
+  
+  bool ClientInformation::setPartialGamestateID(int id){
+    boost::recursive_mutex::scoped_lock lock(mutex_);
+    if(!this)
+      return false;
+    partialGamestateID_=id;
+    return true;
   }
 
   int ClientInformation::getID() {
-    return clientID_;
+    boost::recursive_mutex::scoped_lock lock(mutex_);
+    if(!this)
+      return CLIENTID_UNKNOWN;
+    else
+      return clientID_;
   }
 
   ENetPeer *ClientInformation::getPeer() {
-    return peer_;
+    boost::recursive_mutex::scoped_lock lock(mutex_);
+    if(this)
+      return peer_;
+    else
+      return NULL;
+  }
+  
+  bool ClientInformation::getHead(){
+    boost::recursive_mutex::scoped_lock lock(mutex_);
+    return head_;
+  }
+  
+  void ClientInformation::setHead(bool h){
+    boost::recursive_mutex::scoped_lock lock(mutex_);
+    head_=h;
+  }
+  
+  int ClientInformation::getFailures(){
+    boost::recursive_mutex::scoped_lock lock(mutex_);
+    return failures_;
+  }
+  void ClientInformation::addFailure(){
+    boost::recursive_mutex::scoped_lock lock(mutex_);
+    failures_++;
+  }
+  void ClientInformation::resetFailures(){
+    boost::recursive_mutex::scoped_lock lock(mutex_);
+    failures_=0;
   }
 
   int ClientInformation::getGamestateID() {
-    return gamestateID_;
+    boost::recursive_mutex::scoped_lock lock(mutex_);
+    if(this)
+      return gamestateID_;
+    else
+      return -1;
+  }
+  
+  int ClientInformation::getPartialGamestateID() {
+    boost::recursive_mutex::scoped_lock lock(mutex_);
+    if(this)
+      return partialGamestateID_;
+    else
+      return -1;
   }
 
   ClientInformation *ClientInformation::insertBack(ClientInformation *ins) {
+    boost::recursive_mutex::scoped_lock lock(mutex_);
+    if(!this)
+      return NULL;
     ClientInformation *temp = this;
     while(temp->next()!=0){
@@ -163,4 +239,7 @@
 
   bool ClientInformation::removeClient(int clientID) {
+    boost::recursive_mutex::scoped_lock lock(mutex_);
+    if(!this || clientID==CLIENTID_UNKNOWN)
+      return false;
     ClientInformation *temp = this;
     while(temp!=0 && temp->getID()!=clientID)
@@ -173,7 +252,10 @@
 
   bool ClientInformation::removeClient(ENetPeer *peer) {
+    boost::recursive_mutex::scoped_lock lock(mutex_);
+    if(!this || !peer)
+      return false;
     ClientInformation *temp = this;
     while(temp!=0){
-      if(!temp->head)
+      if(!temp->head_)
         if(temp->getPeer()->address.host==peer->address.host && temp->getPeer()->address.port==peer->address.port)
           break;
@@ -193,9 +275,9 @@
   */
   ClientInformation *ClientInformation::findClient(int clientID, bool look_backwards) {
-    ClientInformation *temp = this;
-    if (temp->head)
+    boost::recursive_mutex::scoped_lock lock(mutex_);
+    ClientInformation *temp = this;
+    if (temp->head_)
       temp=temp->next();
-    //bugfix: temp to temp->next(), get last elem if not found, not segflt
-    while(temp->next()!=0 && temp->getID()!=clientID){
+    while(temp!=0 && temp->getID()!=clientID){
       temp = temp->next();
     }
@@ -211,8 +293,8 @@
   */
   ClientInformation *ClientInformation::findClient(ENetAddress *address, bool look_backwards) {
-    ClientInformation *temp = this;
-    //bugfix: temp to temp->next(), get last elem if not found, not segflt
-    while(temp->next()!=0){
-      if(temp->head){
+    boost::recursive_mutex::scoped_lock lock(mutex_);
+    ClientInformation *temp = this;
+    while(temp!=0){
+      if(temp->head_){
         temp = temp->next();
         continue;
@@ -226,10 +308,18 @@
   }
 
-  void ClientInformation::setSynched(bool s) {
+  bool ClientInformation::setSynched(bool s) {
+    boost::recursive_mutex::scoped_lock lock(mutex_);
+    if(!this)
+      return false;
     synched_=s;
+    return true;
   }
 
   bool ClientInformation::getSynched() {
-    return synched_;
+    boost::recursive_mutex::scoped_lock lock(mutex_);
+    if(this)
+      return synched_;
+    else
+      return false;
   }
 
Index: code/trunk/src/network/ClientInformation.h
===================================================================
--- code/trunk/src/network/ClientInformation.h	(revision 1359)
+++ code/trunk/src/network/ClientInformation.h	(revision 1360)
@@ -44,6 +44,8 @@
 
 #include <enet/enet.h>
+#include <boost/thread/recursive_mutex.hpp>
 
 #define GAMESTATEID_INITIAL -1
+#define CLIENTID_UNKNOWN -2
 
 namespace network
@@ -62,14 +64,11 @@
     ClientInformation *next();
     ClientInformation *prev();
-    bool setNext(ClientInformation *next);
-    bool setPrev(ClientInformation *prev);
-    ClientInformation *insertAfter(ClientInformation *ins);
-    ClientInformation *insertBefore(ClientInformation *ins);
     ClientInformation *insertBack(ClientInformation *ins);
     
     // set functions
     void setID(int clientID);
-    void setPeer(ENetPeer *peer);
-    void setGamestateID(int id);
+    bool setPeer(ENetPeer *peer);
+    bool setGamestateID(int id);
+    bool setPartialGamestateID(int id);
     inline void setShipID(int id){ShipID_=id;}
     
@@ -78,6 +77,12 @@
     int getID();
     int getGamestateID();
+    int getPartialGamestateID();
     ENetPeer *getPeer();
+    bool getHead();
+    void setHead(bool h);
     
+    int getFailures();
+    void addFailure();
+    void resetFailures();
     
     bool removeClient(int clientID);
@@ -88,11 +93,14 @@
     ClientInformation *findClient(ENetAddress *address, bool look_backwards=false);
 
-    void setSynched(bool s);
+    bool setSynched(bool s);
     bool getSynched();
 
-    bool head;
-    unsigned short failures_;
 
-  private:
+    private:
+      bool setNext(ClientInformation *next);
+      bool setPrev(ClientInformation *prev);
+    ClientInformation *insertAfter(ClientInformation *ins);
+    ClientInformation *insertBefore(ClientInformation *ins);
+    
     ClientInformation *preve;
     ClientInformation *nexte;
@@ -101,6 +109,11 @@
     int clientID_;
     int gamestateID_;
+    int partialGamestateID_;
     int ShipID_;   // this is the unique objectID
     bool synched_;
+    bool head_;
+    unsigned short failures_;
+    static boost::recursive_mutex mutex_;
+    
   };
 
Index: code/trunk/src/network/ConnectionManager.cc
===================================================================
--- code/trunk/src/network/ConnectionManager.cc	(revision 1359)
+++ code/trunk/src/network/ConnectionManager.cc	(revision 1360)
@@ -101,4 +101,6 @@
     ENetPacket *packet=getPacket(address);
     ClientInformation *temp =head_->findClient(&address);
+    if(!temp)
+      return NULL;
     clientID=temp->getID();
     return packet;
@@ -124,5 +126,8 @@
 
   bool ConnectionManager::addPacket(ENetPacket *packet, ENetPeer *peer) {
-    if(enet_peer_send(peer, (enet_uint8)head_->findClient(&(peer->address))->getID() , packet)!=0)
+    ClientInformation *temp = head_->findClient(&(peer->address));
+    if(!temp)
+      return false;
+    if(enet_peer_send(peer, (enet_uint8)temp->getID() , packet)!=0)
       return false;
     return true;
@@ -130,5 +135,8 @@
 
   bool ConnectionManager::addPacket(ENetPacket *packet, int clientID) {
-    if(enet_peer_send(head_->findClient(clientID)->getPeer(), (enet_uint8)clientID, packet)!=0)
+    ClientInformation *temp = head_->findClient(clientID);
+    if(!temp)
+      return false;
+    if(enet_peer_send(temp->getPeer(), (enet_uint8)clientID, packet)!=0)
       return false;
     return true;
@@ -185,6 +193,4 @@
           addClient(event);
           //this is a workaround to ensure thread safety
-          /*if(!addFakeConnectRequest(&event))
-            COUT(3) << "Problem pushing fakeconnectRequest to queue" << std::endl;*/
           COUT(5) << "Con.Man: connection event has occured" << std::endl;
           break;
@@ -195,4 +201,6 @@
           if(head_->findClient(&event->peer->address))
             processData(event);
+          else
+            COUT(3) << "received a packet from a client we don't know" << std::endl;
           break;
         case ENET_EVENT_TYPE_DISCONNECT:
@@ -200,4 +208,5 @@
           break;
         case ENET_EVENT_TYPE_NONE:
+          receiverThread_->yield();
           break;
       }
@@ -233,5 +242,6 @@
       case ENET_EVENT_TYPE_DISCONNECT:
         COUT(4) << "disconnecting all clients" << std::endl;
-        delete head_->findClient(&(event.peer->address));
+        if(head_->findClient(&(event.peer->address)))
+          delete head_->findClient(&(event.peer->address));
         //maybe needs bugfix: might also be a reason for the server to crash
         temp = temp->next();
@@ -259,5 +269,9 @@
   bool ConnectionManager::addClient(ENetEvent *event) {
     ClientInformation *temp = head_->insertBack(new ClientInformation);
-    if(temp->prev()->head) { //not good if you use anything else than insertBack
+    if(!temp){
+      COUT(2) << "Conn.Man. could not add client" << std::endl;
+      return false;
+    }
+    if(temp->prev()->getHead()) { //not good if you use anything else than insertBack
       temp->prev()->setID(0); //bugfix: not necessary but usefull
       temp->setID(1);
@@ -266,5 +280,5 @@
       temp->setID(temp->prev()->getID()+1);
     temp->setPeer(event->peer);
-    COUT(4) << "Con.Man: added client id: " << temp->getID() << std::endl;
+    COUT(3) << "Con.Man: added client id: " << temp->getID() << std::endl;
     return true;
   }
@@ -283,5 +297,5 @@
 
   void ConnectionManager::syncClassid(int clientID) {
-    unsigned int network_id=0;
+    unsigned int network_id=0, failures=0;
     std::string classname;
     orxonox::Identifier *id;
@@ -293,8 +307,11 @@
       classname = id->getName();
       network_id = id->getNetworkID();
+      if(network_id==0)
+        COUT(3) << "we got a null class id: " << id->getName() << std::endl;
       COUT(4) << "Con.Man:syncClassid:\tnetwork_id: " << network_id << ", classname: " << classname << std::endl;
 
-      addPacket(packet_gen.clid( (int)network_id, classname ), clientID);
-
+      while(!addPacket(packet_gen.clid( (int)network_id, classname ), clientID) && failures < 10){
+        failures++;
+      }
       ++it;
     }
@@ -305,12 +322,18 @@
   bool ConnectionManager::createClient(int clientID){
     ClientInformation *temp = head_->findClient(clientID);
+    if(!temp){
+      COUT(2) << "Conn.Man. could not create client with id: " << clientID << std::endl;
+      return false;
+    }
     COUT(4) << "Con.Man: creating client id: " << temp->getID() << std::endl;
     syncClassid(temp->getID());
     COUT(4) << "creating spaceship for clientid: " << temp->getID() << std::endl;
     // TODO: this is only a hack, untill we have a possibility to define default player-join actions
-    createShip(temp);
-    COUT(4) << "created spaceship" << std::endl;
+    if(!createShip(temp))
+      COUT(2) << "Con.Man. could not create ship for clientid: " << clientID << std::endl;
+    else
+      COUT(3) << "created spaceship" << std::endl;
     temp->setSynched(true);
-    COUT(4) << "sending welcome" << std::endl;
+    COUT(3) << "sending welcome" << std::endl;
     sendWelcome(temp->getID(), temp->getShipID(), true);
     return true;
@@ -319,6 +342,9 @@
   bool ConnectionManager::removeClient(int clientID){
     orxonox::Iterator<orxonox::SpaceShip> it = orxonox::ObjectList<orxonox::SpaceShip>::start();
+    ClientInformation *client = head_->findClient(clientID);
+    if(!client)
+      return false;
     while(it){
-      if(it->objectID!=head_->findClient(clientID)->getShipID()){
+      if(it->objectID!=client->getShipID()){
         ++it;
         continue;
@@ -333,4 +359,6 @@
   
   bool ConnectionManager::createShip(ClientInformation *client){
+    if(!client)
+      return false;
     orxonox::Identifier* id = ID("SpaceShip");
     if(!id){
@@ -351,4 +379,5 @@
     no->setRotDamp(1.0);
     no->setCamera("cam_"+client->getID());
+    no->classID = id->getNetworkID();
     no->create();
     
@@ -369,7 +398,9 @@
   
   bool ConnectionManager::sendWelcome(int clientID, int shipID, bool allowed){
-    addPacket(packet_gen.generateWelcome(clientID, shipID, allowed),clientID);
-    sendPackets();
-    return true;
+    if(addPacket(packet_gen.generateWelcome(clientID, shipID, allowed),clientID)){
+      sendPackets();
+      return true;
+    }else
+      return false;
   }
   
Index: code/trunk/src/network/GameStateClient.cc
===================================================================
--- code/trunk/src/network/GameStateClient.cc	(revision 1359)
+++ code/trunk/src/network/GameStateClient.cc	(revision 1360)
@@ -47,4 +47,5 @@
     COUT(5) << "this: " << this << std::endl;
     last_diff_=0;
+    last_gamestate_=GAMESTATEID_INITIAL-1;
   }
 
@@ -56,4 +57,9 @@
     printGameStateMap();
     GameState *gs, *reference;
+    /*if(compstate->id<last_gamestate_){
+      // network packets got messed up
+      COUT(3) << "received an obsolete gamestate" << std::endl;
+      return false;
+    }*/
     if(compstate->diffed && compstate->base_id!=GAMESTATEID_INITIAL){
       std::map<int, GameState*>::iterator it = gameStateMap.find(compstate->base_id);
@@ -77,4 +83,5 @@
         COUT(4) << "adding decoded gs with id: " << gs->id << " diffed from: " << gs->base_id << std::endl;
         last_diff_=gs->base_id;
+        //last_gamestate_=gs->id;
         return true;
       }else{
@@ -145,13 +152,19 @@
           if(!id){
             COUT(4) << "We could not identify a new object; classid: " << sync.classID << std::endl;
-            continue;
+            return false;
           }
           Synchronisable *no = dynamic_cast<Synchronisable *>(id->fabricate());
           COUT(4) << "loadsnapshot: classid: " << sync.classID << " objectID: " << sync.objectID << " length: " << sync.length << std::endl;
+          if(!no){
+            COUT(2) << "coudl not frabricate classid: " << sync.classID << " objectID: " << sync.objectID << " identifier: " << id << std::endl;
+            break;
+          }
           no->objectID=sync.objectID;
           no->classID=sync.classID;
           // update data and create object/entity...
-          if( !no->updateData(sync) )
+          if( !no->updateData(sync) ){
             COUT(1) << "We couldn't update the object: " << sync.objectID << std::endl;
+            return false;
+          }
           if( !no->create() )
             COUT(1) << "We couldn't manifest (create() ) the object: " << sync.objectID << std::endl;
@@ -349,4 +362,6 @@
     COUT(4) << "using diffed gamestate" << std::endl;
     GameState *t = decode(diff);
+    if(!t)
+      return NULL;
     GameState *r = undiff(old, t);
     delete[] t->data;
Index: code/trunk/src/network/GameStateClient.h
===================================================================
--- code/trunk/src/network/GameStateClient.h	(revision 1359)
+++ code/trunk/src/network/GameStateClient.h	(revision 1360)
@@ -71,4 +71,5 @@
 
     int           last_diff_;
+    int           last_gamestate_;
     std::map<int, GameState *> gameStateMap;
     
Index: code/trunk/src/network/GameStateManager.cc
===================================================================
--- code/trunk/src/network/GameStateManager.cc	(revision 1359)
+++ code/trunk/src/network/GameStateManager.cc	(revision 1360)
@@ -117,5 +117,4 @@
         client = it->second;
       GameState *server = reference;
-      //head_->findClient(clientID)->setGamestateID(id);
       COUT(3) << "client: " << client << " server: " << server << " gamestatemap: " << &gameStateMap << std::endl;
       if(client)
@@ -127,5 +126,4 @@
       GameState *server = reference;
 //       ackGameState(clientID, reference->id);
-      //head_->findClient(clientID)->setGamestateID(id);
       return encode(server);
       // return an undiffed gamestate and set appropriate flags
@@ -223,4 +221,12 @@
     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){
@@ -270,5 +276,5 @@
       ++it;
     }
-    
+    //client->setPartialGamestateID(state->id);
     return true;
   }
@@ -427,10 +433,16 @@
   void GameStateManager::ackGameState(int clientID, int gamestateID) {
     ClientInformation *temp = head_->findClient(clientID);
+    if(temp==0)
+      return;
     int curid = temp->getGamestateID();
+    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
-    --(gameStateUsed.find(curid)->second);
+    if(curid!=GAMESTATEID_INITIAL)
+      --(gameStateUsed.find(curid)->second);
     ++(gameStateUsed.find(gamestateID)->second);
     temp->setGamestateID(gamestateID);
@@ -458,5 +470,8 @@
   
   void GameStateManager::removeClient(ClientInformation* client){
-    gameStateUsed[client->getGamestateID()]--;
+    if(!client)
+      return;
+    if(client->getGamestateID()>=0)
+      gameStateUsed[client->getGamestateID()]--;
     head_->removeClient(client->getID());
   }
Index: code/trunk/src/network/NetworkPrereqs.h
===================================================================
--- code/trunk/src/network/NetworkPrereqs.h	(revision 1359)
+++ code/trunk/src/network/NetworkPrereqs.h	(revision 1360)
@@ -56,4 +56,19 @@
 #endif
 
+//-----------------------------------------------------------------------
+// fixed width integers
+//-----------------------------------------------------------------------
+#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
+typedef __int8            int8_t;
+typedef __int16           int16_t;
+typedef __int32           int32_t;
+typedef __int64           int64_t;
+typedef unsigned __int8   uint8_t;
+typedef unsigned __int16  uint16_t;
+typedef unsigned __int32  uint32_t;
+typedef unsigned __int64  uint64_t;
+#else
+# include "inttypes.h"
+#endif
 
 //-----------------------------------------------------------------------
Index: code/trunk/src/network/PacketBuffer.cc
===================================================================
--- code/trunk/src/network/PacketBuffer.cc	(revision 1359)
+++ code/trunk/src/network/PacketBuffer.cc	(revision 1360)
@@ -41,5 +41,5 @@
 namespace network
 {
-  boost::mutex networkPacketBufferMutex;
+   boost::recursive_mutex PacketBuffer::mutex_;
 
   PacketBuffer::PacketBuffer() {
@@ -52,5 +52,5 @@
 
   bool PacketBuffer::push(ENetEvent *ev) {
-    boost::mutex::scoped_lock lock(networkPacketBufferMutex);
+    boost::recursive_mutex::scoped_lock lock(mutex_);
     //std::cout << "event size inside packetbuffer " << ev->packet->dataLength << std::endl;
     //   if(closed)
@@ -61,6 +61,7 @@
       last=first;
       last->next=NULL;
-      // change this!!!!!!! 
+      // change this!!!!!!!  ---- we are not doing stl so we won't change this
       last->packet = ev->packet;
+      last->address = ev->peer->address;
       //last->address = ev->peer->address;
     } else {
@@ -72,9 +73,9 @@
       // save the packet to the new element
       last->packet = ev->packet;
+      last->address = ev->peer->address;
       //last->address = ev->peer->address;
     }
-    // pseudo bugfix: added a return false statement for error handling
-    if ( last->packet == ev->packet ) return true;
-    return false;
+    lock.unlock();
+    return true;
   }
 
@@ -82,23 +83,10 @@
   //moving first pointer to next element
   ENetPacket *PacketBuffer::pop() {
-    boost::mutex::scoped_lock lock(networkPacketBufferMutex);
-    //std::cout << "packetbuffer pop" << std::endl;
-    if(first!=NULL /*&& !closed*/){
-      QueueItem *temp = first;
-      // get packet
-      ENetPacket *pck=first->packet;
-      // remove first element
-      first = first->next;
-      delete temp;
-      //std::cout << "pop size of packet " << pck->dataLength << std::endl;
-      return pck;
-    } else{
-      //std::cout << "nothing to return" << std::endl;
-      return NULL;
-    }
+    ENetAddress address;
+    return pop(address);
   }
 
   ENetPacket *PacketBuffer::pop(ENetAddress &address) {
-    boost::mutex::scoped_lock lock(networkPacketBufferMutex);
+    boost::recursive_mutex::scoped_lock lock(mutex_);
     //std::cout << "packetbuffer pop(address)" << std::endl;
     if(first!=NULL /*&& !closed*/){
@@ -110,7 +98,9 @@
       first = first->next;
       delete temp;
+      lock.unlock();
       //std::cout << "pop(address) size of packet " << pck->dataLength << std::endl;
       return pck;
     } else{
+      lock.unlock();
       return NULL;
     }
Index: code/trunk/src/network/PacketBuffer.h
===================================================================
--- code/trunk/src/network/PacketBuffer.h	(revision 1359)
+++ code/trunk/src/network/PacketBuffer.h	(revision 1360)
@@ -45,4 +45,5 @@
 
 #include <enet/enet.h>
+#include <boost/thread/recursive_mutex.hpp>
 
 namespace network
@@ -76,5 +77,5 @@
     QueueItem *last;
     bool closed;
-
+    static boost::recursive_mutex mutex_;
   };
 
Index: code/trunk/src/network/PacketDecoder.cc
===================================================================
--- code/trunk/src/network/PacketDecoder.cc	(revision 1359)
+++ code/trunk/src/network/PacketDecoder.cc	(revision 1360)
@@ -91,4 +91,22 @@
   }
   
+  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
 
@@ -111,4 +129,5 @@
     void *data = (void *)new unsigned char[length];
     memcpy(data, (void *)(packet->data+2*sizeof(int)), length);
+    enet_packet_destroy( packet );
     return true;
   }
@@ -156,4 +175,8 @@
   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;
Index: code/trunk/src/network/PacketGenerator.cc
===================================================================
--- code/trunk/src/network/PacketGenerator.cc	(revision 1359)
+++ code/trunk/src/network/PacketGenerator.cc	(revision 1360)
@@ -46,4 +46,29 @@
 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() { }
 
@@ -64,5 +89,5 @@
   ENetPacket* command( int dataLength, void *data, int reliable = ENET_PACKET_FLAG_RELIABLE )
   {
-    void *stream = new char[dataLength + 2*sizeof(int)];
+    unsigned char *stream = new unsigned char[dataLength + 2*sizeof(int)];
     if(!stream)
       return NULL;
@@ -135,8 +160,11 @@
     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;
     ENetPacket *packet = enet_packet_create( data , totalLen, reliable );
     delete[] data;
+    if(!addCRC(packet))
+      COUT(3) << "could not add crc to gamestate packet" << std::endl;
     return packet;
   }
@@ -174,4 +202,19 @@
     return packet;
   }
+  
+  
+  bool PacketGenerator::addCRC( ENetPacket *packet){
+    unsigned char *data = packet->data;
+    uint32_t crc32=calcCRC(data, packet->dataLength);
+    // now append the crc to the packet data
+    int oldlength = packet->dataLength;
+    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: code/trunk/src/network/PacketManager.h
===================================================================
--- code/trunk/src/network/PacketManager.h	(revision 1359)
+++ code/trunk/src/network/PacketManager.h	(revision 1360)
@@ -38,4 +38,5 @@
 
 #define CLIENTID_CLIENT -1
+#define NETWORK_CRC32POLY 0x04C11DB7 /* CRC-32 Polynom */
 
 //enum netowk generally used to set the type ID of a packet
@@ -48,4 +49,7 @@
   *
   */
+  //void calcCRC(uint32_t &crc32, int bit);
+  uint32_t calcCRC(unsigned char *data, unsigned int dataLength);
+  
   class PacketGenerator
   {
@@ -53,14 +57,15 @@
     PacketGenerator();
     //call one of this functions out of an instance of PacketGenerator to create a packet
-    ENetPacket* acknowledgement( int state, int reliable = ENET_PACKET_FLAG_RELIABLE );
+    ENetPacket* acknowledgement( int state, int reliable = 0 ); // we do not want reliability
     ENetPacket* command( int dataLength, void *data, int reliable = ENET_PACKET_FLAG_RELIABLE );
     ENetPacket* mousem( double x, double y, int reliable = ENET_PACKET_FLAG_RELIABLE );
     ENetPacket* keystrike( char press, int reliable = ENET_PACKET_FLAG_RELIABLE );
     ENetPacket* chatMessage( const char* message, int reliable = ENET_PACKET_FLAG_RELIABLE );
-    ENetPacket* gstate( GameStateCompressed *states, int reliable = ENET_PACKET_FLAG_RELIABLE );
+    ENetPacket* 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);
   };
 
@@ -84,5 +89,5 @@
 
   private:
-
+    bool testAndRemoveCRC(ENetPacket *packet);
 
 
Index: code/trunk/src/network/Server.cc
===================================================================
--- code/trunk/src/network/Server.cc	(revision 1359)
+++ code/trunk/src/network/Server.cc	(revision 1360)
@@ -117,7 +117,9 @@
     ENetPacket *packet = packet_gen.chatMessage(msg.c_str());
     //std::cout <<"adding packets" << std::endl;
-    connection->addPacketAll(packet);
+    if(connection->addPacketAll(packet))
     //std::cout <<"added packets" << std::endl;
-    return connection->sendPackets();
+      return connection->sendPackets();
+    else
+      return false;
   }
 
@@ -147,5 +149,4 @@
     processQueue();
     updateGamestate();
-
 //     usleep(500000); // TODO remove
     return;
@@ -162,7 +163,9 @@
       //clientID here is a reference to grab clientID from ClientInformation
       packet = connection->getPacket(clientID);
+      if(!packet)
+        continue;
       //if statement to catch case that packetbuffer is empty
       if( !elaborate(packet, clientID) ) 
-        COUT(4) << "Server: PacketBuffer empty" << std::endl;
+        COUT(3) << "Server: could not elaborate" << std::endl;
     }
   }
@@ -189,5 +192,5 @@
     bool added=false;
     while(temp != NULL){
-      if(temp->head){
+      if(temp->getHead()){
         temp=temp->next();
         //think this works without continue
@@ -211,7 +214,7 @@
       //std::cout << "adding gamestate" << std::endl;
       if ( !(connection->addPacket(packet_gen.gstate(gs), cid)) ){
-        COUT(3) << "Server: packet with client id (cid): " << cid << " not sended: " << temp->failures_ << std::endl; 
-        temp->failures_++;
-        if(temp->failures_ > 20 )
+        COUT(3) << "Server: packet with client id (cid): " << cid << " not sended: " << temp->getFailures() << std::endl; 
+        temp->addFailure();
+        if(temp->getFailures() > 20 )
           disconnectClient(temp);
       //std::cout << "added gamestate" << std::endl;
@@ -238,5 +241,5 @@
   
   bool Server::processConnectRequest( connectRequest *con, int clientID ){
-    COUT(4) << "processing connectRequest " << std::endl;
+    COUT(3) << "processing connectRequest " << std::endl;
     //connection->addPacket(packet_gen.gstate(gamestates->popGameState(clientID)) , clientID);
     connection->createClient(clientID);
@@ -250,10 +253,12 @@
         COUT(3) << "Could not push gamestate\t\t\t\t=====" << std::endl;
     else
-        clients->findClient(clientID)->failures_=0;
+      if(clients->findClient(clientID))
+        clients->findClient(clientID)->resetFailures();
   }
 
   void Server::disconnectClient(int clientID){
     ClientInformation *client = clients->findClient(clientID);
-    disconnectClient(client);
+    if(client)
+      disconnectClient(client);
   }
   void Server::disconnectClient( ClientInformation *client){
Index: code/trunk/src/network/Synchronisable.cc
===================================================================
--- code/trunk/src/network/Synchronisable.cc	(revision 1359)
+++ code/trunk/src/network/Synchronisable.cc	(revision 1360)
@@ -153,5 +153,7 @@
   syncData Synchronisable::getData(unsigned char *mem){
     //std::cout << "inside getData" << std::endl;
-    classID=this->getIdentifier()->getNetworkID();
+    if(classID==0)
+      COUT(3) << "classid 0 " << this->getIdentifier()->getName() << std::endl;
+    this->classID=this->getIdentifier()->getNetworkID();
     std::list<synchronisableVariable *>::iterator i;
     syncData retVal;
Index: code/trunk/src/network/diffTest.cc
===================================================================
--- code/trunk/src/network/diffTest.cc	(revision 1359)
+++ code/trunk/src/network/diffTest.cc	(revision 1360)
@@ -466,4 +466,6 @@
 bool addClientTest( ENetEvent* event, ClientInformation*& head ) {
   ClientInformation *temp = head->insertBack(new ClientInformation);
+  if(!temp)
+    return false;
   if(temp->prev()->head) {
     temp->prev()->setID(0);
@@ -475,9 +477,10 @@
   std::cout << "added client id: " << temp->getID() << std::endl;
 
-  temp->setSynched(true);
-  return true;
+  return temp->setSynched(true);
 }
 
 void printClientInformationBox( ClientInformation* box ) {
+  if(!box)
+    return;
   std::cout << "ClientList: id: " << box->getID() << "\t";
   std::cout << "g_id: " << box->getGamestateID() << " \t";
Index: code/trunk/src/orxonox/OrxonoxPlatform.h
===================================================================
--- code/trunk/src/orxonox/OrxonoxPlatform.h	(revision 1359)
+++ code/trunk/src/orxonox/OrxonoxPlatform.h	(revision 1360)
@@ -196,4 +196,5 @@
 //typedef unsigned short uint16;
 //typedef unsigned char uint8;
+// proper approach
 
 #ifdef ORXONOX_DOUBLE_PRECISION
Index: code/trunk/src/orxonox/objects/Projectile.cc
===================================================================
--- code/trunk/src/orxonox/objects/Projectile.cc	(revision 1359)
+++ code/trunk/src/orxonox/objects/Projectile.cc	(revision 1360)
@@ -63,4 +63,6 @@
 
         this->destroyTimer_.setTimer(this->lifetime_, false, this, createExecutor(createFunctor(&Projectile::destroyObject)));
+        this->classID = this->getIdentifier()->getNetworkID(); // TODO: remove this hack
+//        COUT(3) << this->classID << std::endl;
     }
 
Index: code/trunk/src/orxonox/objects/SpaceShip.cc
===================================================================
--- code/trunk/src/orxonox/objects/SpaceShip.cc	(revision 1359)
+++ code/trunk/src/orxonox/objects/SpaceShip.cc	(revision 1360)
@@ -62,4 +62,13 @@
     SpaceShip* SpaceShip::instance_s;
 
+    SpaceShip *SpaceShip::getLocalShip(){
+      Iterator<SpaceShip> it;
+      for(it = ObjectList<SpaceShip>::start(); it; ++it){
+        if((it)->server_ || ( network::Client::getSingleton() && network::Client::getSingleton()->getShipID()==it->objectID ) )
+          return *it;
+      }
+      return NULL;
+    }
+    
     SpaceShip::SpaceShip() :
       //testvector_(0,0,0),
@@ -145,12 +154,13 @@
     void SpaceShip::init()
     {
-    if ((server_ || ( network::Client::getSingleton() && network::Client::getSingleton()->getShipID()==objectID ) ))
-    {
-          if (!setMouseEventCallback_)
-          {
-              InputManager::addMouseHandler(this, "SpaceShip");
-              setMouseEventCallback_ = true;
-          }
-    }
+        if ((server_ || ( network::Client::getSingleton() && network::Client::getSingleton()->getShipID()==objectID ) ))
+        {
+              if (!setMouseEventCallback_)
+              {
+                  InputManager::addMouseHandler(this, "SpaceShip");
+                  //InputManager::enableMouseHandler("SpaceShip");
+                  setMouseEventCallback_ = true;
+              }
+        }
 
         // START CREATING THRUSTER
@@ -394,5 +404,7 @@
         if (this->bLMousePressed_ && this->timeToReload_ <= 0)
         {
+          
             Projectile *p = new Projectile(this);
+            
             p->setBacksync(true);
             this->timeToReload_ = this->reloadTime_;
Index: code/trunk/src/orxonox/objects/SpaceShip.h
===================================================================
--- code/trunk/src/orxonox/objects/SpaceShip.h	(revision 1359)
+++ code/trunk/src/orxonox/objects/SpaceShip.h	(revision 1360)
@@ -44,4 +44,7 @@
     {
         public:
+          
+            static SpaceShip *getLocalShip();
+            
             SpaceShip();
             ~SpaceShip();
Index: code/trunk/src/orxonox/objects/WorldEntity.cc
===================================================================
--- code/trunk/src/orxonox/objects/WorldEntity.cc	(revision 1359)
+++ code/trunk/src/orxonox/objects/WorldEntity.cc	(revision 1360)
@@ -138,12 +138,12 @@
       registerVar( (void*) &(this->getOrientation().z), sizeof(this->getOrientation().z), network::DATA, 0x3);
       // register velocity_
-//       registerVar( (void*) &(this->getVelocity().x), sizeof(this->getVelocity().x), network::DATA, 0x3);
-//       registerVar( (void*) &(this->getVelocity().y), sizeof(this->getVelocity().y), network::DATA, 0x3);
-//       registerVar( (void*) &(this->getVelocity().z), sizeof(this->getVelocity().z), network::DATA, 0x3);
-//       // register rotationAxis/rate
-//       registerVar( (void*) &(this->getRotationRate()), sizeof(this->getRotationRate()), network::DATA, 0x3);
-//       registerVar( (void*) &(this->getRotationAxis().x), sizeof(this->getRotationAxis().x), network::DATA, 0x3);
-//       registerVar( (void*) &(this->getRotationAxis().y), sizeof(this->getRotationAxis().y), network::DATA, 0x3);
-//       registerVar( (void*) &(this->getRotationAxis().z), sizeof(this->getRotationAxis().z), network::DATA, 0x3);
+      registerVar( (void*) &(this->getVelocity().x), sizeof(this->getVelocity().x), network::DATA, 0x3);
+      registerVar( (void*) &(this->getVelocity().y), sizeof(this->getVelocity().y), network::DATA, 0x3);
+      registerVar( (void*) &(this->getVelocity().z), sizeof(this->getVelocity().z), network::DATA, 0x3);
+      // register rotationAxis/rate
+      registerVar( (void*) &(this->getRotationRate()), sizeof(this->getRotationRate()), network::DATA, 0x3);
+      registerVar( (void*) &(this->getRotationAxis().x), sizeof(this->getRotationAxis().x), network::DATA, 0x3);
+      registerVar( (void*) &(this->getRotationAxis().y), sizeof(this->getRotationAxis().y), network::DATA, 0x3);
+      registerVar( (void*) &(this->getRotationAxis().z), sizeof(this->getRotationAxis().z), network::DATA, 0x3);
       // register scale of node
       registerVar( (void*) &(this->getScale().x), sizeof(this->getScale().x), network::DATA, 0x3);
@@ -152,9 +152,9 @@
       //register staticity
       registerVar( (void*) &(this->bStatic_), sizeof(this->bStatic_), network::DATA, 0x3);
-      //register acceleration
-      // register velocity_
-//       registerVar( (void*) &(this->getAcceleration().x), sizeof(this->getAcceleration().x), network::DATA, 0x3);
-//       registerVar( (void*) &(this->getAcceleration().y), sizeof(this->getAcceleration().y), network::DATA, 0x3);
-//       registerVar( (void*) &(this->getAcceleration().z), sizeof(this->getAcceleration().z), network::DATA, 0x3);
+      //register acceleration & momentum
+      registerVar( (void*) &(this->getAcceleration().x), sizeof(this->getAcceleration().x), network::DATA, 0x3);
+      registerVar( (void*) &(this->getAcceleration().y), sizeof(this->getAcceleration().y), network::DATA, 0x3);
+      registerVar( (void*) &(this->getAcceleration().z), sizeof(this->getAcceleration().z), network::DATA, 0x3);
+      registerVar( (void*) &(this->getMomentum()), sizeof(this->getMomentum()), network::DATA);
     }
 
