]>
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.
18 #include "config.h" /* generated by Configure script */
20 #include <sys/types.h>
22 #include <sys/param.h>
23 #include <sys/ioctl.h>
37 /* WARPLIB must be readable and writeable by warp, but not by anyone who you
38 * don't trust. In other words, to set up warp so everyone can play and
39 * no one can cheat, give warp a uid of its own and make warp setuid to
40 * that uid. WARPLIB must then NOT be made writeable by the world,
41 * since no attempt is made to encrypt saved games or anything.
42 * (It must be readable by the world, however, due to a strangeness in
46 #define SAVEDIR "/var/games/warp"
47 #define NEWSFILE "warp.news"
48 #define HELPFILE "warp.doc"
49 #define LOCKFILE ".warp.lock"
50 #define LOGFILE "warp.log"
51 #define SCOREBOARD "warp.top"
52 #define LSCOREBOARD "warp.lowtop"
53 #define FSCOREBOARD "warp.funtop"
54 #define TMPSCOREBOARD "warp.topnew"
55 #define WARPMACRO "%X/Kbmap.%{TERM}"
58 #ifndef WARPLIB /* ~ and %l only ("~%l" is permissable) */
60 # define WARPLIB PRIVLIB
62 # define WARPLIB "/usr/games/warp"
68 #define PERMMAPS 8 /* how many starmaps are permanent */
69 #define MAPS 20 /* how many starmaps to choose from */
70 /* (MAPS - PERMMAPS is # of half-gone universes) */
73 * Screen size info, minimum screen size is 23x40 (actually 24x80).
74 * YSIZE and XSIZE should be relatively prime so that a torpedo launched
75 * at an angle will eventually cover the whole screen.
76 * To calculate a new position for something:
77 * new_position = (current_position + delta + ?SIZE00) % ?SIZE
78 * This allows for negative deltas of up to ?SIZE00 (% doesn't work right
79 * on negative numbers).
80 * ?SIZE01, etc. are fudges for efficiency--they already include a delta.
102 EXT
char amb
[YSIZE
][XSIZE
];
109 # define isalnum(c) (isalpha(c) || isdigit(c))
114 #elif defined TERMIOS
115 # include <termios.h>
120 #include <sys/timeb.h>
124 #define BITSPERBYTE 8
125 #define LBUFLEN 512 /* line buffer length */
128 # define CBUFLEN 256 /* command buffer length */
129 # define PUSHSIZE 128
131 # define CBUFLEN 512 /* command buffer length */
132 # define PUSHSIZE 256
135 # define MAXFILENAME 128
137 # define MAXFILENAME 512
139 #define FINISHCMD 0177
141 /* some handy defs */
143 #define Ctl(ch) (ch & 037)
145 #define strNE(s1,s2) (strcmp(s1,s2))
146 #define strEQ(s1,s2) (!strcmp(s1,s2))
147 #define strnNE(s1,s2,l) (strncmp(s1,s2,l))
148 #define strnEQ(s1,s2,l) (!strncmp(s1,s2,l))
150 #define sgn(x) ((x) < 0 ? -1 : (x) > 0)
152 /* Things we can figure out ourselves */
155 # define BSD42 /* do we have Berkeley 4.2? */
170 #define UNLINK(victim) unlink(victim)
172 /* Valid substitutions for strings marked with % comment are:
173 * %H Host name (yours)
174 * %L Login name (yours)
175 * %N Full name (yours)
176 * %O Original working directory (where you ran warp from)
177 * %X Warp library directory
179 * %. Directory containing . files
180 * %$ current process number
181 * %{name} Environment variable "name". %{name-default} form allowed.
183 * Print prompt and insert what is typed.
185 * Insert output of command.
186 * %(test_text=pattern?if_text:else_text)
187 * Substitute if_text if test_text matches pattern, otherwise
188 * substitute else_text. Use != for negated match.
189 * % substitutions are done on test_text, if_text, and else_text.
190 * (Note: %() only works if CONDSUB defined.)
193 /* *** System Dependent Stuff *** */
195 /* NOTE: many of these are defined in the config.h file */
198 # define ROOTID 0 /* uid of superuser */
201 # define sigset signal
202 # define sigignore(sig) signal(sig,SIG_IGN)
205 # define LOGDIRFIELD 6 /* Which field (origin 1) is the */
206 /* login directory in /etc/passwd? */
207 /* (If it is not kept in passwd, */
208 /* but getpwnam() returns it, */
209 /* define the symbol GETPWENT) */
215 /* Undefine any of the following features to save both I and D space */
216 /* In general, earlier ones are easier to get along without */
217 /* Pdp11's without split I and D may have to undefine them all */
218 #define DEBUGGING /* include debugging code */
219 #define PUSHBACK /* macros and keymaps using pushback buffer */
220 #define CONDSUB /* allow %(cond?text:text) */
221 #define BACKTICK /* allow %`command` */
222 #define PROMPTTTY /* allow %"prompt" */
223 #define GETLOGIN /* use getlogin() routine as backup to environment */
224 /* variables USER or LOGNAME */
225 #define TILDENAME /* allow ~logname expansion */
226 #define GETWD /* use our getwd() instead of piped in pwd */
227 #define SETUIDGID /* substitute eaccess() for access() so that rn */
228 /* can run setuid or setgid */
229 /* if not setuid or setgid, you don't need it */
230 #define VERBOSE /* compile in more informative messages */
231 #define TERSE /* compile in shorter messages */
233 /* some dependencies among options */
236 # define eaccess access
241 # define IF(c) if (c)
251 # define IF(c) "IF" outside of VERBOSE???
252 # define ELSE "ELSE" outside of VERBOSE???
256 # define assert(ex) {if (!(ex)){fprintf(stderr,"Assertion failed: file %s, line %d\r\n", __FILE__, __LINE__);sig_catcher(0);}}
258 # define assert(ex) ;
261 #define TCSIZE 512 /* capacity for termcap strings */
263 /* End of Space Conservation Section */
265 /* More System Dependencies */
267 /* preferred shell for use in doshell routine */
268 /* ksh or sh would be okay here */
270 # define PREFSHELL "/bin/csh"
273 /* path to fastest starting shell */
275 # define SH "/bin/sh"
278 /* location of macro file */
281 # define WARPMACRO "%./.warpmac"
285 /* location of full name */
288 # define FULLNAMEFILE "%./.fullname"
292 /* a motd-like file for warp */
293 #ifndef WARPNEWSNAME /* % and ~ */
294 # define WARPNEWSNAME "%X/warp.news"
299 /* *** end of the machine dependent stuff *** */
303 /* file statistics area */
305 EXT
struct stat filestat
;
307 /* various things of type char */
309 EXT
char buf
[LBUFLEN
+1]; /* general purpose line buffer */
311 EXT
char *cwd
INIT(NULL
); /* current working directory */
316 EXT
int debug
INIT(0); /* -D */
317 # define DEB_FILEXP 64
322 EXT
bool verbose
INIT(true); /* +t */
328 EXT
FILE *tmpfp
INIT(NULL
); /* scratch fp */
334 /* Factored strings */
336 EXT
char nullstr
[] INIT("");
337 EXT
char readerr
[] INIT("warp read error");
338 EXT
char cantopen
[] INIT("Can't open %s\r\n");
341 #define NOCD "Can't chdir to directory %s\r\n"
343 #define NOCD "Can't find %s\r\n"
346 EXT
bool justonemoretime
INIT(true);
347 EXT
bool keepgoing
INIT(true);
349 EXT
bool friendspec
INIT(false);
350 EXT
bool piratespec
INIT(false);
351 EXT
bool amoebaspec
INIT(false);
352 EXT
bool starspec
INIT(false);
353 EXT
bool klingspec
INIT(false);
354 EXT
bool apolspec
INIT(false);
355 EXT
bool crushspec
INIT(false);
356 EXT
bool romspec
INIT(false);
357 EXT
bool prespec
INIT(false);
358 EXT
bool tholspec
INIT(false);
359 EXT
bool gornspec
INIT(false);
360 EXT
bool beginner
INIT(false);
361 EXT
bool massacre
INIT(false);
362 EXT
bool lowspeed
INIT(false);
363 EXT
bool debugging
INIT(false);
364 EXT
bool didkill
INIT(false);
365 EXT
bool experimenting
INIT(false);
366 EXT
bool scorespec
INIT(false);
367 EXT
bool metakey
INIT(false);
370 EXT
int panic
INIT(0);
397 EXT
int ismarts
INIT(0);
398 EXT
int numos
INIT(0);
399 EXT
int numxes
INIT(0);
408 EXT
int prescene
INIT(-1);
426 EXT
char spbuf
[1024];