Author: cazfi
Date: Wed Aug 12 18:01:34 2015
New Revision: 29475

URL: http://svn.gna.org/viewcvs/freeciv?rev=29475&view=rev
Log:
Added client option to automatically update default server and port options to 
match
previously used server.

Requested by Markus Raab <deb...@markus-raab.org>

See bug #21752

Modified:
    branches/S2_6/client/client_main.c
    branches/S2_6/client/clinet.c
    branches/S2_6/client/options.c
    branches/S2_6/client/options.h

Modified: branches/S2_6/client/client_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/client_main.c?rev=29475&r1=29474&r2=29475&view=diff
==============================================================================
--- branches/S2_6/client/client_main.c  (original)
+++ branches/S2_6/client/client_main.c  Wed Aug 12 18:01:34 2015
@@ -615,7 +615,9 @@
     sz_strlcpy(sound_plugin_name, options.default_sound_plugin_name); 
   }
   if (server_host[0] == '\0') {
-    sz_strlcpy(server_host, options.default_server_host); 
+    sz_strlcpy(server_host, options.default_server_host);
+  } else if (options.use_prev_server) {
+    sz_strlcpy(options.default_server_host, server_host);
   }
   if (user_name[0] == '\0') {
     sz_strlcpy(user_name, options.default_user_name); 
@@ -639,6 +641,8 @@
   }
   if (server_port == -1) {
     server_port = options.default_server_port;
+  } else if (options.use_prev_server) {
+    options.default_server_port = server_port;
   }
 
   /* This seed is not saved anywhere; randoms in the client should

Modified: branches/S2_6/client/clinet.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/clinet.c?rev=29475&r1=29474&r2=29475&view=diff
==============================================================================
--- branches/S2_6/client/clinet.c       (original)
+++ branches/S2_6/client/clinet.c       Wed Aug 12 18:01:34 2015
@@ -252,6 +252,11 @@
     return -1;
   }
 
+  if (options.use_prev_server) {
+    sz_strlcpy(options.default_server_host, hostname);
+    options.default_server_port = port;
+  }
+
   return 0;
 }
 

Modified: branches/S2_6/client/options.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/options.c?rev=29475&r1=29474&r2=29475&view=diff
==============================================================================
--- branches/S2_6/client/options.c      (original)
+++ branches/S2_6/client/options.c      Wed Aug 12 18:01:34 2015
@@ -79,6 +79,8 @@
   .default_chat_logfile = GUI_DEFAULT_CHAT_LOGFILE,
 
   .save_options_on_exit = TRUE,
+
+  .use_prev_server = FALSE,
 
 /** Migrations **/
   .gui_gtk3_migrated_from_gtk2 = FALSE,
@@ -1751,6 +1753,14 @@
                     "in the connection dialogs or with the -a command-line "
                     "parameter."),
                  COC_NETWORK, GUI_STUB, NULL, NULL),
+  GEN_BOOL_OPTION(use_prev_server, N_("Default to previously used server"),
+                  N_("Automatically update \"Server\" and \"Server port\" "
+                     "options to match your latest connection, so by "
+                     "default you connect to the same server you used "
+                     "on the previous run. You should enable "
+                     "saving options on exit too, so that the automatic "
+                     "updates to the options get saved too."),
+                  COC_NETWORK, GUI_STUB, NULL, NULL),
   GEN_STR_OPTION(default_server_host,
                  N_("Server"),
                  N_("This is the default server hostname that will be used "

Modified: branches/S2_6/client/options.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/options.h?rev=29475&r1=29474&r2=29475&view=diff
==============================================================================
--- branches/S2_6/client/options.h      (original)
+++ branches/S2_6/client/options.h      Wed Aug 12 18:01:34 2015
@@ -89,7 +89,8 @@
 {
   char default_user_name[512];
   char default_server_host[512];
-  int default_server_port; 
+  int  default_server_port;
+  bool use_prev_server;
   char default_metaserver[512];
   char default_tileset_name[512];
   char default_sound_set_name[512];


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to