1 /*
2  * XPilot NG, a multiplayer space war game.
3  *
4  * Copyright (C) 1991-2001 by
5  *
6  *      Bj�rn Stabell        <bjoern@xpilot.org>
7  *      Ken Ronny Schouten   <ken@xpilot.org>
8  *      Bert Gijsbers        <bert@xpilot.org>
9  *      Dick Balaska         <dick@xpilot.org>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24  */
25 
26 #include "xpclient_x11.h"
27 
28 char			**Argv;
29 int			Argc;
30 
printfile(const char * filename)31 static void printfile(const char *filename)
32 {
33     FILE		*fp;
34     int			c;
35 
36     if ((fp = fopen(filename, "r")) == NULL)
37 	return;
38 
39     while ((c = fgetc(fp)) != EOF)
40 	putchar(c);
41 
42     fclose(fp);
43 }
44 
Program_name(void)45 const char *Program_name(void)
46 {
47     return "xpilot-ng-x11";
48 }
49 
50 /*
51  * Oh glorious main(), without thee we cannot exist.
52  */
main(int argc,char * argv[])53 int main(int argc, char *argv[])
54 {
55     int result, retval = 1;
56     bool auto_shutdown = false;
57     Connect_param_t *conpar = &connectParam;
58 
59     /*
60      * --- Output copyright notice ---
61      */
62     printf("  " COPYRIGHT ".\n"
63 	   "  " TITLE " comes with ABSOLUTELY NO WARRANTY; "
64 	      "for details see the\n"
65 	   "  provided COPYING file.\n\n");
66     if (strcmp(Conf_localguru(), PACKAGE_BUGREPORT))
67 	printf("  %s is responsible for the local installation.\n\n",
68 	       Conf_localguru());
69 
70     Conf_print();
71 
72     Argc = argc;
73     Argv = argv;
74 
75     /*
76      * --- Miscellaneous initialization ---
77      */
78     init_error(argv[0]);
79 
80     seedMT( (unsigned)time(NULL) ^ Get_process_id());
81 
82     memset(conpar, 0, sizeof(Connect_param_t));
83 
84     /*
85      * --- Create global option array ---
86      */
87     Store_default_options();
88     Store_X_options();
89     Store_hud_options();
90     Store_paintradar_options();
91     Store_xpaint_options();
92     Store_guimap_options();
93     Store_guiobject_options();
94     Store_talk_macro_options();
95     Store_key_options();
96     Store_record_options();
97     Store_color_options();
98 
99     /*
100      * --- Check commandline arguments and resource files ---
101      */
102     memset(&xpArgs, 0, sizeof(xp_args_t));
103     Parse_options(&argc, argv);
104     /*strcpy(clientname,connectParam.nick_name); */
105 
106     Config_init();
107     Handle_X_options();
108 
109     /* CLIENTRANK */
110     Init_saved_scores();
111 
112     if (xpArgs.list_servers)
113 	xpArgs.auto_connect = true;
114 
115     if (xpArgs.shutdown_reason[0] != '\0') {
116 	auto_shutdown = true;
117 	xpArgs.auto_connect = true;
118     }
119 
120     /*
121      * --- Message of the Day ---
122      */
123     printfile(Conf_localmotdfile());
124 
125     if (xpArgs.text || xpArgs.auto_connect || argv[1]) {
126 	if (xpArgs.list_servers)
127 	    printf("LISTING AVAILABLE SERVERS:\n");
128 
129 	result = Contact_servers(argc - 1, &argv[1],
130 				 xpArgs.auto_connect, xpArgs.list_servers,
131 				 auto_shutdown, xpArgs.shutdown_reason,
132 				 0, NULL, NULL, NULL, NULL,
133 				 conpar);
134     }
135     else
136 	result = Welcome_screen(conpar);
137 
138     if (result == 1)
139 	retval = Join(conpar);
140 
141     if (instruments.clientRanker)
142 	Print_saved_scores();
143 
144     return retval;
145 }
146