Complete.Org: Mailing Lists: Archives: freeciv-dev: June 2006:
[Freeciv-Dev] (PR#17703) better GGZ-mode tests
Home

[Freeciv-Dev] (PR#17703) better GGZ-mode tests

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#17703) better GGZ-mode tests
From: "Jason Dorje Short" <jdorje@xxxxxxxxx>
Date: Wed, 7 Jun 2006 12:12:35 -0700
Reply-to: bugs@xxxxxxxxxxx

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

This patch simplifies the checks for GGZ mode slightly.  Instead of 
using a command line parameter (--zone) it uses the built-in GGZ 
functions to check for GGZ mode (i.e., to check if the program was 
launched by GGZ).

This patch is probably only for the dev branch.

-jason

Index: server/civserver.c
===================================================================
--- server/civserver.c  (revision 12012)
+++ server/civserver.c  (working copy)
@@ -184,10 +184,6 @@
       srvarg.saves_pathname = option; /* Never freed. */
     } else if (is_option("--version", argv[inx]))
       showvers = TRUE;
-#ifdef GGZ_SERVER
-    else if (is_option("--zone", argv[inx]))
-      with_ggz = TRUE;
-#endif
     else {
       fc_fprintf(stderr, _("Error: unknown option '%s'\n"), argv[inx]);
       showhelp = TRUE;
@@ -247,9 +243,6 @@
     fc_fprintf(stderr,
               _("  -R, --Ranklog FILE\tUse FILE as ranking logfile\n"));
     fc_fprintf(stderr, _("  -v, --version\t\tPrint the version number\n"));
-#ifdef GGZ_SERVER
-    fc_fprintf(stderr, _("  -z, --zone\t\tEnable GGZ mode\n"));
-#endif
     fc_fprintf(stderr, _("Report bugs to <%s>.\n"), BUG_EMAIL_ADDRESS);
     exit(EXIT_SUCCESS);
   }
Index: server/ggzserver.c
===================================================================
--- server/ggzserver.c  (revision 12012)
+++ server/ggzserver.c  (working copy)
@@ -177,6 +177,8 @@
 ****************************************************************************/
 void ggz_initialize(void)
 {
+  with_ggz = ggzdmod_is_ggz_mode();
+
   if (with_ggz) {
     int ggz_socket;
 
Index: data/civclient.dsc.in
===================================================================
--- data/civclient.dsc.in       (revision 12012)
+++ data/civclient.dsc.in       (working copy)
@@ -2,7 +2,7 @@
 
 [ModuleInfo]
 Author = See http://www.freeciv.org/people.phtml
-CommandLine = @prefix@/bin/civclient --zone
+CommandLine = @prefix@/bin/civclient
 Frontend = any
 Homepage = http://www.freeciv.org/
 Name = Freeciv
Index: client/gui-gtk-2.0/gui_main.c
===================================================================
--- client/gui-gtk-2.0/gui_main.c       (revision 12012)
+++ client/gui-gtk-2.0/gui_main.c       (working copy)
@@ -1163,7 +1163,7 @@
 ****************************************************************************/
 static void ggz_game_launched(void)
 {
-  ggz_initialize();
+  ggz_begin();
 }
 #endif
 
Index: client/ggzclient.c
===================================================================
--- client/ggzclient.c  (revision 12012)
+++ client/ggzclient.c  (working copy)
@@ -15,21 +15,54 @@
 #include <config.h>
 #endif
 
-#ifdef GGZ_CLIENT
-
-#include <ggzmod.h>
-
 #include "fciconv.h"
 #include "fcintl.h"
+#include "rand.h"
 
 #include "gui_main_g.h"
 
 #include "clinet.h"
 #include "ggzclient.h"
 
+#ifdef GGZ_CLIENT
+#  include <ggzmod.h>
+#endif
 
-bool with_ggz = FALSE;
+#ifdef GGZ_GTK
+#  include <ggz-embed.h>
+#endif
 
+
+bool with_ggz;
+
+/****************************************************************************
+  Initializations for GGZ, including checks to see if we are being run from
+  inside GGZ.
+****************************************************************************/
+void ggz_initialize(void)
+{
+#ifdef GGZ_CLIENT
+  with_ggz = ggzmod_is_ggz_mode();
+
+  if (with_ggz) {
+    ggz_begin();
+  }
+#endif
+
+#ifdef GGZ_GTK
+  {
+    char buf[128];
+
+    user_username(buf, sizeof(buf));
+    cat_snprintf(buf, sizeof(buf), "%d", myrand(100));
+    ggz_embed_ensure_server("Pubserver", "pubserver.freeciv.org",
+                           5688, buf);
+  }
+#endif
+}
+
+#ifdef GGZ_CLIENT
+
 static GGZMod *ggzmod;
 
 /****************************************************************************
@@ -58,9 +91,9 @@
 }
 
 /****************************************************************************
-  Connect to the GGZ client, if GGZ is being used.
+  Connect to the GGZ client.
 ****************************************************************************/
-void ggz_initialize(void)
+void ggz_begin(void)
 {
   int ggz_socket;
 
Index: client/ggzclient.h
===================================================================
--- client/ggzclient.h  (revision 12012)
+++ client/ggzclient.h  (working copy)
@@ -13,24 +13,24 @@
 #ifndef FC__GGZCLIENT_H
 #define FC__GGZCLIENT_H
 
-#ifdef GGZ_CLIENT
-
 #include "shared.h"
 
 extern bool with_ggz;
 
 void ggz_initialize(void);
+
+#ifdef GGZ_CLIENT
+
+void ggz_begin(void);
 void input_from_ggz(int socket);
 
 bool user_get_rating(const char *name, int *rating);
 bool user_get_record(const char *name,
                     int *wins, int *losses, int *ties, int *forfeits);
 
-
 #else
 
-#  define with_ggz FALSE
-#  define ggz_initialize() (void)0
+#  define ggz_begin() (void)0
 #  define input_from_ggz(socket) (void)0
 #  define user_get_rating(p, r) (FALSE)
 #  define user_get_record(p, w, l, t, f) (FALSE)
Index: client/civclient.c
===================================================================
--- client/civclient.c  (revision 12012)
+++ client/civclient.c  (working copy)
@@ -25,10 +25,6 @@
 #include <stdlib.h>
 #include <time.h>
 
-#ifdef GGZ_GTK
-#  include <ggz-embed.h>
-#endif
-
 #include "capstr.h"
 #include "dataio.h"
 #include "diptreaty.h"
@@ -227,9 +223,6 @@
       fc_fprintf(stderr, _("  -t, --tiles FILE\t"
                           "Use data file FILE.tilespec for tiles\n"));
       fc_fprintf(stderr, _("  -v, --version\t\tPrint the version number\n"));
-#ifdef GGZ_CLIENT
-    fc_fprintf(stderr, _("  -z, --zone\t\tEnable GGZ mode\n"));
-#endif
       fc_fprintf(stderr, _("      --\t\t"
                           "Pass any following options to the UI.\n"
                           "\t\t\tTry \"%s -- --help\" for more.\n"), argv[0]);
@@ -280,10 +273,6 @@
     } else if ((option = get_option_malloc("--tiles", argv, &i, argc))) {
       sz_strlcpy(tileset_name, option);
       free(option);
-#ifdef GGZ_CLIENT
-    } else if (is_option("--zone", argv[i])) {
-      with_ggz = TRUE;
-#endif
     } else if (is_option("--", argv[i])) {
       ui_separator = TRUE;
     } else {
@@ -360,20 +349,8 @@
   audio_real_init(sound_set_name, sound_plugin_name);
   audio_play_music("music_start", NULL);
 
-  if (with_ggz) {
-    ggz_initialize();
-  }
-#ifdef GGZ_GTK
-  {
-    char buf[128];
+  ggz_initialize();
 
-    user_username(buf, sizeof(buf));
-    cat_snprintf(buf, sizeof(buf), "%d", myrand(100));
-    ggz_embed_ensure_server("Pubserver", "pubserver.freeciv.org",
-                           5688, buf);
-  }
-#endif
-
   /* run gui-specific client */
   ui_main(argc, argv);
 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#17703) better GGZ-mode tests, Jason Dorje Short <=