Index: code/branches/network/src/network/Client.cc
===================================================================
--- code/branches/network/src/network/Client.cc	(revision 1424)
+++ code/branches/network/src/network/Client.cc	(revision 1425)
@@ -246,4 +246,13 @@
       elaborate(event->packet, 0); // ================= i guess we got to change this .... (client_ID is always same = server)
     }
+    int gameStateID = gamestate.processGameState();
+    if(gameStateID!=GAMESTATEID_INITIAL){
+      // ack gamestate and set synched
+      if(!isSynched_)
+        isSynched_=true;
+      if(!client_connection.addPacket(pck_gen.acknowledgement(gameStateID)))
+        COUT(3) << "could not ack gamestate" << std::endl;
+    }
+    gamestate.cleanup();
     if(!client_connection.sendPackets())
       COUT(3) << "Problem sending packets to server" << std::endl;
@@ -252,15 +261,6 @@
 
   void Client::processGamestate( GameStateCompressed *data, int clientID){
-    int id = data->id;
     COUT(5) << "received gamestate id: " << data->id << std::endl;
-    if(gamestate.pushGameState(data)){
-      if(!isSynched_)
-        isSynched_=true;
-      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;
-    }
+    gamestate.addGameState(data);
   }
 
Index: code/branches/network/src/network/GameStateClient.cc
===================================================================
--- code/branches/network/src/network/GameStateClient.cc	(revision 1424)
+++ code/branches/network/src/network/GameStateClient.cc	(revision 1425)
@@ -21,7 +21,7 @@
  *
  *   Author:
- *      ...
+ *      Oliver Scheuss
  *   Co-authors:
- *      ...
+ *      Dumeni Manatschal
  *
  */
@@ -35,5 +35,4 @@
 #include "Synchronisable.h"
 
-#define GAMESTATEID_INITIAL -1
 
 namespace network
@@ -48,4 +47,6 @@
     last_diff_=0;
     last_gamestate_=GAMESTATEID_INITIAL-1;
+    tempGameState_=NULL;
+    myShip_=NULL;
   }
 
@@ -102,4 +103,28 @@
     delete gs;
     return cgs;
+  }
+  
+  void GameStateClient::addGameState(GameStateCompressed *gs){
+    if(tempGameState_!=NULL){
+      //delete the obsolete gamestate
+      if(tempGameState_->id>gs->id)
+        return;
+      delete[] tempGameState_->data;
+      delete tempGameState_;
+    }
+    tempGameState_=gs;
+  }
+  int GameStateClient::processGameState(){
+    if(tempGameState_==NULL)
+      return GAMESTATEID_INITIAL;
+    int id=tempGameState_->id;
+    bool b = saveShipCache();
+    if(pushGameState(tempGameState_)){
+      if(b)
+        loadShipCache();
+      return id;
+    }
+    else
+      return GAMESTATEID_INITIAL;
   }
   
@@ -388,4 +413,5 @@
       gameStateMap.erase(temp);
     }
+    tempGameState_=NULL;
   }
 
@@ -400,4 +426,29 @@
   }
   
+  bool GameStateClient::saveShipCache(){
+    if(myShip_==NULL)
+      myShip_ = orxonox::SpaceShip::getLocalShip();
+    if(myShip_){
+      //      unsigned char *data = new unsigned char[myShip_->getSize()];
+      int size=myShip_->getSize(0x3);
+      if(size==0)
+        return false;
+      unsigned char *data = new unsigned char [size];
+      shipCache_ = myShip_->getData(data, 0x1);
+      return true;
+    }else
+      return false;
+  }
+  
+  bool GameStateClient::loadShipCache(){
+    if(myShip_){
+      myShip_->updateData(shipCache_, 0x2);
+      if(shipCache_.data){
+        delete[] shipCache_.data;
+      }
+      return true;
+    }else
+      return false;
+  }
   
     //##### ADDED FOR TESTING PURPOSE #####
Index: code/branches/network/src/network/GameStateClient.h
===================================================================
--- code/branches/network/src/network/GameStateClient.h	(revision 1424)
+++ code/branches/network/src/network/GameStateClient.h	(revision 1425)
@@ -21,7 +21,7 @@
  *
  *   Author:
- *      ...
+ *      Oliver Scheuss
  *   Co-authors:
- *      ...
+ *      Dumeni Manatschal
  *
  */
@@ -33,5 +33,5 @@
 //
 //
-// Author:  <>, (C) 2007
+// Author:  Oliver Scheuss, (C) 2007
 //
 // Copyright: See COPYING file that comes with this distribution
@@ -46,5 +46,8 @@
 #include "core/CorePrereqs.h"
 #include "PacketTypes.h"
+#include "objects/SpaceShip.h"
 
+
+#define GAMESTATEID_INITIAL -1
 
 namespace network
@@ -56,10 +59,12 @@
     ~GameStateClient();
     
+    void addGameState(GameStateCompressed *gs);
+    int processGameState();
+    GameStateCompressed *popPartialGameState();
+    void cleanup();
+  private:
     bool pushGameState(GameStateCompressed *compstate);
-    GameStateCompressed *popPartialGameState();
-  private:
     bool loadSnapshot(GameState *state);
     GameState *getPartialSnapshot();
-    void cleanup();
     GameState *undiff(GameState *old, GameState *diff);
     GameStateCompressed *compress_(GameState *a);
@@ -69,8 +74,13 @@
     void removeObject(orxonox::Iterator<Synchronisable> &it);
     void printGameStateMap();
+    bool saveShipCache();
+    bool loadShipCache();
 
     int           last_diff_;
     int           last_gamestate_;
     std::map<int, GameState *> gameStateMap;
+    GameStateCompressed *tempGameState_; // we save the received gamestates here during processQueue
+    orxonox::SpaceShip *myShip_;
+    syncData shipCache_;
     
     
Index: code/branches/network/src/network/GameStateManager.cc
===================================================================
--- code/branches/network/src/network/GameStateManager.cc	(revision 1424)
+++ code/branches/network/src/network/GameStateManager.cc	(revision 1425)
@@ -68,4 +68,27 @@
     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();
   }
   
Index: code/branches/network/src/network/GameStateManager.h
===================================================================
--- code/branches/network/src/network/GameStateManager.h	(revision 1424)
+++ code/branches/network/src/network/GameStateManager.h	(revision 1425)
@@ -72,10 +72,13 @@
     ~GameStateManager();
     
+    void addGameState(GameStateCompressed *gs, int clientID);
+    void processGameStates();
+    
     void update();
     GameStateCompressed *popGameState(int clientID);
-    bool pushGameState(GameStateCompressed *gs, int clientID);
     void ackGameState(int clientID, int gamestateID);
     void removeClient(ClientInformation *client);
-  private:
+    private:
+    bool pushGameState(GameStateCompressed *gs, int clientID);
     void cleanup(); // "garbage handler"
     GameState *getSnapshot();
@@ -91,4 +94,5 @@
     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;
     ClientInformation *head_;
Index: code/branches/network/src/network/Server.cc
===================================================================
--- code/branches/network/src/network/Server.cc	(revision 1424)
+++ code/branches/network/src/network/Server.cc	(revision 1425)
@@ -157,4 +157,5 @@
   void Server::tick(float time) {
     processQueue();
+    gamestates->processGameStates();
     updateGamestate();
 //     usleep(500000); // TODO remove
@@ -245,5 +246,6 @@
           disconnectClient(temp);
       //std::cout << "added gamestate" << std::endl;
-      }
+      }else
+        temp->resetFailures();
       added=true;
       temp=temp->next();
@@ -276,9 +278,9 @@
   void Server::processGamestate( GameStateCompressed *data, int clientID){
     COUT(4) << "processing partial gamestate from client " << clientID << std::endl;
-    if(!gamestates->pushGameState(data, clientID))
-        COUT(3) << "Could not push gamestate\t\t\t\t=====" << 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();
+        clients->findClient(clientID)->resetFailures();*/
   }
   
Index: code/branches/network/src/network/Synchronisable.cc
===================================================================
--- code/branches/network/src/network/Synchronisable.cc	(revision 1424)
+++ code/branches/network/src/network/Synchronisable.cc	(revision 1425)
@@ -70,4 +70,5 @@
   bool Synchronisable::create(){
     this->classID = this->getIdentifier()->getNetworkID();
+    COUT(4) << "setting classid from " << this->getIdentifier()->getName() << " to: " << classID << std::endl;
     return true;
   }
@@ -156,6 +157,8 @@
   * @return data containing all variables and their sizes
   */
-  syncData Synchronisable::getData(unsigned char *mem){
+  syncData Synchronisable::getData(unsigned char *mem, int mode){
     //std::cout << "inside getData" << std::endl;
+    if(mode==0x0)
+      mode=state_;
     if(classID==0)
       COUT(3) << "classid 0 " << this->getIdentifier()->getName() << std::endl;
@@ -172,5 +175,5 @@
     for(i=syncList->begin(); n<datasize && i!=syncList->end(); ++i){
       //(std::memcpy(retVal.data+n, (const void*)(&(i->size)), sizeof(int));
-      if( ((*i)->mode & state_) == 0 ){
+      if( ((*i)->mode & mode) == 0 ){
         COUT(5) << "not getting data: " << std::endl;
         continue;  // this variable should only be received
@@ -199,5 +202,7 @@
   * @return true/false
   */
-  bool Synchronisable::updateData(syncData vars){
+  bool Synchronisable::updateData(syncData vars, int mode){
+    if(mode==0x0)
+      mode=state_;
     unsigned char *data=vars.data;
     std::list<synchronisableVariable *>::iterator i;
@@ -208,7 +213,7 @@
     COUT(5) << "Synchronisable: objectID " << vars.objectID << ", classID " << vars.classID << " size: " << vars.length << " synchronising data" << std::endl;
     for(i=syncList->begin(); i!=syncList->end(); i++){
-      if( ((*i)->mode ^ state_) == 0 ){
+      if( ((*i)->mode ^ mode) == 0 ){
         COUT(5) << "synchronisable: not updating variable " << std::endl;
-        continue;  // this variable should only be updated
+        continue;  // this variable should only be set
       }
       COUT(5) << "Synchronisable: element size: " << (*i)->size << " type: " << (*i)->type << std::endl;
@@ -235,9 +240,11 @@
   * @return amount of bytes
   */
-  int Synchronisable::getSize(){
+  int Synchronisable::getSize(int mode){
     int tsize=0;
+    if(mode==0x0)
+      mode=state_;
     std::list<synchronisableVariable *>::iterator i;
     for(i=syncList->begin(); i!=syncList->end(); i++){
-      if( ((*i)->mode & state_) == 0 )
+      if( ((*i)->mode & mode) == 0 )
         continue;  // this variable should only be received, so dont add its size to the send-size
       switch((*i)->type){
Index: code/branches/network/src/network/Synchronisable.h
===================================================================
--- code/branches/network/src/network/Synchronisable.h	(revision 1424)
+++ code/branches/network/src/network/Synchronisable.h	(revision 1425)
@@ -83,7 +83,7 @@
     void registerVar(void *var, int size, variableType t, int mode=1);
     //  syncData getData();
-    syncData getData(unsigned char *mem);
-    int getSize();
-    bool updateData(syncData vars);
+    syncData getData(unsigned char *mem, int mode=0x0);
+    int getSize(int mode=0x0);
+    bool updateData(syncData vars, int mode=0x0);
     void setBacksync(bool sync);
     bool getBacksync();
Index: code/branches/network/src/orxonox/objects/Ambient.h
===================================================================
--- code/branches/network/src/orxonox/objects/Ambient.h	(revision 1424)
+++ code/branches/network/src/orxonox/objects/Ambient.h	(revision 1425)
@@ -47,5 +47,5 @@
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
             void setAmbientLight(const ColourValue& colour);
-            bool create();
+            virtual bool create();
             void registerAllVariables();
 
Index: code/branches/network/src/orxonox/objects/Explosion.cc
===================================================================
--- code/branches/network/src/orxonox/objects/Explosion.cc	(revision 1424)
+++ code/branches/network/src/orxonox/objects/Explosion.cc	(revision 1425)
@@ -80,7 +80,9 @@
     };
     
-    bool Explosion::create(){
-      return WorldEntity::create();
-    }
+    /*bool Explosion::create(){
+      if(!WorldEntity::create())
+        return false;
+      classID=this->getIdentifier()->getNetworkID();
+    }*/
 
     void Explosion::destroyObject()
Index: code/branches/network/src/orxonox/objects/Explosion.h
===================================================================
--- code/branches/network/src/orxonox/objects/Explosion.h	(revision 1424)
+++ code/branches/network/src/orxonox/objects/Explosion.h	(revision 1425)
@@ -43,5 +43,5 @@
             virtual ~Explosion();
             void destroyObject();
-            bool create();
+            virtual bool create(){return WorldEntity::create();}
 
         private:
Index: code/branches/network/src/orxonox/objects/Model.h
===================================================================
--- code/branches/network/src/orxonox/objects/Model.h	(revision 1424)
+++ code/branches/network/src/orxonox/objects/Model.h	(revision 1425)
@@ -45,5 +45,5 @@
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
             void setMesh(const std::string& meshname);
-            bool create();
+            virtual bool create();
 
         protected:
Index: code/branches/network/src/orxonox/objects/NPC.cc
===================================================================
--- code/branches/network/src/orxonox/objects/NPC.cc	(revision 1424)
+++ code/branches/network/src/orxonox/objects/NPC.cc	(revision 1425)
@@ -67,8 +67,4 @@
   }
   
-  bool NPC::create(){
-    Model::create();
-    return true;
-  }
 
   /**
Index: code/branches/network/src/orxonox/objects/NPC.h
===================================================================
--- code/branches/network/src/orxonox/objects/NPC.h	(revision 1424)
+++ code/branches/network/src/orxonox/objects/NPC.h	(revision 1425)
@@ -53,5 +53,5 @@
       void setValues(Vector3 location, Vector3 speed, Vector3 acceleration, bool movable);
       void registerAllVariables();
-      bool create();
+      virtual bool create(){return Model::create();}
 
     private:
Index: code/branches/network/src/orxonox/objects/Projectile.cc
===================================================================
--- code/branches/network/src/orxonox/objects/Projectile.cc	(revision 1424)
+++ code/branches/network/src/orxonox/objects/Projectile.cc	(revision 1425)
@@ -91,5 +91,6 @@
                 if (this->getPosition().squaredDistance(it->getPosition()) <= (radius*radius))
                 {
-                    new Explosion(this);
+                    Explosion *exp = new Explosion(this);
+                    exp->create();
                     delete this;
                     return;
Index: code/branches/network/src/orxonox/objects/Projectile.h
===================================================================
--- code/branches/network/src/orxonox/objects/Projectile.h	(revision 1424)
+++ code/branches/network/src/orxonox/objects/Projectile.h	(revision 1425)
@@ -46,4 +46,5 @@
             void destroyObject();
             virtual void tick(float dt);
+            virtual bool create(){return WorldEntity::create();}
 
         private:
Index: code/branches/network/src/orxonox/objects/Skybox.h
===================================================================
--- code/branches/network/src/orxonox/objects/Skybox.h	(revision 1424)
+++ code/branches/network/src/orxonox/objects/Skybox.h	(revision 1425)
@@ -47,5 +47,5 @@
             void setSkybox(const std::string& skyboxname);
             
-            bool create();
+            virtual bool create();
             void registerAllVariables();
             void setSkyboxSrc(const std::string &src);
Index: code/branches/network/src/orxonox/objects/SpaceShip.cc
===================================================================
--- code/branches/network/src/orxonox/objects/SpaceShip.cc	(revision 1424)
+++ code/branches/network/src/orxonox/objects/SpaceShip.cc	(revision 1425)
@@ -70,5 +70,5 @@
       Iterator<SpaceShip> it;
       for(it = ObjectList<SpaceShip>::start(); it; ++it){
-        if((it)->server_ || ( network::Client::getSingleton() && network::Client::getSingleton()->getShipID()==it->objectID ) )
+        if( (it)->myShip_ )
           return *it;
       }
@@ -109,5 +109,5 @@
       mouseY_(0.0f),
       emitterRate_(0.0f),
-      server_(false)
+      myShip_(false)
     {
         RegisterObject(SpaceShip);
@@ -140,4 +140,8 @@
 
     bool SpaceShip::create(){
+      if(!myShip_){
+        if(network::Client::getSingleton() && objectID == network::Client::getSingleton()->getShipID())
+          myShip_=true;
+      }
       if(Model::create())
         this->init();
@@ -299,5 +303,5 @@
         XMLPortParamLoadOnly(SpaceShip, "transDamp", setTransDamp, xmlelement, mode);
         XMLPortParamLoadOnly(SpaceShip, "rotDamp", setRotDamp, xmlelement, mode);
-        server_=true; // TODO: this is only a hack
+        myShip_=true; // TODO: this is only a hack
         SpaceShip::create();
         getFocus();
@@ -354,4 +358,5 @@
 
             Projectile *p = new Projectile(this);
+            p->create();
 
             p->setBacksync(true);
@@ -439,5 +444,5 @@
             this->tt_->setRate(0);
 
-        if( (network::Client::getSingleton() &&  network::Client::getSingleton()->getShipID() == objectID) || server_ )
+        if( myShip_ )
         {
           COUT(4) << "steering our ship: " << objectID << std::endl;
Index: code/branches/network/src/orxonox/objects/SpaceShip.h
===================================================================
--- code/branches/network/src/orxonox/objects/SpaceShip.h	(revision 1424)
+++ code/branches/network/src/orxonox/objects/SpaceShip.h	(revision 1425)
@@ -49,5 +49,5 @@
             SpaceShip();
             ~SpaceShip();
-            bool create();
+            virtual bool create();
             void registerAllVariables();
             void init();
@@ -81,4 +81,6 @@
             Vector3 getOrth();
             Camera* getCamera();
+            
+            bool getMyShip(){return myShip_;}
 
         private:
@@ -135,5 +137,5 @@
 
             float emitterRate_;
-            bool server_;
+            bool myShip_;
 
             static SpaceShip* instance_s;
Index: code/branches/network/src/orxonox/objects/WorldEntity.cc
===================================================================
--- code/branches/network/src/orxonox/objects/WorldEntity.cc	(revision 1424)
+++ code/branches/network/src/orxonox/objects/WorldEntity.cc	(revision 1425)
@@ -153,8 +153,8 @@
       registerVar( (void*) &(this->bStatic_), sizeof(this->bStatic_), 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);
+//       registerVar( (void*) &(this->getAcceleration().x), sizeof(this->getAcceleration().x), network::DATA, 0x2);
+//       registerVar( (void*) &(this->getAcceleration().y), sizeof(this->getAcceleration().y), network::DATA, 0x2);
+//       registerVar( (void*) &(this->getAcceleration().z), sizeof(this->getAcceleration().z), network::DATA, 0x2);
+//       registerVar( (void*) &(this->getMomentum()), sizeof(this->getMomentum()), network::DATA, 0x2); // only backsync
     }
 
Index: code/branches/network/src/orxonox/objects/WorldEntity.h
===================================================================
--- code/branches/network/src/orxonox/objects/WorldEntity.h	(revision 1424)
+++ code/branches/network/src/orxonox/objects/WorldEntity.h	(revision 1425)
@@ -53,5 +53,5 @@
             virtual void loadParams(TiXmlElement* xmlElem);
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-            inline bool create(){ return Synchronisable::create(); }
+            virtual inline bool create(){ return Synchronisable::create(); }
 
             void attachWorldEntity(WorldEntity* entity);
