Index: code/trunk/src/network/PacketDecoder.cc
===================================================================
--- code/trunk/src/network/PacketDecoder.cc	(revision 1360)
+++ code/trunk/src/network/PacketDecoder.cc	(revision 1502)
@@ -68,10 +68,4 @@
     case COMMAND:
       return command( packet, clientId );
-    case MOUSE:
-      mousem( packet, clientId );
-      return true;
-    case KEYBOARD:
-      keystrike( packet, clientId );
-      return true;
     case CHAT:
       chatMessage( packet, clientId );
@@ -90,5 +84,5 @@
     return false;
   }
-  
+
   bool PacketDecoder::testAndRemoveCRC(ENetPacket *packet){
     uint32_t submittetcrc;
@@ -108,5 +102,5 @@
     return false;
   }
-  
+
   // ATTENTION: TODO watch, that arguments we pass over to the processFunction gets deleted in THE PROCESSXXX function
 
@@ -124,7 +118,9 @@
     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);
@@ -133,29 +129,9 @@
   }
 
-  void PacketDecoder::mousem( ENetPacket* packet, int clientId )
-  {
-    mouse* mouseMove = new mouse;
-    //copy data of packet->data to new struct
-    *mouseMove = *(mouse*)packet->data;
-
-    //clean memory
-    enet_packet_destroy( packet );
-    printMouse( mouseMove ); //debug info
-  }
-
-  void PacketDecoder::keystrike( ENetPacket* packet, int clientId )
-  {
-    keyboard* key = new keyboard;
-    *key = *(keyboard*)packet->data; //see above
-
-    //clean memory
-    enet_packet_destroy( packet );
-    printKey( key ); //debug info
-
-  }
-
   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
@@ -185,7 +161,4 @@
       return;
     }
-    //since it's not alowed to use void* for pointer arithmetic
-    //FIXME: variable never used
-    unsigned char* data = (unsigned char *)(packet->data);
     //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) );
@@ -202,9 +175,15 @@
     //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 );
@@ -221,4 +200,6 @@
     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];
@@ -229,6 +210,6 @@
     processClassid(cid);
   }
-  
-  
+
+
   bool PacketDecoder::decodeWelcome( ENetPacket* packet, int clientID ){
     welcome *w = new welcome;
@@ -240,5 +221,5 @@
     return processWelcome(w);
   }
-  
+
   bool PacketDecoder::decodeConnectRequest( ENetPacket *packet, int clientID ){
     connectRequest *con = new connectRequest;
@@ -279,10 +260,10 @@
     return;
   }
-  
+
   bool PacketDecoder::processWelcome( welcome *w ){
     delete w;
     return true;
   }
-  
+
   bool PacketDecoder::processConnectRequest( connectRequest *con, int clientID ){
     COUT(3) << "packetdecoder: processing connectRequest" << std::endl;
@@ -299,20 +280,11 @@
   }
 
-  void PacketDecoder::printMouse( mouse* data )
-  {
-    COUT(5) << "data id: " << data->id << std::endl;
-    COUT(5) << "data:    " << data->x << " " << data->y << std::endl;
-  }
-
-  void PacketDecoder::printKey( keyboard* data )
-  {
-    COUT(5) << "data id: " << data->id << std::endl;
-    COUT(5) << "data:    " << (char)data->press << 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;
