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