]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - warp/warp.h
1 /* Header: warp.h,v 7.0.1.2 86/12/12 17:08:42 lwall Exp */
4 * Revision 7.0.1.2 86/12/12 17:08:42 lwall
5 * Baseline for net release.
7 * Revision 7.0.1.1 86/10/16 10:54:26 lwall
8 * Added Damage. Fixed random bugs.
10 * Revision 7.0 86/10/08 15:17:55 lwall
11 * Split into separate files. Added amoebas and pirates.
19 #include "warp-config.h" /* generated by Configure script */
21 #include <sys/types.h>
23 #include <sys/param.h>
24 #include <sys/ioctl.h>
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
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}"
59 #ifndef WARPLIB /* ~ and %l only ("~%l" is permissable) */
61 # define WARPLIB PRIVLIB
63 # define WARPLIB PREFIX"/games/warp"
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) */
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.
103 EXT
char amb
[YSIZE
][XSIZE
];
110 # define isalnum(c) (isalpha(c) || isdigit(c))
115 #elif defined TERMIOS
116 # include <termios.h>
121 #include <sys/timeb.h>
125 #define BITSPERBYTE 8
126 #define LBUFLEN 512 /* line buffer length */
129 # define CBUFLEN 256 /* command buffer length */
130 # define PUSHSIZE 128
132 # define CBUFLEN 512 /* command buffer length */
133 # define PUSHSIZE 256
136 # define MAXFILENAME 128
138 # define MAXFILENAME 512
140 #define FINISHCMD 0177
142 /* some handy defs */
144 #define Ctl(ch) (ch & 037)
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))
151 #define sgn(x) ((x) < 0 ? -1 : (x) > 0)
153 /* Things we can figure out ourselves */
156 # define BSD42 /* do we have Berkeley 4.2? */
171 #define UNLINK(victim) unlink(victim)
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
180 * %. Directory containing . files
181 * %$ current process number
182 * %{name} Environment variable "name". %{name-default} form allowed.
184 * Print prompt and insert what is typed.
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.)
194 /* *** System Dependent Stuff *** */
196 /* NOTE: many of these are defined in the config.h file */
199 # define ROOTID 0 /* uid of superuser */
202 # define sigset signal
203 # define sigignore(sig) signal(sig,SIG_IGN)
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) */
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 */
234 /* some dependencies among options */
237 # define eaccess access
242 # define IF(c) if (c)
252 # define IF(c) "IF" outside of VERBOSE???
253 # define ELSE "ELSE" outside of VERBOSE???
257 # define assert(ex) {if (!(ex)){fprintf(stderr,"Assertion failed: file %s, line %d\r\n", __FILE__, __LINE__);sig_catcher(0);}}
259 # define assert(ex) ;
262 #define TCSIZE 512 /* capacity for termcap strings */
264 /* End of Space Conservation Section */
266 /* More System Dependencies */
268 /* preferred shell for use in doshell routine */
269 /* ksh or sh would be okay here */
271 # define PREFSHELL "/bin/sh"
274 /* path to fastest starting shell */
276 # define SH "/bin/sh"
279 /* location of macro file */
282 # define WARPMACRO "%./.warpmac"
286 /* location of full name */
289 # define FULLNAMEFILE "%./.fullname"
293 /* a motd-like file for warp */
294 #ifndef WARPNEWSNAME /* % and ~ */
295 # define WARPNEWSNAME "%X/warp.news"
300 /* *** end of the machine dependent stuff *** */
304 /* file statistics area */
306 EXT
struct stat filestat
;
308 /* various things of type char */
310 EXT
char buf
[LBUFLEN
+1]; /* general purpose line buffer */
312 EXT
char *cwd
INIT(NULL
); /* current working directory */
317 EXT
int debug
INIT(0); /* -D */
318 # define DEB_FILEXP 64
323 EXT
bool verbose
INIT(true); /* +t */
329 EXT
FILE *tmpfp
INIT(NULL
); /* scratch fp */
335 /* Factored strings */
337 EXT
char nullstr
[] INIT("");
338 EXT
char readerr
[] INIT("warp read error");
339 EXT
char cantopen
[] INIT("Can't open %s\r\n");
342 #define NOCD "Can't chdir to directory %s\r\n"
344 #define NOCD "Can't find %s\r\n"
347 EXT
bool justonemoretime
INIT(true);
348 EXT
bool keepgoing
INIT(true);
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);
371 EXT
int panic
INIT(0);
398 EXT
int ismarts
INIT(0);
399 EXT
int numos
INIT(0);
400 EXT
int numxes
INIT(0);
409 EXT
int prescene
INIT(-1);
427 EXT
char spbuf
[1024];