Index: code/branches/multiplayerFS15/src/libraries/network/MasterServer.cc
===================================================================
--- code/branches/multiplayerFS15/src/libraries/network/MasterServer.cc	(revision 10434)
+++ code/branches/multiplayerFS15/src/libraries/network/MasterServer.cc	(revision 10447)
@@ -44,7 +44,4 @@
   /* forward declaration so the linker doesn't complain */
   MasterServer *MasterServer::instance = NULL;
-
-
-
 
   /* command: list servers */
@@ -266,4 +263,11 @@
     char *addrconv = (char *) calloc( 50, 1 );
     enet_address_get_host_ip( &(event->peer->address), addrconv, 49 );
+    /* convert to string */
+    std::string ip = std::string( addrconv );
+    /* delete addrconv */
+    if( addrconv ) free( addrconv );
+
+    /* pointer to full packet data */
+    char * packetdata = (char *)event->packet->data;
 
     /* output debug info about the data that has come */
@@ -271,14 +275,10 @@
 
     /* GAME SERVER OR CLIENT CONNECTION? */
-    if( !strncmp( (char *)event->packet->data, MSPROTO_GAME_SERVER,
-      MSPROTO_GAME_SERVER_LEN ) )
+    if( !strncmp(packetdata, MSPROTO_GAME_SERVER, MSPROTO_GAME_SERVER_LEN ) )
     { /* Game server */
 
-      if( !strncmp( (char *)event->packet->data
-        + MSPROTO_GAME_SERVER_LEN+1,
-        MSPROTO_REGISTER_SERVER, MSPROTO_REGISTER_SERVER_LEN ) )
+      if( !strncmp( packetdata + MSPROTO_GAME_SERVER_LEN+1, MSPROTO_REGISTER_SERVER, MSPROTO_REGISTER_SERVER_LEN ) )
       { /* register new server */
-        mainlist.addServer( packet::ServerInformation( event ),
-          event->peer );
+        mainlist.addServer( packet::ServerInformation( event ), event->peer );
 
         /* tell people we did so */
@@ -287,10 +287,6 @@
       }
 
-      else if( !strncmp( (char *)event->packet->data
-        + MSPROTO_GAME_SERVER_LEN+1,
-        MSPROTO_SERVERDC, MSPROTO_SERVERDC_LEN ) )
-      {
-        /* create string from peer data */
-        std::string ip = std::string( addrconv );
+      else if( !strncmp( packetdata + MSPROTO_GAME_SERVER_LEN+1, MSPROTO_SERVERDC, MSPROTO_SERVERDC_LEN ) )
+      { /* disconnect server */
 
         /* remove the server from the list it belongs to */
@@ -302,10 +298,7 @@
       /* TODO add hook for disconnect here */
 
-      else if( !strncmp( (char *)event->packet->data
-        + MSPROTO_GAME_SERVER_LEN+1,
-        MSPROTO_SET_NAME, MSPROTO_SET_NAME_LEN ) )
-      {
+      else if( !strncmp( packetdata + MSPROTO_GAME_SERVER_LEN+1, MSPROTO_SET_NAME, MSPROTO_SET_NAME_LEN ) )
+      { /* save server name */
         /* create string from peer data */
-        std::string ip = std::string( addrconv );
         std::string data (event->packet->data,event->packet->data + event->packet->dataLength );
         std::string name = data.substr(MSPROTO_GAME_SERVER_LEN+1 + MSPROTO_SET_NAME_LEN + 1);
@@ -318,10 +311,7 @@
       }
 
-      else if( !strncmp( (char *)event->packet->data
-        + MSPROTO_GAME_SERVER_LEN+1,
-        MSPROTO_SET_CLIENTS, MSPROTO_SET_CLIENTS_LEN ) )
-      {
+      else if( !strncmp( packetdata + MSPROTO_GAME_SERVER_LEN+1, MSPROTO_SET_CLIENTS, MSPROTO_SET_CLIENTS_LEN ) )
+      { /* save client count from server */
         /* create string from peer data */
-        std::string ip = std::string( addrconv );
         std::string data (event->packet->data,event->packet->data + event->packet->dataLength );
         std::string textform= data.substr(MSPROTO_GAME_SERVER_LEN + 1 + MSPROTO_SET_CLIENTS_LEN + 1);
@@ -334,9 +324,7 @@
       }
     }
-    else if( !strncmp( (char *)event->packet->data, MSPROTO_CLIENT,
-      MSPROTO_CLIENT_LEN) )
+    else if( !strncmp( packetdata, MSPROTO_CLIENT, MSPROTO_CLIENT_LEN) )
     { /* client */
-      if( !strncmp( (char *)event->packet->data + MSPROTO_CLIENT_LEN+1,
-        MSPROTO_REQ_LIST, MSPROTO_REQ_LIST_LEN ) )
+      if( !strncmp( packetdata + MSPROTO_CLIENT_LEN+1, MSPROTO_REQ_LIST, MSPROTO_REQ_LIST_LEN ) )
         /* send server list */
         helper_sendlist( event );
@@ -344,7 +332,4 @@
     else
     { /* bad message, don't do anything. */ }
-
-    /* delete addrconv */
-    if( addrconv ) free( addrconv );
 
     /* Clean up the packet now that we're done using it. */
