Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2005:
[Freeciv-Dev] Re: (PR#14819) gui-sdl server list connection
Home

[Freeciv-Dev] Re: (PR#14819) gui-sdl server list connection

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#14819) gui-sdl server list connection
From: "Christian Prochaska" <cp.ml.freeciv.dev@xxxxxxxxxxxxxx>
Date: Sun, 11 Dec 2005 02:25:44 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=14819 >

On 12/10/05, Jason Short <jdorje@xxxxxxxxxxxxxxxxxxxxx> wrote:
>
> <URL: http://bugs.freeciv.org/Ticket/Display.html?id=14819 >
>
> When you press "connect to lan" or "connect to metaserver" in the start
> screen, you have to wait while the server list is downloaded.  But at
> the end the server list isn't displayed and only the regular server
> select dialog is present.
>
> -jason
>
>

Here's a patch that gives some more time for scanning. My lan server
server on localhost was found, but the client crashes when searching
for public servers and I don't know what the reason is. I wait until
server_scan_get_servers() returns a server list (!= NULL), but for
some reason server_list_iterate() ends without a single iteration on
this list.

diff -urN -X devel/diff_ignore devel_distclean/client/gui-sdl/connectdlg.c 
devel/client/gui-sdl/connectdlg.c
--- devel_distclean/client/gui-sdl/connectdlg.c 2005-11-27 01:35:27.000000000 
+0100
+++ devel/client/gui-sdl/connectdlg.c   2005-12-11 11:06:00.000000000 +0100
@@ -59,7 +59,7 @@
 
 
 static struct server_list *pServer_list = NULL;
-static struct server_scan *pServer_scan = NULL;    
+static struct server_scan *pServer_scan = NULL; 
     
 static struct ADVANCED_DLG *pMeta_Severs = NULL;
 static struct SMALL_DLG *pStartMenu = NULL;
@@ -167,10 +167,12 @@
   switch (server_scan_get_type(scan)) {
   case SERVER_SCAN_LOCAL:
     server_scan_finish(pServer_scan);
+    pServer_scan = NULL;
     pServer_list = NULL;
     break;
   case SERVER_SCAN_GLOBAL:
     server_scan_finish(pServer_scan);
+    pServer_scan = NULL;
     pServer_list = NULL;
     break;
   case SERVER_SCAN_LAST:
@@ -185,15 +187,28 @@
 **************************************************************************/
 static struct server_list *sdl_create_server_list(bool lan)
 {
+  struct server_list *server_list = NULL;
+    
   if (lan) {
     pServer_scan = server_scan_begin(SERVER_SCAN_LOCAL, server_scan_error);    
  
     } else {
     pServer_scan = server_scan_begin(SERVER_SCAN_GLOBAL, server_scan_error);   
   
     }
 
+  assert(pServer_scan);
+  
   SDL_Delay(5000);
+    
+  int i;
+  for (i = 0; i < 100; i++) {
+    server_list = server_scan_get_servers(pServer_scan);
+    if (server_list) {
+      break;
+    }
+    SDL_Delay(100);
+  }
   
-  return server_scan_get_servers(pServer_scan);
+  return server_list;
 }
 
 
@@ -242,7 +257,7 @@
   
   FREESURFACE(pLogo);
   FREESTRING16(pStr);
-  
+
   pServer_list = sdl_create_server_list(lan_scan);
 
   popup_meswin_dialog(true);        
@@ -281,7 +296,7 @@
   /* ------------------------------ */
   
   server_list_iterate(pServer_list, pServer) {
-    
+
     my_snprintf(cBuf, sizeof(cBuf), "%s Port %s Ver: %s %s %s %s\n%s",
        pServer->host, pServer->port, pServer->version, _(pServer->state),
                _("Players"), pServer->nplayers, pServer->message);
@@ -308,6 +323,9 @@
     }
     
   } server_list_iterate_end;
+
+  
+  assert(count > 0);
   
   pMeta_Severs->pBeginWidgetList = pNewWidget;
   pMeta_Severs->pBeginActiveWidgetList = pNewWidget;

[Prev in Thread] Current Thread [Next in Thread]