annotate main.c @ 3:5a977ccbc7a9 default tip

Empty changelog
author darius
date Sat, 06 Dec 1997 05:41:29 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1 /* $Id: main.c,v 1.1.1.1 1997/12/06 05:41:29 darius Exp $ */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
3 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
4 * main.c
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
5 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
6 #include "copyright.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
7
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
8 #include <stdio.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
9 #include <string.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
10 #include <sys/types.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
11 #include <signal.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
12 #include <setjmp.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
13 #include <pwd.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
14 #ifdef hpux
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
15 #include <time.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
16 #else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
17 #include <sys/time.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
18 #include <sys/wait.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
19 #endif /* hpux */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
20 #include "Wlib.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
21 #include "defs.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
22 #include "struct.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
23 #include "data.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
24 #include "packets.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
25 #include "proto.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
26 #include "gameconf.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
27 #ifdef SOUND
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
28 #include "Slib.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
29 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
30 #include "sound.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
31
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
32 jmp_buf env;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
33
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
34 #ifdef AMIGA
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
35 /* needed for metafork... implemented by running a whole new copy
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
36 don't honestly know why I bothered ;-) */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
37 char **command_line;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
38 int global_argc;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
39 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
40
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
41 #ifdef GATEWAY
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
42 #define DEFAULT_GATEWAY "atlgw" /* for Quar */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
43
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
44 static char *get_gw P((void));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
45 static unsigned long mkaddr P((char *m));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
46 static void getUdpPort P((void));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
47 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
48
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
49 extern int UdpLocalPort;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
50 /* Prototypes */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
51 static void printUsage P((char *prog));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
52 static void show_credits ();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
53
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
54 int
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
55 main(argc, argv)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
56 int argc;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
57 char **argv;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
58 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
59 int intrupt();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
60 int team, s_type;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
61 char *dpyname = NULL;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
62 int usage = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
63 int err = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
64 char *name, *ptr, *cp;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
65 #if !defined(NeXT) && !defined(RS6K) && !defined(SVR4)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
66 char *rindex();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
67 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
68 struct passwd *pwent;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
69 int passive = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
70 #ifdef METASERVER
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
71 int usemeta = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
72 #endif /* METASERVER */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
73 /* char *defaultsFile=NULL;*/
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
74
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
75 pseudo[0] = defpasswd[0] = '\0';
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
76
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
77 #ifdef AMIGA
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
78 command_line = argv;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
79 global_argc=argc;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
80 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
81
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
82 name = *argv++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
83 argc--;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
84 if ((ptr = rindex(name, '/')) != NULL)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
85 name = ptr + 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
86 #ifdef GATEWAY
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
87 netaddr = -1; /* special NULL address */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
88 serverName = get_gw(); /* default machine is gw */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
89 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
90 while (*argv) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
91 if (**argv != '-') {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
92 serverName = *argv; /* don't abort argument processing */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
93 argv++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
94 argc--;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
95 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
96 ++*argv;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
97
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
98 argc--;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
99 ptr = *argv++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
100 while (*ptr) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
101 switch (*ptr) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
102 case 'C': /* character name */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
103 (void) strncpy(pseudo, *argv, sizeof(pseudo));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
104 argv++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
105 argc--;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
106 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
107
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
108 case 'c': /* Credits */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
109 show_credits();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
110 exit (0);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
111 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
112
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
113 case 'P': /* authorization password */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
114 (void) strncpy(defpasswd, *argv, sizeof(defpasswd));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
115 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
116 int i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
117 for (i = 0; (*argv)[i]; i++)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
118 (*argv)[i] = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
119 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
120 argv++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
121 argc--;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
122 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
123
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
124 case 'u':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
125 usage++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
126 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
127 case 's':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
128 if (*argv) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
129 xtrekPort = atoi(*argv);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
130 passive = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
131 argv++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
132 argc--;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
133 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
134 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
135 case 'p':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
136 if (*argv) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
137 xtrekPort = atoi(*argv);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
138 argv++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
139 argc--;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
140 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
141 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
142 case 'd':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
143 dpyname = *argv;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
144 argc--;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
145 argv++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
146 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
147 #ifdef METASERVER
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
148 case 'm':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
149 usemeta = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
150 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
151 #endif /* METASERVER */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
152 case 'h':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
153 serverName = *argv;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
154 if (!serverName)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
155 err++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
156 #ifdef GATEWAY
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
157 gw_mach = *argv;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
158 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
159 argc--;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
160 argv++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
161 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
162 #ifdef GATEWAY
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
163 case 'H':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
164 netaddr = mkaddr(*argv);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
165 argc--;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
166 argv++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
167 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
168 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
169
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
170 case 't':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
171 title = *argv;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
172 argc--;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
173 argv++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
174 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
175 case 'r':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
176 defaultsFile = *argv;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
177 argv++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
178 argc--;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
179 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
180 #ifdef AUTHORIZE
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
181 case 'o':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
182 RSA_Client = -1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
183 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
184 case 'R':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
185 RSA_Client = -2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
186 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
187 #else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
188 case 'o':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
189 case 'R':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
190 printf("This client does not have binary authorization.\n");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
191 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
192 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
193 case 'e':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
194 #ifdef AUTHORIZE
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
195 checkExpire(1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
196 #else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
197 printf("This client does not RSA verify and will not expire.\n");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
198 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
199 exit(0);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
200 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
201 case 'f': /* list ftp sites */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
202 fprintf(stderr, "\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
203 The newest version of the Paradise client can be found at:\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
204 ftp.pnetrek.org in /pub/paradise/bin/\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
205 or ftp.cs.umn.edu in /users/glamm/paradise/bin/\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
206 \n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
207 Quick ftp instructions:\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
208 This assumes you are bob@school.edu and are using a Sun workstation\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
209 ('sparc' architecture). Modify with your mailing address and architecture.\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
210 Type:\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
211 ftp ftp.cs.umn.edu\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
212 (at name prompt) anonymous\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
213 (at password prompt) bob@school.edu\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
214 (at ftp> prompt) cd users/glamm/paradise/bin\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
215 (at ftp> prompt) binary\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
216 (at ftp> prompt) dir\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
217 (lots of files printed - pick out the latest release for your architecture.\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
218 all the client binaries begin with 'netrek'.)\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
219 (at ftp> prompt) get netrek.Sparc-SunOS-static\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
220 (note: static and dynamic are functionally the same.\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
221 (at ftp> prompt) bye\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
222 \n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
223 That's it!\n");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
224 exit(0);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
225 case 'G':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
226 if (*argv) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
227 ghoststart++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
228 ghost_pno = atoi(*argv);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
229 printf("Emergency restart being attempted...\n");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
230 argv++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
231 argc--;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
232 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
233 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
234 case '2': /* force paradise */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
235 paradise = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
236 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
237 #ifdef RECORDER
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
238 case 'F': /* File playback */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
239 if (*argv) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
240 playFile = strdup(*argv);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
241 playback = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
242 argv++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
243 argc--;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
244 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
245 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
246 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
247 case 'U':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
248 if(*argv == NULL || (UdpLocalPort = atoi(*argv)) <= 0) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
249 fprintf(stderr, "Error: -U requires a port number\n");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
250 usage++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
251 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
252 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
253 argc--;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
254 argv++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
255 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
256 default:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
257 fprintf(stderr, "%s: unknown option '%c'\n", name, *ptr);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
258 err++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
259 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
260 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
261 ptr++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
262 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
263 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
264 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
265 #ifdef GATEWAY
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
266 if (netaddr == -1) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
267 fprintf(stderr,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
268 "netrek: no remote address set (-H). Restricted server will not work.\n");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
269 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
270 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
271
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
272
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
273
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
274 inittrigtables();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
275
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
276 initStars(); /* moved from redraw.c at KAO\'s suggestion */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
277
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
278 if (usage || err) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
279 printUsage(name);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
280 #ifdef AUTHORIZE
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
281 checkExpire(1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
282 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
283 exit(0);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
284 /* exit(err); Exits from checkExpire */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
285 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
286 defaultsFile = initDefaults(defaultsFile);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
287
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
288 #ifdef AUTHORIZE
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
289 if (RSA_Client != -1)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
290 checkExpire(0);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
291 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
292
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
293 /* compatability */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
294 if (argc > 0)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
295 serverName = argv[0];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
296
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
297 srandom(getpid() + time((long *) 0));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
298
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
299 #ifdef RECORDER
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
300 if(playback || booleanDefault("playback",0)) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
301 defNickName = "playback";
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
302 usemeta=0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
303 serverName = "playback";
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
304 } else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
305 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
306 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
307 if (serverName) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
308 char temp[80], *s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
309 sprintf(temp, "server.%s", serverName);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
310 if ((s = getdefault(temp))) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
311 s=strdup(s);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
312 printf("Using nickname \"%s\" for server %s\n", serverName, s);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
313 defNickName = serverName;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
314 serverName = s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
315 defFlavor = getdefault("flavor");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
316 if(defFlavor)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
317 defFlavor=strdup(defFlavor);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
318 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
319 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
320 if (!serverName) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
321 if(serverName = getdefault("server"))
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
322 serverName = strdup(serverName);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
323 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
324 if (!serverName && !passive) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
325 serverName = DEFAULT_SERVER;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
326 #ifdef METASERVER
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
327 usemeta = 1; /* no server specified, show the menu */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
328 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
329 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
330 if (passive)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
331 serverName = "passive"; /* newwin gets a wrong title otherwise */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
332
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
333 if (xtrekPort < 0)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
334 xtrekPort = intDefault("port", -1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
335 if (xtrekPort < 0)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
336 xtrekPort = DEFAULT_PORT;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
337 #if 0
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
338 #ifdef AUTHORIZE
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
339 if (RSA_Client >= 0)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
340 RSA_Client = booleanDefault("useRSA", RSA_Client);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
341 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
342 RSA_Client = (RSA_Client == -2);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
343 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
344 #endif /* 0 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
345
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
346 } /* playback */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
347 build_default_configuration();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
348
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
349 #ifdef METASERVER
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
350 metaserverAddress = stringDefault("metaserver",
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
351 "metaserver.ecst.csuchico.edu");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
352 if (usemeta)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
353 parsemeta();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
354 #endif /* METASERVER */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
355
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
356 W_Initialize(dpyname);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
357 #ifdef SOUND
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
358 S_Initialize();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
359 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
360
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
361
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
362 #ifdef METASERVER
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
363 metaFork = booleanDefault("metaFork", metaFork);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
364 /* do the metawindow thang */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
365 if (usemeta) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
366 metawindow();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
367 metainput();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
368 if (metaFork)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
369 W_Initialize(dpyname);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
370 newwin(dpyname, name);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
371 } else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
372 #endif /* METASERVER */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
373
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
374 /* this creates the necessary x windows for the game */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
375 newwin(dpyname, name);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
376
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
377 #ifdef TIMELORD
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
378 start_timelord();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
379 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
380
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
381 /* open memory...? */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
382 openmem();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
383 #ifdef RECORDER
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
384 if (!startPlayback())
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
385 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
386 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
387 if (!passive) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
388 callServer(xtrekPort, serverName);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
389 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
390 connectToServer(xtrekPort);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
391 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
392 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
393 #ifdef FEATURE
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
394 sendFeature("FEATURE_PACKETS", 'S', 1, 0, 0);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
395 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
396
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
397 timeStart = time(NULL);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
398 findslot();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
399
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
400 /* sets all the settings from defaults file (.xtrekrc probably) */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
401 resetDefaults();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
402
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
403 #ifdef UNIX_SOUND
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
404 init_sound();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
405 play_sound(SND_PARADISE);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
406 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
407
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
408 mapAll();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
409 /* signal(SIGINT, SIG_IGN);*/
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
410 signal(SIGCHLD, (void (*) ()) reaper);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
411
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
412 /* Get login name */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
413 if ((pwent = getpwuid(getuid())) != NULL)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
414 (void) strncpy(login, pwent->pw_name, sizeof(login));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
415 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
416 (void) strncpy(login, "Bozo", sizeof(login));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
417 login[sizeof(login) - 1] = '\0';
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
418
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
419 if (pseudo[0] == '\0') {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
420 if ((cp = getdefault("name")) != 0)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
421 (void) strncpy(pseudo, cp, sizeof(pseudo));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
422 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
423 (void) strncpy(pseudo, login, sizeof(pseudo));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
424 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
425 pseudo[sizeof(pseudo) - 1] = '\0';
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
426
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
427 if (defpasswd[0] == '\0') {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
428 char buf[100], buf2[100]; /* added password by character name -JR */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
429 sprintf(buf,"password.%s",pseudo);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
430 if (serverName) /* password by server name -TH */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
431 sprintf(buf2, "password.%s", serverName);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
432 if((cp = getdefault(buf)) || (cp = getdefault(buf2)) ||
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
433 (cp = getdefault("password")))
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
434 (void) strncpy(defpasswd, cp, sizeof(defpasswd));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
435 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
436 defpasswd[sizeof(defpasswd) - 1] = '\0';
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
437
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
438 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
439 sendLoginReq("Gray Lensman", "hh", "sfd", 0); loginAccept = -1; while
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
440 (loginAccept == -1) { socketPause(1,0); readFromServer(); }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
441 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
442 getname(pseudo, defpasswd);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
443 loggedIn = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
444 #ifdef TIMER
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
445 timeBank[T_SERVER] = timeStart;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
446 timeBank[T_DAY] = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
447 #endif /* TIMER */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
448
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
449
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
450 #ifdef AUTOKEY
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
451 /* autokey.c */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
452 autoKeyDefaults();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
453 #endif /* AUTOKEY */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
454
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
455 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
456 Set p_hostile to hostile, so if keeppeace is on, the guy starts off
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
457 hating everyone (like a good fighter should)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
458 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
459 me->p_hostile = (1 << number_of_teams) - 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
460
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
461 redrawTstats();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
462
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
463 me->p_planets = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
464 me->p_genoplanets = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
465 me->p_armsbomb = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
466 me->p_genoarmsbomb = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
467 /* Set up a reasonable default */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
468 me->p_whydead = KQUIT;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
469 me->p_teami = -1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
470 s_type = defaultShip(CRUISER); /* from rlb7h 11/15/91 TC */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
471
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
472 if (booleanDefault("netStats", 1))
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
473 startPing(); /* tell the server that we support pings */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
474
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
475 #ifdef AUTOKEY
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
476 if (autoKey) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
477 /* XX: changes entire state of display */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
478 W_AutoRepeatOff();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
479 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
480 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
481 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
482 hack to make galaxy class ships work. This could be more elegant, but
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
483 the configuration code would have to be modified quite a bit, since
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
484 the client doesn't know if it's on a paradise server until after it
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
485 connects, and it needs the configuration info before it connects.
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
486 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
487 init_galaxy_class();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
488
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
489 initkeymap(-1); /* needs to have ship types initialized -JR */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
490
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
491 setjmp(env); /* Reentry point of game */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
492
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
493 if (ghoststart) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
494 int i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
495
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
496 ghoststart = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
497
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
498 for (i = -1; i < 5; i++)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
499 if (teaminfo[i].letter == me->p_mapchars[0])
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
500 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
501
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
502 me->p_teami = i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
503
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
504 if (me->p_damage > me->p_ship->s_maxdamage) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
505 me->p_status = POUTFIT;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
506 } else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
507 me->p_status = PALIVE;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
508 } else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
509 me->p_status = POUTFIT;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
510
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
511 while (1) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
512 switch (me->p_status) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
513 case POUTFIT:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
514 case PTQUEUE:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
515 /* give the player the motd and find out which team he wants */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
516 #if 1
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
517 new_entrywindow(&team, &s_type);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
518 #else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
519 entrywindow(&team, &s_type);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
520 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
521 allowPlayerlist = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
522 if (W_IsMapped(playerw))
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
523 playerlist();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
524
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
525 #ifdef RECORDER
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
526 if (!playback)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
527 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
528 if (team == -1) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
529 W_DestroyWindow(w);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
530 #ifdef AUTOKEY
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
531 if (autoKey)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
532 W_AutoRepeatOn();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
533 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
534 sendByeReq();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
535 sleep(1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
536 printf("OK, bye!\n");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
537 EXIT(0);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
538 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
539 sendVersion();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
540 myship = getship(myship->s_type);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
541
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
542 currentship = myship->s_type;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
543
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
544 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
545 sendOptionsPacket(); /* this would totally blast any flags you
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
546 had on the server
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
547 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
548
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
549 redrawall = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
550 enter();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
551 calibrate_stats();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
552 W_ClearWindow(w);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
553 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
554 for (i = 0; i < NSIG; i++) { signal(i, SIG_IGN); }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
555 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
556
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
557 me->p_status = PALIVE; /* Put player in game */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
558
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
559 #ifdef UNIX_SOUND
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
560 kill_sound ();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
561 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
562
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
563 #ifdef HOCKEY
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
564 hockeyInit();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
565 #endif /*HOCKEY*/
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
566
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
567 #ifdef TIMER
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
568 timeBank[T_SHIP] = time(NULL);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
569 #endif /* TIMER */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
570
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
571 if (showStats) /* Default showstats are on. */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
572 W_MapWindow(statwin);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
573
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
574 #ifdef GATEWAY
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
575 /* pick a nice set of UDP ports */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
576 getUdpPort();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
577 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
578
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
579 #if ATM
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
580 if (tryUdp && commMode != COMM_UDP) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
581 sendUdpReq(COMM_UDP);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
582 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
583 #endif /* ATM */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
584 #ifdef SHORT_PACKETS
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
585 if (tryShort) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
586 sendShortReq(SPK_VON);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
587 tryShort = 0; /* only try it once */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
588 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
589 #endif /* SHORT_PACKETS */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
590 /* Send request for a full update */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
591 if (askforUpdate) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
592 if(recv_short)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
593 sendShortReq(SPK_SALL);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
594 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
595 sendUdpReq(COMM_UPDATE);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
596 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
597 sendUpdatePacket(1000000 / updateSpeed);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
598
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
599 W_Deiconify(baseWin);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
600
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
601 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
602 case PALIVE:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
603 case PEXPLODE:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
604 case PDEAD:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
605 case POBSERVE:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
606
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
607 #ifdef TIMELORD
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
608 /* reading the MOTD doesn't count against your playing time */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
609 update_timelord_notcount();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
610 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
611
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
612 /* Get input until the player quits or dies */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
613 input();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
614 W_ClearWindow(mapw);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
615 #ifdef TIMELORD
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
616 /* get any fractional minutes we missed */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
617 update_timelord(1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
618 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
619 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
620 default:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
621 printf("client has p_status=%d. how strange\n", me->p_status);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
622 me->p_status = POUTFIT;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
623 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
624 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
625
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
626 /* NOTREACHED */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
627 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
628
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
629 static void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
630 printUsage(prog)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
631 char *prog;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
632 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
633 fprintf(stderr, "Usage:\n %s [ options ] [ ntserv-host ]\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
634 Where options are\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
635 [-h] host server host name\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
636 [-p] port server port number\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
637 [-r] xtrekrc defaults file to replace ~/.xtrekrc\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
638 [-t] title window manager title\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
639 [-d] display set Xwindows display\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
640 [-C] name netrek pseudonym\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
641 [-P] passwd passwd to use to attempt autologin\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
642 [-R] use RSA authorization (default)\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
643 [-o] use old (non-RSA) authorization\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
644 [-s] port wait for connection from ntserv on a port (debugging)\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
645 %s\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
646 %s\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
647 [-U] port specify base local UDP port number to use\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
648 [-e] check the expire time on the client\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
649 [-f] how to get the newest client\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
650 [-u] print usage\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
651 [-c] Paradise credits\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
652 For emergency restart:\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
653 [-2] force paradise - use if you were on a paradise server\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
654 [-G] playernum specify player number to use\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
655 [-s] port specify socket number to use\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
656 Paradise Client %s\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
657 For more information on how to play Paradise, use Netscape or Internet\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
658 Explorer and connect to:\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
659 http://www.pnetrek.org/ OR\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
660 http://www.cs.umn.edu/users/glamm/paradise/\n\n", prog,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
661 #ifdef METASERVER
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
662 " [-m] check metaserver for active servers\n",
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
663 #else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
664 "",
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
665 #endif /* METASERVER */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
666 #ifdef RECORDER
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
667 " [-F] file Replay from file instead of connecting\n",
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
668 #else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
669 "",
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
670 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
671 CLIENTVERS);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
672 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
673
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
674 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
675 reaper()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
676 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
677 #if defined(hpux) || defined(SVR4) || defined(AMIGA)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
678 wait((int *) 0);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
679 #else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
680 /* well, hell, just use NULL, it works for everything else anyway */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
681 /* while (wait3((union wait *) 0, WNOHANG, NULL) > 0);*/
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
682 while(wait3(NULL, WNOHANG, NULL) > 0);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
683 #endif /* hpux */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
684 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
685
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
686 #ifdef GATEWAY
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
687 static struct udpmap_t {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
688 int uid;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
689 int serv_port;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
690 int port;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
691 int local_port;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
692 } udpmap[] = {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
693 /* 5000, 5001, 5000 *//* generic */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
694 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
695 1290, 5010, 5011, 5010
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
696 }, /* fadden */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
697 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
698 757, 5020, 5021, 5020
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
699 }, /* user2 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
700 };
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
701 #define MAPSIZE (sizeof(udpmap) / sizeof(struct udpmap_t))
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
702
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
703 static void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
704 getUdpPort()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
705 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
706 int i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
707 uid_t uid;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
708 char *gw_m, *gw_p, *gw_lp, *gw_sp, *err, *getenv();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
709
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
710 /* should always be set prior, but in case not .. */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
711 if (!gw_mach) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
712 gw_m = getenv("GW_MACH");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
713 if (gw_m)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
714 gw_mach = gw_m;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
715 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
716 gw_mach = DEFAULT_GATEWAY;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
717 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
718 uid = getuid();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
719
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
720 for (i = 0; i < MAPSIZE; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
721 if (uid == udpmap[i].uid) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
722 gw_serv_port = udpmap[i].serv_port;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
723 gw_port = udpmap[i].port;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
724 gw_local_port = udpmap[i].local_port;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
725 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
726 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
727 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
728
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
729 gw_p = getenv("GW_PORT");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
730 gw_sp = getenv("GW_SPORT");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
731 gw_lp = getenv("GW_LPORT");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
732
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
733 if (gw_p) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
734 gw_port = strtol(gw_p, &err, 10);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
735 if (err == gw_p) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
736 fprintf(stderr, "netrek: malformed integer for GW_PORT: %s\n",
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
737 gw_p);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
738 /* let something else complain about port 0 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
739 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
740 } else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
741 gw_port = 5001;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
742 if (gw_sp) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
743 gw_serv_port = strtol(gw_sp, &err, 10);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
744 if (err == gw_sp) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
745 fprintf(stderr, "netrek: malformed integer for GW_SPORT: %s\n",
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
746 gw_sp);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
747 /* let something else complain about port 0 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
748 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
749 } else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
750 gw_serv_port = 5000;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
751
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
752 if (gw_lp) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
753 gw_local_port = strtol(gw_lp, &err, 10);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
754 if (err == gw_lp) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
755 fprintf(stderr, "netrek: malformed integer for GW_LPORT: %s\n",
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
756 gw_lp);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
757 /* let something else complain about port 0 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
758 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
759 } else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
760 gw_local_port = 5000;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
761
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
762 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
763 printf("gw_mach: \'%s\'\n", gw_mach); printf("gw_local_port: %d\n",
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
764 gw_local_port); printf("gw_serv_port: %d\n", gw_serv_port);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
765 printf("gw_port: %d\n", gw_port);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
766 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
767 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
768
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
769 #include <sys/socket.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
770 #include <netinet/in.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
771 #include <netdb.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
772
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
773 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
774 * In the event of problems assiocated with the above include files the
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
775 * following routine can be alternately used to convert a string
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
776 * ("xxx.xxx.xxx.xxx") to an internet address number.
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
777 *
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
778 * (author: Andy McFadden)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
779 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
780
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
781 #ifdef notneeded
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
782 unsigned long
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
783 dotAddrToNetAddr(str)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
784 char *str;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
785 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
786 char *t;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
787 unsigned long answer = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
788 t = str;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
789 for (i = 0; i < 4; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
790 answer = (answer << 8) | atoi(t);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
791 while (*t && *t != '.')
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
792 t++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
793 if (*t)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
794 t++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
795 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
796 return answer;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
797 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
798 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
799
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
800 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
801 * More network "correct" routine
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
802 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
803
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
804 static unsigned long
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
805 mkaddr(m)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
806 char *m;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
807 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
808 struct in_addr ad;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
809 struct hostent *hp;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
810
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
811 hp = gethostbyname(m);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
812 if (!hp) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
813 ad.s_addr = inet_addr(m);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
814 if (ad.s_addr == -1) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
815 fprintf(stderr, "netrek: unknown host \'%s\'\n", m);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
816 exit(1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
817 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
818 } else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
819 bcopy(hp->h_addr, (char *) &ad, hp->h_length);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
820
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
821 return ad.s_addr;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
822 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
823
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
824 static char *
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
825 get_gw()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
826 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
827 char *gw_m;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
828
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
829 gw_m = getenv("GW_MACH");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
830 if (gw_m)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
831 gw_mach = gw_m;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
832 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
833 gw_mach = DEFAULT_GATEWAY;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
834
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
835 return gw_mach;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
836 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
837
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
838 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
839
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
840 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
841 show_credits()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
842 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
843 printf ("Paradise Netrek\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
844 \n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
845 Copyright (c) 1986 Chris Guthrie\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
846 Copyright (c) 1989 Kevin P. Smith\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
847 Copyright (c) 1993 Larry Denys, Kurt Olsen, Brandon Gillespie, and\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
848 Robert Forsman\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
849 Copyright (c) Eric Mehlaff, Sujal Patel, Robert Glamm, \n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
850 Lars Bernhardsson, Kurt Siegl, Nick Trown\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
851 \n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
852 Paradise Developers\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
853 Larry Deny Robert Forsman\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
854 Brandon Gillespie Kurt Olsen\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
855 \n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
856 Paradise Contributors (In alphabetical order):\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
857 Terence Chang Mike McGrath\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
858 Bill Dyess Matthew Mead\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
859 Jerry Frain Gary Parnes\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
860 Robert Glamm Sujal Patel\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
861 T. Hadley Joe Rumsey\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
862 Heath A. Kehoe Rado Smiljanic\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
863 Andy McFadden Joe Young\n\
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
864 ");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
865 }