Index: branches/proxy/src/lib/network/message_manager.cc
===================================================================
--- branches/proxy/src/lib/network/message_manager.cc	(revision 9507)
+++ branches/proxy/src/lib/network/message_manager.cc	(revision 9508)
@@ -44,5 +44,5 @@
 MessageManager::~MessageManager ()
 {
-  for ( MessageQueue::iterator it = messageQueue.begin(); it != messageQueue.end(); it++ )
+  for ( MessageQueue::iterator it = outgoingMessageQueue.begin(); it != outgoingMessageQueue.end(); it++ )
   {
     for ( std::list<NetworkMessage>::iterator it2 = it->second.messages.begin(); it2 != it->second.messages.end(); it2++ )
@@ -59,5 +59,5 @@
   }
 
-  messageQueue.clear();
+  outgoingMessageQueue.clear();
 
   this->messageHandlerMap.clear();
@@ -85,9 +85,9 @@
   int n;
 
-  n = Converter::intToByteArray( messageQueue[userId].toAck.size(), data + i, maxLength );
+  n = Converter::intToByteArray( outgoingMessageQueue[userId].toAck.size(), data + i, maxLength );
   i += n;
   assert( n == INTSIZE );
 
-  for ( std::list<int>::iterator it = messageQueue[userId].toAck.begin(); it != messageQueue[userId].toAck.end(); it++)
+  for ( std::list<int>::iterator it = outgoingMessageQueue[userId].toAck.begin(); it != outgoingMessageQueue[userId].toAck.end(); it++)
   {
     n = Converter::intToByteArray( *it, data + i, maxLength );
@@ -96,11 +96,11 @@
   }
 
-  messageQueue[userId].toAck.clear();
-
-  n = Converter::intToByteArray( messageQueue[userId].messages.size(), data + i, maxLength );
+  outgoingMessageQueue[userId].toAck.clear();
+
+  n = Converter::intToByteArray( outgoingMessageQueue[userId].messages.size(), data + i, maxLength );
   i += n;
   assert( n == INTSIZE );
 
-  for ( std::list<NetworkMessage>::iterator it = messageQueue[userId].messages.begin(); it != messageQueue[userId].messages.end(); it++ )
+  for ( std::list<NetworkMessage>::iterator it = outgoingMessageQueue[userId].messages.begin(); it != outgoingMessageQueue[userId].messages.end(); it++ )
   {
     n = Converter::intToByteArray( it->length, data + i, maxLength );
@@ -112,5 +112,5 @@
     assert( n == INTSIZE );
 
-    n = Converter::intToByteArray( it->messageId, data + i, maxLength );
+    n = Converter::intToByteArray( it->messageType, data + i, maxLength );
     i += n;
     assert( n == INTSIZE );
@@ -168,6 +168,7 @@
   i += n;
 
-  int messageLength, messageId;
-
+  int messageLength, messageType;
+
+  // now go through all messages
   for ( int j = 0; j < nMessages; j++ )
   {
@@ -183,16 +184,20 @@
 
     assert( i + INTSIZE <= length );
-    n = Converter::byteArrayToInt( data + i, &messageId );
+    n = Converter::byteArrayToInt( data + i, &messageType );
     assert( n == INTSIZE );
     i += n;
 
     if ( number > 0 )
-      messageQueue[userId].toAck.push_back( number );
+      outgoingMessageQueue[userId].toAck.push_back( number );
 
     assert( i + messageLength <= length );
-    assert( messageHandlerMap.find( (MessageId)messageId ) != messageHandlerMap.end() );
-    if ( std::find( messageQueue[userId].recievedMessages.begin(), messageQueue[userId].recievedMessages.end(), number )== messageQueue[userId].recievedMessages.end() )
-    {
-      if ( !(*(messageHandlerMap[(MessageId)messageId].cb))( (MessageId)messageId, data + i, messageLength, messageHandlerMap[(MessageId)messageId].someData, userId ) )
+    // make sure there is a message handler for this message type
+    assert( messageHandlerMap.find( (MessageType)messageType ) != messageHandlerMap.end() );
+
+
+    if ( std::find( outgoingMessageQueue[userId].recievedMessages.begin(), outgoingMessageQueue[userId].recievedMessages.end(), number ) ==
+         outgoingMessageQueue[userId].recievedMessages.end() )
+    {
+      if ( !(*(messageHandlerMap[(MessageType)messageType].cb))( (MessageType)messageType, data + i, messageLength, messageHandlerMap[(MessageType)messageType].someData, userId ) )
       {
         NetworkMessage msg;
@@ -201,10 +206,10 @@
         memcpy( msg.data, data + i, messageLength );
         msg.length = messageLength;
-        msg.messageId = (MessageId)messageId;
+        msg.messageType = (MessageType)messageType;
         msg.number = userId;
 
-        incomingMessageBuffer.push_back( msg );
+        incomingMessageQueue.push_back( msg );
       }
-      messageQueue[userId].recievedMessages.push_back( number );
+      outgoingMessageQueue[userId].recievedMessages.push_back( number );
     }
     i += messageLength;
@@ -213,7 +218,7 @@
 
   //TODO maybe handle incomingMessage in tick function. else local messages will not be handled if no clients are connected
-  for ( std::list<NetworkMessage>::iterator it = incomingMessageBuffer.begin(); it != incomingMessageBuffer.end();  )
-  {
-    if ( (*(messageHandlerMap[it->messageId].cb))( it->messageId, it->data, it->length, messageHandlerMap[it->messageId].someData, it->number ) )
+  for ( std::list<NetworkMessage>::iterator it = incomingMessageQueue.begin(); it != incomingMessageQueue.end();  )
+  {
+    if ( (*(messageHandlerMap[it->messageType].cb))( it->messageType, it->data, it->length, messageHandlerMap[it->messageType].someData, it->number ) )
     {
       std::list<NetworkMessage>::iterator delIt = it;
@@ -221,5 +226,5 @@
         delete it->data;
       it++;
-      incomingMessageBuffer.erase( delIt );
+      incomingMessageQueue.erase( delIt );
       continue;
     }
@@ -228,5 +233,5 @@
 
   //walk throu message queue and remove acked messages
-  for ( std::list<NetworkMessage>::iterator it = messageQueue[userId].messages.begin(); it != messageQueue[userId].messages.end();  )
+  for ( std::list<NetworkMessage>::iterator it = outgoingMessageQueue[userId].messages.begin(); it != outgoingMessageQueue[userId].messages.end();  )
   {
     if ( std::find( acks.begin(), acks.end(), it->number) != acks.end() )
@@ -234,5 +239,5 @@
       std::list<NetworkMessage>::iterator delIt = it;
       it++;
-      messageQueue[userId].messages.erase( delIt );
+      outgoingMessageQueue[userId].messages.erase( delIt );
       continue;
     }
@@ -241,8 +246,8 @@
 
   //TODO find bether way. maybe with timestamp
-  if ( messageQueue[userId].recievedMessages.size() > 1000 )
-  {
-    for ( int j = 0; j < messageQueue[userId].recievedMessages.size() - 1000; j++ )
-      messageQueue[userId].recievedMessages.erase( messageQueue[userId].recievedMessages.begin() );
+  if ( outgoingMessageQueue[userId].recievedMessages.size() > 1000 )
+  {
+    for ( int j = 0; j < outgoingMessageQueue[userId].recievedMessages.size() - 1000; j++ )
+      outgoingMessageQueue[userId].recievedMessages.erase( outgoingMessageQueue[userId].recievedMessages.begin() );
   }
 
@@ -258,8 +263,8 @@
 void MessageManager::cleanUpUser( int userId )
 {
-  if ( messageQueue.find( userId ) == messageQueue.end() )
+  if ( outgoingMessageQueue.find( userId ) == outgoingMessageQueue.end() )
     return;
 
-  for ( std::list<NetworkMessage>::iterator it = messageQueue[userId].messages.begin(); it != messageQueue[userId].messages.end(); it++ )
+  for ( std::list<NetworkMessage>::iterator it = outgoingMessageQueue[userId].messages.begin(); it != outgoingMessageQueue[userId].messages.end(); it++ )
   {
     if ( it->data )
@@ -268,25 +273,25 @@
   }
 
-  messageQueue[userId].toAck.clear();
-
-  messageQueue.erase( userId );
-}
-
-/**
- * registers function to handle messages with id messageId. someData is passed to callbackfuntion
- * @param messageId message id to handle
+  outgoingMessageQueue[userId].toAck.clear();
+
+  outgoingMessageQueue.erase( userId );
+}
+
+/**
+ * registers function to handle messages with id messageType. someData is passed to callbackfuntion
+ * @param messageType message id to handle
  * @param cb function pointer to callback function
  * @param someData this pointer is passed to callback function without modification
  * @return true on success
  */
-bool MessageManager::registerMessageHandler( MessageId messageId, MessageCallback cb, void * someData )
+bool MessageManager::registerMessageHandler( MessageType messageType, MessageCallback cb, void * someData )
 {
   MessageHandler messageHandler;
 
   messageHandler.cb = cb;
-  messageHandler.messageId = messageId;
+  messageHandler.messageType = messageType;
   messageHandler.someData = someData;
 
-  messageHandlerMap[messageId] = messageHandler;
+  messageHandlerMap[messageType] = messageHandler;
 
   return true;
@@ -300,6 +305,6 @@
 {
   // just do something so map creates a new entry
-  messageQueue[userId].toAck.clear();
-  //assert( messageQueue[userId].messages.size() == 0 );
+  outgoingMessageQueue[userId].toAck.clear();
+  //assert( outgoingMessageQueue[userId].messages.size() == 0 );
 }
 
@@ -311,13 +316,14 @@
  *               RT_NOT_USER send to all but reciever
  *
- * @param messageId message id
+ * @param messageType message id
  * @param data pointer to data
  * @param dataLength length of data
- * @param recieverType
- * @param reciever
- */
-void MessageManager::sendMessage( MessageId messageId, byte * data, int dataLength, RecieverType recieverType, int reciever, MessagePriority messagePriority )
-{
-  for ( MessageQueue::iterator it = messageQueue.begin(); it != messageQueue.end(); it++ )
+ * @param recieverType type of the receiver
+ * @param reciever the userId of the receiver if needed (depends on the ReceiverType)
+ */
+void MessageManager::sendMessage( MessageType messageType, byte * data, int dataLength, RecieverType recieverType, int reciever, MessagePriority messagePriority )
+{
+
+  for ( MessageQueue::iterator it = this->outgoingMessageQueue.begin(); it != this->outgoingMessageQueue.end(); it++ )
   {
     if (
@@ -335,5 +341,5 @@
       memcpy( msg.data, data, dataLength );
       msg.length = dataLength;
-      msg.messageId = messageId;
+      msg.messageType = messageType;
       msg.number = newNumber++;
       msg.priority = messagePriority;
@@ -350,11 +356,11 @@
     memcpy( msg.data, data, dataLength );
     msg.length = dataLength;
-    msg.messageId = messageId;
+    msg.messageType = messageType;
     msg.number = SharedNetworkData::getInstance()->getHostID();
     msg.priority = messagePriority;
 
-    incomingMessageBuffer.push_back( msg );
-  }
-}
-
-
+    incomingMessageQueue.push_back( msg );
+  }
+}
+
+
Index: branches/proxy/src/lib/network/message_manager.h
===================================================================
--- branches/proxy/src/lib/network/message_manager.h	(revision 9507)
+++ branches/proxy/src/lib/network/message_manager.h	(revision 9508)
@@ -20,5 +20,5 @@
       int length
       int number
-      int MessageId
+      int MessageType
       byte * data
     )[1..nmsg]
@@ -27,5 +27,5 @@
 
 //!< different message ids
-enum MessageId
+enum MessageType
 {
   TESTMESSAGEID                  = 1,         //!< for testing purposes
@@ -40,5 +40,5 @@
 
 
-typedef bool (*MessageCallback)( MessageId messageId, byte * data, int dataLength, void * someData, int userId );
+typedef bool (*MessageCallback)( MessageType messageType, byte * data, int dataLength, void * someData, int userId );
 
 enum RecieverType
@@ -61,5 +61,5 @@
 struct NetworkMessage
 {
-  MessageId        messageId;
+  MessageType        messageType;
   byte *           data;
   int              length;
@@ -77,12 +77,14 @@
 typedef std::map<int,MessageUserQueue> MessageQueue;
 
+
+
 struct MessageHandler
 {
   MessageCallback cb;
-  MessageId       messageId;
+  MessageType       messageType;
   void *          someData;
 };
 
-typedef std::map<MessageId,MessageHandler> MessageHandlerMap;
+typedef std::map<MessageType,MessageHandler> MessageHandlerMap;
 
 //! A class for sending messages over network
@@ -95,8 +97,12 @@
    virtual ~MessageManager();
 
-   bool registerMessageHandler( MessageId messageId, MessageCallback cb, void * someData );
+   bool registerMessageHandler( MessageType messageType, MessageCallback cb, void * someData );
 
-   void sendMessage( MessageId messageId, byte * data, int dataLength, RecieverType recieverType, int reciever, MessagePriority messagePriority );
+   void sendMessage( MessageType messageType, byte * data, int dataLength, RecieverType recieverType, int reciever, MessagePriority messagePriority );
 
+   void initUser( int userId );
+
+
+  private:
    virtual int getStateDiff( int userId, byte* data, int maxLength, int stateId, int fromStateId, int priorityTH );
    virtual int setStateDiff( int userId, byte* data, int length, int stateId, int fromStateId );
@@ -105,14 +111,14 @@
    virtual void handleRecvState( int userId, int stateId, int fromStateId ){}
 
-   void initUser( int userId );
-
 
  private:
-   static MessageManager *   singletonRef;
-   MessageQueue              messageQueue;           //!< stores messages to send
+   static MessageManager *   singletonRef;           //!< the singleton reference
+
+   std::list<NetworkMessage> incomingMessageQueue;   //!< the incoming message buffer
+   MessageQueue              outgoingMessageQueue;   //!< stores messages to send
    MessageHandlerMap         messageHandlerMap;      //!< contains handlers for messages
 
    int                       newNumber;              //!< used to create unique message numbers
-   std::list<NetworkMessage> incomingMessageBuffer;
+
 
 };
Index: branches/proxy/src/lib/network/network_game_manager.cc
===================================================================
--- branches/proxy/src/lib/network/network_game_manager.cc	(revision 9507)
+++ branches/proxy/src/lib/network/network_game_manager.cc	(revision 9508)
@@ -159,5 +159,5 @@
 /**
  * handler for remove synchronizeable messages
- * @param messageId
+ * @param messageType
  * @param data
  * @param dataLength
@@ -166,5 +166,5 @@
  * @return true on successfull handling else handler will be called again
  */
-bool NetworkGameManager::delSynchronizeableHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId )
+bool NetworkGameManager::delSynchronizeableHandler( MessageType messageType, byte * data, int dataLength, void * someData, int userId )
 {
 
@@ -224,5 +224,5 @@
 /**
  * handler for MSGID_PREFEREDTEAM message
- * @param messageId
+ * @param messageType
  * @param data
  * @param dataLength
@@ -231,5 +231,5 @@
  * @return
  */
-bool NetworkGameManager::preferedTeamHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId )
+bool NetworkGameManager::preferedTeamHandler( MessageType messageType, byte * data, int dataLength, void * someData, int userId )
 {
   assert( SharedNetworkData::getInstance()->isMasterServer() /*||  SharedNetworkData::getInstance()->isProxyServerActive()*/);
@@ -314,10 +314,10 @@
 
 
-bool NetworkGameManager::chatMessageHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId )
+bool NetworkGameManager::chatMessageHandler( MessageType messageType, byte * data, int dataLength, void * someData, int userId )
 {
   PRINTF(0)("NetworkGameManager::chatMessageHandler %d %d\n", userId, SharedNetworkData::getInstance()->getHostID() );
   if ( (SharedNetworkData::getInstance()->isMasterServer() /*|| SharedNetworkData::getInstance()->isProxyServerActive()*/) && userId !=  SharedNetworkData::getInstance()->getHostID() )
   {
-    MessageManager::getInstance()->sendMessage( messageId, data, dataLength, RT_ALL_BUT_ME, 0, MP_HIGHBANDWIDTH );
+    MessageManager::getInstance()->sendMessage( messageType, data, dataLength, RT_ALL_BUT_ME, 0, MP_HIGHBANDWIDTH );
   }
 
@@ -334,6 +334,6 @@
   }
 
-  int messageType = 0;
-  Converter::byteArrayToInt( data, &messageType );
+  int chatType = 0;
+  Converter::byteArrayToInt( data, &chatType);
   int senderUserId = 0;
   Converter::byteArrayToInt( data+INTSIZE, &senderUserId );
@@ -341,5 +341,5 @@
   Converter::byteArrayToString( data+2*INTSIZE, message, dataLength-2*INTSIZE );
 
-  rules.handleChatMessage( senderUserId, message, messageType );
+  rules.handleChatMessage( senderUserId, message, chatType);
 
   return true;
Index: branches/proxy/src/lib/network/network_game_manager.h
===================================================================
--- branches/proxy/src/lib/network/network_game_manager.h	(revision 9507)
+++ branches/proxy/src/lib/network/network_game_manager.h	(revision 9508)
@@ -70,7 +70,7 @@
     NetworkGameManager();
 
-    static bool delSynchronizeableHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId );
-    static bool preferedTeamHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId );
-    static bool chatMessageHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId );
+    static bool delSynchronizeableHandler( MessageType messageType, byte * data, int dataLength, void * someData, int userId );
+    static bool preferedTeamHandler( MessageType messageType, byte * data, int dataLength, void * someData, int userId );
+    static bool chatMessageHandler( MessageType messageType, byte * data, int dataLength, void * someData, int userId );
 
     void setPreferedTeam( int userId, int teamId );
Index: branches/proxy/src/lib/network/player_stats.cc
===================================================================
--- branches/proxy/src/lib/network/player_stats.cc	(revision 9507)
+++ branches/proxy/src/lib/network/player_stats.cc	(revision 9508)
@@ -212,5 +212,5 @@
 }
 
-bool PlayerStats::changeNickHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId )
+bool PlayerStats::changeNickHandler( MessageType messageType, byte * data, int dataLength, void * someData, int userId )
 {
   std::string newNick;
Index: branches/proxy/src/lib/network/player_stats.h
===================================================================
--- branches/proxy/src/lib/network/player_stats.h	(revision 9507)
+++ branches/proxy/src/lib/network/player_stats.h	(revision 9508)
@@ -66,5 +66,5 @@
     inline std::string getNickName(){ return this->nickName; }
     void setNickName( std::string nick );
-    static bool changeNickHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId );
+    static bool changeNickHandler( MessageType messageType, byte * data, int dataLength, void * someData, int userId );
     void shellNick( const std::string&  newNick );
 
