[Freeciv-Dev] (PR#13561) Move autoconnect code to the common client code
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: |
[Freeciv-Dev] (PR#13561) Move autoconnect code to the common client code |
From: |
"Mateusz Stefek" <mstefek@xxxxxxxxx> |
Date: |
Fri, 29 Jul 2005 01:29:00 -0700 |
Reply-to: |
bugs@xxxxxxxxxxx |
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13561 >
See $SUBJECT
--
mateusz
Index: client/civclient.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/civclient.c,v
retrieving revision 1.228
diff -u -r1.228 civclient.c
--- client/civclient.c 16 Jul 2005 09:04:53 -0000 1.228
+++ client/civclient.c 29 Jul 2005 08:24:57 -0000
@@ -540,7 +540,7 @@
_("There was an error while auto connecting; aborting."));
exit(EXIT_FAILURE);
} else {
- server_autoconnect();
+ start_autoconnecting_to_server();
auto_connect = FALSE; /* don't try this again */
}
}
@@ -662,6 +662,8 @@
{
double time_until_next_call = 1.0;
+ time_until_next_call = MIN(time_until_next_call, try_to_autoconnect());
+
if (get_client_state() != CLIENT_GAME_RUNNING_STATE) {
return time_until_next_call;
}
Index: client/clinet.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/clinet.c,v
retrieving revision 1.116
diff -u -r1.116 clinet.c
--- client/clinet.c 28 Apr 2005 17:19:52 -0000 1.116
+++ client/clinet.c 29 Jul 2005 08:25:11 -0000
@@ -909,3 +909,86 @@
my_closesocket(socklan);
delete_server_list(lan_servers);
}
+
+static bool autoconnecting = FALSE;
+/**************************************************************************
+ Make an attempt to autoconnect to the server.
+ It returns number of seconds it should be called again.
+**************************************************************************/
+double try_to_autoconnect(void)
+{
+ char errbuf[512];
+ static int count = 0;
+#ifndef WIN32_NATIVE
+ static int warning_shown = 0;
+#endif
+
+ if (!autoconnecting) {
+ return FC_INFINITY;
+ }
+
+ count++;
+
+ if (count >= MAX_AUTOCONNECT_ATTEMPTS) {
+ freelog(LOG_FATAL,
+ _("Failed to contact server \"%s\" at port "
+ "%d as \"%s\" after %d attempts"),
+ server_host, server_port, user_name, count);
+ exit(EXIT_FAILURE);
+ }
+
+ switch (try_to_connect(user_name, errbuf, sizeof(errbuf))) {
+ case 0: /* Success! */
+ /* Don't call me again */
+ autoconnecting = FALSE;
+ return FC_INFINITY;
+#ifndef WIN32_NATIVE
+ /* See PR#4042 for more info on issues with try_to_connect() and errno. */
+ case ECONNREFUSED: /* Server not available (yet) */
+ if (!warning_shown) {
+ freelog(LOG_NORMAL, _("Connection to server refused. "
+ "Please start the server."));
+ append_output_window(_("Connection to server refused. "
+ "Please start the server."));
+ warning_shown = 1;
+ }
+ /* Try again in 0.5 seconds */
+ return 0.001 * AUTOCONNECT_INTERVAL;
+#endif
+ default: /* All other errors are fatal */
+ freelog(LOG_FATAL,
+ _("Error contacting server \"%s\" at port %d "
+ "as \"%s\":\n %s\n"),
+ server_host, server_port, user_name, errbuf);
+ exit(EXIT_FAILURE);
+ }
+}
+
+/**************************************************************************
+ Start trying to autoconnect to civserver. Calls
+ get_server_address(), then arranges for try_to_autoconnect(), which
+ calls try_to_connect(), to be called roughly every
+ AUTOCONNECT_INTERVAL milliseconds, until success, fatal error or
+ user intervention.
+**************************************************************************/
+void start_autoconnecting_to_server(void)
+{
+ char buf[512];
+
+ my_snprintf(buf, sizeof(buf),
+ _("Auto-connecting to server \"%s\" at port %d "
+ "as \"%s\" every %f second(s) for %d times"),
+ server_host, server_port, user_name,
+ 0.001 * AUTOCONNECT_INTERVAL,
+ MAX_AUTOCONNECT_ATTEMPTS);
+ append_output_window(buf);
+
+ if (get_server_address(server_host, server_port, buf, sizeof(buf)) < 0) {
+ freelog(LOG_FATAL,
+ _("Error contacting server \"%s\" at port %d "
+ "as \"%s\":\n %s\n"),
+ server_host, server_port, user_name, buf);
+ exit(EXIT_FAILURE);
+ }
+ autoconnecting = TRUE;
+}
Index: client/clinet.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/clinet.h,v
retrieving revision 1.20
diff -u -r1.20 clinet.h
--- client/clinet.h 4 Oct 2004 04:37:32 -0000 1.20
+++ client/clinet.h 29 Jul 2005 08:25:11 -0000
@@ -77,4 +77,6 @@
struct server_list *get_lan_server_list(void);
void finish_lanserver_scan(void);
+double try_to_autoconnect(void);
+void start_autoconnecting_to_server(void);
#endif /* FC__CLINET_H */
Index: client/gui-ftwl/connectdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-ftwl/connectdlg.c,v
retrieving revision 1.5
diff -u -r1.5 connectdlg.c
--- client/gui-ftwl/connectdlg.c 22 Mar 2005 20:04:42 -0000 1.5
+++ client/gui-ftwl/connectdlg.c 29 Jul 2005 08:25:23 -0000
@@ -157,76 +157,6 @@
}
/**************************************************************************
- Start trying to autoconnect to civserver.
- Calls get_server_address(), then arranges for
- autoconnect_callback(), which calls try_to_connect(), to be called
- roughly every AUTOCONNECT_INTERVAL milliseconds, until success,
- fatal error or user intervention.
-**************************************************************************/
-void server_autoconnect(void)
-{
- char buf[512];
- int outcome;
-
- my_snprintf(buf, sizeof(buf),
- _("Auto-connecting to server \"%s\" at port %d as \"%s\""),
- server_host, server_port, user_name);
- append_output_window(buf);
- outcome = get_server_address(server_host, server_port, buf, sizeof(buf));
- if (outcome < 0) {
- freelog(LOG_FATAL,
- _("Error contacting server \"%s\" at port %d "
- "as \"%s\":\n %s\n"),
- server_host, server_port, user_name, buf);
- exit(EXIT_FAILURE);
- }
- try_to_autoconnect(NULL);
-}
-
-/**************************************************************************
- Make an attempt to autoconnect to the server. If the server isn't
- there yet, arrange for this routine to be called again in about
- AUTOCONNECT_INTERVAL milliseconds. If anything else goes wrong, log
- a fatal error.
-
- Return FALSE iff autoconnect succeeds.
-**************************************************************************/
-static void try_to_autoconnect(void *data)
-{
- char errbuf[512];
- static int count = 0;
-
- count++;
-
- /* abort if after 10 seconds the server couldn't be reached */
-
- if (AUTOCONNECT_INTERVAL * count >= 10000) {
- freelog(LOG_FATAL,
- _("Failed to contact server \"%s\" at port "
- "%d as \"%s\" after %d attempts"),
- server_host, server_port, user_name, count);
- exit(EXIT_FAILURE);
- }
-
- switch (try_to_connect(user_name, errbuf, sizeof(errbuf))) {
- case 0:
- /* Success! */
- return;
- case ECONNREFUSED:
- /* Server not available (yet) - wait & retry */
- sw_add_timeout(AUTOCONNECT_INTERVAL, try_to_autoconnect, NULL);
- return;
- default:
- /* All other errors are fatal */
- freelog(LOG_FATAL,
- _("Error contacting server \"%s\" at port %d "
- "as \"%s\":\n %s\n"),
- server_host, server_port, user_name, errbuf);
- exit(EXIT_FAILURE);
- }
-}
-
-/**************************************************************************
...
**************************************************************************/
void close_connection_dialog(void)
Index: client/gui-gtk-2.0/connectdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/connectdlg.c,v
retrieving revision 1.53
diff -u -r1.53 connectdlg.c
--- client/gui-gtk-2.0/connectdlg.c 14 Nov 2004 22:49:39 -0000 1.53
+++ client/gui-gtk-2.0/connectdlg.c 29 Jul 2005 08:25:23 -0000
@@ -118,81 +118,3 @@
{
}
-/**************************************************************************
- Make an attempt to autoconnect to the server.
- (server_autoconnect() gets GTK to call this function every so often.)
-**************************************************************************/
-static int try_to_autoconnect(gpointer data)
-{
- char errbuf[512];
- static int count = 0;
-#ifndef WIN32_NATIVE
- static int warning_shown = 0;
-#endif
-
- count++;
-
- if (count >= MAX_AUTOCONNECT_ATTEMPTS) {
- freelog(LOG_FATAL,
- _("Failed to contact server \"%s\" at port "
- "%d as \"%s\" after %d attempts"),
- server_host, server_port, user_name, count);
- exit(EXIT_FAILURE);
- }
-
- switch (try_to_connect(user_name, errbuf, sizeof(errbuf))) {
- case 0: /* Success! */
- return FALSE; /* Tells GTK not to call this
- function again */
-#ifndef WIN32_NATIVE
- /* See PR#4042 for more info on issues with try_to_connect() and errno. */
- case ECONNREFUSED: /* Server not available (yet) */
- if (!warning_shown) {
- freelog(LOG_NORMAL, _("Connection to server refused. "
- "Please start the server."));
- append_output_window(_("Connection to server refused. "
- "Please start the server."));
- warning_shown = 1;
- }
- return TRUE; /* Tells GTK to keep calling this function */
-#endif
- default: /* All other errors are fatal */
- freelog(LOG_FATAL,
- _("Error contacting server \"%s\" at port %d "
- "as \"%s\":\n %s\n"),
- server_host, server_port, user_name, errbuf);
- exit(EXIT_FAILURE);
- }
-}
-
-/**************************************************************************
- Start trying to autoconnect to civserver. Calls
- get_server_address(), then arranges for try_to_autoconnect(), which
- calls try_to_connect(), to be called roughly every
- AUTOCONNECT_INTERVAL milliseconds, until success, fatal error or
- user intervention. (Doesn't use widgets, but is GTK-specific
- because it calls gtk_timeout_add().)
-**************************************************************************/
-void server_autoconnect()
-{
- char buf[512];
-
- my_snprintf(buf, sizeof(buf),
- _("Auto-connecting to server \"%s\" at port %d "
- "as \"%s\" every %f second(s) for %d times"),
- server_host, server_port, user_name,
- 0.001 * AUTOCONNECT_INTERVAL,
- MAX_AUTOCONNECT_ATTEMPTS);
- append_output_window(buf);
-
- if (get_server_address(server_host, server_port, buf, sizeof(buf)) < 0) {
- freelog(LOG_FATAL,
- _("Error contacting server \"%s\" at port %d "
- "as \"%s\":\n %s\n"),
- server_host, server_port, user_name, buf);
- exit(EXIT_FAILURE);
- }
- if (try_to_autoconnect(NULL)) {
- gtk_timeout_add(AUTOCONNECT_INTERVAL, try_to_autoconnect, NULL);
- }
-}
Index: client/gui-mui/connectdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/connectdlg.c,v
retrieving revision 1.15
diff -u -r1.15 connectdlg.c
--- client/gui-mui/connectdlg.c 5 Feb 2005 07:15:37 -0000 1.15
+++ client/gui-mui/connectdlg.c 29 Jul 2005 08:25:23 -0000
@@ -249,79 +249,6 @@
}
}
-/**************************************************************************
- Make an attempt to autoconnect to the server. If the server isn't
- there yet, arrange for this routine to be called again in about
- AUTOCONNECT_INTERVAL milliseconds. If anything else goes wrong, log
- a fatal error.
-**************************************************************************/
-static int try_to_autoconnect(void)
-{
-// Implement me
- return 0;
-#if 0
- char errbuf[512];
- static int count = 0;
-
- count++;
-
- /* abort if after 10 seconds the server couldn't be reached */
-
- if (AUTOCONNECT_INTERVAL * count >= 10000) {
- freelog(LOG_FATAL,
- _("Failed to contact server \"%s\" at port "
- "%d as \"%s\" after %d attempts"),
- server_host, server_port, connect_name, count);
-
- }
-
- switch (try_to_connect(connect_name, errbuf, sizeof(errbuf))) {
- case 0: /* Success! */
- return;
- case ECONNREFUSED: /* Server not available (yet) - wait & retry */
- /*PORTME*/ schedule_timer
- (AUTOCONNECT_INTERVAL, try_to_autoconnect, NULL);
- default: /* All other errors are fatal */
- freelog(LOG_FATAL,
- _("Error contacting server \"%s\" at port %d "
- "as \"%s\":\n %s\n"),
- server_host, server_port, connect_name, errbuf);
- /*PORTME*/ exit_application(error code);
- }
-#endif
-}
-
-/**************************************************************************
- Start trying to autoconnect to civserver.
- Calls get_server_address(), then arranges for
- autoconnect_callback(), which calls try_to_connect(), to be called
- roughly every AUTOCONNECT_INTERVAL milliseconds, until success,
- fatal error or user intervention.
-**************************************************************************/
-void server_autoconnect()
-{
- char buf[512];
- int outcome;
-
- my_snprintf(buf, sizeof(buf),
- _("Auto-connecting to server \"%s\" at port %d "
- "as \"%s\" every %d.%d second(s) for %d times"),
- server_host, server_port, user_name,
- AUTOCONNECT_INTERVAL / 1000,AUTOCONNECT_INTERVAL % 1000,
- MAX_AUTOCONNECT_ATTEMPTS);
- append_output_window(buf);
-
- outcome = get_server_address(server_host, server_port, buf, sizeof(buf));
- if (outcome < 0) {
- freelog(LOG_FATAL,
- _("Error contacting server \"%s\" at port %d "
- "as \"%s\":\n %s\n"),
- server_host, server_port, user_name, buf);
- exit(EXIT_FAILURE);
- }
- try_to_autoconnect();
-}
-
/****************************************************************************
Set the list of available rulesets. The default ruleset should be
"default", and if the user changes this then set_ruleset() should be
Index: client/gui-sdl/connectdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/connectdlg.c,v
retrieving revision 1.24
diff -u -r1.24 connectdlg.c
--- client/gui-sdl/connectdlg.c 20 Nov 2004 21:27:17 -0000 1.24
+++ client/gui-sdl/connectdlg.c 29 Jul 2005 08:25:31 -0000
@@ -1150,71 +1150,3 @@
flush_all();
}
-/**************************************************************************
- Make an attempt to autoconnect to the server.
-**************************************************************************/
-bool try_to_autoconnect(void)
-{
- char errbuf[512];
- static int count = 0;
- static int warning_shown = 0;
-
- count++;
-
- if (count >= MAX_AUTOCONNECT_ATTEMPTS) {
- freelog(LOG_FATAL,
- _("Failed to contact server \"%s\" at port "
- "%d as \"%s\" after %d attempts"),
- server_host, server_port, user_name, count);
-
- exit(EXIT_FAILURE);
- }
-
- if(try_to_connect(user_name, errbuf, sizeof(errbuf))) {
- /* Server not available (yet) */
- if (!warning_shown) {
- freelog(LOG_NORMAL, _("Connection to server refused. "
- "Please start the server."));
- append_output_window(_("Connection to server refused. "
- "Please start the server."));
- warning_shown = 1;
- }
- return FALSE; /* Tells Client to keep calling this function */
- }
-
- /* Success! */
- return TRUE; /* Tells Client not to call this function again */
-}
-
-/**************************************************************************
- Start trying to autoconnect to civserver.
- Calls get_server_address(), then arranges for
- autoconnect_callback(), which calls try_to_connect(), to be called
- roughly every AUTOCONNECT_INTERVAL milliseconds, until success,
- fatal error or user intervention.
-**************************************************************************/
-void server_autoconnect()
-{
- char buf[512];
-
- my_snprintf(buf, sizeof(buf),
- _("Auto-connecting to server \"%s\" at port %d "
- "as \"%s\" every %d.%d second(s) for %d times"),
- server_host, server_port, user_name,
- AUTOCONNECT_INTERVAL / 1000, AUTOCONNECT_INTERVAL % 1000,
- MAX_AUTOCONNECT_ATTEMPTS);
- append_output_window(buf);
-
- if (get_server_address(server_host, server_port, buf, sizeof(buf)) < 0) {
- freelog(LOG_FATAL,
- _("Error contacting server \"%s\" at port %d "
- "as \"%s\":\n %s\n"),
- server_host, server_port, user_name, buf);
-
-
- exit(EXIT_FAILURE);
- }
- if (!try_to_autoconnect()) {
- add_autoconnect_to_timer();
- }
-}
Index: client/gui-stub/connectdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-stub/connectdlg.c,v
retrieving revision 1.13
diff -u -r1.13 connectdlg.c
--- client/gui-stub/connectdlg.c 28 Mar 2005 17:19:27 -0000 1.13
+++ client/gui-stub/connectdlg.c 29 Jul 2005 08:25:35 -0000
@@ -105,76 +105,3 @@
/* PORTME */
}
-
-/**************************************************************************
- Start trying to autoconnect to civserver.
- Calls get_server_address(), then arranges for
- autoconnect_callback(), which calls try_to_connect(), to be called
- roughly every AUTOCONNECT_INTERVAL milliseconds, until success,
- fatal error or user intervention.
-**************************************************************************/
-void server_autoconnect(void)
-{
- char buf[512];
- int outcome;
-
- my_snprintf(buf, sizeof(buf),
- _("Auto-connecting to server \"%s\" at port %d as \"%s\""),
- server_host, server_port, user_name);
- append_output_window(buf);
- outcome = get_server_address(server_host, server_port, buf, sizeof(buf));
- if (outcome < 0) {
- freelog(LOG_FATAL,
- _("Error contacting server \"%s\" at port %d "
- "as \"%s\":\n %s\n"),
- server_host, server_port, user_name, buf);
- exit(EXIT_FAILURE);
- }
- try_to_autoconnect();
-}
-
-/**************************************************************************
- Make an attempt to autoconnect to the server. If the server isn't
- there yet, arrange for this routine to be called again in about
- AUTOCONNECT_INTERVAL milliseconds. If anything else goes wrong, log
- a fatal error.
-
- Return FALSE iff autoconnect succeeds.
-**************************************************************************/
-static void try_to_autoconnect(void)
-{
- char errbuf[512];
- static int count = 0;
-
- count++;
-
- /* abort if after 10 seconds the server couldn't be reached */
-
- if (AUTOCONNECT_INTERVAL * count >= 10000) {
- freelog(LOG_FATAL,
- _("Failed to contact server \"%s\" at port "
- "%d as \"%s\" after %d attempts"),
- server_host, server_port, user_name, count);
- exit(EXIT_FAILURE);
- }
-
- switch (try_to_connect(user_name, errbuf, sizeof(errbuf))) {
- case 0:
- /* Success! */
- return;
- case ECONNREFUSED:
- /* Server not available (yet) - wait & retry */
-#if 0
- /* PORTME */
- schedule_timer(AUTOCONNECT_INTERVAL, try_to_autoconnect, NULL);
-#endif
- return;
- default:
- /* All other errors are fatal */
- freelog(LOG_FATAL,
- _("Error contacting server \"%s\" at port %d "
- "as \"%s\":\n %s\n"),
- server_host, server_port, user_name, errbuf);
- exit(EXIT_FAILURE);
- }
-}
Index: client/gui-win32/connectdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/connectdlg.c,v
retrieving revision 1.37
diff -u -r1.37 connectdlg.c
--- client/gui-win32/connectdlg.c 20 Jul 2005 02:04:31 -0000 1.37
+++ client/gui-win32/connectdlg.c 29 Jul 2005 08:25:42 -0000
@@ -659,87 +659,6 @@
}
/**************************************************************************
- Make an attempt to autoconnect to the server.
- (server_autoconnect() gets GTK to call this function every so often.)
-**************************************************************************/
-static int try_to_autoconnect()
-{
- char errbuf[512];
- static int count = 0;
-
- count++;
-
- if (count >= MAX_AUTOCONNECT_ATTEMPTS) {
- freelog(LOG_FATAL,
- _("Failed to contact server \"%s\" at port "
- "%d as \"%s\" after %d attempts"),
- server_host, server_port, user_name, count);
- exit(EXIT_FAILURE);
- }
-
- switch (try_to_connect(user_name, errbuf, sizeof(errbuf))) {
- case 0: /* Success! */
- return FALSE; /* Do not call this
- function again */
-#if 0
- case ECONNREFUSED: /* Server not available (yet) */
- return TRUE; /* Keep calling this function */
-#endif
- default: /* All other errors are fatal */
- freelog(LOG_FATAL,
- _("Error contacting server \"%s\" at port %d "
- "as \"%s\":\n %s\n"),
- server_host, server_port, user_name, errbuf);
- exit(EXIT_FAILURE);
- }
-}
-
-/**************************************************************************
-
-**************************************************************************/
-static void CALLBACK autoconnect_timer(HWND hwnd,UINT uMsg,
- UINT idEvent,DWORD dwTime)
-{
- printf("Timer\n");
- if (!try_to_autoconnect())
- KillTimer(NULL, autoconnect_timer_id);
-}
-
-/**************************************************************************
- Start trying to autoconnect to civserver. Calls
- get_server_address(), then arranges for try_to_autoconnect(), which
- calls try_to_connect(), to be called roughly every
- AUTOCONNECT_INTERVAL milliseconds, until success, fatal error or
- user intervention.
-**************************************************************************/
-void server_autoconnect()
-{
- char buf[512];
-
- my_snprintf(buf, sizeof(buf),
- _("Auto-connecting to server \"%s\" at port %d "
- "as \"%s\" every %d.%d second(s) for %d times"),
- server_host, server_port, user_name,
- AUTOCONNECT_INTERVAL / 1000,AUTOCONNECT_INTERVAL % 1000,
- MAX_AUTOCONNECT_ATTEMPTS);
- append_output_window(buf);
- if (get_server_address(server_host, server_port, buf, sizeof(buf)) < 0) {
- freelog(LOG_FATAL,
- _("Error contacting server \"%s\" at port %d "
- "as \"%s\":\n %s\n"),
- server_host, server_port, user_name, buf);
- exit(EXIT_FAILURE);
- }
- printf("server_autoconnect\n");
- if (try_to_autoconnect()) {
- printf("T2\n");
- autoconnect_timer_id = SetTimer(root_window, 3, AUTOCONNECT_INTERVAL,
- autoconnect_timer);
- }
-
-}
-
-/**************************************************************************
Handle the saving and loading functions.
**************************************************************************/
void handle_save_load(const char *title, bool is_save)
Index: client/gui-xaw/connectdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/connectdlg.c,v
retrieving revision 1.38
diff -u -r1.38 connectdlg.c
--- client/gui-xaw/connectdlg.c 29 May 2005 10:40:44 -0000 1.38
+++ client/gui-xaw/connectdlg.c 29 Jul 2005 08:25:47 -0000
@@ -529,74 +529,3 @@
*list=NULL;
return 0;
}
-
-/**************************************************************************
- Make an attempt to autoconnect to the server. If the server isn't
- there yet, get the Xt kit to call this routine again about
- AUTOCONNECT_INTERVAL milliseconds. If anything else goes wrong, log
- a fatal error.
-**************************************************************************/
-static void try_to_autoconnect(XtPointer data, XtIntervalId * id)
-{
- char errbuf[512];
- static int count = 0;
-
- count++;
-
- if (count >= MAX_AUTOCONNECT_ATTEMPTS) {
- freelog(LOG_FATAL,
- _("Failed to contact server \"%s\" at port "
- "%d as \"%s\" after %d attempts"),
- server_host, server_port, user_name, count);
- exit(EXIT_FAILURE);
- }
-
- switch (try_to_connect(user_name, errbuf, sizeof(errbuf))) {
- /* Success! */
- case 0:
- return;
-
- /* Server not available (yet) - wait & retry */
- case ECONNREFUSED:
- XtAppAddTimeOut(app_context,
- AUTOCONNECT_INTERVAL, try_to_autoconnect, NULL);
- break;
-
- /* All other errors are fatal */
- default:
- freelog(LOG_FATAL,
- _("Error contacting server \"%s\" at port %d "
- "as \"%s\":\n %s\n"),
- server_host, server_port, user_name, errbuf);
- exit(EXIT_FAILURE);
- }
-}
-
-/**************************************************************************
- Start trying to autoconnect to civserver.
- Calls get_server_address() then try_to_autoconnect().
-**************************************************************************/
-void server_autoconnect()
-{
- char buf[512];
- int outcome;
-
- my_snprintf(buf, sizeof(buf),
- _("Auto-connecting to server \"%s\" at port %d "
- "as \"%s\" every %d.%d second(s) for %d times"),
- server_host, server_port, user_name,
- AUTOCONNECT_INTERVAL / 1000,AUTOCONNECT_INTERVAL % 1000,
- MAX_AUTOCONNECT_ATTEMPTS);
- append_output_window(buf);
- outcome = get_server_address(server_host, server_port, buf, sizeof(buf));
- if (outcome < 0) {
- freelog(LOG_FATAL,
- _("Error contacting server \"%s\" at port %d "
- "as \"%s\":\n %s\n"),
- server_host, server_port, user_name, buf);
- exit(EXIT_FAILURE);
- }
-
- try_to_autoconnect(NULL, NULL);
- XtSetSensitive(toplevel, True);
-}
Index: client/include/connectdlg_g.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/include/connectdlg_g.h,v
retrieving revision 1.7
diff -u -r1.7 connectdlg_g.h
--- client/include/connectdlg_g.h 5 Feb 2005 07:15:37 -0000 1.7
+++ client/include/connectdlg_g.h 29 Jul 2005 08:25:47 -0000
@@ -17,7 +17,6 @@
void really_close_connection_dialog(void);
void gui_server_connect(void);
-void server_autoconnect(void);
void gui_set_rulesets(int num_rulesets, char **rulesets);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#13561) Move autoconnect code to the common client code,
Mateusz Stefek <=
|
|