diff -u2rP -X ../diff-ignore ../freeciv/client/civclient.c ./client/civclient.c --- ../freeciv/client/civclient.c Mon Dec 27 22:02:03 1999 +++ ./client/civclient.c Sun Jan 23 20:50:08 2000 @@ -54,4 +54,7 @@ #include "plrdlg_g.h" #include "repodlgs_g.h" +#include "support.h" +#include "tilespec.h" +#include "mem.h" #include "civclient.h" @@ -65,4 +68,10 @@ enum client_states client_state=CLIENT_BOOT_STATE; +extern char metaserver []; +extern char server_host []; +extern char name []; +extern int server_port; +static char * tile_set_name; + int seconds_to_turndone; @@ -75,43 +84,78 @@ ... **************************************************************************/ -char usage[] = -N_("Usage: %s [-hlNpsv][--help] [--log] [--name] [--port]\n\t [--server] [--debug] [--version] [--tiles]\n"); - -/************************************************************************** -... -**************************************************************************/ int main(int argc, char *argv[]) { + int i; + int loglevel; + char *logfile=NULL; + char *option=NULL; + init_nls(); dont_run_as_root(argv[0], "freeciv_client"); + + /* set default argument values */ + loglevel=LOG_NORMAL; + server_port=DEFAULT_SOCK_PORT; + mystrlcpy(server_host, "localhost", 512); + mystrlcpy(metaserver, METALIST_ADDR, 256); + name[0] = '\0'; + + i = 1; - if(argc>1 && strstr(argv[1],"-help")) { - fprintf(stderr, _("This is the Freeciv client\n")); - fprintf(stderr, _(usage), argv[0]); - fprintf(stderr, _(" -help\t\tPrint a summary of the options\n")); - fprintf(stderr, _(" -log F\tUse F as logfile\n")); - fprintf(stderr, _(" -name N\tUse N as name\n")); - fprintf(stderr, _(" -port N\tconnect to port N\n")); - fprintf(stderr, _(" -server S\tConnect to the server at S\n")); - fprintf(stderr, _(" -metaserver A\tConnect to the metaserver at A\n")); + while (i < argc) { + if (is_option("--help", argv[i])) { + fprintf(stderr, _("Usage: %s [option ...]\nValid options are:\n"), argv[0]); + fprintf(stderr, _(" -h, --help\t\tPrint a summary of the options\n")); + fprintf(stderr, _(" -l, --log==FILE\tUse FILE as logfile\n")); + fprintf(stderr, _(" -n, --name=NAME\tUse NAME as name\n")); + fprintf(stderr, _(" -p, --port=PORT\tconnect to port PORT\n")); + fprintf(stderr, _(" -s, --server=HOST\tConnect to the server at HOST\n")); + fprintf(stderr, _(" -m, --meta=HOST\tConnect to the metaserver at HOST\n")); +#ifdef SOUND + fprintf(stderr, _(" -s, --sound=FILE F\tRead sound information from FILE\n")); +#endif #ifdef DEBUG - fprintf(stderr, _(" -debug N\tSet debug log level (0,1,2,3," - "or 3:file1,min,max:...)\n")); + fprintf(stderr, _(" -d, --debug=NUM\tSet debug log level (0,1,2,3," + "or 3:file1,min,max:...)\n")); #else - fprintf(stderr, _(" -debug N\tSet debug log level (0,1,2)\n")); + fprintf(stderr, _(" -d, --debug=NUM\tSet debug log level (0,1,2)\n")); #endif - fprintf(stderr, _(" -version\tPrint the version number\n")); - fprintf(stderr, _(" -tiles D\tLook in data subdirectory D for the tiles\n")); - fprintf(stderr, _("Report bugs to <%s>.\n"), BUG_EMAIL_ADDRESS); - exit(0); - } - - if(argc>1 && strstr(argv[1],"-version")) { + fprintf(stderr, _(" -v, --version\tPrint the version number\n")); + fprintf(stderr, _(" -t, --tiles=DIR\tLook in data subdirectory DIR for tiles\n")); + } else if (is_option("--version",argv[i])) { fprintf(stderr, "%s\n", FREECIV_NAME_VERSION); exit(0); + } else if ((option = get_option("--log",argv,&i,argc)) != NULL) + logfile = mystrdup(option); /* never free()d */ + else if ((option = get_option("--name",argv,&i,argc)) != NULL) + mystrlcpy(name, option, 512); + else if ((option = get_option("--metaserver",argv,&i,argc)) != NULL) + mystrlcpy(metaserver, option, 256); + else if ((option = get_option("--port",argv,&i,argc)) != NULL) + server_port=atoi(option); + else if ((option = get_option("--server",argv,&i,argc)) != NULL) + mystrlcpy(server_host, option, 512); + else if ((option = get_option("--debug",argv,&i,argc)) != NULL) { + loglevel=log_parse_level_str(option); + if (loglevel==-1) { + exit(1); + } + } else if ((option = get_option("--tiles",argv,&i,argc)) != NULL) { + tile_set_name=option; + } else { + fprintf(stderr, _("Unrecognized option: \"%s\"\n"), argv[i]); + exit(1); + } + i++; + } /* of while */ + + log_init(logfile, loglevel, NULL); + + /* after log_init: */ + if (name[0] == '\0') { + mystrlcpy(name, user_username(), 512); } - /* audio_init(); */ init_messages_where(); init_our_capability(); @@ -122,7 +166,9 @@ mysrand(time(NULL)); + boot_help_texts(); + tilespec_read_toplevel(tile_set_name); /* get tile sizes etc */ + ui_main(argc, argv); return 0; - /* audio_term(); */ } diff -u2rP -X ../diff-ignore ../freeciv/client/gui-gtk/gui_main.c ./client/gui-gtk/gui_main.c --- ../freeciv/client/gui-gtk/gui_main.c Mon Jan 3 13:47:20 2000 +++ ./client/gui-gtk/gui_main.c Sun Jan 23 20:17:26 2000 @@ -54,4 +54,5 @@ #include "options.h" #include "spaceshipdlg.h" +#include "mem.h" #include "tilespec.h" @@ -70,10 +71,4 @@ -extern char metaserver []; -extern char server_host []; -extern char name []; -extern int server_port; -static char * tile_set_name; - extern enum client_states client_state; @@ -158,24 +153,11 @@ /************************************************************************** - Print the usage information, including one line help on each option, + Print extra usage information, including one line help on each option, to stderr. **************************************************************************/ static void print_usage(const char *argv0) { - fprintf(stderr, _("Usage: %s [option ...]\nValid options are:\n"), argv0); - fprintf(stderr, _(" -h, --help\t\tPrint a summary of the options.\n")); - fprintf(stderr, _(" -l, --log=FILE\tUse FILE as logfile.\n")); - fprintf(stderr, _(" -N, --Name=NAME\tUse NAME.\n")); - fprintf(stderr, _(" -p, --port=PORT\tConnect to PORT.\n")); - fprintf(stderr, _(" -s, --server=SERVER\tConnect to the server SERVER.\n")); - fprintf(stderr, _(" -m, --metaserver=METASERVER\tSet metaserver address to METASERVER.\n")); -#ifdef DEBUG - fprintf(stderr, _(" -d, --debug=LEVEL\tSet debug log LEVEL (0,1,2,3," - "or 3:file1,min,max:...)\n")); -#else - fprintf(stderr, _(" -d, --debug=LEVEL\tSet debug log LEVEL (0,1,2).\n")); -#endif - fprintf(stderr, _(" -t, --tiles=DIR\tLook in directory DIR for the tiles.\n")); - fprintf(stderr, _(" -v, --version\t\tPrint the version number.\n")); + /* add client-specific usage information here */ + fprintf(stderr, _("Report bugs to <%s>.\n"), BUG_EMAIL_ADDRESS); } @@ -185,57 +167,16 @@ static void parse_options(int argc, char **argv) { - char *logfile = NULL; - char *option=NULL; /* really use as a pointer */ - int loglevel; int i; - /* set default argument values */ - loglevel=LOG_NORMAL; - server_port=DEFAULT_SOCK_PORT; - mystrlcpy(server_host, "localhost", 512); - mystrlcpy(metaserver, METALIST_ADDR, 256); - name[0] = '\0'; - i = 1; while (i < argc) { if (is_option("--help", argv[i])) - { + { print_usage(argv[0]); exit(0); - } - else if (is_option("--version",argv[i])) - { - fprintf(stderr, "%s\n", FREECIV_NAME_VERSION); - exit(0); - } - else if ((option = get_option("--log",argv,&i,argc)) != NULL) - logfile = mystrdup(option); /* never free()d */ - else if ((option = get_option("--name",argv,&i,argc)) != NULL) - mystrlcpy(name, option, 512); - else if ((option = get_option("--metaserver",argv,&i,argc)) != NULL) - mystrlcpy(metaserver, option, 256); - else if ((option = get_option("--port",argv,&i,argc)) != NULL) - server_port=atoi(option); - else if ((option = get_option("--server",argv,&i,argc)) != NULL) - mystrlcpy(server_host, option, 512); - else if ((option = get_option("--debug",argv,&i,argc)) != NULL) - { - loglevel=log_parse_level_str(option); - if (loglevel==-1) { - exit(1); - } } - else if ((option = get_option("--tiles",argv,&i,argc)) != NULL) - tile_set_name=option; i += 1; } - - log_init(logfile, loglevel, NULL); - - /* after log_init: */ - if (name[0] == '\0') { - mystrlcpy(name, user_username(), 512); - } } @@ -601,8 +542,4 @@ gtk_init(&argc, &argv); - boot_help_texts(); /* after log_init */ - - tilespec_read_toplevel(tile_set_name); /* get tile sizes etc */ - display_color_type=get_visual(); diff -u2rP -X ../diff-ignore ../freeciv/client/gui-mui/gui_main.c ./client/gui-mui/gui_main.c --- ../freeciv/client/gui-mui/gui_main.c Thu Jan 6 13:05:00 2000 +++ ./client/gui-mui/gui_main.c Sun Jan 23 20:41:48 2000 @@ -80,32 +80,14 @@ -extern char metaserver[]; -extern char server_host[]; -extern char name[]; -extern int server_port; -static char *tile_set_name; extern int seconds_to_turndone; /************************************************************************** - Print the usage information, including one line help on each option, + Print extra usage information, including one line help on each option, to stderr. **************************************************************************/ static void print_usage(const char *argv0) { - fprintf(stderr, "Usage: %s [option ...]\nValid options are:\n", argv0); - fprintf(stderr, " -h, --help\t\tPrint a summary of the options.\n"); - fprintf(stderr, " -l, --log=FILE\tUse FILE as logfile.\n"); - fprintf(stderr, " -N, --Name=NAME\tUse NAME.\n"); - fprintf(stderr, " -p, --port=PORT\tConnect to PORT.\n"); - fprintf(stderr, " -s, --server=SERVER\tConnect to the server SERVER.\n"); - fprintf(stderr, " -m, --metaserver=METASERVER\tSet metaserver address to METASERVER.\n"); -#ifdef DEBUG - fprintf(stderr, " -d, --debug=LEVEL\tSet debug log LEVEL (0,1,2,3," - "or 3:file1,min,max:...)\n"); -#else - fprintf(stderr, " -d, --debug=LEVEL\tSet debug log LEVEL (0,1,2).\n"); -#endif - fprintf(stderr, " -t, --tiles=DIR\tLook in directory DIR for the tiles.\n"); - fprintf(stderr, " -v, --version\t\tPrint the version number.\n"); + /* add client-specific usage information here */ + fprintf(stderr, _("Report bugs to <%s>.\n"), BUG_EMAIL_ADDRESS); } @@ -115,16 +97,6 @@ static void parse_options(int argc, char **argv) { - char *logfile = NULL; - char *option = NULL; /* really use as a pointer */ - int loglevel; int i; - /* set default argument values */ - loglevel = LOG_NORMAL; - server_port = DEFAULT_SOCK_PORT; - strcpy(server_host, "localhost"); - strcpy(metaserver, METALIST_ADDR); - name[0] = '\0'; - i = 1; while (i < argc) @@ -135,39 +107,6 @@ exit(0); } - else if (is_option("--version", argv[i])) - { - fprintf(stderr, "%s\n", FREECIV_NAME_VERSION); - exit(0); - } - else if ((option = get_option("--log", argv, &i, argc)) != NULL) - logfile = mystrdup(option); /* never free()d */ - else if ((option = get_option("--name", argv, &i, argc)) != NULL) - strcpy(name, option); - else if ((option = get_option("--metaserver", argv, &i, argc)) != NULL) - strcpy(metaserver, option); - else if ((option = get_option("--port", argv, &i, argc)) != NULL) - server_port = atoi(option); - else if ((option = get_option("--server", argv, &i, argc)) != NULL) - strcpy(server_host, option); - else if ((option = get_option("--debug", argv, &i, argc)) != NULL) - { - loglevel = log_parse_level_str(option); - if (loglevel == -1) - { - exit(1); - } - } - else if ((option = get_option("--tiles", argv, &i, argc)) != NULL) - tile_set_name = option; i += 1; } - - log_init(logfile, loglevel, NULL); - - /* after log_init: */ - if (name[0] == '\0') - { - strcpy(name, user_username()); - } } @@ -1297,6 +1236,4 @@ { parse_options(argc, argv); - boot_help_texts(); /* after log_init */ - tilespec_read_toplevel(tile_set_name); /* get tile sizes etc */ atexit(ui_exit); diff -u2rP -X ../diff-ignore ../freeciv/client/gui-xaw/gui_main.c ./client/gui-xaw/gui_main.c --- ../freeciv/client/gui-xaw/gui_main.c Mon Jan 3 13:47:26 2000 +++ ./client/gui-xaw/gui_main.c Sun Jan 23 20:33:19 2000 @@ -67,10 +67,4 @@ extern String fallback_resources[]; -/* in civclient.c; FIXME hardcoded sizes */ -extern char name[]; -extern char server_host[]; -extern char metaserver[]; -extern int server_port; - extern int num_units_below; @@ -239,9 +233,8 @@ void ui_main(int argc, char *argv[]) { - int i, loglevel; + int i; Pixmap icon_pixmap; XtTranslations TextFieldTranslations; Dimension w,h; - char *tile_set_name = NULL; /* include later - pain to see the warning at every run */ @@ -261,10 +254,4 @@ XtNumber(resources), NULL, 0); - loglevel = log_parse_level_str(appResources.loglevel_str); - if (loglevel==-1) { - exit(1); - } - log_init(appResources.logfile, loglevel, NULL); - /* XSynchronize(display, 1); XSetErrorHandler(myerr);*/ @@ -292,32 +279,4 @@ } - if(appResources.name) { - mystrlcpy(name, appResources.name, 512); - } else { - mystrlcpy(name, user_username(), 512); - } - - if(appResources.server) - mystrlcpy(server_host, appResources.server, 512); - else { - mystrlcpy(server_host, "localhost", 512); - } - - if(appResources.metaserver) - mystrlcpy(metaserver, appResources.metaserver, 256); - else { - mystrlcpy(metaserver, METALIST_ADDR, 256); - } - - if(appResources.port) - server_port=appResources.port; - else - server_port=DEFAULT_SOCK_PORT; - - if(appResources.tileset) - tile_set_name=appResources.tileset; - - boot_help_texts(); /* after log_init */ - display = XtDisplay(toplevel); screen_number=XScreenNumberOfScreen(XtScreen(toplevel)); @@ -326,5 +285,4 @@ display_color_type=get_visual(); - if(display_color_type!=COLOR_DISPLAY) { @@ -340,9 +298,4 @@ init_color_system(); - - - /* get tile sizes etc, required for setup_widgets: */ - /* also, get cityname font name, required to load the font: */ - tilespec_read_toplevel(tile_set_name); {