home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Games / warp / warp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-03  |  10.3 KB  |  449 lines

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