home *** CD-ROM | disk | FTP | other *** search
- Path: uunet!zephyr.ens.tek.com!master!saab!billr
- From: billr@saab.CNA.TEK.COM (Bill Randle)
- Newsgroups: comp.sources.games
- Subject: v14i026: xpilot - Multiplayer gravity war game hand-shake program, Part24/24
- Message-ID: <3321@master.CNA.TEK.COM>
- Date: 4 Aug 92 19:32:34 GMT
- Sender: news@master.CNA.TEK.COM
- Lines: 1235
- Approved: billr@saab.CNA.TEK.COM
-
- Submitted-by: Bjoern Stabell <bjoerns@staff.cs.uit.no>
- Posting-number: Volume 14, Issue 26
- Archive-name: xpilot/Part24
- Environment: X11, ANSI C
-
-
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 24 (of 24)."
- # Contents: BUGS CREDITS RESOURCES TODO fonts/README man6/README
- # maps/test.uue src/bit.h src/error.c src/error.h src/lib/Imakefile
- # src/limits.h src/map.h src/math.c src/proto.h src/strcasecmp.c
- # src/syslimit.c src/types.h
- # Wrapped by billr@saab on Tue Aug 4 10:39:00 1992
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'BUGS' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'BUGS'\"
- else
- echo shar: Extracting \"'BUGS'\" \(276 characters\)
- sed "s/^X//" >'BUGS' <<'END_OF_FILE'
- XKNOWN BUGS
- X==========
- X- Doesn't handle limited dogfight properly, don't use until fixed (the mode
- X isn't very popular).
- X- Doesn't always manage to contact server (could be I'm pouring too many
- X packets into the buffers at once).
- X- Sometimes you're able to lock on yourself.
- END_OF_FILE
- if test 276 -ne `wc -c <'BUGS'`; then
- echo shar: \"'BUGS'\" unpacked with wrong size!
- fi
- # end of 'BUGS'
- fi
- if test -f 'CREDITS' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'CREDITS'\"
- else
- echo shar: Extracting \"'CREDITS'\" \(453 characters\)
- sed "s/^X//" >'CREDITS' <<'END_OF_FILE'
- XPre-v1.2 credits:
- X
- X Arne Helme socklib
- X Tom Grydeland maps, fonts and ideas
- X
- X Lots of, LOTS OF beta testers at our site
- X
- XWe'd like to thank the following persons, without them there wouldn't have
- Xbeen a v1.2.
- X
- X Christos Zoulas monochrome fixes
- X Abraham Maurice robots, timing
- X Greg Renda rebinding of keys, wormholes etc.
- X
- X Dave Lemke
- X Keith Cantrell
- X Chris Marshall
- X Sigmund Austigard
- X Martin Rutishauser
- X Frank Tore Johansen
- X Hermann Dunkel
- END_OF_FILE
- if test 453 -ne `wc -c <'CREDITS'`; then
- echo shar: \"'CREDITS'\" unpacked with wrong size!
- fi
- # end of 'CREDITS'
- fi
- if test -f 'RESOURCES' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'RESOURCES'\"
- else
- echo shar: Extracting \"'RESOURCES'\" \(2105 characters\)
- sed "s/^X//" >'RESOURCES' <<'END_OF_FILE'
- X!
- X! This file lists up the X resources that XPilot understands and their
- X! default values.
- X!
- Xxpilot*name: <login name> #nick name
- Xxpilot*power: 45.0 #use 5.0-55.0
- Xxpilot*turnSpeed: 30.0 #use 8.0-64.0
- Xxpilot*turnResistance: 0.12 #use 0.1-0.9
- Xxpilot*altPower: 35.0
- Xxpilot*altTurnSpeed: 25.0
- Xxpilot*altTurnResistance: 0.12
- Xxpilot*team: 0 #0=no team (1-9)
- Xxpilot*fuelNotify: 500.0 #HUDfuel on
- Xxpilot*fuelWarning: 200.0 #HUDfuel flash
- Xxpilot*fuelCritical: 100.0 #HUDfuel flash fast
- Xxpilot*showHUD: true #HUD on/off
- Xxpilot*verticalHUDLine: false
- Xxpilot*horizontalHUDLine: true
- Xxpilot*fuelMeter: false
- Xxpilot*fuelGauge: false
- Xxpilot*turnSpeedMeter: false
- Xxpilot*powerMeter: false
- X
- X!
- X! These are the default keybindings, they are tailormade for HP keyboards, but
- X! with some SUN functionality thrown in:
- X!
- Xxpilot*keyLockNext: Right Next
- Xxpilot*keyLockPrev: Left Prior
- Xxpilot*keyLockClose: Up Down Select
- Xxpilot*keyChangeHome: Home
- Xxpilot*keyShield: Meta_R space
- Xxpilot*keyFireShot: Return
- Xxpilot*keyFireMissile: backslash Linefeed
- Xxpilot*keyDropMine: Tab
- Xxpilot*keyTurnLeft: a
- Xxpilot*keyTurnRight: s
- Xxpilot*keySelfDestruct: q
- Xxpilot*keyIdMode: i
- Xxpilot*keyPause: p
- Xxpilot*keyToggleVelocity: v
- Xxpilot*keyToggleCompass: c
- Xxpilot*keySwapSettings: Escape
- Xxpilot*keyRefuel: f Control_L Control_R Caps_Lock
- Xxpilot*keyIncreasePower: KP_Multiply
- Xxpilot*keyDecreasePower: KP_Divide
- Xxpilot*keyIncreaseTurnspeed: KP_Add
- Xxpilot*keyDecreaseTurnspeed: KP_Subtract
- Xxpilot*keyThrust: Shift_L Shift_R
- Xxpilot*keyCloak: BackSpace
- Xxpilot*keySlowdown: bracketleft braceleft
- Xxpilot*keySpeedup: bracketright braceright
- END_OF_FILE
- if test 2105 -ne `wc -c <'RESOURCES'`; then
- echo shar: \"'RESOURCES'\" unpacked with wrong size!
- fi
- # end of 'RESOURCES'
- fi
- if test -f 'TODO' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'TODO'\"
- else
- echo shar: Extracting \"'TODO'\" \(463 characters\)
- sed "s/^X//" >'TODO' <<'END_OF_FILE'
- XTODO list for XPilot
- X====================
- X- double buffering on labels. (?)
- X- thrust flame moved a little further back.
- X- bouncing.
- X- better detection of servers and contact mechanism (TCP instead of UDP maybe).
- X- more bitplanes/colours, at least the possibility to determine this yourself.
- X- no players may have the same name, maybe save player ratings.
- X- enhance team option (team with names, own colors and home bases?)
- X- make an xp-ed (xpilot-ed) map editor.
- END_OF_FILE
- if test 463 -ne `wc -c <'TODO'`; then
- echo shar: \"'TODO'\" unpacked with wrong size!
- fi
- # end of 'TODO'
- fi
- if test -f 'fonts/README' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'fonts/README'\"
- else
- echo shar: Extracting \"'fonts/README'\" \(453 characters\)
- sed "s/^X//" >'fonts/README' <<'END_OF_FILE'
- X(NOTE, these fonts are not needed by xpilot (or xpilots), they are provided
- Xmerely as a help for those of you who want to use a standard text editor to
- Xgenerate maps.)
- X
- XFirst, make the fonts (done in the directory where the .bdf files are):
- X
- Xksh:
- X for font in map*.bdf
- X do
- X bdftosnf $font | compress > ${font%%.bdf}.scf
- X done
- X mkfontdir
- X
- XTo install these fonts in your font-path, use the following commands:
- X
- X xset fp+ <this-directory>
- X xset fp rehash
- END_OF_FILE
- if test 453 -ne `wc -c <'fonts/README'`; then
- echo shar: \"'fonts/README'\" unpacked with wrong size!
- fi
- # end of 'fonts/README'
- fi
- if test -f 'man6/README' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'man6/README'\"
- else
- echo shar: Extracting \"'man6/README'\" \(95 characters\)
- sed "s/^X//" >'man6/README' <<'END_OF_FILE'
- XTo read these files without installing them on your system, use
- X
- X nroff -man <filename> | more
- END_OF_FILE
- if test 95 -ne `wc -c <'man6/README'`; then
- echo shar: \"'man6/README'\" unpacked with wrong size!
- fi
- # end of 'man6/README'
- fi
- if test -f 'maps/test.uue' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'maps/test.uue'\"
- else
- echo shar: Extracting \"'maps/test.uue'\" \(1395 characters\)
- sed "s/^X//" >'maps/test.uue' <<'END_OF_FILE'
- Xbegin 644 test.map
- XM,S!X,S`*,`I3;VUE('5N<&QE87-A;G0@<W5R<')I<V5S(&9O<B!E=F5R>6]N
- XM90I4;VT@1W)Y9&5L86YD"GAX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX
- XM>`IX("`K("`@("`@(#YR("T\("`@("`@("`@("`^('@*>"`@("`@("`@("!D
- XM1F8@/"`@("`@("`@("`@("!X"G@@("!Q=R`@("`@(&,@("`@("`@("`@("`@
- XM("H@>`IX("`@87,@("`@("`@("`@("`@("`@("`@("`@('@*>"`@("`@("`@
- XM("`@("`@("`@("`@("`@("`@/"!X"G@@("`@("`@("`@("`@("`@("`@("`@
- XM("`@("`@>`IX("`@("`@("`@("`@("`@("`@("`@("`@("`@,'@*>"`@("`@
- XM("`@("`@("`@("`@("`@("`@("`@(#%X"G@@("`@("`@("`@("`@("`@("`@
- XM("`@("`@("`R>`IX("`@("`@("`@("`@("`@("`@("`@("`@("`@,W@*>"`@
- XM("`@("`@("`@("`@("`@("`@("`@("`@(#1X"G@@("`@("`@("`@("`@("`@
- XM("`@("`@("`@("`U>`IX("`@("`@("`@("`@("`@("`@("`@("`@("`@-G@*
- XM>"`@("`@("`@("`@("`@("`@("`@("`@("`@(#=X"G@@("`@("`@("`@("`@
- XM("`@("`@("`@("`@("`X>`IX("`@("`@("`@("`@("`@("`@("`@("`@("`@
- XM.7@*>"`@("`@("`@("`@("!R("`@("`@("`@("`@("!X"G@@("`@("`@("`@
- XM(#QD*F8^("`@("`@("`@("`@>`IX("`@("`@("`@("`@(&,@("`@("`@("`@
- XM("`@('@*>"`@("`@("`@("`@("`@("`@("`@("`@("`@("!X"G@@("`@("`@
- XM("`@("`@("`@("`@("`@("`@("`@>`IX("`@("`@("`@("`@("`@("`@("`@
- XM("`@("`@('@*>"`@("`@("`@("`@("`@("`@("`@("`@("`@("!X"G@@<7,@
- XM("`@("`@("`@("`@("`@("`@("`@("`@>`IX<7,@("`@("`@("`@("`@("`@
- XM("`@("`@("`@('@*>',@("`@("`@("`@("`@("`@("`@("`@("`@("!X"G@N
- XM+BXN+BXN+BXN+BXN+BXN+BXN+BXN+BXN+BXN>`IX*RXJ+BLN+BXN+BXN+BXN
- XM+BXN+BXN+BXN+BXN<7@*>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX>'AX
- X!"BXN
- X`
- Xend
- END_OF_FILE
- if test 1395 -ne `wc -c <'maps/test.uue'`; then
- echo shar: \"'maps/test.uue'\" unpacked with wrong size!
- fi
- # end of 'maps/test.uue'
- fi
- if test -f 'src/bit.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/bit.h'\"
- else
- echo shar: Extracting \"'src/bit.h'\" \(448 characters\)
- sed "s/^X//" >'src/bit.h' <<'END_OF_FILE'
- X/* bit.h,v 1.4 1992/06/25 03:23:46 bjoerns Exp
- X *
- X * This file is part of the XPilot project, written by
- X *
- X * Bjxrn Stabell (bjoerns@stud.cs.uit.no)
- X * Ken Ronny Schouten (kenrsc@stud.cs.uit.no)
- X *
- X * Copylefts are explained in the LICENSE file.
- X */
- X
- X#ifndef BIT_H
- X#define BIT_H
- X
- X#define SET_BIT(w, bit) w |= (bit);
- X#define CLR_BIT(w, bit) w &= (~(bit));
- X#define BIT(w, bit) ( w & (bit) )
- X#define TOGGLE_BIT(w, bit) w ^= (bit);
- X
- X#endif
- END_OF_FILE
- echo shar: 1 control character may be missing from \"'src/bit.h'\"
- if test 448 -ne `wc -c <'src/bit.h'`; then
- echo shar: \"'src/bit.h'\" unpacked with wrong size!
- fi
- # end of 'src/bit.h'
- fi
- if test -f 'src/error.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/error.c'\"
- else
- echo shar: Extracting \"'src/error.c'\" \(1928 characters\)
- sed "s/^X//" >'src/error.c' <<'END_OF_FILE'
- X/* error.c,v 1.6 1992/06/28 07:55:03 bjoerns Exp
- X *
- X * Adapted from 'The UNIX Programming Environment' by Kernighan & Pike
- X * and an example from the manualpage for vprintf by
- X * Gaute Nessan, University of Tromsoe (gaute@staff.cs.uit.no).
- X *
- X * Modified by Bjoern Stabell (bjoerns@staff.cs.uit.no).
- X */
- X
- X#include "error.h"
- X
- X#ifndef lint
- Xstatic char sourceid[] =
- X "@(#)error.c,v 1.6 1992/06/28 07:55:03 bjoerns Exp";
- X#endif
- X
- X
- X
- X/*
- X * This file defines two entry points:
- X *
- X * init_error() - Initialize the error routine, accepts program name
- X * as input.
- X * error() - perror() with printf functionality.
- X */
- X
- X
- X
- X/*
- X * Global data.
- X */
- X#define MAX_PROG_LENGTH 256
- Xstatic char progname[MAX_PROG_LENGTH];
- X
- X
- X
- X/*
- X * Functions.
- X */
- Xvoid
- X init_error(prog)
- Xchar *prog;
- X{
- X char *p = strrchr(prog, '/');
- X
- X strncpy(progname, p ? p+1 : prog, MAX_PROG_LENGTH); /* Beautify arv[0] */
- X}
- X
- X
- X
- X#if defined(__STDC__) && !defined(__sun__)
- X
- X/*
- X * Ok, let's do it the ANSI C way.
- X */
- Xvoid error(char *fmt, ...)
- X{
- X va_list ap; /* Argument pointer */
- X int e = errno; /* Store errno */
- X
- X
- X va_start(ap, fmt);
- X
- X if (progname[0] != '\0')
- X fprintf(stderr, "%s: ", progname);
- X
- X vfprintf(stderr, fmt, ap);
- X
- X if (e != 0)
- X fprintf(stderr, " (%s)", strerror(e));
- X
- X fprintf(stderr, "\n");
- X
- X va_end(args);
- X}
- X
- X#else
- X
- X/*
- X * Hm, we'd better stick to the K&R way.
- X */
- Xvoid
- X error(va_alist)
- Xva_dcl /* Note that the format argument cannot be separately *
- X * declared because of the definition of varargs. */
- X{
- X va_list args;
- X int e = errno;
- X extern int sys_nerr;
- X extern char *sys_errlist[];
- X char *fmt;
- X
- X
- X va_start(args);
- X
- X if (progname[0] != '\0')
- X fprintf(stderr, "%s: ", progname);
- X
- X fmt = va_arg(args, char *);
- X (void) vfprintf(stderr, fmt, args);
- X
- X if (e > 0 && e < sys_nerr)
- X fprintf(stderr, " (%s)", sys_errlist[e]);
- X
- X fprintf(stderr, "\n");
- X
- X va_end(args);
- X}
- X
- X#endif
- END_OF_FILE
- if test 1928 -ne `wc -c <'src/error.c'`; then
- echo shar: \"'src/error.c'\" unpacked with wrong size!
- fi
- # end of 'src/error.c'
- fi
- if test -f 'src/error.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/error.h'\"
- else
- echo shar: Extracting \"'src/error.h'\" \(753 characters\)
- sed "s/^X//" >'src/error.h' <<'END_OF_FILE'
- X/* error.h,v 1.2 1992/06/28 07:55:04 bjoerns Exp
- X *
- X * Adapted from 'The UNIX Programming Environment' by Kernighan & Pike
- X * and an example from the manualpage for vprintf by
- X * Gaute Nessan, University of Tromsoe (gaute@staff.cs.uit.no).
- X *
- X * Modified by Bjoern Stabell (bjoerns@staff.cs.uit.no).
- X */
- X
- X#ifndef ERROR_H
- X#define ERROR_H
- X
- X/*
- X * Prototypes and include files.
- X */
- X
- X#include <errno.h>
- X#include <stdio.h>
- X#if defined(__STDC__) && !defined(__sun__)
- X# include <stdarg.h>
- X#else
- X# include <varargs.h>
- X#endif
- X#include <string.h>
- X
- X#if defined(__STDC__) && !defined(__sun__)
- X extern void init_error(char *prog);
- X extern void error(char *fmt, ...);
- X#else
- X extern void init_error();
- X extern void error();
- X#endif
- X
- X#endif /* ERROR_H */
- END_OF_FILE
- if test 753 -ne `wc -c <'src/error.h'`; then
- echo shar: \"'src/error.h'\" unpacked with wrong size!
- fi
- # end of 'src/error.h'
- fi
- if test -f 'src/lib/Imakefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/lib/Imakefile'\"
- else
- echo shar: Extracting \"'src/lib/Imakefile'\" \(155 characters\)
- sed "s/^X//" >'src/lib/Imakefile' <<'END_OF_FILE'
- X# @(#)Imakefile 23/01/92
- X# Imakefile - socklib
- X
- XOBJS = socklib.o
- XSRCS = socklib.c
- X
- X#
- X# Make socklib
- X#
- XNormalLibraryTarget(socklib, $(OBJS))
- XDependTarget()
- END_OF_FILE
- if test 155 -ne `wc -c <'src/lib/Imakefile'`; then
- echo shar: \"'src/lib/Imakefile'\" unpacked with wrong size!
- fi
- # end of 'src/lib/Imakefile'
- fi
- if test -f 'src/limits.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/limits.h'\"
- else
- echo shar: Extracting \"'src/limits.h'\" \(2560 characters\)
- sed "s/^X//" >'src/limits.h' <<'END_OF_FILE'
- X/* limits.h,v 1.4 1992/06/28 05:38:16 bjoerns Exp
- X *
- X * This file is part of the XPilot project, written by
- X *
- X * Bjxrn Stabell (bjoerns@stud.cs.uit.no)
- X * Ken Ronny Schouten (kenrsc@stud.cs.uit.no)
- X *
- X * Copylefts are explained in the LICENSE file.
- X */
- X
- X#ifndef LIMITS_H
- X#define LIMITS_H
- X
- X#include <limits.h>
- X
- X/*
- X * DBL_MAX and RAND_MAX is ANSI C standard, but some architectures (BSD) use
- X * MAXDOUBLE and INT_MAX instead.
- X */
- X#ifndef DBL_MAX
- X# include <values.h>
- X# define DBL_MAX MAXDOUBLE
- X#endif
- X#ifndef RAND_MAX
- X# define RAND_MAX INT_MAX
- X#endif
- X
- X/* Not everyone has PI (or M_PI defined). */
- X#ifndef M_PI
- X#define PI 3.14159265358979323846
- X#else
- X#define PI M_PI
- X#endif
- X
- X#define MOD(x, y) (((x)>=(y) || (x)<0) ? ((x)>=(y)?(x)-(y):(x)+(y)) :(x))
- X#define TABLE_SIZE RES
- X#define tsin(x) (tbl_sin[MOD(x, TABLE_SIZE)])
- X#define tcos(x) (tbl_sin[MOD((x)+TABLE_SIZE/4, TABLE_SIZE)])
- X
- X#define TEAM(i, j) (BIT(Players[i]->status, PAUSE) || \
- X BIT(Players[j]->status, PAUSE) ? \
- X true : (BIT(World.rules->mode, TEAM_PLAY) ? \
- X ((Players[i]->team == Players[j]->team) && \
- X Players[i]->team!=0) : false))
- X
- X#define ABS(x) ( (x)<0 ? -(x) : (x) )
- X#ifndef MAX
- X#define MIN(x, y) ( (x)>(y) ? (y) : (x) )
- X#define MAX(x, y) ( (x)>(y) ? (x) : (y) )
- X#endif
- X#define sqr(x) ( (x)*(x) )
- X#define LENGTH(x, y) ( sqrt(sqr(x) + sqr(y)) )
- X#define LIMIT(val, lo, hi) val = val>hi ? hi : (val<lo ? lo : val)
- X
- X#define CANNON_DEAD_TIME 900
- X#define RECOVERY_DELAY 128
- X
- X#define MAX_BASES 64
- X#define MAX_PLAYERS MAX_BASES /* Miscellaneous limits */
- X#define MAX_MSGS 8
- X#define MAX_CHARS 80
- X#define MAX_KEY_DEFS 100
- X#define MAX_SCROLL_LEN 4096
- X#define MAX_STATUS_CHARS 200
- X#define MIN_PAUSE 800
- X#define MAX_SHOTS 64
- X#define MAX_TOTAL_SHOTS 16384
- X#define MAX_STATION_FUEL 500.0
- X#define MAX_ID 2048 /* Should suffice :) */
- X#define STATION_REGENERATION 0.06
- X#define MAX_PLAYER_FUEL 2600.0
- X#define MIN_PLAYER_FUEL 350.0
- X#define MAX_PLAYER_TURNSPEED 64.0
- X#define MIN_PLAYER_TURNSPEED 4.0
- X#define MAX_PLAYER_POWER 55.0
- X#define MIN_PLAYER_POWER 5.0
- X#define REFUEL_RATE 5.0
- X#define RACE_PLAYER_FUEL 500.0
- X#define DEFAULT_PLAYER_FUEL 1000.0
- X#define RES 128
- X#define GRAVS_POWER 2.7
- X#define SMART_SHOT_ACC 0.6
- X#define SPEED_LIMIT 65.0
- X#define SMART_SHOT_MAX_SPEED 22.0
- X#define ENERGY_RANGE_FACTOR 2.5
- X#define SHOTS_ANGLE (RES/40)
- X#define WARNING_DISTANCE 800.0
- X#define VISIBILITY_DISTANCE 1000.0
- X#define MAX_KEY_DEFS 100
- X
- X#define BLOCK_SZ 35
- X
- X#define SHIP_SZ 14 /* Size (pixels) of radius for legal HIT! */
- X
- X#define MSG_LEN 256
- X
- X#endif
- END_OF_FILE
- echo shar: 1 control character may be missing from \"'src/limits.h'\"
- if test 2560 -ne `wc -c <'src/limits.h'`; then
- echo shar: \"'src/limits.h'\" unpacked with wrong size!
- fi
- # end of 'src/limits.h'
- fi
- if test -f 'src/map.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/map.h'\"
- else
- echo shar: Extracting \"'src/map.h'\" \(2316 characters\)
- sed "s/^X//" >'src/map.h' <<'END_OF_FILE'
- X/* map.h,v 1.6 1992/06/28 05:38:18 bjoerns Exp
- X *
- X * This file is part of the XPilot project, written by
- X *
- X * Bjxrn Stabell (bjoerns@stud.cs.uit.no)
- X * Ken Ronny Schouten (kenrsc@stud.cs.uit.no)
- X *
- X * Copylefts are explained in the LICENSE file.
- X */
- X
- X#ifndef MAP_H
- X#define MAP_H
- X
- X#include "types.h"
- X#include "rules.h"
- X#include "limits.h"
- X
- X/*
- X * Default map name, set to your own favourite -
- X * or set it to "N/A", in which case the computer
- X * will generate a random map. (Not very good)
- X */
- X#define DEFAULT_MAP "continent"
- X
- X#define MAX_FUELS 128
- X#define MAX_GRAVS 512
- X#define MAX_CANNONS 512
- X#define MAX_CHECKS 10
- X#define MAX_WORMHOLES 50
- X
- X#define SPACE 0
- X#define BASE 1
- X#define FILLED 2
- X#define FILLED_NO_DRAW 3
- X#define REC_LU 4
- X#define REC_LD 5
- X#define REC_RU 6
- X#define REC_RD 7
- X#define FUEL 8
- X#define CANNON 9
- X#define CHECK 10
- X#define SPECIAL 11
- X#define POS_GRAV 20
- X#define NEG_GRAV 21
- X#define CWISE_GRAV 22
- X#define ACWISE_GRAV 23
- X#define WORMHOLE 24
- X
- X#ifndef MAP_DIR
- X#define MAP_DIR (LIBDIR "maps/")
- X#endif
- X
- X#define DIR_RIGHT 0
- X#define DIR_UP (RES/4)
- X#define DIR_LEFT (RES/2)
- X#define DIR_DOWN (3*RES/4)
- X
- X#define ITEM_SMART_SHOT_PACK 0
- X#define ITEM_CLOAKING_DEVICE 1
- X#define ITEM_ENERGY_PACK 2
- X#define ITEM_WIDEANGLE_SHOT 3
- X#define ITEM_REAR_SHOT 4
- X#define ITEM_MINE_PACK 5
- X#define ITEM_SENSOR_PACK 6
- X#define NUM_ITEMS 7
- X
- X
- X
- Xtypedef struct {
- X position pos;
- X double left;
- X} fuel_t;
- X
- Xtypedef struct {
- X ipos pos;
- X double force;
- X} grav_t;
- X
- Xtypedef struct {
- X ipos pos;
- X int dir;
- X int dead_time;
- X bool active;
- X} cannon_t;
- X
- Xtypedef struct {
- X int max; /* Max on world at a given time */
- X int num; /* Number active right now */
- X int chance; /* Chance for the item to appear on this world */
- X} item_t;
- X
- X
- Xtypedef struct {
- X int x, y; /* Size of world */
- X rules_t *rules;
- X char name[MAX_CHARS];
- X char author[MAX_CHARS];
- X
- X u_byte **block;
- X vector **gravity;
- X
- X item_t items[NUM_ITEMS];
- X
- X int NumBases;
- X ipos base[MAX_BASES];
- X int NumFuels;
- X fuel_t fuel[MAX_FUELS];
- X int NumGravs;
- X grav_t grav[MAX_GRAVS];
- X int NumCannons;
- X cannon_t cannon[MAX_CANNONS];
- X int NumChecks;
- X ipos check[MAX_CHECKS];
- X int NumWormholes;
- X ipos wormhole[MAX_WORMHOLES];
- X} World_map;
- X
- X#endif
- END_OF_FILE
- echo shar: 1 control character may be missing from \"'src/map.h'\"
- if test 2316 -ne `wc -c <'src/map.h'`; then
- echo shar: \"'src/map.h'\" unpacked with wrong size!
- fi
- # end of 'src/map.h'
- fi
- if test -f 'src/math.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/math.c'\"
- else
- echo shar: Extracting \"'src/math.c'\" \(2395 characters\)
- sed "s/^X//" >'src/math.c' <<'END_OF_FILE'
- X/* math.c,v 1.7 1992/06/28 05:38:19 bjoerns Exp
- X *
- X * This file is part of the XPilot project, written by
- X *
- X * Bjxrn Stabell (bjoerns@stud.cs.uit.no)
- X * Ken Ronny Schouten (kenrsc@stud.cs.uit.no)
- X *
- X * Copylefts are explained in the LICENSE file.
- X */
- X
- X#include "global.h"
- X
- X
- X#define GRAV_RANGE 10
- X#define PTS_IN_SHIP 3
- X
- X#ifndef lint
- Xstatic char sourceid[] =
- X "@(#)math.c,v 1.7 1992/06/28 05:38:19 bjoerns Exp";
- X#endif
- X
- Xdouble tbl_sin[TABLE_SIZE];
- Xwireobj ships[RES];
- X
- X
- X
- Xvoid Make_table(void)
- X{
- X int i;
- X
- X for (i=0; i<TABLE_SIZE; i++)
- X tbl_sin[i] = sin((2*PI) * ((double)i/TABLE_SIZE));
- X}
- X
- X
- Xvoid Make_ships(void)
- X{
- X int i, z;
- X
- X
- X ships[0].pts=(position *)malloc(PTS_IN_SHIP*sizeof(position));
- X ships[0].pts[0].x = 15; ships[0].pts[0].y = 0;
- X ships[0].pts[1].x = -9; ships[0].pts[1].y = 8;
- X ships[0].pts[2].x = -9; ships[0].pts[2].y = -8;
- X ships[0].num_points=PTS_IN_SHIP;
- X
- X for (i=1; i<RES; i++) {
- X ships[i].pts=(position *)malloc(PTS_IN_SHIP*sizeof(position));
- X
- X for (z=0; z<PTS_IN_SHIP; z++) {
- X ships[i].pts[z].x = tcos(i)*ships[0].pts[z].x
- X - tsin(i)*ships[0].pts[z].y;
- X ships[i].pts[z].y = tsin(i)*ships[0].pts[z].x
- X + tcos(i)*ships[0].pts[z].y;
- X }
- X }
- X}
- X
- X
- Xvoid Free_ships(void)
- X{
- X int dir;
- X
- X
- X for (dir=0; dir<RES; dir++)
- X free(ships[dir].pts);
- X}
- X
- X
- Xvoid Compute_gravity(void)
- X{
- X int xi, yi, g, gx, gy;
- X double theta, avst, dx, dy;
- X
- X
- X for (xi=0; xi<World.x; xi++)
- X for (yi=0; yi<World.y; yi++) {
- X World.gravity[xi][yi].y = Gravity;
- X World.gravity[xi][yi].x = 0.0;
- X }
- X
- X for (g=0; g<World.NumGravs; g++) {
- X gx = World.grav[g].pos.x;
- X gy = World.grav[g].pos.y;
- X
- X for (xi = (gx>GRAV_RANGE) ? gx-GRAV_RANGE : 0;
- X (xi<gx+GRAV_RANGE) && (xi<World.x); xi++)
- X for (yi = (gy>GRAV_RANGE) ? gy-GRAV_RANGE : 0;
- X (yi<gy+GRAV_RANGE) && (yi<World.y); yi++) {
- X dx = (double)(gx - xi);
- X dy = (double)(gy - yi);
- X
- X if ((dy == 0) && (dx == 0)) /* In a grav? */
- X continue;
- X
- X avst = (double)LENGTH(dx, dy);
- X if (dx != 0.0) {
- X theta = atan2(dy, dx);
- X } else
- X if (dy > 0)
- X theta = PI/2.0;
- X else
- X theta = 3.0*PI/2.0;
- X
- X if (World.block[gx][gy] == CWISE_GRAV ||
- X World.block[gx][gy] == ACWISE_GRAV)
- X theta += PI/2.0;
- X
- X World.gravity[xi][yi].x += cos(theta)*World.grav[g].force/
- X sqr(avst);
- X World.gravity[xi][yi].y += sin(theta)*World.grav[g].force/
- X sqr(avst);
- X }
- X }
- X}
- END_OF_FILE
- echo shar: 1 control character may be missing from \"'src/math.c'\"
- if test 2395 -ne `wc -c <'src/math.c'`; then
- echo shar: \"'src/math.c'\" unpacked with wrong size!
- fi
- # end of 'src/math.c'
- fi
- if test -f 'src/proto.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/proto.h'\"
- else
- echo shar: Extracting \"'src/proto.h'\" \(4942 characters\)
- sed "s/^X//" >'src/proto.h' <<'END_OF_FILE'
- X/* proto.h,v 1.5 1992/06/28 05:38:25 bjoerns Exp
- X *
- X * This file is part of the XPilot project, written by
- X *
- X * Bjxrn Stabell (bjoerns@stud.cs.uit.no)
- X * Ken Ronny Schouten (kenrsc@stud.cs.uit.no)
- X *
- X * Copylefts are explained in the LICENSE file.
- X */
- X
- X#ifndef PROTO_H
- X#define PROTO_H
- X
- X#include <X11/Xlib.h>
- X#include "types.h"
- X#include "object.h"
- X#include "pack.h"
- X
- X
- X/*
- X * Prototypes for xinit.c
- X */
- Xextern u_byte Init_window(int ind);
- Xextern void Alloc_msgs(int number);
- Xextern void Free_msgs(int number);
- Xextern void DrawShadowText(int ind, Display *disp, Window w, GC gc, int x,
- X int start_y, char *str, Pixel fg, Pixel bg);
- Xextern void Expose_info_window(int ind);
- Xextern void Expose_help_window(int ind);
- Xextern void Expose_button_window(int ind, int color, Window w);
- Xextern void Info(int ind, Window w);
- Xextern void Help(int ind, Window w);
- Xextern void Quit(int ind);
- Xextern int FatalError(Display *disp);
- Xextern void Set_labels(void);
- X
- X/*
- X * Prototypes for collision.c
- X */
- Xextern int Rate(int winner, int looser);
- Xextern void Check_collision(void);
- Xextern bool Landing(int ind, int point);
- X
- X/*
- X * Prototypes for dbuff.c
- X */
- Xextern void itob(long i);
- Xextern dbuff_state_t *start_dbuff(int ind, Display *display, Colormap cmap,
- X unsigned long planes, XColor *colors);
- Xextern void dbuff_switch(register int ind, register dbuff_state_t *state);
- Xextern void end_dbuff(int ind, dbuff_state_t *state);
- X
- X/*
- X * Prototypes for def.c
- X */
- Xextern void Get_defaults(int ind);
- X
- X/*
- X * Prototypes for draw.c
- X */
- Xextern char *scroll(char *string, int start, int length);
- Xextern void Draw_objects();
- Xextern void Draw_ships(int draw, int data);
- Xextern void Draw_shots(int draw, int data);
- Xextern void Draw_meters(int draw, int data);
- Xextern void Display_hud(int draw, int data);
- Xextern void Display_fuel_gauge(int draw, int data);
- Xextern void Display_velocity_gauge(int draw, int data);
- Xextern void Display_power_gauge(int draw, int data);
- Xextern void Display_compass(int draw, int data);
- Xextern void Draw_cannon(int draw, int data);
- Xextern void Display_message(int draw, int ind);
- Xextern void Set_message(char *message);
- Xextern void Draw_radar(int draw, int data);
- Xextern void Display_time(int draw, int data);
- Xextern void Draw_world(int draw, int data);
- Xextern void Draw_world_radar(int draw);
- X
- X/*
- X * Prototypes for error.c
- X */
- X#include "error.h"
- X
- X/*
- X * Prototypes for event.c
- X */
- Xextern void Refuel(int ind);
- Xextern void Key_event(int ind, XEvent *event);
- X
- X/*
- X * Prototypes for map.c
- X */
- Xextern void Optimize_map();
- Xextern void Print_map(void) /* Debugging only. */;
- Xextern void Init_map(void);
- Xextern void Free_map(void);
- Xextern void Alloc_map(void);
- Xextern void Load_map(char *map);
- Xextern void Generate_random_map(void);
- X
- X/*
- X * Prototypes for math.c
- X */
- Xextern void Make_table(void);
- Xextern void Make_ships(void);
- Xextern void Free_ships(void);
- Xextern void Compute_gravity(void);
- X
- X/*
- X * Prototypes for parser.c
- X */
- Xextern void Parser(int argc, char *argv[]);
- X
- X/*
- X * Prototypes for play.c
- X */
- Xextern void Thrust(int ind);
- Xextern void Turn_thrust(int ind);
- Xextern void Recoil(object *ship, object *shot);
- Xextern void Delta_mv(object *ship, object *obj);
- Xextern void Alloc_shots(int number);
- Xextern void Free_shots(int number);
- Xextern void Place_item(int type);
- Xextern void Place_mine(int ind);
- Xextern void Cannon_fire(int ind);
- Xextern void Fire_shot(int ind, int type, int dir);
- Xextern void Delete_shot(int ind);
- Xextern void Move_smart_shot(int ind);
- Xextern void Explode_object(double x, double y, int real_dir,
- X int spread, int intensity);
- Xextern void Explode(int ind);
- X
- X/*
- X * Prototypes for player.c
- X */
- Xextern void Pick_startpos(int ind);
- Xextern void Go_home(int ind);
- Xextern void Init_player(int ind);
- Xextern void Alloc_players(int number);
- Xextern void Free_players(int number);
- Xextern void Set_label_strings(void);
- X/*extern void Reset_all_players(void);*/
- Xextern void Compute_game_status(void);
- Xextern void Delete_player(int ind);
- Xextern void Kill_player(int ind);
- X
- X/*
- X * Prototypes for robot.c
- X */
- Xextern void Init_robot(int ind);
- Xextern void Update_robots(void);
- X
- X/*
- X * Prototypes for rules.c
- X */
- Xextern void Set_world_rules(int rule_ind);
- X
- X/*
- X * Prototypes for server.c
- X */
- Xextern int main(int argc, char *argv[]);
- Xextern void Main_Loop();
- Xextern void End_game(void);
- Xextern void Dump_pack(core_pack_t *p);
- Xextern bool Check_new_players(void);
- Xextern bool Owner(char *name);
- Xextern void Handle_signal(int sig_no);
- Xextern void Log_game(char *heading);
- X
- X/*
- X * Prototypes for syslimit.c
- X */
- Xextern bool Is_allowed(void);
- X
- X/*
- X * Prototypes for update.c
- X */
- Xextern void Update_objects(void);
- X
- X/*
- X * Prototypes for usleep.c
- X */
- Xextern int usleep(unsigned long usec);
- Xextern long seconds(void);
- X
- X/*
- X * Prototypes for xpilot.c
- X */
- Xextern void initaddr(void);
- Xextern void printfile(char *name);
- Xextern bool Get_contact_message(void);
- Xextern int Get_reply_message(reply_pack_t *p);
- Xextern bool Connect_to_server(void);
- X
- X#endif
- END_OF_FILE
- echo shar: 1 control character may be missing from \"'src/proto.h'\"
- if test 4942 -ne `wc -c <'src/proto.h'`; then
- echo shar: \"'src/proto.h'\" unpacked with wrong size!
- fi
- # end of 'src/proto.h'
- fi
- if test -f 'src/strcasecmp.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/strcasecmp.c'\"
- else
- echo shar: Extracting \"'src/strcasecmp.c'\" \(622 characters\)
- sed "s/^X//" >'src/strcasecmp.c' <<'END_OF_FILE'
- X/* strcasecmp.c,v 1.3 1992/06/26 15:25:51 bjoerns Exp
- X *
- X * This file is part of the XPilot project, written by
- X *
- X * Bjxrn Stabell (bjoerns@stud.cs.uit.no)
- X * Ken Ronny Schouten (kenrsc@stud.cs.uit.no)
- X *
- X * Copylefts are explained in the LICENSE file.
- X */
- X
- X#include <ctype.h>
- X
- X#ifndef lint
- Xstatic char sourceid[] =
- X "@(#)strcasecmp.c,v 1.3 1992/06/26 15:25:51 bjoerns Exp";
- X#endif
- X
- X/*
- X * By Ian Malcom Brown.
- X */
- Xint
- X strcasecmp(str1, str2)
- Xchar *str1, *str2;
- X{
- X int c1, c2;
- X
- X
- X do {
- X c1 = tolower(*str1++);
- X c2 = tolower(*str2++);
- X } while(c1 != 0 && c2 != 0 && c1 == c2);
- X
- X return(c1 - c2);
- X}
- END_OF_FILE
- echo shar: 1 control character may be missing from \"'src/strcasecmp.c'\"
- if test 622 -ne `wc -c <'src/strcasecmp.c'`; then
- echo shar: \"'src/strcasecmp.c'\" unpacked with wrong size!
- fi
- # end of 'src/strcasecmp.c'
- fi
- if test -f 'src/syslimit.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/syslimit.c'\"
- else
- echo shar: Extracting \"'src/syslimit.c'\" \(2359 characters\)
- sed "s/^X//" >'src/syslimit.c' <<'END_OF_FILE'
- X/* syslimit.c,v 1.8 1992/06/27 02:14:24 bjoerns Exp
- X *
- X * This file is part of the XPilot project, written by
- X *
- X * Bjxrn Stabell (bjoerns@stud.cs.uit.no)
- X * Ken Ronny Schouten (kenrsc@stud.cs.uit.no)
- X *
- X * Copylefts are explained in the LICENSE file.
- X */
- X
- X#include <stdio.h> /* Could be moved below the #ifdef, but then */
- X /* we would get a warning (empty source file) */
- X /* each time LIMIT_ACCESS isn't defined. */
- X#ifdef LIMIT_ACCESS
- X
- X#include <time.h>
- X#include "pack.h"
- X
- X#define PATTERN "lglab[01]"
- X#define FREELIMIT 7
- X
- X#define RUPTIME "/usr/bin/ruptime "
- X#define GREP "/usr/local/bin/ggrep "
- X#define WC_L "/bin/wc -l "
- X#define RWHO "/usr/bin/rwho -a "
- X
- X#ifndef lint
- Xstatic char sourceid[] =
- X "@(#)syslimit.c,v 1.8 1992/06/27 02:14:24 bjoerns Exp";
- X#endif
- X
- Xextern Pack req;
- X
- X
- X
- X/*
- X * This routine is not useful outside UiT but may be used as a skeleton for
- X * similar routines, if similar problems should occur... :)
- X */
- Xbool Is_allowed(void)
- X{
- X FILE *fp;
- X int total_no, no_free, in_use;
- X struct tm *now;
- X time_t tmp;
- X
- X
- X if (strstr(req.display, "lglab") == NULL)
- X return (true);
- X
- X printf("------------------\n");
- X
- X if (strstr(req.display, "lglab2") != NULL) {
- X printf("Atsjoooooo! I can't, sorry! :)\n");
- X return (false);
- X }
- X tmp = time((time_t)NULL);
- X now = localtime(&tmp);
- X
- X if (now->tm_hour >= 8 && now->tm_hour < 16) {
- X if (now->tm_wday != 0 && now->tm_wday != 6) {
- X printf("You'll have to wait %d hours and %d minutes until "
- X "you're allowed to play.\n",
- X 16 - now->tm_hour, 60 - now->tm_min);
- X return (false);
- X }
- X }
- X
- X printf("Checking number of unused workstations."); fflush(stdout);
- X
- X fp = popen(RUPTIME "|" GREP PATTERN "|" GREP "\" up \"|" WC_L, "r");
- X fscanf(fp, "%d", &total_no);
- X pclose(fp);
- X
- X printf("."); fflush(stdout);
- X
- X fp = popen(RWHO "|" GREP "console |" GREP PATTERN "|" WC_L, "r");
- X fscanf(fp, "%d", &in_use);
- X pclose(fp);
- X
- X printf(".\n"); fflush(stdout);
- X
- X no_free = total_no - in_use;
- X
- X printf("%d out of %d machines are free. "
- X "Current limit is at %d machines.\n", no_free, total_no, FREELIMIT);
- X
- X if (no_free >= FREELIMIT) {
- X return (true);
- X } else {
- X printf("You will not be allowed to play until %d more users log out.\n",
- X FREELIMIT-no_free);
- X return (false);
- X }
- X}
- X
- X#endif /* LIMIT_ACCESS */
- END_OF_FILE
- echo shar: 1 control character may be missing from \"'src/syslimit.c'\"
- if test 2359 -ne `wc -c <'src/syslimit.c'`; then
- echo shar: \"'src/syslimit.c'\" unpacked with wrong size!
- fi
- # end of 'src/syslimit.c'
- fi
- if test -f 'src/types.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/types.h'\"
- else
- echo shar: Extracting \"'src/types.h'\" \(527 characters\)
- sed "s/^X//" >'src/types.h' <<'END_OF_FILE'
- X/* types.h,v 1.1 1992/06/25 03:24:19 bjoerns Exp
- X *
- X * This file is part of the XPilot project, written by
- X *
- X * Bjxrn Stabell (bjoerns@stud.cs.uit.no)
- X * Ken Ronny Schouten (kenrsc@stud.cs.uit.no)
- X *
- X * Copylefts are explained in the LICENSE file.
- X */
- X
- X#ifndef TYPES_H
- X#define TYPES_H
- X
- X#include <sys/types.h>
- X
- Xtypedef signed char byte;
- Xtypedef unsigned char u_byte;
- X
- Xtypedef enum {true = 1, false = 0} bool;
- X
- Xtypedef struct { float x, y; } vector;
- Xtypedef vector position;
- Xtypedef struct { int x, y; } ipos;
- X
- X#endif
- END_OF_FILE
- echo shar: 1 control character may be missing from \"'src/types.h'\"
- if test 527 -ne `wc -c <'src/types.h'`; then
- echo shar: \"'src/types.h'\" unpacked with wrong size!
- fi
- # end of 'src/types.h'
- fi
- echo shar: End of archive 24 \(of 24\).
- cp /dev/null ark24isdone
- MISSING=""
- 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
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 24 archives.
- echo "\nNow run 'bldmaps.sh' to build the map files"
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-