home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / games / volume14 / xpilot / part24 < prev    next >
Encoding:
Internet Message Format  |  1992-08-30  |  33.3 KB

  1. Path: uunet!zephyr.ens.tek.com!master!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v14i026:  xpilot - Multiplayer gravity war game hand-shake program, Part24/24
  5. Message-ID: <3321@master.CNA.TEK.COM>
  6. Date: 4 Aug 92 19:32:34 GMT
  7. Sender: news@master.CNA.TEK.COM
  8. Lines: 1235
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: Bjoern Stabell <bjoerns@staff.cs.uit.no>
  12. Posting-number: Volume 14, Issue 26
  13. Archive-name: xpilot/Part24
  14. Environment: X11, ANSI C
  15.  
  16.  
  17.  
  18. #! /bin/sh
  19. # This is a shell archive.  Remove anything before this line, then unpack
  20. # it by saving it into a file and typing "sh file".  To overwrite existing
  21. # files, type "sh file -c".  You can also feed this as standard input via
  22. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  23. # will see the following message at the end:
  24. #        "End of archive 24 (of 24)."
  25. # Contents:  BUGS CREDITS RESOURCES TODO fonts/README man6/README
  26. #   maps/test.uue src/bit.h src/error.c src/error.h src/lib/Imakefile
  27. #   src/limits.h src/map.h src/math.c src/proto.h src/strcasecmp.c
  28. #   src/syslimit.c src/types.h
  29. # Wrapped by billr@saab on Tue Aug  4 10:39:00 1992
  30. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  31. if test -f 'BUGS' -a "${1}" != "-c" ; then 
  32.   echo shar: Will not clobber existing file \"'BUGS'\"
  33. else
  34. echo shar: Extracting \"'BUGS'\" \(276 characters\)
  35. sed "s/^X//" >'BUGS' <<'END_OF_FILE'
  36. XKNOWN BUGS
  37. X==========
  38. X- Doesn't handle limited dogfight properly, don't use until fixed (the mode
  39. X  isn't very popular).
  40. X- Doesn't always manage to contact server (could be I'm pouring too many
  41. X  packets into the buffers at once).
  42. X- Sometimes you're able to lock on yourself.
  43. END_OF_FILE
  44. if test 276 -ne `wc -c <'BUGS'`; then
  45.     echo shar: \"'BUGS'\" unpacked with wrong size!
  46. fi
  47. # end of 'BUGS'
  48. fi
  49. if test -f 'CREDITS' -a "${1}" != "-c" ; then 
  50.   echo shar: Will not clobber existing file \"'CREDITS'\"
  51. else
  52. echo shar: Extracting \"'CREDITS'\" \(453 characters\)
  53. sed "s/^X//" >'CREDITS' <<'END_OF_FILE'
  54. XPre-v1.2 credits:
  55. X
  56. X    Arne Helme            socklib
  57. X    Tom Grydeland            maps, fonts and ideas
  58. X
  59. X    Lots of, LOTS OF beta testers at our site
  60. X
  61. XWe'd like to thank the following persons, without them there wouldn't have
  62. Xbeen a v1.2.
  63. X
  64. X    Christos Zoulas            monochrome fixes
  65. X    Abraham Maurice            robots, timing
  66. X    Greg Renda            rebinding of keys, wormholes etc.
  67. X
  68. X    Dave Lemke
  69. X    Keith Cantrell
  70. X    Chris Marshall
  71. X    Sigmund Austigard
  72. X    Martin Rutishauser
  73. X    Frank Tore Johansen
  74. X    Hermann Dunkel
  75. END_OF_FILE
  76. if test 453 -ne `wc -c <'CREDITS'`; then
  77.     echo shar: \"'CREDITS'\" unpacked with wrong size!
  78. fi
  79. # end of 'CREDITS'
  80. fi
  81. if test -f 'RESOURCES' -a "${1}" != "-c" ; then 
  82.   echo shar: Will not clobber existing file \"'RESOURCES'\"
  83. else
  84. echo shar: Extracting \"'RESOURCES'\" \(2105 characters\)
  85. sed "s/^X//" >'RESOURCES' <<'END_OF_FILE'
  86. X!
  87. X! This file lists up the X resources that XPilot understands and their
  88. X! default values.
  89. X!
  90. Xxpilot*name:                            <login name>        #nick name
  91. Xxpilot*power:                           45.0                #use 5.0-55.0
  92. Xxpilot*turnSpeed:                       30.0                #use 8.0-64.0
  93. Xxpilot*turnResistance:                  0.12                #use 0.1-0.9
  94. Xxpilot*altPower:                        35.0
  95. Xxpilot*altTurnSpeed:                    25.0
  96. Xxpilot*altTurnResistance:               0.12
  97. Xxpilot*team:                            0                   #0=no team (1-9)
  98. Xxpilot*fuelNotify:                      500.0               #HUDfuel on
  99. Xxpilot*fuelWarning:                     200.0               #HUDfuel flash
  100. Xxpilot*fuelCritical:                    100.0               #HUDfuel flash fast
  101. Xxpilot*showHUD:                         true                #HUD on/off
  102. Xxpilot*verticalHUDLine:                 false
  103. Xxpilot*horizontalHUDLine:               true
  104. Xxpilot*fuelMeter:                       false
  105. Xxpilot*fuelGauge:                       false
  106. Xxpilot*turnSpeedMeter:                  false
  107. Xxpilot*powerMeter:                      false
  108. X
  109. X!
  110. X! These are the default keybindings, they are tailormade for HP keyboards, but
  111. X! with some SUN functionality thrown in:
  112. X!
  113. Xxpilot*keyLockNext:        Right Next
  114. Xxpilot*keyLockPrev:        Left Prior
  115. Xxpilot*keyLockClose:        Up Down Select
  116. Xxpilot*keyChangeHome:        Home
  117. Xxpilot*keyShield:        Meta_R space
  118. Xxpilot*keyFireShot:        Return
  119. Xxpilot*keyFireMissile:        backslash Linefeed
  120. Xxpilot*keyDropMine:        Tab
  121. Xxpilot*keyTurnLeft:        a
  122. Xxpilot*keyTurnRight:        s
  123. Xxpilot*keySelfDestruct:        q
  124. Xxpilot*keyIdMode:        i
  125. Xxpilot*keyPause:        p
  126. Xxpilot*keyToggleVelocity:    v
  127. Xxpilot*keyToggleCompass:    c
  128. Xxpilot*keySwapSettings:        Escape
  129. Xxpilot*keyRefuel:        f Control_L Control_R Caps_Lock
  130. Xxpilot*keyIncreasePower:    KP_Multiply
  131. Xxpilot*keyDecreasePower:    KP_Divide
  132. Xxpilot*keyIncreaseTurnspeed:    KP_Add
  133. Xxpilot*keyDecreaseTurnspeed:    KP_Subtract
  134. Xxpilot*keyThrust:        Shift_L Shift_R
  135. Xxpilot*keyCloak:        BackSpace
  136. Xxpilot*keySlowdown:        bracketleft braceleft
  137. Xxpilot*keySpeedup:        bracketright braceright
  138. END_OF_FILE
  139. if test 2105 -ne `wc -c <'RESOURCES'`; then
  140.     echo shar: \"'RESOURCES'\" unpacked with wrong size!
  141. fi
  142. # end of 'RESOURCES'
  143. fi
  144. if test -f 'TODO' -a "${1}" != "-c" ; then 
  145.   echo shar: Will not clobber existing file \"'TODO'\"
  146. else
  147. echo shar: Extracting \"'TODO'\" \(463 characters\)
  148. sed "s/^X//" >'TODO' <<'END_OF_FILE'
  149. XTODO list for XPilot
  150. X====================
  151. X- double buffering on labels. (?)
  152. X- thrust flame moved a little further back.
  153. X- bouncing.
  154. X- better detection of servers and contact mechanism (TCP instead of UDP maybe).
  155. X- more bitplanes/colours, at least the possibility to determine this yourself.
  156. X- no players may have the same name, maybe save player ratings.
  157. X- enhance team option (team with names, own colors and home bases?)
  158. X- make an xp-ed (xpilot-ed) map editor.
  159. END_OF_FILE
  160. if test 463 -ne `wc -c <'TODO'`; then
  161.     echo shar: \"'TODO'\" unpacked with wrong size!
  162. fi
  163. # end of 'TODO'
  164. fi
  165. if test -f 'fonts/README' -a "${1}" != "-c" ; then 
  166.   echo shar: Will not clobber existing file \"'fonts/README'\"
  167. else
  168. echo shar: Extracting \"'fonts/README'\" \(453 characters\)
  169. sed "s/^X//" >'fonts/README' <<'END_OF_FILE'
  170. X(NOTE, these fonts are not needed by xpilot (or xpilots), they are provided
  171. Xmerely as a help for those of you who want to use a standard text editor to
  172. Xgenerate maps.)
  173. X
  174. XFirst, make the fonts (done in the directory where the .bdf files are):
  175. X
  176. Xksh:
  177. X    for font in map*.bdf
  178. X    do
  179. X        bdftosnf $font | compress > ${font%%.bdf}.scf
  180. X    done
  181. X    mkfontdir
  182. X
  183. XTo install these fonts in your font-path, use the following commands:
  184. X
  185. X    xset fp+ <this-directory>
  186. X    xset fp rehash
  187. END_OF_FILE
  188. if test 453 -ne `wc -c <'fonts/README'`; then
  189.     echo shar: \"'fonts/README'\" unpacked with wrong size!
  190. fi
  191. # end of 'fonts/README'
  192. fi
  193. if test -f 'man6/README' -a "${1}" != "-c" ; then 
  194.   echo shar: Will not clobber existing file \"'man6/README'\"
  195. else
  196. echo shar: Extracting \"'man6/README'\" \(95 characters\)
  197. sed "s/^X//" >'man6/README' <<'END_OF_FILE'
  198. XTo read these files without installing them on your system, use
  199. X
  200. X    nroff -man <filename> | more
  201. END_OF_FILE
  202. if test 95 -ne `wc -c <'man6/README'`; then
  203.     echo shar: \"'man6/README'\" unpacked with wrong size!
  204. fi
  205. # end of 'man6/README'
  206. fi
  207. if test -f 'maps/test.uue' -a "${1}" != "-c" ; then 
  208.   echo shar: Will not clobber existing file \"'maps/test.uue'\"
  209. else
  210. echo shar: Extracting \"'maps/test.uue'\" \(1395 characters\)
  211. sed "s/^X//" >'maps/test.uue' <<'END_OF_FILE'
  212. Xbegin 644 test.map
  213. XM,S!X,S`*,`I3;VUE('5N<&QE87-A;G0@<W5R<')I<V5S(&9O<B!E=F5R>6]N
  214. XM90I4;VT@1W)Y9&5L86YD"GAX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX
  215. XM>`IX("`K("`@("`@(#YR("T\("`@("`@("`@("`^('@*>"`@("`@("`@("!D
  216. XM1F8@/"`@("`@("`@("`@("!X"G@@("!Q=R`@("`@(&,@("`@("`@("`@("`@
  217. XM("H@>`IX("`@87,@("`@("`@("`@("`@("`@("`@("`@('@*>"`@("`@("`@
  218. XM("`@("`@("`@("`@("`@("`@/"!X"G@@("`@("`@("`@("`@("`@("`@("`@
  219. XM("`@("`@>`IX("`@("`@("`@("`@("`@("`@("`@("`@("`@,'@*>"`@("`@
  220. XM("`@("`@("`@("`@("`@("`@("`@(#%X"G@@("`@("`@("`@("`@("`@("`@
  221. XM("`@("`@("`R>`IX("`@("`@("`@("`@("`@("`@("`@("`@("`@,W@*>"`@
  222. XM("`@("`@("`@("`@("`@("`@("`@("`@(#1X"G@@("`@("`@("`@("`@("`@
  223. XM("`@("`@("`@("`U>`IX("`@("`@("`@("`@("`@("`@("`@("`@("`@-G@*
  224. XM>"`@("`@("`@("`@("`@("`@("`@("`@("`@(#=X"G@@("`@("`@("`@("`@
  225. XM("`@("`@("`@("`@("`X>`IX("`@("`@("`@("`@("`@("`@("`@("`@("`@
  226. XM.7@*>"`@("`@("`@("`@("!R("`@("`@("`@("`@("!X"G@@("`@("`@("`@
  227. XM(#QD*F8^("`@("`@("`@("`@>`IX("`@("`@("`@("`@(&,@("`@("`@("`@
  228. XM("`@('@*>"`@("`@("`@("`@("`@("`@("`@("`@("`@("!X"G@@("`@("`@
  229. XM("`@("`@("`@("`@("`@("`@("`@>`IX("`@("`@("`@("`@("`@("`@("`@
  230. XM("`@("`@('@*>"`@("`@("`@("`@("`@("`@("`@("`@("`@("!X"G@@<7,@
  231. XM("`@("`@("`@("`@("`@("`@("`@("`@>`IX<7,@("`@("`@("`@("`@("`@
  232. XM("`@("`@("`@('@*>',@("`@("`@("`@("`@("`@("`@("`@("`@("!X"G@N
  233. XM+BXN+BXN+BXN+BXN+BXN+BXN+BXN+BXN+BXN>`IX*RXJ+BLN+BXN+BXN+BXN
  234. XM+BXN+BXN+BXN+BXN<7@*>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX
  235. X!"BXN
  236. X`
  237. Xend
  238. END_OF_FILE
  239. if test 1395 -ne `wc -c <'maps/test.uue'`; then
  240.     echo shar: \"'maps/test.uue'\" unpacked with wrong size!
  241. fi
  242. # end of 'maps/test.uue'
  243. fi
  244. if test -f 'src/bit.h' -a "${1}" != "-c" ; then 
  245.   echo shar: Will not clobber existing file \"'src/bit.h'\"
  246. else
  247. echo shar: Extracting \"'src/bit.h'\" \(448 characters\)
  248. sed "s/^X//" >'src/bit.h' <<'END_OF_FILE'
  249. X/* bit.h,v 1.4 1992/06/25 03:23:46 bjoerns Exp
  250. X *
  251. X *    This file is part of the XPilot project, written by
  252. X *
  253. X *        Bjxrn Stabell (bjoerns@stud.cs.uit.no)
  254. X *        Ken Ronny Schouten (kenrsc@stud.cs.uit.no)
  255. X *
  256. X *    Copylefts are explained in the LICENSE file.
  257. X */
  258. X
  259. X#ifndef    BIT_H
  260. X#define    BIT_H
  261. X
  262. X#define SET_BIT(w, bit)        w |= (bit);
  263. X#define CLR_BIT(w, bit)        w &= (~(bit));
  264. X#define BIT(w, bit)        ( w & (bit) )
  265. X#define TOGGLE_BIT(w, bit)    w ^= (bit);
  266. X
  267. X#endif
  268. END_OF_FILE
  269. echo shar: 1 control character may be missing from \"'src/bit.h'\"
  270. if test 448 -ne `wc -c <'src/bit.h'`; then
  271.     echo shar: \"'src/bit.h'\" unpacked with wrong size!
  272. fi
  273. # end of 'src/bit.h'
  274. fi
  275. if test -f 'src/error.c' -a "${1}" != "-c" ; then 
  276.   echo shar: Will not clobber existing file \"'src/error.c'\"
  277. else
  278. echo shar: Extracting \"'src/error.c'\" \(1928 characters\)
  279. sed "s/^X//" >'src/error.c' <<'END_OF_FILE'
  280. X/* error.c,v 1.6 1992/06/28 07:55:03 bjoerns Exp
  281. X *
  282. X * Adapted from 'The UNIX Programming Environment' by Kernighan & Pike
  283. X * and an example from the manualpage for vprintf by
  284. X * Gaute Nessan, University of Tromsoe (gaute@staff.cs.uit.no).
  285. X *
  286. X * Modified by Bjoern Stabell (bjoerns@staff.cs.uit.no).
  287. X */
  288. X
  289. X#include "error.h"
  290. X
  291. X#ifndef    lint
  292. Xstatic char sourceid[] =
  293. X    "@(#)error.c,v 1.6 1992/06/28 07:55:03 bjoerns Exp";
  294. X#endif
  295. X
  296. X
  297. X
  298. X/*
  299. X * This file defines two entry points:
  300. X *
  301. X * init_error()        - Initialize the error routine, accepts program name
  302. X *              as input.
  303. X * error()        - perror() with printf functionality.
  304. X */
  305. X
  306. X
  307. X
  308. X/*
  309. X * Global data.
  310. X */
  311. X#define    MAX_PROG_LENGTH    256
  312. Xstatic char        progname[MAX_PROG_LENGTH];
  313. X
  314. X
  315. X
  316. X/*
  317. X * Functions.
  318. X */
  319. Xvoid
  320. X    init_error(prog)
  321. Xchar *prog;
  322. X{
  323. X    char *p = strrchr(prog, '/');
  324. X
  325. X    strncpy(progname, p ? p+1 : prog, MAX_PROG_LENGTH);   /* Beautify arv[0] */
  326. X}
  327. X
  328. X
  329. X
  330. X#if defined(__STDC__) && !defined(__sun__)
  331. X
  332. X/*
  333. X * Ok, let's do it the ANSI C way.
  334. X */
  335. Xvoid error(char *fmt, ...)
  336. X{
  337. X    va_list     ap;            /* Argument pointer */
  338. X    int         e = errno;        /* Store errno */
  339. X
  340. X
  341. X    va_start(ap, fmt);
  342. X
  343. X    if (progname[0] != '\0')
  344. X    fprintf(stderr, "%s: ", progname);
  345. X
  346. X    vfprintf(stderr, fmt, ap);
  347. X
  348. X    if (e != 0)
  349. X    fprintf(stderr, " (%s)", strerror(e));
  350. X
  351. X    fprintf(stderr, "\n");
  352. X
  353. X    va_end(args);
  354. X}
  355. X
  356. X#else
  357. X
  358. X/*
  359. X * Hm, we'd better stick to the K&R way.
  360. X */
  361. Xvoid
  362. X    error(va_alist)
  363. Xva_dcl        /* Note that the format argument cannot be separately    *
  364. X         * declared because of the definition of varargs.    */
  365. X{
  366. X    va_list     args;
  367. X    int         e = errno;
  368. X    extern int     sys_nerr;
  369. X    extern char *sys_errlist[];
  370. X    char    *fmt;
  371. X
  372. X
  373. X    va_start(args);
  374. X
  375. X    if (progname[0] != '\0')
  376. X    fprintf(stderr, "%s: ", progname);
  377. X
  378. X    fmt = va_arg(args, char *);
  379. X    (void) vfprintf(stderr, fmt, args);
  380. X
  381. X    if (e > 0 && e < sys_nerr)
  382. X    fprintf(stderr, " (%s)", sys_errlist[e]);
  383. X
  384. X    fprintf(stderr, "\n");
  385. X
  386. X    va_end(args);
  387. X}
  388. X
  389. X#endif
  390. END_OF_FILE
  391. if test 1928 -ne `wc -c <'src/error.c'`; then
  392.     echo shar: \"'src/error.c'\" unpacked with wrong size!
  393. fi
  394. # end of 'src/error.c'
  395. fi
  396. if test -f 'src/error.h' -a "${1}" != "-c" ; then 
  397.   echo shar: Will not clobber existing file \"'src/error.h'\"
  398. else
  399. echo shar: Extracting \"'src/error.h'\" \(753 characters\)
  400. sed "s/^X//" >'src/error.h' <<'END_OF_FILE'
  401. X/* error.h,v 1.2 1992/06/28 07:55:04 bjoerns Exp
  402. X *
  403. X * Adapted from 'The UNIX Programming Environment' by Kernighan & Pike
  404. X * and an example from the manualpage for vprintf by
  405. X * Gaute Nessan, University of Tromsoe (gaute@staff.cs.uit.no).
  406. X *
  407. X * Modified by Bjoern Stabell (bjoerns@staff.cs.uit.no).
  408. X */
  409. X
  410. X#ifndef    ERROR_H
  411. X#define    ERROR_H
  412. X
  413. X/*
  414. X * Prototypes and include files.
  415. X */
  416. X
  417. X#include <errno.h>
  418. X#include <stdio.h>
  419. X#if defined(__STDC__) && !defined(__sun__)
  420. X#   include <stdarg.h>
  421. X#else
  422. X#   include <varargs.h>
  423. X#endif
  424. X#include <string.h>
  425. X
  426. X#if defined(__STDC__) && !defined(__sun__)
  427. X    extern void init_error(char *prog);
  428. X    extern void error(char *fmt, ...);
  429. X#else
  430. X    extern void init_error();
  431. X    extern void error();
  432. X#endif
  433. X
  434. X#endif    /* ERROR_H */
  435. END_OF_FILE
  436. if test 753 -ne `wc -c <'src/error.h'`; then
  437.     echo shar: \"'src/error.h'\" unpacked with wrong size!
  438. fi
  439. # end of 'src/error.h'
  440. fi
  441. if test -f 'src/lib/Imakefile' -a "${1}" != "-c" ; then 
  442.   echo shar: Will not clobber existing file \"'src/lib/Imakefile'\"
  443. else
  444. echo shar: Extracting \"'src/lib/Imakefile'\" \(155 characters\)
  445. sed "s/^X//" >'src/lib/Imakefile' <<'END_OF_FILE'
  446. X# @(#)Imakefile 23/01/92
  447. X# Imakefile - socklib
  448. X
  449. XOBJS = socklib.o
  450. XSRCS = socklib.c
  451. X
  452. X#
  453. X# Make socklib
  454. X#
  455. XNormalLibraryTarget(socklib, $(OBJS))
  456. XDependTarget()
  457. END_OF_FILE
  458. if test 155 -ne `wc -c <'src/lib/Imakefile'`; then
  459.     echo shar: \"'src/lib/Imakefile'\" unpacked with wrong size!
  460. fi
  461. # end of 'src/lib/Imakefile'
  462. fi
  463. if test -f 'src/limits.h' -a "${1}" != "-c" ; then 
  464.   echo shar: Will not clobber existing file \"'src/limits.h'\"
  465. else
  466. echo shar: Extracting \"'src/limits.h'\" \(2560 characters\)
  467. sed "s/^X//" >'src/limits.h' <<'END_OF_FILE'
  468. X/* limits.h,v 1.4 1992/06/28 05:38:16 bjoerns Exp
  469. X *
  470. X *    This file is part of the XPilot project, written by
  471. X *
  472. X *        Bjxrn Stabell (bjoerns@stud.cs.uit.no)
  473. X *        Ken Ronny Schouten (kenrsc@stud.cs.uit.no)
  474. X *
  475. X *    Copylefts are explained in the LICENSE file.
  476. X */
  477. X
  478. X#ifndef LIMITS_H
  479. X#define    LIMITS_H
  480. X
  481. X#include <limits.h>
  482. X
  483. X/*
  484. X * DBL_MAX and RAND_MAX is ANSI C standard, but some architectures (BSD) use
  485. X * MAXDOUBLE and INT_MAX instead.
  486. X */
  487. X#ifndef    DBL_MAX
  488. X#   include <values.h>
  489. X#   define  DBL_MAX    MAXDOUBLE
  490. X#endif
  491. X#ifndef    RAND_MAX
  492. X#   define  RAND_MAX    INT_MAX
  493. X#endif
  494. X
  495. X/* Not everyone has PI (or M_PI defined). */
  496. X#ifndef    M_PI
  497. X#define PI        3.14159265358979323846
  498. X#else
  499. X#define    PI        M_PI
  500. X#endif
  501. X
  502. X#define MOD(x, y)    (((x)>=(y) || (x)<0) ? ((x)>=(y)?(x)-(y):(x)+(y)) :(x))
  503. X#define TABLE_SIZE    RES
  504. X#define tsin(x)        (tbl_sin[MOD(x, TABLE_SIZE)])
  505. X#define tcos(x)        (tbl_sin[MOD((x)+TABLE_SIZE/4, TABLE_SIZE)])
  506. X
  507. X#define TEAM(i, j)    (BIT(Players[i]->status, PAUSE) ||        \
  508. X                BIT(Players[j]->status, PAUSE) ?    \
  509. X            true : (BIT(World.rules->mode, TEAM_PLAY) ?    \
  510. X            ((Players[i]->team == Players[j]->team) &&    \
  511. X            Players[i]->team!=0) : false))
  512. X
  513. X#define ABS(x)            ( (x)<0 ? -(x) : (x) )
  514. X#ifndef MAX
  515. X#define MIN(x, y)        ( (x)>(y) ? (y) : (x) )
  516. X#define MAX(x, y)        ( (x)>(y) ? (x) : (y) )
  517. X#endif
  518. X#define sqr(x)            ( (x)*(x) )
  519. X#define LENGTH(x, y)        ( sqrt(sqr(x) + sqr(y)) )
  520. X#define LIMIT(val, lo, hi)    val = val>hi ? hi : (val<lo ? lo : val)
  521. X
  522. X#define CANNON_DEAD_TIME    900
  523. X#define    RECOVERY_DELAY        128
  524. X
  525. X#define MAX_BASES        64
  526. X#define MAX_PLAYERS        MAX_BASES        /* Miscellaneous limits */
  527. X#define MAX_MSGS        8
  528. X#define MAX_CHARS        80
  529. X#define    MAX_KEY_DEFS        100
  530. X#define MAX_SCROLL_LEN        4096
  531. X#define MAX_STATUS_CHARS    200
  532. X#define MIN_PAUSE        800
  533. X#define MAX_SHOTS        64
  534. X#define MAX_TOTAL_SHOTS        16384
  535. X#define MAX_STATION_FUEL    500.0
  536. X#define MAX_ID            2048            /* Should suffice :) */
  537. X#define STATION_REGENERATION    0.06
  538. X#define MAX_PLAYER_FUEL        2600.0
  539. X#define MIN_PLAYER_FUEL        350.0
  540. X#define MAX_PLAYER_TURNSPEED    64.0
  541. X#define MIN_PLAYER_TURNSPEED    4.0
  542. X#define MAX_PLAYER_POWER    55.0
  543. X#define MIN_PLAYER_POWER    5.0
  544. X#define REFUEL_RATE        5.0
  545. X#define RACE_PLAYER_FUEL    500.0
  546. X#define DEFAULT_PLAYER_FUEL    1000.0
  547. X#define RES        128
  548. X#define GRAVS_POWER        2.7
  549. X#define SMART_SHOT_ACC        0.6
  550. X#define SPEED_LIMIT        65.0
  551. X#define SMART_SHOT_MAX_SPEED    22.0
  552. X#define ENERGY_RANGE_FACTOR    2.5
  553. X#define SHOTS_ANGLE        (RES/40)
  554. X#define WARNING_DISTANCE    800.0
  555. X#define VISIBILITY_DISTANCE    1000.0
  556. X#define MAX_KEY_DEFS        100
  557. X
  558. X#define BLOCK_SZ        35
  559. X
  560. X#define SHIP_SZ        14  /* Size (pixels) of radius for legal HIT! */
  561. X
  562. X#define MSG_LEN            256
  563. X
  564. X#endif
  565. END_OF_FILE
  566. echo shar: 1 control character may be missing from \"'src/limits.h'\"
  567. if test 2560 -ne `wc -c <'src/limits.h'`; then
  568.     echo shar: \"'src/limits.h'\" unpacked with wrong size!
  569. fi
  570. # end of 'src/limits.h'
  571. fi
  572. if test -f 'src/map.h' -a "${1}" != "-c" ; then 
  573.   echo shar: Will not clobber existing file \"'src/map.h'\"
  574. else
  575. echo shar: Extracting \"'src/map.h'\" \(2316 characters\)
  576. sed "s/^X//" >'src/map.h' <<'END_OF_FILE'
  577. X/* map.h,v 1.6 1992/06/28 05:38:18 bjoerns Exp
  578. X *
  579. X *    This file is part of the XPilot project, written by
  580. X *
  581. X *        Bjxrn Stabell (bjoerns@stud.cs.uit.no)
  582. X *        Ken Ronny Schouten (kenrsc@stud.cs.uit.no)
  583. X *
  584. X *    Copylefts are explained in the LICENSE file.
  585. X */
  586. X
  587. X#ifndef    MAP_H
  588. X#define    MAP_H
  589. X
  590. X#include "types.h"
  591. X#include "rules.h"
  592. X#include "limits.h"
  593. X
  594. X/*
  595. X * Default map name, set to your own favourite -
  596. X * or set it to "N/A", in which case the computer
  597. X * will generate a random map. (Not very good)
  598. X */
  599. X#define DEFAULT_MAP        "continent"
  600. X
  601. X#define MAX_FUELS        128
  602. X#define MAX_GRAVS        512
  603. X#define MAX_CANNONS        512
  604. X#define MAX_CHECKS        10
  605. X#define MAX_WORMHOLES        50
  606. X
  607. X#define SPACE            0
  608. X#define BASE            1
  609. X#define FILLED            2
  610. X#define FILLED_NO_DRAW        3
  611. X#define REC_LU            4
  612. X#define REC_LD            5
  613. X#define REC_RU            6
  614. X#define REC_RD            7
  615. X#define FUEL            8
  616. X#define CANNON            9
  617. X#define CHECK            10
  618. X#define SPECIAL            11
  619. X#define POS_GRAV        20
  620. X#define NEG_GRAV        21
  621. X#define CWISE_GRAV        22
  622. X#define ACWISE_GRAV        23
  623. X#define WORMHOLE        24
  624. X
  625. X#ifndef MAP_DIR
  626. X#define MAP_DIR            (LIBDIR "maps/")
  627. X#endif
  628. X
  629. X#define DIR_RIGHT        0
  630. X#define DIR_UP            (RES/4)
  631. X#define DIR_LEFT        (RES/2)
  632. X#define DIR_DOWN        (3*RES/4)
  633. X
  634. X#define ITEM_SMART_SHOT_PACK    0
  635. X#define ITEM_CLOAKING_DEVICE    1
  636. X#define ITEM_ENERGY_PACK    2
  637. X#define ITEM_WIDEANGLE_SHOT    3
  638. X#define ITEM_REAR_SHOT        4
  639. X#define ITEM_MINE_PACK        5
  640. X#define ITEM_SENSOR_PACK    6
  641. X#define NUM_ITEMS        7
  642. X
  643. X
  644. X
  645. Xtypedef struct {
  646. X    position    pos;
  647. X    double    left;
  648. X} fuel_t; 
  649. X
  650. Xtypedef struct {
  651. X    ipos    pos;
  652. X    double    force;
  653. X} grav_t;
  654. X
  655. Xtypedef struct {
  656. X    ipos    pos;
  657. X    int        dir;
  658. X    int        dead_time;
  659. X    bool    active;
  660. X} cannon_t;
  661. X
  662. Xtypedef struct {
  663. X    int max;        /* Max on world at a given time */
  664. X    int num;        /* Number active right now */
  665. X    int chance;        /* Chance for the item to appear on this world */
  666. X} item_t;
  667. X
  668. X
  669. Xtypedef struct {
  670. X    int        x, y;                    /* Size of world */
  671. X    rules_t    *rules;
  672. X    char    name[MAX_CHARS];
  673. X    char    author[MAX_CHARS];
  674. X
  675. X    u_byte    **block;
  676. X    vector    **gravity;
  677. X
  678. X    item_t    items[NUM_ITEMS];
  679. X
  680. X    int        NumBases;
  681. X    ipos    base[MAX_BASES];
  682. X    int        NumFuels;
  683. X    fuel_t    fuel[MAX_FUELS];
  684. X    int        NumGravs;
  685. X    grav_t    grav[MAX_GRAVS];
  686. X    int        NumCannons;
  687. X    cannon_t    cannon[MAX_CANNONS];
  688. X    int        NumChecks;
  689. X    ipos    check[MAX_CHECKS];
  690. X    int        NumWormholes;
  691. X    ipos    wormhole[MAX_WORMHOLES];
  692. X} World_map;
  693. X
  694. X#endif
  695. END_OF_FILE
  696. echo shar: 1 control character may be missing from \"'src/map.h'\"
  697. if test 2316 -ne `wc -c <'src/map.h'`; then
  698.     echo shar: \"'src/map.h'\" unpacked with wrong size!
  699. fi
  700. # end of 'src/map.h'
  701. fi
  702. if test -f 'src/math.c' -a "${1}" != "-c" ; then 
  703.   echo shar: Will not clobber existing file \"'src/math.c'\"
  704. else
  705. echo shar: Extracting \"'src/math.c'\" \(2395 characters\)
  706. sed "s/^X//" >'src/math.c' <<'END_OF_FILE'
  707. X/* math.c,v 1.7 1992/06/28 05:38:19 bjoerns Exp
  708. X *
  709. X *    This file is part of the XPilot project, written by
  710. X *
  711. X *        Bjxrn Stabell (bjoerns@stud.cs.uit.no)
  712. X *        Ken Ronny Schouten (kenrsc@stud.cs.uit.no)
  713. X *
  714. X *    Copylefts are explained in the LICENSE file.
  715. X */
  716. X
  717. X#include "global.h"
  718. X
  719. X
  720. X#define GRAV_RANGE  10
  721. X#define PTS_IN_SHIP 3
  722. X
  723. X#ifndef    lint
  724. Xstatic char sourceid[] =
  725. X    "@(#)math.c,v 1.7 1992/06/28 05:38:19 bjoerns Exp";
  726. X#endif
  727. X
  728. Xdouble      tbl_sin[TABLE_SIZE];
  729. Xwireobj        ships[RES];
  730. X
  731. X
  732. X
  733. Xvoid Make_table(void)
  734. X{
  735. X    int i;
  736. X
  737. X    for (i=0; i<TABLE_SIZE; i++)
  738. X    tbl_sin[i] = sin((2*PI) * ((double)i/TABLE_SIZE));
  739. X}
  740. X
  741. X
  742. Xvoid Make_ships(void)
  743. X{
  744. X    int i, z;
  745. X
  746. X
  747. X    ships[0].pts=(position *)malloc(PTS_IN_SHIP*sizeof(position));
  748. X    ships[0].pts[0].x = 15; ships[0].pts[0].y =  0;
  749. X    ships[0].pts[1].x = -9; ships[0].pts[1].y =  8;
  750. X    ships[0].pts[2].x = -9; ships[0].pts[2].y = -8;
  751. X    ships[0].num_points=PTS_IN_SHIP;
  752. X
  753. X    for (i=1; i<RES; i++) {
  754. X    ships[i].pts=(position *)malloc(PTS_IN_SHIP*sizeof(position));
  755. X
  756. X    for (z=0; z<PTS_IN_SHIP; z++) {
  757. X        ships[i].pts[z].x = tcos(i)*ships[0].pts[z].x
  758. X        - tsin(i)*ships[0].pts[z].y;
  759. X        ships[i].pts[z].y = tsin(i)*ships[0].pts[z].x
  760. X        + tcos(i)*ships[0].pts[z].y;
  761. X    }
  762. X    }
  763. X}
  764. X
  765. X
  766. Xvoid Free_ships(void)
  767. X{
  768. X    int dir;
  769. X
  770. X
  771. X    for (dir=0; dir<RES; dir++)
  772. X    free(ships[dir].pts);
  773. X}
  774. X
  775. X
  776. Xvoid Compute_gravity(void)
  777. X{
  778. X    int xi, yi, g, gx, gy;
  779. X    double theta, avst, dx, dy;
  780. X
  781. X
  782. X    for (xi=0; xi<World.x; xi++)
  783. X    for (yi=0; yi<World.y; yi++) {
  784. X        World.gravity[xi][yi].y = Gravity;
  785. X        World.gravity[xi][yi].x = 0.0;
  786. X    }
  787. X
  788. X    for (g=0; g<World.NumGravs; g++) {
  789. X    gx = World.grav[g].pos.x;
  790. X    gy = World.grav[g].pos.y;
  791. X
  792. X    for (xi = (gx>GRAV_RANGE) ? gx-GRAV_RANGE : 0;
  793. X         (xi<gx+GRAV_RANGE) && (xi<World.x); xi++)
  794. X        for (yi = (gy>GRAV_RANGE) ? gy-GRAV_RANGE : 0;
  795. X         (yi<gy+GRAV_RANGE) && (yi<World.y); yi++) {
  796. X        dx = (double)(gx - xi);
  797. X        dy = (double)(gy - yi);
  798. X
  799. X        if ((dy == 0) && (dx == 0))    /* In a grav? */
  800. X            continue;
  801. X
  802. X        avst = (double)LENGTH(dx, dy);
  803. X        if (dx != 0.0) {
  804. X            theta = atan2(dy, dx);
  805. X        } else
  806. X            if (dy > 0)
  807. X            theta = PI/2.0;
  808. X            else
  809. X            theta = 3.0*PI/2.0;
  810. X
  811. X        if (World.block[gx][gy] == CWISE_GRAV ||
  812. X            World.block[gx][gy] == ACWISE_GRAV)
  813. X            theta += PI/2.0;
  814. X
  815. X        World.gravity[xi][yi].x += cos(theta)*World.grav[g].force/
  816. X            sqr(avst);
  817. X        World.gravity[xi][yi].y += sin(theta)*World.grav[g].force/
  818. X            sqr(avst);
  819. X        }
  820. X    }
  821. X}
  822. END_OF_FILE
  823. echo shar: 1 control character may be missing from \"'src/math.c'\"
  824. if test 2395 -ne `wc -c <'src/math.c'`; then
  825.     echo shar: \"'src/math.c'\" unpacked with wrong size!
  826. fi
  827. # end of 'src/math.c'
  828. fi
  829. if test -f 'src/proto.h' -a "${1}" != "-c" ; then 
  830.   echo shar: Will not clobber existing file \"'src/proto.h'\"
  831. else
  832. echo shar: Extracting \"'src/proto.h'\" \(4942 characters\)
  833. sed "s/^X//" >'src/proto.h' <<'END_OF_FILE'
  834. X/* proto.h,v 1.5 1992/06/28 05:38:25 bjoerns Exp
  835. X *
  836. X *    This file is part of the XPilot project, written by
  837. X *
  838. X *        Bjxrn Stabell (bjoerns@stud.cs.uit.no)
  839. X *        Ken Ronny Schouten (kenrsc@stud.cs.uit.no)
  840. X *
  841. X *    Copylefts are explained in the LICENSE file.
  842. X */
  843. X
  844. X#ifndef    PROTO_H
  845. X#define    PROTO_H
  846. X
  847. X#include <X11/Xlib.h>
  848. X#include "types.h"
  849. X#include "object.h"
  850. X#include "pack.h"
  851. X
  852. X
  853. X/*
  854. X * Prototypes for xinit.c
  855. X */
  856. Xextern u_byte Init_window(int ind);
  857. Xextern void Alloc_msgs(int number);
  858. Xextern void Free_msgs(int number);
  859. Xextern void DrawShadowText(int ind, Display *disp, Window w, GC gc, int x,
  860. X               int start_y, char *str, Pixel fg, Pixel bg);
  861. Xextern void Expose_info_window(int ind);
  862. Xextern void Expose_help_window(int ind);
  863. Xextern void Expose_button_window(int ind, int color, Window w);
  864. Xextern void Info(int ind, Window w);
  865. Xextern void Help(int ind, Window w);
  866. Xextern void Quit(int ind);
  867. Xextern int FatalError(Display *disp);
  868. Xextern void Set_labels(void);
  869. X
  870. X/*
  871. X * Prototypes for collision.c
  872. X */
  873. Xextern int Rate(int winner, int looser);
  874. Xextern void Check_collision(void);
  875. Xextern bool Landing(int ind, int point);
  876. X
  877. X/*
  878. X * Prototypes for dbuff.c
  879. X */
  880. Xextern void itob(long i);
  881. Xextern dbuff_state_t *start_dbuff(int ind, Display *display, Colormap cmap,
  882. X                  unsigned long planes, XColor *colors);
  883. Xextern void dbuff_switch(register int ind, register dbuff_state_t *state);
  884. Xextern void end_dbuff(int ind, dbuff_state_t *state);
  885. X
  886. X/*
  887. X * Prototypes for def.c
  888. X */
  889. Xextern void Get_defaults(int ind);
  890. X
  891. X/*
  892. X * Prototypes for draw.c
  893. X */
  894. Xextern char *scroll(char *string, int start, int length);
  895. Xextern void Draw_objects();
  896. Xextern void Draw_ships(int draw, int data);
  897. Xextern void Draw_shots(int draw, int data);
  898. Xextern void Draw_meters(int draw, int data);
  899. Xextern void Display_hud(int draw, int data);
  900. Xextern void Display_fuel_gauge(int draw, int data);
  901. Xextern void Display_velocity_gauge(int draw, int data);
  902. Xextern void Display_power_gauge(int draw, int data);
  903. Xextern void Display_compass(int draw, int data);
  904. Xextern void Draw_cannon(int draw, int data);
  905. Xextern void Display_message(int draw, int ind);
  906. Xextern void Set_message(char *message);
  907. Xextern void Draw_radar(int draw, int data);
  908. Xextern void Display_time(int draw, int data);
  909. Xextern void Draw_world(int draw, int data);
  910. Xextern void Draw_world_radar(int draw);
  911. X
  912. X/*
  913. X * Prototypes for error.c
  914. X */
  915. X#include "error.h"
  916. X
  917. X/*
  918. X * Prototypes for event.c
  919. X */
  920. Xextern void Refuel(int ind);
  921. Xextern void Key_event(int ind, XEvent *event);
  922. X
  923. X/*
  924. X * Prototypes for map.c
  925. X */
  926. Xextern void Optimize_map();
  927. Xextern void Print_map(void)            /* Debugging only. */;
  928. Xextern void Init_map(void);
  929. Xextern void Free_map(void);
  930. Xextern void Alloc_map(void);
  931. Xextern void Load_map(char *map);
  932. Xextern void Generate_random_map(void);
  933. X
  934. X/*
  935. X * Prototypes for math.c
  936. X */
  937. Xextern void Make_table(void);
  938. Xextern void Make_ships(void);
  939. Xextern void Free_ships(void);
  940. Xextern void Compute_gravity(void);
  941. X
  942. X/*
  943. X * Prototypes for parser.c
  944. X */
  945. Xextern void Parser(int argc, char *argv[]);
  946. X
  947. X/*
  948. X * Prototypes for play.c
  949. X */
  950. Xextern void Thrust(int ind);
  951. Xextern void Turn_thrust(int ind);
  952. Xextern void Recoil(object *ship, object *shot);
  953. Xextern void Delta_mv(object *ship, object *obj);
  954. Xextern void Alloc_shots(int number);
  955. Xextern void Free_shots(int number);
  956. Xextern void Place_item(int type);
  957. Xextern void Place_mine(int ind);
  958. Xextern void Cannon_fire(int ind);
  959. Xextern void Fire_shot(int ind, int type, int dir);
  960. Xextern void Delete_shot(int ind);
  961. Xextern void Move_smart_shot(int ind);
  962. Xextern void Explode_object(double x, double y, int real_dir,
  963. X               int spread, int intensity);
  964. Xextern void Explode(int ind);
  965. X
  966. X/*
  967. X * Prototypes for player.c
  968. X */
  969. Xextern void Pick_startpos(int ind);
  970. Xextern void Go_home(int ind);
  971. Xextern void Init_player(int ind);
  972. Xextern void Alloc_players(int number);
  973. Xextern void Free_players(int number);
  974. Xextern void Set_label_strings(void);
  975. X/*extern void Reset_all_players(void);*/
  976. Xextern void Compute_game_status(void);
  977. Xextern void Delete_player(int ind);
  978. Xextern void Kill_player(int ind);
  979. X
  980. X/*
  981. X * Prototypes for robot.c
  982. X */
  983. Xextern void Init_robot(int ind);
  984. Xextern void Update_robots(void);
  985. X
  986. X/*
  987. X * Prototypes for rules.c
  988. X */
  989. Xextern void Set_world_rules(int rule_ind);
  990. X
  991. X/*
  992. X * Prototypes for server.c
  993. X */
  994. Xextern int main(int argc, char *argv[]);
  995. Xextern void Main_Loop();
  996. Xextern void End_game(void);
  997. Xextern void Dump_pack(core_pack_t *p);
  998. Xextern bool Check_new_players(void);
  999. Xextern bool Owner(char *name);
  1000. Xextern void Handle_signal(int sig_no);
  1001. Xextern void Log_game(char *heading);
  1002. X
  1003. X/*
  1004. X * Prototypes for syslimit.c
  1005. X */
  1006. Xextern bool Is_allowed(void);
  1007. X
  1008. X/*
  1009. X * Prototypes for update.c
  1010. X */
  1011. Xextern void Update_objects(void);
  1012. X
  1013. X/*
  1014. X * Prototypes for usleep.c
  1015. X */
  1016. Xextern int usleep(unsigned long usec);
  1017. Xextern long seconds(void);
  1018. X
  1019. X/*
  1020. X * Prototypes for xpilot.c
  1021. X */
  1022. Xextern void initaddr(void);
  1023. Xextern void printfile(char *name);
  1024. Xextern bool Get_contact_message(void);
  1025. Xextern int Get_reply_message(reply_pack_t *p);
  1026. Xextern bool Connect_to_server(void);
  1027. X
  1028. X#endif
  1029. END_OF_FILE
  1030. echo shar: 1 control character may be missing from \"'src/proto.h'\"
  1031. if test 4942 -ne `wc -c <'src/proto.h'`; then
  1032.     echo shar: \"'src/proto.h'\" unpacked with wrong size!
  1033. fi
  1034. # end of 'src/proto.h'
  1035. fi
  1036. if test -f 'src/strcasecmp.c' -a "${1}" != "-c" ; then 
  1037.   echo shar: Will not clobber existing file \"'src/strcasecmp.c'\"
  1038. else
  1039. echo shar: Extracting \"'src/strcasecmp.c'\" \(622 characters\)
  1040. sed "s/^X//" >'src/strcasecmp.c' <<'END_OF_FILE'
  1041. X/* strcasecmp.c,v 1.3 1992/06/26 15:25:51 bjoerns Exp
  1042. X *
  1043. X *    This file is part of the XPilot project, written by
  1044. X *
  1045. X *        Bjxrn Stabell (bjoerns@stud.cs.uit.no)
  1046. X *        Ken Ronny Schouten (kenrsc@stud.cs.uit.no)
  1047. X *
  1048. X *    Copylefts are explained in the LICENSE file.
  1049. X */
  1050. X
  1051. X#include <ctype.h>
  1052. X
  1053. X#ifndef    lint
  1054. Xstatic char sourceid[] =
  1055. X    "@(#)strcasecmp.c,v 1.3 1992/06/26 15:25:51 bjoerns Exp";
  1056. X#endif
  1057. X
  1058. X/*
  1059. X * By Ian Malcom Brown.
  1060. X */
  1061. Xint
  1062. X    strcasecmp(str1, str2)
  1063. Xchar *str1, *str2;
  1064. X{
  1065. X    int    c1, c2;
  1066. X
  1067. X
  1068. X    do {
  1069. X    c1 = tolower(*str1++);
  1070. X    c2 = tolower(*str2++);
  1071. X    } while(c1 != 0 && c2 != 0 && c1 == c2);
  1072. X
  1073. X    return(c1 - c2);
  1074. X}
  1075. END_OF_FILE
  1076. echo shar: 1 control character may be missing from \"'src/strcasecmp.c'\"
  1077. if test 622 -ne `wc -c <'src/strcasecmp.c'`; then
  1078.     echo shar: \"'src/strcasecmp.c'\" unpacked with wrong size!
  1079. fi
  1080. # end of 'src/strcasecmp.c'
  1081. fi
  1082. if test -f 'src/syslimit.c' -a "${1}" != "-c" ; then 
  1083.   echo shar: Will not clobber existing file \"'src/syslimit.c'\"
  1084. else
  1085. echo shar: Extracting \"'src/syslimit.c'\" \(2359 characters\)
  1086. sed "s/^X//" >'src/syslimit.c' <<'END_OF_FILE'
  1087. X/* syslimit.c,v 1.8 1992/06/27 02:14:24 bjoerns Exp
  1088. X *
  1089. X *    This file is part of the XPilot project, written by
  1090. X *
  1091. X *        Bjxrn Stabell (bjoerns@stud.cs.uit.no)
  1092. X *        Ken Ronny Schouten (kenrsc@stud.cs.uit.no)
  1093. X *
  1094. X *    Copylefts are explained in the LICENSE file.
  1095. X */
  1096. X
  1097. X#include <stdio.h>        /* Could be moved below the #ifdef, but then */
  1098. X                /* we would get a warning (empty source file) */
  1099. X                /* each time LIMIT_ACCESS isn't defined. */
  1100. X#ifdef    LIMIT_ACCESS
  1101. X
  1102. X#include <time.h>
  1103. X#include "pack.h"
  1104. X
  1105. X#define PATTERN        "lglab[01]"
  1106. X#define FREELIMIT    7
  1107. X
  1108. X#define RUPTIME        "/usr/bin/ruptime "
  1109. X#define GREP        "/usr/local/bin/ggrep "
  1110. X#define WC_L        "/bin/wc -l "
  1111. X#define RWHO        "/usr/bin/rwho -a "
  1112. X
  1113. X#ifndef    lint
  1114. Xstatic char sourceid[] =
  1115. X    "@(#)syslimit.c,v 1.8 1992/06/27 02:14:24 bjoerns Exp";
  1116. X#endif
  1117. X
  1118. Xextern Pack        req;
  1119. X
  1120. X
  1121. X
  1122. X/*
  1123. X * This routine is not useful outside UiT but may be used as a skeleton for
  1124. X * similar routines, if similar problems should occur... :)
  1125. X */
  1126. Xbool Is_allowed(void)
  1127. X{
  1128. X    FILE *fp;
  1129. X    int total_no, no_free, in_use;
  1130. X    struct tm *now;
  1131. X    time_t        tmp;
  1132. X
  1133. X
  1134. X    if (strstr(req.display, "lglab") == NULL)
  1135. X    return (true);
  1136. X
  1137. X    printf("------------------\n");
  1138. X
  1139. X    if (strstr(req.display, "lglab2") != NULL) {
  1140. X    printf("Atsjoooooo! I can't, sorry! :)\n");
  1141. X    return (false);
  1142. X    }
  1143. X    tmp = time((time_t)NULL);
  1144. X    now = localtime(&tmp);
  1145. X
  1146. X    if (now->tm_hour >= 8 && now->tm_hour < 16) {
  1147. X    if (now->tm_wday != 0 && now->tm_wday != 6) {
  1148. X        printf("You'll have to wait %d hours and %d minutes until "
  1149. X           "you're allowed to play.\n",
  1150. X           16 - now->tm_hour, 60 - now->tm_min);
  1151. X        return (false);
  1152. X    }
  1153. X    }
  1154. X
  1155. X    printf("Checking number of unused workstations."); fflush(stdout);
  1156. X
  1157. X    fp = popen(RUPTIME "|" GREP PATTERN "|" GREP "\" up \"|" WC_L, "r");
  1158. X    fscanf(fp, "%d", &total_no);
  1159. X    pclose(fp);
  1160. X
  1161. X    printf("."); fflush(stdout);
  1162. X
  1163. X    fp = popen(RWHO "|" GREP "console |" GREP PATTERN "|" WC_L, "r");
  1164. X    fscanf(fp, "%d", &in_use);
  1165. X    pclose(fp);
  1166. X
  1167. X    printf(".\n"); fflush(stdout);
  1168. X
  1169. X    no_free = total_no - in_use;
  1170. X
  1171. X    printf("%d out of %d machines are free. "
  1172. X       "Current limit is at %d machines.\n", no_free, total_no, FREELIMIT);
  1173. X
  1174. X    if (no_free >= FREELIMIT) {
  1175. X    return (true);
  1176. X    } else {
  1177. X    printf("You will not be allowed to play until %d more users log out.\n",
  1178. X           FREELIMIT-no_free);
  1179. X    return (false);
  1180. X    }
  1181. X}
  1182. X
  1183. X#endif    /* LIMIT_ACCESS */
  1184. END_OF_FILE
  1185. echo shar: 1 control character may be missing from \"'src/syslimit.c'\"
  1186. if test 2359 -ne `wc -c <'src/syslimit.c'`; then
  1187.     echo shar: \"'src/syslimit.c'\" unpacked with wrong size!
  1188. fi
  1189. # end of 'src/syslimit.c'
  1190. fi
  1191. if test -f 'src/types.h' -a "${1}" != "-c" ; then 
  1192.   echo shar: Will not clobber existing file \"'src/types.h'\"
  1193. else
  1194. echo shar: Extracting \"'src/types.h'\" \(527 characters\)
  1195. sed "s/^X//" >'src/types.h' <<'END_OF_FILE'
  1196. X/* types.h,v 1.1 1992/06/25 03:24:19 bjoerns Exp
  1197. X *
  1198. X *    This file is part of the XPilot project, written by
  1199. X *
  1200. X *        Bjxrn Stabell (bjoerns@stud.cs.uit.no)
  1201. X *        Ken Ronny Schouten (kenrsc@stud.cs.uit.no)
  1202. X *
  1203. X *    Copylefts are explained in the LICENSE file.
  1204. X */
  1205. X
  1206. X#ifndef    TYPES_H
  1207. X#define    TYPES_H
  1208. X
  1209. X#include <sys/types.h>
  1210. X
  1211. Xtypedef signed char    byte;
  1212. Xtypedef unsigned char    u_byte;
  1213. X
  1214. Xtypedef enum {true = 1, false = 0} bool;
  1215. X
  1216. Xtypedef struct { float x, y; }    vector;
  1217. Xtypedef vector            position;
  1218. Xtypedef struct { int x, y; }    ipos;
  1219. X
  1220. X#endif
  1221. END_OF_FILE
  1222. echo shar: 1 control character may be missing from \"'src/types.h'\"
  1223. if test 527 -ne `wc -c <'src/types.h'`; then
  1224.     echo shar: \"'src/types.h'\" unpacked with wrong size!
  1225. fi
  1226. # end of 'src/types.h'
  1227. fi
  1228. echo shar: End of archive 24 \(of 24\).
  1229. cp /dev/null ark24isdone
  1230. MISSING=""
  1231. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 ; do
  1232.     if test ! -f ark${I}isdone ; then
  1233.     MISSING="${MISSING} ${I}"
  1234.     fi
  1235. done
  1236. if test "${MISSING}" = "" ; then
  1237.     echo You have unpacked all 24 archives.
  1238.     echo "\nNow run 'bldmaps.sh' to build the map files"
  1239.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1240. else
  1241.     echo You still need to unpack the following archives:
  1242.     echo "        " ${MISSING}
  1243. fi
  1244. ##  End of shell archive.
  1245. exit 0
  1246.