Index: code/branches/network3/src/network/ClientConnection.cc
===================================================================
--- code/branches/network3/src/network/ClientConnection.cc	(revision 1251)
+++ code/branches/network3/src/network/ClientConnection.cc	(revision 1253)
@@ -112,7 +112,12 @@
     if(server==NULL)
       return false;
-    if(enet_peer_send(server, 1, packet)!=0)
-      return false;
-    return true;
+    if(!packet){
+      COUT(4) << "Cl.con: addpacket: invalid packet" << std::endl;
+      return false;
+    }
+    if(enet_peer_send(server, 0, packet)<0)
+      return false;
+    else
+      return true;
   }
 
Index: code/branches/network3/src/network/GameStateClient.cc
===================================================================
--- code/branches/network3/src/network/GameStateClient.cc	(revision 1251)
+++ code/branches/network3/src/network/GameStateClient.cc	(revision 1253)
@@ -64,4 +64,6 @@
       if(!reference){
         COUT(4) << "pushGameState: no reference found to diff" << std::endl;
+        delete[] compstate->data;
+        delete compstate;
         return false;
       }
@@ -89,5 +91,8 @@
   GameStateCompressed *GameStateClient::popPartialGameState(){
     GameState *gs = getPartialSnapshot();
-    return compress_(gs);
+    GameStateCompressed *cgs = compress_(gs);
+    delete[] gs->data;
+    delete gs;
+    return cgs;
   }
   
@@ -166,9 +171,4 @@
 
   GameState *GameStateClient::getPartialSnapshot(){
-    
-    GameState *reference;
-//     std::map<int, GameState*>::iterator it = --gameStateMap.end();
-//     reference=(--gameStateMap.end())->second;
-    
     //std::cout << "begin getSnapshot" << std::endl;
     //the size of the gamestate
@@ -306,6 +306,4 @@
     compressedGamestate->complete = a->complete;
     compressedGamestate->base_id = a->base_id;
-    delete[] a->data;
-    delete a;
     return compressedGamestate;
   }
@@ -344,6 +342,4 @@
     gamestate->complete = a->complete;
 
-    delete[] a->data; //delete compressed data
-    delete a; //we do not need the old (struct) gamestate anymore
 
     return gamestate;
@@ -353,16 +349,14 @@
     COUT(4) << "using diffed gamestate" << std::endl;
     GameState *t = decode(diff);
-    return undiff(old, t);
-//     return t;
+    GameState *r = undiff(old, t);
+    delete[] t->data;
+    delete t;
+    return r;
   }
 
   GameState *GameStateClient::decode(GameStateCompressed *x) {
     GameState *t = decompress(x);
-    /*GameState *t = new GameState;
-    t->base_id = x->base_id;
-    t->id = x->id;
-    t->diffed = x->diffed;
-    t->data = x->data;
-    t->size = x->normsize;*/
+    delete[] x->data;
+    delete x;
     return t;
   }
Index: code/branches/network3/src/network/GameStateManager.cc
===================================================================
--- code/branches/network3/src/network/GameStateManager.cc	(revision 1251)
+++ code/branches/network3/src/network/GameStateManager.cc	(revision 1253)
@@ -129,6 +129,10 @@
   bool GameStateManager::pushGameState( GameStateCompressed *gs, int clientID ){
     GameState *ugs = decompress(gs);
-    return loadPartialSnapshot(ugs, clientID);
-    
+    delete[] gs->data;
+    delete gs;
+    bool result = loadPartialSnapshot(ugs, clientID);
+    delete[] ugs->data;
+    delete ugs;
+    return result;
   }
 
@@ -261,6 +265,4 @@
     }
     
-    delete[] state->data;
-    delete state;
     return true;
   }
@@ -280,20 +282,13 @@
     COUT(4) << "G.St.Man: this will be a DIFFED gamestate" << std::endl;
     GameState *r = diff(a,b);
-//     r->diffed = true;
-//     GameState *r = b;
-//     r->diffed = false;
-    return compress_(r);
-    /*GameStateCompressed *g = new GameStateCompressed;
-    g->base_id = r->base_id;
-    g->id = r->id;
-    g->diffed = r->diffed;
-    g->data = r->data;
-    g->normsize = r->size;
-    g->compsize = r->size;
-    return g*/;
+    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;
Index: code/branches/network3/src/network/Server.cc
===================================================================
--- code/branches/network3/src/network/Server.cc	(revision 1251)
+++ code/branches/network3/src/network/Server.cc	(revision 1253)
@@ -223,5 +223,5 @@
 
   void Server::processAck( ack *data, int clientID) {
-    COUT(4) << "Server: processing ack from client: " << clientID << "; ack-id: " << data->a << std::endl;
+    COUT(4) << "\b\b\b\n\n\n\n\nServer: processing ack from client: " << clientID << "; ack-id: " << data->a << std::endl;
     gamestates->ackGameState(clientID, data->a);
     delete data;
@@ -240,6 +240,4 @@
     if(!gamestates->pushGameState(data, clientID))
         COUT(3) << "Could not push gamestate\t\t\t\t=====" << std::endl;
-    delete[] data->data;
-    delete data;
   }
 
