Index: code/branches/masterserver/src/libraries/network/MasterServerComm.cc
===================================================================
--- code/branches/masterserver/src/libraries/network/MasterServerComm.cc	(revision 7683)
+++ code/branches/masterserver/src/libraries/network/MasterServerComm.cc	(revision 7684)
@@ -46,4 +46,7 @@
       return 1;
     }
+
+    /* initialize the event holder */
+    this->event = (ENetEvent *)calloc( sizeof(ENetEvent), 1 );
     
     /* install atexit handler for enet */
@@ -89,6 +92,6 @@
 
     /* Wait up to 2 seconds for the connection attempt to succeed. */
-    if (enet_host_service (this->client, &this->event, 2000) > 0 &&
-        this->event.type == ENET_EVENT_TYPE_CONNECT )
+    if (enet_host_service (this->client, this->event, 2000) > 0 &&
+        this->event->type == ENET_EVENT_TYPE_CONNECT )
       fprintf( stdout, "Connection to server succeeded." );
     else
@@ -107,9 +110,9 @@
     /* see whether anything happened */
     /* WORK MARK REMOVE THIS OUTPUT */
-    COUT(2) << "MARK polling...\n";
+    //COUT(2) << "MARK polling...\n";
 
     /* enet_host_service returns 0 if no event occured */
     /* just newly set below test to >0 from >= 0, to be tested */
-    if( enet_host_service( this->client, &this->event, 1000 ) > 0 )
+    if( enet_host_service( this->client, this->event, 1000 ) > 0 )
     { 
       /* address buffer */
@@ -118,5 +121,5 @@
 
       /* check what type of event it is and react accordingly */
-      switch (this->event.type)
+      switch (this->event->type)
       { /* new connection, not supposed to happen. */
         case ENET_EVENT_TYPE_CONNECT: break;
@@ -128,20 +131,21 @@
         case ENET_EVENT_TYPE_RECEIVE: 
           addrconv = (char *) calloc( 50, 1 );
-          enet_address_get_host_ip( &(this->event.peer->address), addrconv, 49 );
+          enet_address_get_host_ip( &(this->event->peer->address), 
+            addrconv, 49 );
 
           /* DEBUG */
           printf( "A packet of length %u containing %s was "
             "received from %s on channel %u.\n",
-            this->event.packet->dataLength,
-            this->event.packet->data,
+            this->event->packet->dataLength,
+            this->event->packet->data,
             addrconv,
-            this->event.channelID );
+            this->event->channelID );
           /* END DEBUG */
 
           /* call the supplied callback, if any. */
           if( (*callback) != NULL )
-            retval = (*callback)( addrconv, &(this->event) );
-
-          enet_packet_destroy( event.packet );
+            retval = (*callback)( addrconv, (this->event) );
+
+          enet_packet_destroy( event->packet );
           if( addrconv ) free( addrconv );
           break;
Index: code/branches/masterserver/src/libraries/network/MasterServerComm.h
===================================================================
--- code/branches/masterserver/src/libraries/network/MasterServerComm.h	(revision 7683)
+++ code/branches/masterserver/src/libraries/network/MasterServerComm.h	(revision 7684)
@@ -85,5 +85,5 @@
 
       /** event data holder */
-      ENetEvent event;
+      ENetEvent *event;
 
       /** address holder */
Index: code/branches/masterserver/src/modules/masterserver/MasterServer.cc
===================================================================
--- code/branches/masterserver/src/modules/masterserver/MasterServer.cc	(revision 7683)
+++ code/branches/masterserver/src/modules/masterserver/MasterServer.cc	(revision 7684)
@@ -36,4 +36,72 @@
   /* singleton stuff */
   //ManageScopedSingleton( MasterServer, ScopeID::Root, false );
+
+  /* helpers */
+  static void 
+  helper_output_debug( ENetEvent *event, char *addrconv )
+  {
+    COUT(4) << "A packet of length" 
+      << event->packet->dataLength
+      << " containing "
+      << (const char*)event->packet->data
+      << " was received from "
+      << addrconv 
+      << " on channel "
+      << event->channelID << "\n";
+  }
+
+  void
+  MasterServer::helper_sendlist( ENetEvent *event )
+  {
+    /* get an iterator */
+    std::list<packet::ServerInformation>::iterator i;
+
+    /* packet holder */
+    ENetPacket *reply;
+
+    /* loop through list elements */
+    for( i = mainlist.serverlist.begin(); i 
+        != mainlist.serverlist.end(); ++i ) 
+    {
+      /* WORK MARK */
+      /* send this particular server */
+      /* build reply string */
+      char *tosend = (char *)calloc( (*i).getServerIP().length() 
+          + MSPROTO_SERVERLIST_ITEM_LEN + 2,1 );
+      if( !tosend ) 
+      { COUT(2) << "Masterserver.cc: Memory allocation failed.\n";
+        continue;
+      } 
+      sprintf( tosend, "%s %s", MSPROTO_SERVERLIST_ITEM, 
+          (*i).getServerIP().c_str() );
+
+      /* create packet from it */
+      reply = enet_packet_create( tosend,
+          strlen( tosend ) + 1, 
+          ENET_PACKET_FLAG_RELIABLE);
+
+      /* Send the reply to the peer over channel id 0. */
+      enet_peer_send( event->peer, 0, reply );
+
+      /* One could just use enet_host_service() instead. */
+      enet_host_flush( this->server );
+
+      /* free the tosend buffer */
+      free( tosend );
+    } 
+
+    /* send end-of-list packet */
+    reply = enet_packet_create( MSPROTO_SERVERLIST_END,
+        MSPROTO_SERVERLIST_END_LEN + 1,
+        ENET_PACKET_FLAG_RELIABLE );
+
+    enet_peer_send( event->peer, 0, reply );
+
+    /* One could just use enet_host_service() instead. */
+    enet_host_flush( this->server );
+  }
+
+
+
 
   /***** EVENTS *****/
@@ -105,30 +173,5 @@
     /* DEBUG */
     /* output debug info about the data that has come, to be removed */
-    COUT(4) << "A packet of length" 
-      << event->packet->dataLength
-      << " containing "
-      << (const char*)event->packet->data
-      << " was received from "
-      << addrconv 
-      << " on channel "
-      << event->channelID << "\n";
-
-    /*
-    //[> send some packet back for testing <]
-    //[> TESTING <]
-
-    //[> Create a reliable reply of size 7 containing "reply\0" <]
-    //ENetPacket * reply = enet_packet_create ("reply", 
-        //strlen ("reply") + 1, 
-        //ENET_PACKET_FLAG_RELIABLE);
-
-    //[> Send the reply to the peer over channel id 0. <]
-    //enet_peer_send( event->peer, 0, reply );
-
-    //[> One could just use enet_host_service() instead. <]
-    //enet_host_flush( this->server );
-
-    //[> /TESTING <]
-    */
+    helper_output_debug( event, addrconv );
 
     /* GAME SERVER OR CLIENT CONNECTION? */
@@ -151,47 +194,8 @@
       MSPROTO_CLIENT_LEN) )
     { /* client */
-      
       if( !strncmp( (char *)event->packet->data + MSPROTO_CLIENT_LEN+1,
         MSPROTO_REQ_LIST, MSPROTO_REQ_LIST_LEN ) )
-      { /* send server list */
-        
-        /* get an iterator */
-        std::list<packet::ServerInformation>::iterator i;
-
-        /* packet holder */
-        ENetPacket *reply;
-
-        /* loop through list elements */
-        for( i = mainlist.serverlist.begin(); i != mainlist.serverlist.end(); ++i ) 
-        {
-          /* WORK MARK */
-          /* send this particular server */
-          /* build reply string */
-          char *tosend = (char *)calloc( (*i).getServerIP().length() + MSPROTO_SERVERLIST_ITEM_LEN + 2,1 );
-          sprintf( tosend, "%s %s", MSPROTO_SERVERLIST_ITEM, (*i).getServerIP().c_str() );
-
-          /* create packet from it */
-           reply = enet_packet_create( tosend,
-            strlen( tosend ) + 1, 
-            ENET_PACKET_FLAG_RELIABLE);
-
-          /* Send the reply to the peer over channel id 0. */
-          enet_peer_send( event->peer, 0, reply );
-
-          /* One could just use enet_host_service() instead. */
-          enet_host_flush( this->server );
-        } 
-
-        /* send end-of-list packet */
-        reply = enet_packet_create( MSPROTO_SERVERLIST_END,
-          MSPROTO_SERVERLIST_END_LEN + 1,
-          ENET_PACKET_FLAG_RELIABLE );
-
-        enet_peer_send( event->peer, 0, reply );
-
-        /* One could just use enet_host_service() instead. */
-        enet_host_flush( this->server );
-
-      }
+        /* send server list */
+        helper_sendlist( event );
     }
     else
Index: code/branches/masterserver/src/modules/masterserver/MasterServer.h
===================================================================
--- code/branches/masterserver/src/modules/masterserver/MasterServer.h	(revision 7683)
+++ code/branches/masterserver/src/modules/masterserver/MasterServer.h	(revision 7684)
@@ -70,4 +70,7 @@
       int eventData( ENetEvent *event );
 
+      /* helpers */
+      void helper_sendlist( ENetEvent *event );
+
       /* members */
       ENetAddress address;
