ddickey@aspen.cray.com (Dan A. Dickey) (10/24/90)
Submitted-by: ddickey@aspen.cray.com (Dan A. Dickey) Posting-number: Volume 10, Issue 13 Archive-name: xtrek/part02 #! /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 # If this archive is complete, you will see the following message at the end: # "End of archive 2 (of 11)." # # Contents: # INSTALL INSTALL.old bitmaps.c colors.c death.c enter.c # interface.c planets.h scorelist.c # # Wrapped by ddickey@cray.com on Thu Oct 11 11:43:50 1990 # PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f INSTALL -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"INSTALL\" else echo shar: Extracting \"INSTALL\" \(5132 characters\) sed "s/^X//" >INSTALL <<'END_OF_INSTALL' XWow...is this an old file. X XBasically, I think you can still follow most of the old stuff for installing Xxtrek on your system. Other additions are here: X X- For systems running the X11/NeWS server on Suns, after doing the install, X go to the library directory where the xtrek font is, and do this: X convertfont xtrek.bdf X bldfamily X This directory must be accessible by any machines on which you are going X to be displaying and playing the xtrek game itself. Not neccessarily X where the in.xtrekd program is running. X X And then add this directory into your fontpath via xset fp+. X XI'm now: X Dan A. Dickey (the same) X ddickey@cray.com (new email address) X X X X==================BEGIN OLD STUFF HERE========== XDisclaimer: This version is only extensively tested on monochrome Suns. X It was also tested on a color Sun (cgfour) and a color SGI-GT. X XThis "version/release" of xtrek is xtrek done right. XNo shared memory, No million and a half programs. XYou will need root priveleges or the assistance of a super-user to install Xthis. Possibly a future version will provide for "normal" users. X XWhat it is is one main xtrek program (in.xtrekd), and a smaller user program to Xstart up a display. The main xtrek program runs on one machine and handles Xall the updating and robot control. It listens on a socket for connection Xrequests from the user program. Also, the main xtrek "server-machine" Xis not required to have graphics hardware attached, nor expected to. X XHere is a table of machines that the server is known to compile/run on: X XMachine Compiles Displays on X------------------------------------------- XSun-4 Yes Sun-3/50 (bwtwo), Sun-4/110 (cgfour), *SGI-GT, X(OS 4.0 & 4.0.1) HP-9000, X XSun-3 Not Tested X(OS 3.5) X XSun-3 Yes Sun-3/50 (bwtwo), *SGI-GT X(OS 3.4) X XSGI-GT Not Tested X(4D1-3.0 - IP4) X XApollo Not Tested X XHP-9000/350 Yes Sun-3/50 (bwtwo), HP-9000, X X X* - Problems: XSGI-GT: The status window boxes are not drawn correctly. X XHere is a table of machines that the startup program is known to compile/run on: X XMachine Compiles & Runs Server Machines Tested X-------------------------------------------------------------- XSun-4 Yes Sun-4 (4.0+) X(OS 4.0 & 4.0.1) X XSun-3 Yes Sun-4 (4.0+), HP-9000 X(OS 4.0) X XSun-3 Yes Sun-4 (4.0+) X(OS 3.5) X XSun-3 Yes Sun-4 (4.0+) X(OS 3.4) X XSGI-GT Yes Sun-4 (4.0+) X(4D1-3.0 - IP4) X XApollo Not Tested X XHP-9000/350 Yes HP-9000, X X X----- XGeneric instructions: XEdit Imakefile. Select the available options (OPTIONS) for your site. XAlso, change XTREKDIR to something that makes sense for your site. X XDo a "make Makefile ; make depend; make". XThis should build all the necessary pieces. XThen, a "make install" should partially install xtrek into the proper directory. XYou'll have to add the directory defined as XTREKDIR to your font path Xfor the server, this can be done by: "xset +fp /usr/games/lib/xtrek" XNOTE: "xset fp /usr/games/lib/xtrek,/usr/lib/X11/fonts" on HP's. X XThen do a "xset fp rehash" on any X-server that you expect to use this Xprogram on. "xlsfonts" should show xtrek as a listed font. X X----- XInstruction for installing on a Sun (release 4.0 or greater) system: XTo add the main xtrek program to your system, you'll need to edit X/etc/inetd.conf. Add the line: Xxtrek stream tcp wait games /usr/games/lib/xtrek/in.xtrekd in.xtrekd X Xthe "games" can be any user, no set-uid permissions are used. Just make Xsure that this coincides with XTREKOWNER in the Makefile so that it can Xread and write the files in /usr/lib/games/lib/xtrek. X XBy changing inetd.conf, the system will start up the main xtrek program when Xa request comes in for it and it is not already running. X XAlso, you'll need to add (For any Sun OS): Xxtrek 5701/tcp xtrek # take a guess Xto your /etc/services file on the system where in.xtrekd is to reside. XOr to the /etc/services file on your yp-master machine for services. X XAlso, if you have machines in your network running SunOS 3.X: Xxtrek 5702/udp xtrek # take a guess X XAnd, if you have machines running SunOS 3.X: Xadd this line: Xxtrek udp /usr/games/lib/xtrek/in.xtrekd Xto the /etc/servers file and restart inetd. X X----- XInstructions for installing on an HP-9000 system: XEdit the file /etc/inetd.conf, add the line: Xxtrek dgram udp wait games /usr/games/lib/xtrek/in.xtrekd in.xtrekd X XEdit the file /etc/services, add the lines: Xxtrek 5701/tcp xtrek Xxtrek 5702/udp xtrek X XThen, restart /etc/inetd and /etc/portmapper either by killing them and Xrestarting, or rebooting the system. X X----- XThen, to play a game just enter "xtrek <machine>", where <machine> is Xthe machine where you changed the inetd.conf file. This assumes that Xyou told inetd to re-read it's configuration file (kill -HUP inetd-pid). XMake sure that your environment variable DISPLAY is set correctly before Xtrying xtrek <machine>. X X----- XGood luck and have fun! X XQUESTIONS & COMMENTS TO: X Dan A. Dickey ddickey@cray.com X XHP testing/changes done by: Matt Burdick - burdick%hpda@hplabs.hp.com XAlso: Jeff Schmidt - jas%hpda@hplabs.hp.com Xstatic char sccsid[] = "@(#)INSTALL 3.1"; END_OF_INSTALL if test 5132 -ne `wc -c <INSTALL`; then echo shar: \"INSTALL\" unpacked with wrong size! fi # end of overwriting check fi if test -f INSTALL.old -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"INSTALL.old\" else echo shar: Extracting \"INSTALL.old\" \(5259 characters\) sed "s/^X//" >INSTALL.old <<'END_OF_INSTALL.old' XThis explains quickly how to run xtrek on a ultrix, XSun 3.20, or HP-UX 5.2 system. Note that other Xoperating systems will probably require fiddling. XThere are notes for various operating systems below. XThere is also a list of recent changes. X XIt is important that the system V shared memory Xsegments are actually compiled into your kernel on Xthe server machine. The clients just need X. X XCreate an appropriate directory for it. The defs.h Xfile contains the paths to this directory. If you Xdon't want it in /usr/games/lib/xtrek, change this Xfile. X XA "make install" will perform the following steps for you. XIf you don't want xtrek and daemon to be suid to root Xor you don't like the choice of directories, either Xchange DESTDIR, XTREKDIR and XTREKOWNER in the Makefile Xor perform these steps by hand: X X Run make. Install xtrek in /usr/games. Robot and X daemon must be in /usr/games/lib/xtrek. Create the X files .motd, .scores, and .planets in X /usr/games/lib/xtrek. X X Xtrek and the daemon must all be setuid X to someone who has write permission on these files. X Root is fine. There are no real security holes in X the game. If you want to avoid this, take out the X shared memory chmoding and make the dot files writable. X XIf you want to change constants in the game, it is Xpretty well set up to allow tweaking. Most of the Xconstants are in defs.h. Player constants were defined Xin getship.c in plans for a future custom designed ship Xoption. X Xnroff -me the document and put it somewhere useful. X XHP-UX notes: X XAlthought I have compiled and run this version of xtrek on Xan HP-UX 5.2 system, there are some things to be aware of. XFirst, my system was a 320. If you have access to a 840 it Xwould clearly be a better choice as a server. It would also Xprovide the wait3 function needed in some of the code. I don't Xknow how the wait's I've put into the code will work out. X XA 320 system, while being sufficient as a display for the game, Xwould probably not work well as a server. X XSun notes: X XSome code was added to prevent people from holding down the X't' key and generating fields of torps with the auto-repeat Xmode. This uses the timer for the xevents and it's not clear Xthat the timer works everywhere. X XThere is one clear bug in the sun Xlib server that can make Xtorpedoes occasionnally fail to fire. If you want to fix this Xbug, replace the line of code in libsun/events.c: X X xe->vse_time = (se->ie_time.tv_usec/10000 + se->ie_time.tv_sec); X Xwith X X xe->vse_time = (se->ie_time.tv_usec/10000 + se->ie_time.tv_sec*100); X XIt appears twice so get 'em both. Note that this stuff is in the source Xto libX.a for the suns. X XApollo Notes: X XWe don't have an apollo to test the code out, but the following lines Xin the xlib code scare me: X X /* this needs to be replaced with a "real" timestamp */ X xe->vse_time += 1; X XI suspect that on an apollo, only one torp in ten will actually be fired. XSee the Sun notes above for more information. X XUltrix notes: X XBefore running make, look for random.o. I found Xthat the ultrix library version wasn't very random, Xso I substituted the 4.3 one which worked better. XLicensing agreements being what they are, the Xversion in this directory just links against Xwhatever random.o is in libc.a. X XIf you have the 4.3 random.o (or .c), just restore Xthe commented-out reference to random.o in the Makefile Xand it will link against your copy. If we ever find a Xgood public domain rand() function, this problem will Xgo away. X X XChanges from version 3.0 to version 4.0: X XPlayers cannot jump teams once in. They must quit and rejoin Xto change teams. X XWhen a team loses its last planet, they cannot hold a coup for 30 Xminutes to an hour of play time. X XThere is an independent team that controls all planets with zero Xarmies. X XFuel cannot go negative now. X XCertain deaths will force you to exit the game completely. X XSome colors have been changed. X XPlayers may not bomb their own planets. (Their crews have wives and Xchildren down there....) X XSince sys V compatibility seems to show up in most 4.3 based include Xfiles, I've gone over to the sys V names of some things like XSIGCHLD -> SIGCLD. X XFixed a bug with showstats that crashed in watch mode. X XThere have been a number of changes to 'improve' play. Not Xeveryone agrees that they are for the better. Ships now Xturn one warp faster. Fuel is used by the engines -- you Xdon't gain fuel at warp 5 anymore. X XEvents now go through info windows properly. X XThe special font effects occur in the info windows. X XThe space key will now also close all special windows. X XYou cannot repair and use transporters at the same time. X XThere are a number of optimizations. Hardcoding the lengths Xof planetnames reduced the number of calls to strlen. The Xstatus line is now drawn by hand to save calls to doprnt(). XAlso, the characters up on the map window for each ship are Xstored in the ship's data structure to avoid more calls to Xdoprnt(). X XRobots are a little smarter and slightly more aggressive. This Xwas meant to stop people from darting in and out while taking Xperiphery planets. X XOverheated weapons can't be wrapped around. X XPeople who hold down the 't' key to get a burst of torps are Xin for a surprise. Torps cannot be fired faster than one every Xtenth of a second. X END_OF_INSTALL.old if test 5259 -ne `wc -c <INSTALL.old`; then echo shar: \"INSTALL.old\" unpacked with wrong size! fi # end of overwriting check fi if test -f bitmaps.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"bitmaps.c\" else echo shar: Extracting \"bitmaps.c\" \(4762 characters\) sed "s/^X//" >bitmaps.c <<'END_OF_bitmaps.c' X/* Xstatic char sccsid[] = "@(#)bitmaps.c 3.1"; X X Copyright (c) 1986 Chris Guthrie X XPermission to use, copy, modify, and distribute this Xsoftware and its documentation for any purpose and without Xfee is hereby granted, provided that the above copyright Xnotice appear in all copies and that both that copyright Xnotice and this permission notice appear in supporting Xdocumentation. No representations are made about the Xsuitability of this software for any purpose. It is Xprovided "as is" without express or implied warranty. X X*/ X X#include <X11/X.h> X X/**** These are the ships ****/ X#define VIEWS 16 X#define ship_width 16 X#define ship_height 16 X X/**** These are the explosions ****/ X X#define ex_width 64 X#define ex_height 64 X X/**** These are the misc things ****/ X X#define cloud_width 7 X#define cloud_height 7 X X#define etorp_width 3 X#define etorp_height 3 X X#define mtorp_width 3 X#define mtorp_height 3 X X#define crossw 15 X#define crossh 15 X X#define crossmask_width 15 X#define crossmask_height 15 X X#define planet_width 30 X#define planet_height 30 X X#define mplanet_width 16 X#define mplanet_height 16 X X#define shield_width 20 X#define shield_height 20 X X#define icon_width 64 X#define icon_height 64 Xchar icon_bits[] = { X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0xf8, 0x83, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, X 0xf0, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, X 0xe0, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, X 0xc0, 0x83, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, X 0xc0, 0x83, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x80, 0xc7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x80, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x1e, 0xf0, 0xbf, 0x7f, 0xe0, 0x1b, 0x0e, X 0x00, 0x3c, 0xf8, 0x9f, 0xff, 0xf8, 0x19, 0x07, X 0x00, 0x3c, 0x80, 0x81, 0xe1, 0x1c, 0x98, 0x03, X 0x00, 0x7e, 0x80, 0x81, 0x71, 0x0e, 0xd8, 0x01, X 0x00, 0x7b, 0x80, 0x81, 0x39, 0x06, 0xf8, 0x00, X 0x00, 0xf3, 0x80, 0x81, 0x1d, 0xfe, 0xf9, 0x03, X 0x80, 0xf1, 0x80, 0x81, 0x7f, 0xfe, 0xf8, 0x07, X 0xc0, 0xe0, 0x81, 0x81, 0xe1, 0x06, 0x18, 0x0e, X 0xc0, 0xe0, 0x81, 0x81, 0xc1, 0x0e, 0x18, 0x0c, X 0x60, 0xe0, 0x83, 0x81, 0xc1, 0x1c, 0x1a, 0x0c, X 0x70, 0xc0, 0x87, 0x81, 0xc1, 0xf8, 0x1b, 0x7c, X 0xfc, 0xe0, 0xdf, 0xc3, 0xe3, 0xe0, 0x3d, 0x3e, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x20, 0xe0, 0xff, 0x0f, 0x30, 0x08, 0x06, X 0x00, 0xfc, 0xe1, 0xff, 0x07, 0x30, 0x7f, 0x06, X 0xe0, 0xff, 0x1f, 0x01, 0x00, 0xf8, 0xff, 0x0f, X 0x00, 0xfe, 0x0f, 0x01, 0x00, 0x80, 0xff, 0x00, X 0x00, 0x70, 0x1c, 0x01, 0x00, 0x00, 0x5d, 0x00, X 0x00, 0x00, 0xf0, 0xff, 0x01, 0x00, 0x3e, 0x00, X 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x36, 0x00, X 0x00, 0x00, 0xf0, 0x3f, 0x00, 0x00, 0x3e, 0x00, X 0x00, 0x00, 0xe0, 0x1f, 0x00, 0x00, 0x1c, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, X 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7f, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x40, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x40, X 0x00, 0xf8, 0x00, 0x00, 0x00, 0xa1, 0x00, 0x40, X 0x00, 0xfe, 0xe3, 0xff, 0x0f, 0xa1, 0x6e, 0x40, X 0x00, 0xff, 0xe7, 0xff, 0x0f, 0xa1, 0xa2, 0x40, X 0x80, 0xff, 0x0f, 0x01, 0x00, 0xa1, 0x66, 0x40, X 0x80, 0x8f, 0x0f, 0x01, 0x00, 0xa1, 0xa2, 0x40, X 0xc0, 0x77, 0x1f, 0x01, 0x00, 0x41, 0xae, 0x42, X 0xc0, 0xfb, 0xfe, 0xff, 0x01, 0x01, 0x00, 0x40, X 0xc0, 0xdb, 0xfe, 0xff, 0x01, 0x01, 0x00, 0x40, X 0xc0, 0xfb, 0xfe, 0xff, 0x01, 0x01, 0x00, 0x40, X 0xc0, 0x77, 0x1f, 0x01, 0x00, 0x81, 0xc0, 0x43, X 0x80, 0x8f, 0x0f, 0x01, 0x00, 0xc1, 0x20, 0x43, X 0x80, 0xff, 0x0f, 0x01, 0x00, 0xa1, 0xa0, 0x42, X 0x00, 0xff, 0xe7, 0xff, 0x0f, 0x91, 0xa0, 0x42, X 0x00, 0xfe, 0xe3, 0xff, 0x0f, 0xf1, 0xa1, 0x42, X 0x00, 0xf8, 0x00, 0x00, 0x00, 0x81, 0x60, 0x42, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0xec, 0x41, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x40, X 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7f, X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; X X#define stipple_width 16 X#define stipple_height 16 Xchar stipple_bits[] = { X 0xfe, 0xfe, 0xfd, 0xfd, 0xfb, 0xfb, 0xf7, 0xf7, X 0xef, 0xef, 0xdf, 0xdf, 0xbf, 0xbf, 0x7f, 0x7f, X 0xfe, 0xfe, 0xfd, 0xfd, 0xfb, 0xfb, 0xf7, 0xf7, X 0xef, 0xef, 0xdf, 0xdf, 0xbf, 0xbf, 0x7f, 0x7f}; X END_OF_bitmaps.c if test 4762 -ne `wc -c <bitmaps.c`; then echo shar: \"bitmaps.c\" unpacked with wrong size! fi # end of overwriting check fi if test -f colors.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"colors.c\" else echo shar: Extracting \"colors.c\" \(5160 characters\) sed "s/^X//" >colors.c <<'END_OF_colors.c' Xstatic char sccsid[] = "@(#)colors.c 3.1"; X X/* X X Copyright (c) 1986 Chris Guthrie X XPermission to use, copy, modify, and distribute this Xsoftware and its documentation for any purpose and without Xfee is hereby granted, provided that the above copyright Xnotice appear in all copies and that both that copyright Xnotice and this permission notice appear in supporting Xdocumentation. No representations are made about the Xsuitability of this software for any purpose. It is Xprovided "as is" without express or implied warranty. X X*/ X X#include <stdio.h> X#include <X11/Xlib.h> X#include <string.h> X#include "defs.h" X#include "data.h" X Xextern int debug; X Xtypedef struct assoc { X char *str; X int bWDef; X char *colorDef; X} ASSOC; X X#define BLACKPIXEL 0 X#define WHITEPIXEL 1 X XASSOC assoc[] = { X { "border", WHITEPIXEL, "blue" }, X { "background", BLACKPIXEL, "black" }, X { "text", WHITEPIXEL, "white" }, X { "nobody", WHITEPIXEL, "blue" }, X { "fed", WHITEPIXEL, "yellow", }, X { "rom", WHITEPIXEL, "red", }, X { "kli", WHITEPIXEL, "green", }, X { "ori", WHITEPIXEL, "#0ff", }, X { "ind", WHITEPIXEL, "brown" }, X { "noteam", BLACKPIXEL, "black" }, X { "god", WHITEPIXEL, "white" }, X { "warning", WHITEPIXEL, "red" }, X { "unknown", WHITEPIXEL, "light grey" }, X { "ralert", WHITEPIXEL, "red" }, X { "yalert", WHITEPIXEL, "yellow" }, X { "galert", WHITEPIXEL, "green" }, X { "me", WHITEPIXEL, "white" }, X { "moon", WHITEPIXEL, "dim grey" }, X { "sun", WHITEPIXEL, "gold" } X}; X XgetColorDefs(p, prog) Xregister struct player *p; Xchar *prog; X{ X int i, invert = 0; X char *color; X Colormap default_colormap; X unsigned long *pp; X X XColor def; X unsigned long white_pix, black_pix; X X if (p->mono) { /* b & w */ X white_pix = XWhitePixel(p->display, p->screen); X black_pix = XBlackPixel(p->display, p->screen); X invert = booleanDefault(p, prog, "reverseVideo"); X for (i = 0; i < sizeof (assoc) / sizeof (*assoc); i++) { X switch (i) { X case 0: pp = &p->borderColor; break; X case 1: pp = &p->backColor; break; X case 2: pp = &p->textColor; break; X case 3: pp = &p->shipCol[0]; break; X case 4: pp = &p->shipCol[1]; break; X case 5: pp = &p->shipCol[2]; break; X case 6: pp = &p->shipCol[3]; break; X case 7: pp = &p->shipCol[4]; break; X case 8: pp = &p->shipCol[5]; break; X case 9: pp = &p->shipCol[6]; break; X case 10:pp = &p->shipCol[7]; break; X case 11:pp = &p->warningColor; break; X case 12:pp = &p->unColor; break; X case 13:pp = &p->rColor; break; X case 14:pp = &p->yColor; break; X case 15:pp = &p->gColor; break; X case 16:pp = &p->myColor; break; X case 17:pp = &p->moonColor; break; X case 18:pp = &p->sunColor; break; X } X if (!invert) X *pp = (assoc[i].bWDef == BLACKPIXEL) X ? black_pix : white_pix; X else X *pp = (assoc[i].bWDef == BLACKPIXEL) X ? white_pix : black_pix; X } X } else { X default_colormap = XDefaultColormap(p->display, p->screen); X for (i = 0; i < sizeof (assoc) / sizeof (*assoc); i++) { X switch (i) { X case 0: pp = &p->borderColor; break; X case 1: pp = &p->backColor; break; X case 2: pp = &p->textColor; break; X case 3: pp = &p->shipCol[0]; break; X case 4: pp = &p->shipCol[1]; break; X case 5: pp = &p->shipCol[2]; break; X case 6: pp = &p->shipCol[3]; break; X case 7: pp = &p->shipCol[4]; break; X case 8: pp = &p->shipCol[5]; break; X case 9: pp = &p->shipCol[6]; break; X case 10:pp = &p->shipCol[7]; break; X case 11:pp = &p->warningColor; break; X case 12:pp = &p->unColor; break; X case 13:pp = &p->rColor; break; X case 14:pp = &p->yColor; break; X case 15:pp = &p->gColor; break; X case 16:pp = &p->myColor; break; X case 17:pp = &p->moonColor; break; X case 18:pp = &p->sunColor; break; X } X if ((color = XGetDefault(p->display, PROGRAM_NAME, assoc[i].str)) X == NULL) X color = assoc[i].colorDef; X def.pixel = 0; X invert = XParseColor(p->display, default_colormap, color, &def); X invert = XAllocColor(p->display, default_colormap, &def); X *pp = def.pixel; X } X } X} X XbooleanDefault(p, prog, def) Xregister struct player *p; Xchar *prog, *def; X{ X char *str; X X /* X * jas (Jeff Schmidt) Allow for either 'on' or 'true' to indicate the X * boolean TRUE state. X */ X X if (debug) X fprintf(stderr, "bD: pno %d", p->p_no); X X if ((str = XGetDefault(p->display, prog, def)) != NULL) { X if (debug) X fprintf(stderr, " def(%s) str(%s)\n", def, str); X if ((strcmp(str, "on") == 0) || (strcmp(str, "true") == 0)) X return (1); X return (0); X } X X if (debug) X fprintf(stderr, " def(%s) str(%s)\n", def, "NULL"); X X return (0); X} X X#define iswhite(c) ((c) == ' ' || c == '\t' || (c) == ',') X XarrayDefault(p, prog, def, sizeP, sp) Xregister struct player *p; Xchar *prog, *def; Xint *sizeP; Xchar *sp; X{ X int max; X char *str; X int rc; X X str = XGetDefault(p->display, PROGRAM_NAME, def); X if (str == NULL) X return (-1); X max = *sizeP; X *sizeP = 0; X X for (;;) { X while (iswhite(*str)) X str++; X if (*str == '\0') X break; X if (++(*sizeP) > max) X return (-1); X if (sscanf(str, "0x%x", &rc) != 1) X return (-1); X sp[*sizeP] = rc; X while (!iswhite(*str) && *str != '\0') X str++; X } X return (0); X} END_OF_colors.c if test 5160 -ne `wc -c <colors.c`; then echo shar: \"colors.c\" unpacked with wrong size! fi # end of overwriting check fi if test -f death.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"death.c\" else echo shar: Extracting \"death.c\" \(4761 characters\) sed "s/^X//" >death.c <<'END_OF_death.c' Xstatic char sccsid[] = "@(#)death.c 3.1"; X/* X X Copyright (c) 1986 Chris Guthrie X XPermission to use, copy, modify, and distribute this Xsoftware and its documentation for any purpose and without Xfee is hereby granted, provided that the above copyright Xnotice appear in all copies and that both that copyright Xnotice and this permission notice appear in supporting Xdocumentation. No representations are made about the Xsuitability of this software for any purpose. It is Xprovided "as is" without express or implied warranty. X X*/ X X#include <X11/Xlib.h> X#include <stdio.h> X#include <signal.h> X#include <setjmp.h> X#if !defined(cray) X#include <sys/types.h> X#endif X X#ifdef hpux X#include <time.h> X#else hpux X#include <sys/time.h> X#endif hpux X X#include "defs.h" X#include "data.h" X Xdeath(p) Xregister struct player *p; X{ X char buf[256]; X register struct player *j; X X switch (p->p_ship->s_whydead) { X case KQUIT: X sprintf(buf, "You have self-destructed"); X warning(p, buf); X break; X case KTORP: X sprintf(buf, "You were killed by a torp from %s (%c%x) who was %d%% damaged", X players[p->p_ship->s_whodead].p_name, X teamlet[players[p->p_ship->s_whodead].p_ship->s_team], X p->p_ship->s_whodead, X players[p->p_ship->s_whodead].p_ship->s_damage); X warning(p, buf); X break; X case KLIGHTNING: X sprintf(buf, "You were killed by a lightning bolt from %s (%c%x)", X players[p->p_ship->s_whodead].p_name, X teamlet[players[p->p_ship->s_whodead].p_ship->s_team], X p->p_ship->s_whodead); X warning(p, buf); X break; X case KPHASER: X sprintf(buf, "You were killed by a phaser shot from %s (%c%x) who was %d%% damaged", X players[p->p_ship->s_whodead].p_name, X teamlet[players[p->p_ship->s_whodead].p_ship->s_team], X p->p_ship->s_whodead, X players[p->p_ship->s_whodead].p_ship->s_damage); X warning(p, buf); X break; X case KPLANET: X if (planets[p->p_ship->s_whodead].pl_type == SUN) X sprintf(buf, "You were killed by radiation from %s", X planets[p->p_ship->s_whodead].pl_name); X else X sprintf(buf, "You were killed by planetary fire from %s (%c)", X planets[p->p_ship->s_whodead].pl_name, X teamlet[planets[p->p_ship->s_whodead].pl_owner]); X warning(p, buf); X break; X case KSHIP: X sprintf(buf, "You were killed by an exploding ship formerly owned by %s (%c%x) who was %d%% damaged", X players[p->p_ship->s_whodead].p_name, X teamlet[players[p->p_ship->s_whodead].p_ship->s_team], X p->p_ship->s_whodead, X players[p->p_ship->s_whodead].p_ship->s_damage); X warning(p, buf); X break; X case KWINNER: X sprintf(buf, "Galaxy has been conquered by %s (%c%x)", X players[p->p_ship->s_whodead].p_name, X teamlet[players[p->p_ship->s_whodead].p_ship->s_team], X players[p->p_ship->s_whodead].p_ship->s_no); X warning(p, buf); X break; X case KVAPOR: X /* The display is vapor...can't tell them anything. */ X break; X default: X sprintf(buf, "You were killed by something unknown to this game?"); X warning(p, buf); X p->mustexit = 1; X break; X } X X if (p->p_ship->s_whydead != KQUIT && p->p_ship->s_whydead != KWINNER) X p->p_ship->s_stats.st_losses++; X X for (j = &players[0]; j < &players[MAXPLAYER]; j++) { X if (p->p_ship == j->p_ship) { X calcstats(j); X savestats(j); X } X } X if (p->p_ship) X resetsstats(p); X X p->p_status = PDEAD; X kill_copilots(p); X p->p_ship->s_explode = DEATHTIME; X X /* If we were being towed, turn off the tower's tractor beam */ X if (p->p_ship->s_flags & SFTOWED) { X ships[p->p_ship->s_towed].s_flags &= ~SFTOWING; X } X /* Turn our own tractor beam off. */ X tow_off(p); X X if (!(p->p_flags & PFROBOT) && p->p_ship->s_whydead != KVAPOR) { X XClearWindow(p->display, p->w); X if (!p->mono) { X/*ICCCM 4.1.9 XSetWindowBorder(p->display, p->baseWin, p->gColor);*/ X/*ICCCM 4.1.9 XSetWindowBorder(p->display, p->iconWin, p->gColor);*/ X } else { X/*ICCCM 4.1.9 XSetWindowBorderPixmap(p->display, p->baseWin, p->gTile);*/ X/*ICCCM 4.1.9 XSetWindowBorderPixmap(p->display, p->iconWin, p->gTile);*/ X } X } X X if (!(p->p_flags & PFROBOT) && p->p_ship->s_whydead != KVAPOR) { X if (ismapped(p, p->playerw)) X XUnmapWindow(p->display, p->playerw); X if (ismapped(p, p->planetw)) X XUnmapWindow(p->display, p->planetw); X if (p->p_infomapped) X destroyInfo(p); X if (ismapped(p, p->war)) X XUnmapWindow(p->display, p->war); X if (p->p_flags & PFSHOWSTATS) X closeStats(p, p->statwin); X /* p->p_status = POUTFIT; */ X } X} X Xkill_copilots(p) Xregister struct player *p; X{ X register int i; X register struct player *co; X X for (i = 0, co = &players[0]; i < MAXPLAYER; i++, co++) { X if (co->p_status == PALIVE && p->p_ship == co->p_ship && co->p_copilot) { X co->p_status = PDEAD; X } X } X} END_OF_death.c if test 4761 -ne `wc -c <death.c`; then echo shar: \"death.c\" unpacked with wrong size! fi # end of overwriting check fi if test -f enter.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"enter.c\" else echo shar: Extracting \"enter.c\" \(5315 characters\) sed "s/^X//" >enter.c <<'END_OF_enter.c' Xstatic char sccsid[] = "@(#)enter.c 3.1"; X X/* X X Copyright (c) 1986 Chris Guthrie X XPermission to use, copy, modify, and distribute this Xsoftware and its documentation for any purpose and without Xfee is hereby granted, provided that the above copyright Xnotice appear in all copies and that both that copyright Xnotice and this permission notice appear in supporting Xdocumentation. No representations are made about the Xsuitability of this software for any purpose. It is Xprovided "as is" without express or implied warranty. X X*/ X X#include <X11/Xlib.h> X#include <stdio.h> X#if !defined(cray) X#include <sys/types.h> X#endif X#include <errno.h> X#include <pwd.h> X#include <string.h> X#include <ctype.h> X#include "defs.h" X#include "data.h" X Xextern int debug; X X/* Enter the game */ X Xlong random(); X Xenter(tno, disp, pno) Xint tno; Xchar *disp; Xint pno; X{ X register struct player *p; X char *pseudo, buf[80]; X register struct planet *l; X register int i; X X pseudo = (char *) NULL; X p = &players[pno]; X if (strcmp(disp, "Nowhere")) { X pseudo = XGetDefault(p->display, PROGRAM_NAME, "name"); X } X if (pseudo == NULL) { X if (strcmp(disp, "Nowhere")) X (void) strncpy(p->p_name, p->p_login, sizeof (p->p_name)); X } else X (void) strncpy(p->p_name, pseudo, sizeof (p->p_name)); X p->p_name[12] = '\0'; X p->p_login[12] = '\0'; X X p->p_no = pno; X getstats(p); X time(&p->p_start_time); X p->p_umsg.m_pending = 0; X p->p_lastm = mctl->mc_current; X p->p_status = PALIVE; X p->p_mapmode = 1; X p->p_namemode = 1; X p->p_statmode = 1; X p->p_warntimer = -1; X p->p_infomapped = 0; X p->mustexit = 0; X p->p_redrawall = 1; X if (debug) X fprintf(stderr, "%d p_copilot %d\n", pno, p->p_copilot); X if (p->p_flags & PFRSHOWSTATS) { X p->statwin = openStats(p); X } X if (!p->p_copilot) X enter_ship(p, disp, tno); X X sprintf(buf, "%c%x", teamlet[p->p_ship->s_team], p->p_ship->s_no); X strncpy(p->p_mapchars, buf, 2); X} X Xvoid Xchecksystems(p) Xregister struct player *p; X{ X register struct planet *l; X register int i; X int plcount[MAXTEAM]; X X /* Reset */ X p->p_pick = 0; X X /* We can always enter at our own system. */ X p->p_pick |= (1 << p->p_ship->s_team); X X if (isGod(p) || p->p_ship->s_team == 0) { X p->p_pick |= ((1 << FED) | (1 << ROM) | (1 << KLI) | (1 << ORI)); X return; X } X X bzero(plcount, sizeof (plcount)); X X for (i = 0, l = &planets[i]; i < MAXPLANETS; i++, l++) { X if (l->pl_type == CLASSM || l->pl_type == DEAD) { X if (l->pl_owner == pdata[i].pl_owner) X plcount[l->pl_owner]++; X } X } X X if (!plcount[FED] && planets[0].pl_owner == p->p_ship->s_team) X p->p_pick |= (1 << FED); X if (!plcount[ROM] && planets[1].pl_owner == p->p_ship->s_team) X p->p_pick |= (1 << ROM); X if (!plcount[KLI] && planets[2].pl_owner == p->p_ship->s_team) X p->p_pick |= (1 << KLI); X if (!plcount[ORI] && planets[3].pl_owner == p->p_ship->s_team) X p->p_pick |= (1 << ORI); X} X Xenter_ship(p, disp, tno) Xregister struct player *p; Xchar *disp; Xint tno; X{ X char *pseudo, buf[80]; X register struct planet *l; X register int i; X char *customship; X X customship = (char *) NULL; X if (strcmp(disp, "Nowhere")) { X#ifdef CUSTOMSHIP X customship = XGetDefault(p->display, PROGRAM_NAME, p->p_shipname); X#endif X } X X p->p_ship->s_stats.st_entries++; X p->p_ship->s_updates = udcounter; X p->p_ship->s_status = 0; X p->p_ship->s_explode = 0; X p->p_ship->s_whydead = 0; X p->p_ship->s_whodead = 0; X p->p_ship->s_flags = SFSHIELD; X p->p_ship->s_dir = 0; X p->p_ship->s_desdir = 0; X p->p_ship->s_speed = 0; X p->p_ship->s_desspeed = 0; X p->p_ship->s_subspeed = 0; X if (!p->p_ship->s_team) X p->p_ship->s_team = tno; X /* Find the teams home planet...using initial setup. */ X for (i = 0, l = &pdata[0]; i < MAXPLANETS; i++, l++) { X if ((l->pl_flags & PLHOME) && (l->pl_owner == tno)) X break; X } X if (i >= MAXPLANETS) /* ...then we didn't find it. */ X l = &planets[0]; /* so just use planet[0] */ X else X l = &planets[i]; /* now switch to current data */ X p->p_ship->s_x = l->pl_x + (random() % 10000) - 5000; X p->p_ship->s_y = l->pl_y + (random() % 10000) - 5000; X p->p_ship->s_ntorp = 0; X p->p_ship->s_damage = 0; X p->p_ship->s_subdamage = 0; X p->p_ship->s_etemp = 0; X p->p_ship->s_etime = 0; X p->p_ship->s_wtemp = 0; X p->p_ship->s_wtime = 0; X p->p_ship->s_subshield = 0; X p->p_ship->s_armies = 0; X#ifndef CUSTOMSHIP X customship = (char *) NULL; X#endif X getship(p, customship); X p->p_ship->s_swar = 0; X p->p_ship->s_hostile = ((1 << FED)|(1 << ROM)|(1 << KLI)|(1 << ORI)); X p->p_ship->s_hostile &= ~(1 << p->p_ship->s_team); X if (p->p_ship->s_team == GOD) X p->p_ship->s_hostile = 0; /* Peaceful God */ X p->p_ship->s_shield = p->p_ship->s_maxshields; X p->p_ship->s_fuel = p->p_ship->s_maxfuel; X p->p_ship->s_delay = 0; X p->p_ship->s_oldalert = SFGREEN; X p->p_ship->s_Ten = 0; X} X Xfindslot() X{ X register int i; X X for (i = 0; i < MAXPLAYER; i++) { X if (players[i].p_status == PFREE) { /* We have a free slot */ X break; X } X } X if (i < MAXPLAYER) { X bzero(&players[i], sizeof(struct player)); /* Slight problem for copilot */ X players[i].p_status = PSETUP; /* possible race code */ X players[i].p_no = i; X } X return(i); X} END_OF_enter.c if test 5315 -ne `wc -c <enter.c`; then echo shar: \"enter.c\" unpacked with wrong size! fi # end of overwriting check fi if test -f interface.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"interface.c\" else echo shar: Extracting \"interface.c\" \(4473 characters\) sed "s/^X//" >interface.c <<'END_OF_interface.c' Xstatic char sccsid[] = "@(#)interface.c 3.1"; X/* X X Copyright (c) 1986 Chris Guthrie X XPermission to use, copy, modify, and distribute this Xsoftware and its documentation for any purpose and without Xfee is hereby granted, provided that the above copyright Xnotice appear in all copies and that both that copyright Xnotice and this permission notice appear in supporting Xdocumentation. No representations are made about the Xsuitability of this software for any purpose. It is Xprovided "as is" without express or implied warranty. X X*/ X X/* This file will include all the interfaces between the input routines X and the daemon. They should be useful for writing robots and the X like */ X X#include <X11/Xlib.h> X#include <stdio.h> X#include <math.h> X#include <signal.h> X#include "defs.h" X#include "data.h" X Xset_speed(p, speed) Xregister struct player *p; Xint speed; X{ X p->p_ship->s_desspeed = speed; X p->p_ship->s_flags &= ~(SFREPAIR | SFBOMB | SFORBIT | SFBEAMUP | SFBEAMDOWN); X} X Xset_course(p, dir) Xregister struct player *p; Xunsigned char dir; X{ X p->p_ship->s_desdir = dir; X p->p_ship->s_flags &= ~(SFBOMB | SFORBIT | SFBEAMUP | SFBEAMDOWN); X} X Xshield_up(p) Xregister struct player *p; X{ X p->p_ship->s_flags |= SFSHIELD; X p->p_ship->s_flags &= ~(SFBOMB | SFREPAIR | SFBEAMUP | SFBEAMDOWN); X} X Xshield_down(p) Xregister struct player *p; X{ X p->p_ship->s_flags &= ~SFSHIELD; X} X Xshield_tog(p) Xregister struct player *p; X{ X p->p_ship->s_flags ^= SFSHIELD; X p->p_ship->s_flags &= ~(SFBOMB | SFREPAIR | SFBEAMUP | SFBEAMDOWN); X} X Xbomb_planet(p) Xregister struct player *p; X{ X if (!(p->p_ship->s_flags & SFORBIT)) { X warning(p, "Must be orbiting to bomb"); X return; X } X p->p_ship->s_flags |= SFBOMB; X p->p_ship->s_flags &= ~(SFSHIELD | SFREPAIR | SFBEAMUP | SFBEAMDOWN); X} X Xbeam_up(p) Xregister struct player *p; X{ X if (!(p->p_ship->s_flags & SFORBIT)) { X warning(p, "Must be orbiting to beam up."); X return; X } X if (!isGod(p) && p->p_ship->s_team != planets[p->p_ship->s_planet].pl_owner) { X warning(p, "Those aren't our armies."); X return; X } X p->p_ship->s_flags |= SFBEAMUP; X p->p_ship->s_flags &= ~(SFSHIELD | SFREPAIR | SFBOMB | SFBEAMDOWN); X} X Xbeam_down(p) Xregister struct player *p; X{ X if (!(p->p_ship->s_flags & SFORBIT)) { X warning(p, "Must be orbiting to beam down."); X return; X } X p->p_ship->s_flags |= SFBEAMDOWN; X p->p_ship->s_flags &= ~(SFSHIELD | SFREPAIR | SFBOMB | SFBEAMUP); X} X Xrepair(p) Xregister struct player *p; X{ X p->p_ship->s_desspeed = 0; X p->p_ship->s_flags |= SFREPAIR; X p->p_ship->s_flags &= ~(SFSHIELD | SFBOMB | SFBEAMUP | SFBEAMDOWN); X} X Xrepair_off(p) Xregister struct player *p; X{ X p->p_ship->s_flags &= ~SFREPAIR; X} X Xrepeat_message(p) Xregister struct player *p; X{ X if (++(p->p_lastm) == MAXMESSAGE) ; X p->p_lastm = 0; X} X Xcloak(p) Xregister struct player *p; X{ X p->p_ship->s_flags ^= SFCLOAK; X} X Xcloak_on(p) Xregister struct player *p; X{ X p->p_ship->s_flags |= SFCLOAK; X} X Xcloak_off(p) Xregister struct player *p; X{ X p->p_ship->s_flags &= ~SFCLOAK; X} X Xtow_off(p) Xregister struct player *p; X{ X p->p_ship->s_flags &= ~SFTOWING; X if (p->p_ship->s_towing >= MAXPLAYER) { X warning(p, "Towing planets is not implemented."); X return; X } X warning(p, "Tractor beam off."); X ships[p->p_ship->s_towing].s_flags &= ~SFTOWED; X} X Xvoid Xtow_on(p, ob) Xregister struct player *p; Xregister struct obtype *ob; X{ X register struct ship *towee; X char obuf[132]; X int dist; X extern double hypot(); X X /* Must check that this is legal to do. */ X if (!(ob->o_type & PLAYERTYPE)) { X warning(p, "Towing planets is not implemented."); X return; X } X X towee = &ships[ob->o_num]; X dist = hypot((double) (p->p_ship->s_x - towee->s_x), X (double) (p->p_ship->s_y - towee->s_y)); X X /* Is ok to capture? */ X if (!isGod(p) && dist > MAX_TB_RANGE) { X sprintf(obuf, "%c%x is out of range of the tractor beams", X teamlet[towee->s_team], towee->s_no); X warning(p, obuf); X return; X } X X if (!isGod(p) && ((random() % MAX_TB_RANGE) / (p->p_ship->s_speed + towee->s_speed + 1)) > dist) { X sprintf(obuf, "The tractor beams failed to capture %c%x", X teamlet[towee->s_team], towee->s_no); X warning(p, obuf); X return; X } X X p->p_ship->s_towing = ob->o_num; X p->p_ship->s_flags |= SFTOWING; X X X towee->s_flags |= SFTOWED; X towee->s_flags &= ~SFORBIT; X towee->s_towed = p->p_ship->s_no; X X sprintf(obuf, "You have %c%x in your tractor beam", X teamlet[towee->s_team], towee->s_no); X warning(p, obuf); X} END_OF_interface.c if test 4473 -ne `wc -c <interface.c`; then echo shar: \"interface.c\" unpacked with wrong size! fi # end of overwriting check fi if test -f planets.h -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"planets.h\" else echo shar: Extracting \"planets.h\" \(4134 characters\) sed "s/^X//" >planets.h <<'END_OF_planets.h' X/* static char sccsid[] = "@(#)planets.h 3.1"; */ X/* X X Copyright (c) 1986 Chris Guthrie X XPermission to use, copy, modify, and distribute this Xsoftware and its documentation for any purpose and without Xfee is hereby granted, provided that the above copyright Xnotice appear in all copies and that both that copyright Xnotice and this permission notice appear in supporting Xdocumentation. No representations are made about the Xsuitability of this software for any purpose. It is Xprovided "as is" without express or implied warranty. X X*/ X Xstruct planet pdata[MAXPLANETS] = { X/* No FLG OWN X Y NAME NL ARM INFO DEAD COUP DRAW TNAME TNL PRIM ORBRAD ORBVAL TYPE ORBANG */ X { 0, PLHOME, FED, 0, 0, "Earth", 0, 50, 0, 0, 0, 0, "", 0, 0, 0, 0, CLASSM, 0 }, X { 1, PLHOME, ROM, 0, 0, "Romulus", 0, 50, 0, 0, 0, 0, "", 0, 0, 0, 0, CLASSM, 0 }, X { 2, PLHOME, KLI, 0, 0, "Klingus", 0, 50, 0, 0, 0, 0, "", 0, 0, 0, 0, CLASSM, 0 }, X { 3, PLHOME, ORI, 0, 0, "Orion", 0, 50, 0, 0, 0, 0, "", 0, 0, 0, 0, CLASSM, 0 }, X { 4, 0, ROM, 0, 0, "Remus", 0, 50, 0, 0, 0, 0, "", 0, 0, 0, 0, DEAD, 0 }, X { 5, 0, KLI, 0, 0, "Leudus", 0, 50, 0, 0, 0, 0, "", 0, 0, 0, 0, DEAD, 0 }, X { 6, 0, ORI, 0, 0, "Oberon", 0, 50, 0, 0, 0, 0, "", 0, 0, 0, 0, DEAD, 0 }, X { 7, 0, FED, 0, 0, "Telos", 0, 50, 0, 0, 0, 0, "", 0, 0, 0, 0, DEAD, 0 }, X { 8, 0, KLI, 0, 0, "Tarsus", 0, 50, 0, 0, 0, 0, "", 0, 0, 0, 0, DEAD, 0 }, X { 9, 0, ORI, 0, 0, "Umbriel", 0, 50, 0, 0, 0, 0, "", 0, 0, 0, 0, DEAD, 0 }, X { 10, 0, FED, 0, 0, "Omega", 0, 50, 0, 0, 0, 0, "", 0, 0, 0, 0, DEAD, 0 }, X { 11, 0, ROM, 0, 0, "Rho", 0, 50, 0, 0, 0, 0, "", 0, 0, 0, 0, DEAD, 0 }, X { 12, 0, SELFRULED, 0, 0, "Janus", 0, 25, 0, 0, 0, 0, "", 0, 0, 0, 0, CLASSM, 0 }, X { 13, 0, SELFRULED, 0, 0, "Elas", 0, 25, 0, 0, 0, 0, "", 0, 0, 0, 0, CLASSM, 0 }, X { 14, 0, SELFRULED, 0, 0, "Sherman", 0, 25, 0, 0, 0, 0, "", 0, 0, 0, 0, CLASSM, 0 }, X { 15, 0, SELFRULED, 0, 0, "Serital", 0, 25, 0, 0, 0, 0, "", 0, 0, 0, 0, DEAD, 0 }, X { 16, 0, SELFRULED, 0, 0, "Cheron", 0, 25, 0, 0, 0, 0, "", 0, 0, 0, 0, DEAD, 0 }, X { 17, 0, SELFRULED, 0, 0, "Dakel", 0, 25, 0, 0, 0, 0, "", 0, 0, 0, 0, CLASSM, 0 }, X { 18, 0, SELFRULED, 0, 0, "Sarac", 0, 25, 0, 0, 0, 0, "", 0, 0, 0, 0, CLASSM, 0 }, X { 19, 0, SELFRULED, 0, 0, "Venar", 0, 25, 0, 0, 0, 0, "", 0, 0, 0, 0, CLASSM, 0 }, X { 20, 0, SELFRULED, 0, 0, "Xidex", 0, 25, 0, 0, 0, 0, "", 0, 0, 0, 0, CLASSM, 0 }, X { 21, 0, SELFRULED, 0, 0, "Oldar", 0, 25, 0, 0, 0, 0, "", 0, 0, 0, 0, DEAD, 0 }, X { 22, 0, SELFRULED, 0, 0, "Eminiar", 0, 25, 0, 0, 0, 0, "", 0, 0, 0, 0, DEAD, 0 }, X { 23, 0, SELFRULED, 0, 0, "Dyneb", 0, 25, 0, 0, 0, 0, "", 0, 0, 0, 0, DEAD, 0 }, X { 24, 0, SELFRULED, 0, 0, "RigelB", 0, 25, 0, 0, 0, 0, "", 0, 0, 0, 0, DEAD, 0 }, X { 25, 0, GOD, 0, 0, "Luna", 0, 0, 0, 0, 0, 0, "", 0, 0, 0, 0, MOON, 0 }, X { 26, PLINVIS, GOD, 0, 0, "Shitface", 256, 30, 0, 0, 0, 0, "", 0, 0, 0, 0, DEAD, 0 }, X { 27, PLINVIS, GOD, 0, 0, "Hell", 0, 128, 0, 0, 0, 0, "", 0, 0, 0, 0, DEAD, 0 }, X { 28, PLINVIS, GOD, 0, 0, "Jinx", 0, 512, 0, 0, 0, 0, "", 0, 0, 0, 0, CLASSM, 0 }, X { 29, 0, GOD, 0, 0, "Sol", 0, 100, 0, 0, 0, 0, "", 0, 0, 0, 0, SUN, 0 }, X { 30, 0, GOD, 0, 0, "Sirius", 0, 100, 0, 0, 0, 0, "", 0, 0, 0, 0, SUN, 0 }, X { 31, 0, GOD, 0, 0, "Kejela", 0, 100, 0, 0, 0, 0, "", 0, 0, 0, 0, SUN, 0 }, X { 32, 0, GOD, 0, 0, "Betelgeuse", 0, 100, 0, 0, 0, 0, "", 0, 0, 0, 0, SUN, 0 }, X { 33, 0, GOD, 0, 0, "Murisak", 0, 100, 0, 0, 0, 0, "", 0, 0, 0, 0, SUN, 0 }, X { 34, PLINVIS, GOD, 0, 0, "Syrinx", 0, 100, 0, 0, 0, 0, "", 0, 0, 0, 0, SUN, 0 }, X { 35, PLINVIS, GOD, 0, 0, "Ghost 1", 0, 0, 0, 0, 0, 0, "", 0, 0, 0, 0, GHOST, 0 }, X { 36, PLINVIS, GOD, 0, 0, "Ghost 2", 0, 0, 0, 0, 0, 0, "", 0, 0, 0, 0, GHOST, 0 }, X { 37, PLINVIS, GOD, 0, 0, "Ghost 3", 0, 0, 0, 0, 0, 0, "", 0, 0, 0, 0, GHOST, 0 }, X { 38, PLINVIS, GOD, 0, 0, "Ghost 4", 0, 0, 0, 0, 0, 0, "", 0, 0, 0, 0, GHOST, 0 }, X { 39, PLINVIS, GOD, 0, 0, "Spare 1", 0, 0, 0, 0, 0, 0, "", 0, 0, 0, 0, GHOST, 0 } X}; X X#define NUMCONPLANETS 25 /* Number of planets need to conquer to win */ END_OF_planets.h if test 4134 -ne `wc -c <planets.h`; then echo shar: \"planets.h\" unpacked with wrong size! fi # end of overwriting check fi if test -f scorelist.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"scorelist.c\" else echo shar: Extracting \"scorelist.c\" \(4893 characters\) sed "s/^X//" >scorelist.c <<'END_OF_scorelist.c' Xstatic char sccsid[] = "@(#)scorelist.c 3.1"; X/* Copyright (c) 1986 Chris Guthrie */ X X X#include <X11/Xlib.h> X#include <stdio.h> X#include <math.h> X#include <signal.h> X#include "defs.h" X#include "data.h" X#include "bitmaps.h" X Xstruct score { X int s_no; X char *p_name; X double st_kills; X double st_maxkills; X int st_losses; X double skill; X int st_torps; X int st_phasers; X int st_planets; X int st_armsbomb; X} player_scores[MAXPLAYER]; X Xscore_cmp(s1, s2) Xregister struct score *s1, *s2; X{ X if (s1->skill < s2->skill) X return(1); X if (s1->skill > s2->skill) X return(-1); X if (s1->st_kills < s2->st_kills) X return(1); X if (s1->st_kills > s2->st_kills) X return(-1); X if (s1->st_maxkills < s2->st_maxkills) X return(1); X if (s1->st_maxkills > s2->st_maxkills) X return(-1); X return(0); X} X Xscorelist(p, fid) Xregister struct player *p; Xint fid; X{ X register int i, t; X register int k = 0; X char buf[BUFSIZ]; X register struct player *j; X struct player team; X int active_team; X int ps_index; X struct score *psp; X X strcpy(buf, " # Name Kills MaxK Killed Skill Torps Phasers Planets Bombed"); X if (p) { X p->p_infomapped = 1; X p->infow = XCreateWindow(p->display, p->mapw, 10, 10, 77 * fontWidth(p->dfont), X (MAXPLAYER + NUMTEAM + 4) * fontHeight(p->dfont), 2, DefaultDepth(p->display, p->screen), InputOutput, X (Visual *) CopyFromParent, 0L, (XSetWindowAttributes *) 0); X /* (MAXPLAYER + NUMTEAM + 4) * fontHeight(dfont), 2, p->foreTile, p->backTile);*/ X XSetWindowBackground(p->display, p->infow, p->backColor); X XMapWindow(p->display, p->infow); X XDrawImageString(p->display, p->infow, p->dfgc, 0, fontHeight(p->dfont), buf, X strlen(buf)); X k = 2; X } else { X write(fid, buf, strlen(buf)); X write(fid, "\n", 1); X } X X ps_index = 0; X for (i = 0, j = &players[i]; i < MAXPLAYER; i++, j++) { X if (j->p_status == PFREE) X continue; X psp = &player_scores[ps_index++]; X psp->s_no = j->p_ship->s_no; X psp->p_name = j->p_name; X psp->st_kills = j->p_stats.st_kills; X psp->st_maxkills = j->p_stats.st_maxkills; X psp->st_losses = j->p_stats.st_losses; X psp->skill = (j->p_stats.st_losses == 0) ? X (j->p_stats.st_kills * 2) : j->p_stats.st_kills / j->p_stats.st_losses; X psp->st_torps = j->p_stats.st_torps; X psp->st_phasers = j->p_stats.st_phasers; X psp->st_planets = j->p_stats.st_planets; X psp->st_armsbomb = j->p_stats.st_armsbomb; X } X qsort(player_scores, ps_index, sizeof (struct score), score_cmp); X X for (i = 0, psp = &player_scores[0]; i < ps_index; i++, psp++) { X sprintf(buf, " %1x %-16.16s %6.2f %5.2f %6d %5.2f %7d %7d %7d %6d", X psp->s_no, X psp->p_name, X psp->st_kills, X psp->st_maxkills, X psp->st_losses, X psp->skill, X psp->st_torps, X psp->st_phasers, X psp->st_planets, X psp->st_armsbomb X ); X if (!p) { X write(fid, buf, strlen(buf)); X write(fid, "\n", 1); X } else { X XDrawImageString(p->display, p->infow, p->dfgc, 0, fontHeight(p->dfont) * k++, buf, strlen(buf)); X } X } X X k++; /* leave a blank line between players and teams */ X if (!p) X write(fid, "\n", 1); X X for (t = 0; t < NUMTEAM; t++) { X team.p_no = t; X if (t == FED) X strcpy(team.p_name, "Federation"); X else if (t == ROM) X strcpy(team.p_name, "Romulan"); X else if (t == ORI) X strcpy(team.p_name, "Orion"); X else if (t == KLI) X strcpy(team.p_name, "Klingon"); X team.p_stats.st_kills = 0; X team.p_stats.st_maxkills = 0; X team.p_stats.st_losses = 0; X team.p_stats.st_torps = 0; X team.p_stats.st_phasers = 0; X team.p_stats.st_planets = 0; X team.p_stats.st_armsbomb = 0; X active_team = 0; X for (i = 0, j = &players[0]; i < MAXPLAYER; i++, j++) { X if (j->p_status == PFREE || j->p_ship->s_team != t) X continue; X if (j->p_copilot) X continue; X active_team = 1; X team.p_stats.st_kills += j->p_ship->s_stats.st_kills; X if (team.p_stats.st_maxkills < j->p_stats.st_maxkills) X team.p_stats.st_maxkills = j->p_stats.st_maxkills; X team.p_stats.st_losses += j->p_ship->s_stats.st_losses; X team.p_stats.st_torps += j->p_ship->s_stats.st_torps; X team.p_stats.st_phasers += j->p_ship->s_stats.st_phasers; X team.p_stats.st_planets += j->p_ship->s_stats.st_planets; X team.p_stats.st_armsbomb += j->p_ship->s_stats.st_armsbomb; X } X if (active_team) { X sprintf(buf, " %1x %-16.16s %6.2f %5.2f %6d %5.2f %7d %7d %7d %6d", X team.p_no, X team.p_name, X team.p_stats.st_kills, X team.p_stats.st_maxkills, X team.p_stats.st_losses, X (team.p_stats.st_losses == 0) ? X (team.p_stats.st_kills * 2) : team.p_stats.st_kills / team.p_stats.st_losses, X team.p_stats.st_torps, X team.p_stats.st_phasers, X team.p_stats.st_planets, X team.p_stats.st_armsbomb X ); X if (!p) { X write(fid, buf, strlen(buf)); X write(fid, "\n", 1); X } else { X XDrawImageString(p->display, p->infow, p->dfgc, 0, fontHeight(p->dfont) * k++, buf, strlen(buf)); X } X } X } X} END_OF_scorelist.c if test 4893 -ne `wc -c <scorelist.c`; then echo shar: \"scorelist.c\" unpacked with wrong size! fi # end of overwriting check fi echo shar: End of archive 2 \(of 11\). cp /dev/null ark2isdone MISSING="" for I in 1 2 3 4 5 6 7 8 9 10 11 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 11 archives. 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 dan ---------------------------------------------------- O'Reilly && Associates argv@sun.com / argv@ora.com Opinions expressed reflect those of the author only.