]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - warp/warp.h
games: remove trailing whitespace in *.c and *.h
[bsdgames-darwin.git] / warp / warp.h
1 /* Header: warp.h,v 7.0.1.2 86/12/12 17:08:42 lwall Exp */
2
3 /* Log: warp.h,v
4 * Revision 7.0.1.2 86/12/12 17:08:42 lwall
5 * Baseline for net release.
6 *
7 * Revision 7.0.1.1 86/10/16 10:54:26 lwall
8 * Added Damage. Fixed random bugs.
9 *
10 * Revision 7.0 86/10/08 15:17:55 lwall
11 * Split into separate files. Added amoebas and pirates.
12 *
13 */
14
15 #ifndef WARP_H
16 #define WARP_H
17
18 #include "config.h"
19 #include "warp-config.h" /* generated by Configure script */
20
21 #include <sys/types.h>
22 #include <sys/stat.h>
23 #include <sys/param.h>
24 #include <sys/ioctl.h>
25
26 #include <term.h>
27 #include <math.h>
28 #include <stdio.h>
29 #include <signal.h>
30 #include <fcntl.h>
31 #include <ctype.h>
32 #include <errno.h>
33 #include <stdbool.h>
34 #include <stdlib.h>
35 #include <string.h>
36 #include <unistd.h>
37
38 /* WARPLIB must be readable and writeable by warp, but not by anyone who you
39 * don't trust. In other words, to set up warp so everyone can play and
40 * no one can cheat, give warp a uid of its own and make warp setuid to
41 * that uid. WARPLIB must then NOT be made writeable by the world,
42 * since no attempt is made to encrypt saved games or anything.
43 * (It must be readable by the world, however, due to a strangeness in
44 * access.)
45 */
46
47 #define SAVEDIR LOCALSTATEDIR"/games/warp"
48 #define NEWSFILE "warp.news"
49 #define HELPFILE "warp.doc"
50 #define LOCKFILE ".warp.lock"
51 #define LOGFILE "warp.log"
52 #define SCOREBOARD "warp.top"
53 #define LSCOREBOARD "warp.lowtop"
54 #define FSCOREBOARD "warp.funtop"
55 #define TMPSCOREBOARD "warp.topnew"
56 #define WARPMACRO "%X/Kbmap.%{TERM}"
57
58 /* warp library */
59 #ifndef WARPLIB /* ~ and %l only ("~%l" is permissable) */
60 # ifdef PRIVLIB
61 # define WARPLIB PRIVLIB
62 # else
63 # define WARPLIB PREFIX"/games/warp"
64 # endif
65 #endif
66
67 EXT char *warplib;
68
69 #define PERMMAPS 8 /* how many starmaps are permanent */
70 #define MAPS 20 /* how many starmaps to choose from */
71 /* (MAPS - PERMMAPS is # of half-gone universes) */
72
73 /*
74 * Screen size info, minimum screen size is 23x40 (actually 24x80).
75 * YSIZE and XSIZE should be relatively prime so that a torpedo launched
76 * at an angle will eventually cover the whole screen.
77 * To calculate a new position for something:
78 * new_position = (current_position + delta + ?SIZE00) % ?SIZE
79 * This allows for negative deltas of up to ?SIZE00 (% doesn't work right
80 * on negative numbers).
81 * ?SIZE01, etc. are fudges for efficiency--they already include a delta.
82 */
83
84 #define XYSIZE 920
85 #define XYSIZEx4 3680
86
87 #define YSIZE 23
88 #define YSIZE00 2300
89 #define YSIZE01 2301
90 #define YSIZE99 2299
91
92 #define XSIZE 40
93 #define XSIZE00 4000
94 #define XSIZE01 4001
95 #define XSIZE99 3999
96 #define XSIZE02 4002
97 #define XSIZE98 3998
98 #define XSIZE03 4003
99 #define XSIZE97 3997
100 #define XSIZE08 4008
101 #define XSIZE92 3992
102
103 EXT char amb[YSIZE][XSIZE];
104
105 #ifdef WHOAMI
106 # include <whoami.h>
107 #endif
108
109 #ifndef isalnum
110 # define isalnum(c) (isalpha(c) || isdigit(c))
111 #endif
112
113 #ifdef TERMIO
114 # include <termio.h>
115 #elif defined TERMIOS
116 # include <termios.h>
117 #else
118 # include <sgtty.h>
119 #endif
120
121 #include <sys/timeb.h>
122
123 # include <pwd.h>
124
125 #define BITSPERBYTE 8
126 #define LBUFLEN 512 /* line buffer length */
127
128 #ifdef pdp11
129 # define CBUFLEN 256 /* command buffer length */
130 # define PUSHSIZE 128
131 #else
132 # define CBUFLEN 512 /* command buffer length */
133 # define PUSHSIZE 256
134 #endif
135 #ifdef pdp11
136 # define MAXFILENAME 128
137 #else
138 # define MAXFILENAME 512
139 #endif
140 #define FINISHCMD 0177
141
142 /* some handy defs */
143
144 #define Ctl(ch) (ch & 037)
145
146 #define strNE(s1,s2) (strcmp(s1,s2))
147 #define strEQ(s1,s2) (!strcmp(s1,s2))
148 #define strnNE(s1,s2,l) (strncmp(s1,s2,l))
149 #define strnEQ(s1,s2,l) (!strncmp(s1,s2,l))
150
151 #define sgn(x) ((x) < 0 ? -1 : (x) > 0)
152
153 /* Things we can figure out ourselves */
154
155 #ifdef SIGPROF
156 # define BSD42 /* do we have Berkeley 4.2? */
157 #endif
158
159 #ifdef FIONREAD
160 # define PENDING
161 #else
162 # ifdef O_NDELAY
163 # define PENDING
164 # else
165 # ifdef RDCHK
166 # define PENDING
167 # endif
168 # endif
169 #endif
170
171 #define UNLINK(victim) unlink(victim)
172
173 /* Valid substitutions for strings marked with % comment are:
174 * %H Host name (yours)
175 * %L Login name (yours)
176 * %N Full name (yours)
177 * %O Original working directory (where you ran warp from)
178 * %X Warp library directory
179 * %~ Home directory
180 * %. Directory containing . files
181 * %$ current process number
182 * %{name} Environment variable "name". %{name-default} form allowed.
183 * %"prompt"
184 * Print prompt and insert what is typed.
185 * %`command`
186 * Insert output of command.
187 * %(test_text=pattern?if_text:else_text)
188 * Substitute if_text if test_text matches pattern, otherwise
189 * substitute else_text. Use != for negated match.
190 * % substitutions are done on test_text, if_text, and else_text.
191 * (Note: %() only works if CONDSUB defined.)
192 */
193
194 /* *** System Dependent Stuff *** */
195
196 /* NOTE: many of these are defined in the config.h file */
197
198 #ifndef ROOTID
199 # define ROOTID 0 /* uid of superuser */
200 #endif
201
202 # define sigset signal
203 # define sigignore(sig) signal(sig,SIG_IGN)
204
205 #ifndef LOGDIRFIELD
206 # define LOGDIRFIELD 6 /* Which field (origin 1) is the */
207 /* login directory in /etc/passwd? */
208 /* (If it is not kept in passwd, */
209 /* but getpwnam() returns it, */
210 /* define the symbol GETPWENT) */
211 #endif
212 #ifndef GCOSFIELD
213 # define GCOSFIELD 5
214 #endif
215
216 /* Undefine any of the following features to save both I and D space */
217 /* In general, earlier ones are easier to get along without */
218 /* Pdp11's without split I and D may have to undefine them all */
219 #define DEBUGGING /* include debugging code */
220 #define PUSHBACK /* macros and keymaps using pushback buffer */
221 #define CONDSUB /* allow %(cond?text:text) */
222 #define BACKTICK /* allow %`command` */
223 #define PROMPTTTY /* allow %"prompt" */
224 #define GETLOGIN /* use getlogin() routine as backup to environment */
225 /* variables USER or LOGNAME */
226 #define TILDENAME /* allow ~logname expansion */
227 #define GETWD /* use our getwd() instead of piped in pwd */
228 #define SETUIDGID /* substitute eaccess() for access() so that rn */
229 /* can run setuid or setgid */
230 /* if not setuid or setgid, you don't need it */
231 #define VERBOSE /* compile in more informative messages */
232 #define TERSE /* compile in shorter messages */
233
234 /* some dependencies among options */
235
236 #ifndef SETUIDGID
237 # define eaccess access
238 #endif
239
240 #ifdef VERBOSE
241 # ifdef TERSE
242 # define IF(c) if (c)
243 # define ELSE else
244 # else /* !TERSE */
245 # define IF(c)
246 # define ELSE
247 # endif
248 #else /* !VERBOSE */
249 # ifndef TERSE
250 # define TERSE
251 # endif
252 # define IF(c) "IF" outside of VERBOSE???
253 # define ELSE "ELSE" outside of VERBOSE???
254 #endif
255
256 #ifdef DEBUGGING
257 # define assert(ex) {if (!(ex)){fprintf(stderr,"Assertion failed: file %s, line %d\r\n", __FILE__, __LINE__);sig_catcher(0);}}
258 #else
259 # define assert(ex) ;
260 #endif
261
262 #define TCSIZE 512 /* capacity for termcap strings */
263
264 /* End of Space Conservation Section */
265
266 /* More System Dependencies */
267
268 /* preferred shell for use in doshell routine */
269 /* ksh or sh would be okay here */
270 #ifndef PREFSHELL
271 # define PREFSHELL "/bin/sh"
272 #endif
273
274 /* path to fastest starting shell */
275 #ifndef SH
276 # define SH "/bin/sh"
277 #endif
278
279 /* location of macro file */
280 #ifndef WARPMACRO
281 # ifdef PUSHBACK
282 # define WARPMACRO "%./.warpmac"
283 # endif
284 #endif
285
286 /* location of full name */
287 #ifndef FULLNAMEFILE
288 # ifndef PASSNAMES
289 # define FULLNAMEFILE "%./.fullname"
290 # endif
291 #endif
292
293 /* a motd-like file for warp */
294 #ifndef WARPNEWSNAME /* % and ~ */
295 # define WARPNEWSNAME "%X/warp.news"
296 #endif
297
298 /* typedefs */
299
300 /* *** end of the machine dependent stuff *** */
301
302 /* GLOBAL THINGS */
303
304 /* file statistics area */
305
306 EXT struct stat filestat;
307
308 /* various things of type char */
309
310 EXT char buf[LBUFLEN+1]; /* general purpose line buffer */
311
312 EXT char *cwd INIT(NULL); /* current working directory */
313
314 /* switches */
315
316 #ifdef DEBUGGING
317 EXT int debug INIT(0); /* -D */
318 # define DEB_FILEXP 64
319 #endif
320
321 #ifdef VERBOSE
322 # ifdef TERSE
323 EXT bool verbose INIT(true); /* +t */
324 # endif
325 #endif
326
327 /* miscellania */
328
329 EXT FILE *tmpfp INIT(NULL); /* scratch fp */
330
331 #define NOMARKING 0
332 #define STANDOUT 1
333 #define UNDERLINE 2
334
335 /* Factored strings */
336
337 EXT char nullstr[] INIT("");
338 EXT char readerr[] INIT("warp read error");
339 EXT char cantopen[] INIT("Can't open %s\r\n");
340
341 #ifdef VERBOSE
342 #define NOCD "Can't chdir to directory %s\r\n"
343 #else
344 #define NOCD "Can't find %s\r\n"
345 #endif
346
347 EXT bool justonemoretime INIT(true);
348 EXT bool keepgoing INIT(true);
349
350 EXT bool friendspec INIT(false);
351 EXT bool piratespec INIT(false);
352 EXT bool amoebaspec INIT(false);
353 EXT bool starspec INIT(false);
354 EXT bool klingspec INIT(false);
355 EXT bool apolspec INIT(false);
356 EXT bool crushspec INIT(false);
357 EXT bool romspec INIT(false);
358 EXT bool prespec INIT(false);
359 EXT bool tholspec INIT(false);
360 EXT bool gornspec INIT(false);
361 EXT bool beginner INIT(false);
362 EXT bool massacre INIT(false);
363 EXT bool lowspeed INIT(false);
364 EXT bool debugging INIT(false);
365 EXT bool didkill INIT(false);
366 EXT bool experimenting INIT(false);
367 EXT bool scorespec INIT(false);
368 EXT bool metakey INIT(false);
369
370 EXT bool bombed_out;
371 EXT int panic INIT(0);
372 EXT bool madgorns;
373
374 EXT int madfriends;
375
376 EXT int inumpirates;
377 EXT int numpirates;
378 EXT int inumfriends;
379 EXT int numfriends;
380 EXT int inumamoebas;
381 EXT int numamoebas;
382 EXT int inumstars;
383 EXT int numstars;
384 EXT int inumenemies;
385 EXT int numenemies;
386 EXT int inumroms;
387 EXT int inumthols;
388 EXT int inumapollos;
389 EXT int numapollos;
390 EXT int apolloflag;
391 EXT int inumcrushes;
392 EXT int numcrushes;
393 EXT int inumgorns;
394 EXT int numgorns;
395 EXT int deados;
396 EXT int deadmudds;
397 EXT int smarts;
398 EXT int ismarts INIT(0);
399 EXT int numos INIT(0);
400 EXT int numxes INIT(0);
401 EXT int ient;
402 EXT int numents;
403 EXT int ibase;
404 EXT int numbases;
405 EXT int inuminhab;
406 EXT int numinhab;
407 EXT int wave;
408 EXT int cumsmarts;
409 EXT int prescene INIT(-1);
410 EXT int scandist;
411 EXT int antibase;
412 EXT int sm35;
413 EXT int sm45;
414 EXT int sm50;
415 EXT int sm55;
416 EXT int sm80;
417 EXT int sm95;
418 EXT int entmax;
419 EXT int basemax;
420 EXT int enemshields;
421 EXT int super;
422 EXT int whenok;
423 EXT int yamblast;
424 EXT int xamblast;
425 EXT int ambsize;
426
427 EXT char spbuf[1024];
428
429 #endif