Index: code/trunk/src/network/GamestateClient.cc
===================================================================
--- code/trunk/src/network/GamestateClient.cc	(revision 1907)
+++ code/trunk/src/network/GamestateClient.cc	(revision 2087)
@@ -29,4 +29,5 @@
 #include "GamestateClient.h"
 
+#include <cassert>
 #include <zlib.h>
 
@@ -40,7 +41,7 @@
 namespace network
 {
-  struct GameStateItem{
+  struct _NetworkExport GameStateItem{
     packet::Gamestate *state;
-    int id;
+    unsigned int id;
   };
 
@@ -50,5 +51,4 @@
     last_gamestate_=GAMESTATEID_INITIAL-1;
     tempGamestate_=NULL;
-    myShip_=NULL;
   }
 
@@ -56,9 +56,9 @@
   }
 
-  bool GamestateClient::ack(int gamestateID, int clientID){
+  bool GamestateClient::ack(unsigned int gamestateID, unsigned int clientID){
     return true;
   }
 
-  bool GamestateClient::add(packet::Gamestate *gs, int clientID){
+  bool GamestateClient::add(packet::Gamestate *gs, unsigned int clientID){
     if(tempGamestate_!=NULL){
       //delete the obsolete gamestate
@@ -75,18 +75,12 @@
       return false;
     int id = GAMESTATEID_INITIAL;
-    bool b = saveShipCache();
     packet::Gamestate *processed = processGamestate(tempGamestate_);
-    if(!processed){
-      if(b)
-        loadShipCache();
-      return false;
-    }
 //    assert(processed);
+    if (!processed)
+        return false;
     //successfully loaded data from gamestate. now save gamestate for diff and delete the old gs
     tempGamestate_=NULL;
     gamestateMap_[processed->getID()]=processed;
     last_diff_ = processed->getID();
-    if(b)
-      loadShipCache();
     id = processed->getID();
     sendAck(id);
@@ -108,10 +102,13 @@
   packet::Gamestate *GamestateClient::getGamestate(){
     packet::Gamestate *gs = new packet::Gamestate();
-    gs->collectData(0);
+    if(!gs->collectData(0)){
+      delete gs;
+      return 0;
+    }
     return gs;
   }
 
   void GamestateClient::cleanup(){
-    std::map<int, packet::Gamestate*>::iterator temp, it = gamestateMap_.begin();
+    std::map<unsigned int, packet::Gamestate*>::iterator temp, it = gamestateMap_.begin();
     while(it!=gamestateMap_.end()){
       if(it->first>=last_diff_)
@@ -126,5 +123,5 @@
 
   void GamestateClient::printGamestateMap(){
-    std::map<int, packet::Gamestate*>::iterator it;
+    std::map<unsigned int, packet::Gamestate*>::iterator it;
     COUT(4) << "gamestates: ";
     for(it=gamestateMap_.begin(); it!=gamestateMap_.end(); it++){
@@ -134,5 +131,5 @@
 
   }
-  
+
   bool GamestateClient::sendAck(unsigned int gamestateID){
     packet::Acknowledgement *ack = new packet::Acknowledgement(gamestateID, 0);
@@ -142,40 +139,7 @@
     }
     else{
-      COUT(3) << "acked a gamestate: " << gamestateID << std::endl;
+      COUT(5) << "acked a gamestate: " << gamestateID << std::endl;
       return true;
     }
-  }
-
-  bool GamestateClient::saveShipCache(){
-    if(myShip_==NULL){
-      myShip_ = orxonox::SpaceShip::getLocalShip();
-//      COUT(2) << "myShip_: " << myShip_ << " getLocalShip(): " << orxonox::SpaceShip::getLocalShip() << std::endl;
-      if(!myShip_)
-	return false;
-    }
-    if(myShip_){
-      //      unsigned char *data = new unsigned char[myShip_->getSize()];
-      int size=myShip_->getSize(0, 0x1);
-      if(size==0)
-        return false;
-      shipCache_ = new unsigned char [size];
-      unsigned char *temp = shipCache_;
-      if(!myShip_->getData(temp, 0, 0x1))
-        COUT(3) << "could not save shipCache" << std::endl;
-      return true;
-    }else
-      return false;
-  }
-
-  bool GamestateClient::loadShipCache(){
-    myShip_=orxonox::SpaceShip::getLocalShip(); //TODO: remove this (only a hack)
-    if(myShip_ && shipCache_){
-      assert(myShip_->getIdentifier());
-      unsigned char *temp = shipCache_;
-      myShip_->updateData(temp, 0x2);
-      delete shipCache_;
-      return true;
-    }else
-      return false;
   }
 
@@ -196,5 +160,5 @@
       delete gs;
       gs=undiffed;
-      COUT(3) << "successfully undiffed gamestate id: " << undiffed->getID() << std::endl;
+      COUT(5) << "successfully undiffed gamestate id: " << undiffed->getID() << std::endl;
     }
     if(gs->spreadData())
