games@tekred.TEK.COM (07/21/88)
Submitted by: Peer Schmitz <peer@cs.kl.ac.uk>
Comp.sources.games: Volume 5, Issue 9
Archive-name: mpss/Part03
#! /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 3 (of 4)."
# Contents: Makefile consoleplots.c cross.c main.c newplayer.c orbit.c
# scan.c ships.c
# Wrapped by billr@saab on Wed Jul 20 17:00:27 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Makefile' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(1665 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X# Makefile for mpss
XTREKOBJS = aliens.o ships.o planets.o scan.o cross.o torpedo.o \
X consoleplots.o cursor.o auto.o dock.o orbit.o keyscan.o \
X main.o newplayer.o processinput.o collision.o setupuniverse.o
XSLAVEOBJS = cursor.o ships.o slave.o
X# Be sure to edit files.h if these pathnames change
XBINDIR = /usr/games
XLIBDIR = /usr/games/mpsslib
XCFLAGS = -O
X
Xall: mpss slave startrek mpssclean
X
Xstartrek: $(TREKOBJS)
X cc $(CFLAGS) -o startrek $(TREKOBJS) -ltermcap -lm
X
Xslave: $(SLAVEOBJS)
X cc $(CFLAGS) -o slave $(SLAVEOBJS) -ltermcap
X
Xmpss: files.h mpss.c
X cc $(CFLAGS) -o mpss mpss.c
X
Xmpssclean: files.h mpssclean.c
X cc $(CFLAGS) -o mpssclean mpssclean.c
X
Xinstall: mpss slave startrek mpssclean mpssmail
X -mkdir $(LIBDIR)
X chmod 777 $(LIBDIR)
X install -s -m 4755 -o daemon startrek $(LIBDIR)
X install -s -m 4755 -o daemon slave $(LIBDIR)
X install -s -m 4777 -o daemon mpssmail $(LIBDIR)
X install -s -m 4755 -o daemon mpssclean $(BINDIR)
X install -s -m 755 -o daemon mpss $(BINDIR)
X
Xclean:
X -rm *.o startrek slave mpss mpssclean core
X
Xslave.o: ships.h files.h slave.c
Xcollision.o: header.h collision.c
Xcross.o: header.h cross.c
Xconsoleplots.o: header.h consoleplots.c
Xtorpedo.o: header.h torpedo.c
Xcursor.o: header.h cursor.c
Xauto.o: header.h auto.c
Xdock.o: header.h dock.c
Xorbit.o: planets.h header.h orbit.c
Xkeyscan.o: header.h keyscan.c
Xmain.o: header.h files.h main.c
Xnewplayer.o: ships.h header.h files.h newplayer.c
Xaliens.o: ships.h header.h aliens.c
Xprocessinput.o: ships.h header.h processinput.c
Xscan.o: ships.h header.h scan.c
Xships.o: ships.h ships.c
Xplanets.o: planets.h planets.c
Xsetupuniverse.o: planets.h header.h setupuniverse.c
END_OF_FILE
if test 1665 -ne `wc -c <'Makefile'`; then
echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'consoleplots.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'consoleplots.c'\"
else
echo shar: Extracting \"'consoleplots.c'\" \(5397 characters\)
sed "s/^X//" >'consoleplots.c' <<'END_OF_FILE'
X
X/*******************************************************************************
X********************************************************************************
X********************************************************************************
X
XPERMISSION TO COPY THIS SOFTWARE IS HEREBY GIVEN BY THE AUTHOR PROVIDED THAT
XTHIS LEADING MESSAGE IS INCLUDED IN ALL OF THE RELEVANT SOURCE FILES.
X
X P. SCHMITZ, UNIVERSITY OF KEELE, MAY 1988.
X
X
X********************************************************************************
X********************************************************************************
X*******************************************************************************/
X#include "header.h"
X
X/*
X*What follows are the routines to draw the console and plot all the
X*data onto it. plot1, plot2 are for the message window.
X*/
X
Xplot1(cp,p)
Xregister struct player *cp;
Xchar p[];
X{
Xif ((cp->id==ROMID)||(cp->id==KLINGID)) return(0);
Xposcurs(cp,20,21);
Xwrite(cp->fd,p,57);
Xbeep(cp);
X}
X
Xplot2(cp,p)
Xregister struct player *cp;
Xchar p[];
X{
Xif ((cp->id==ROMID)||(cp->id==KLINGID)) return(0);
Xposcurs(cp,20,22);
Xwrite(cp->fd,p,57);
X}
X
Xbroadcast(r)
Xchar r[];
X{
Xstruct player *o;
X
Xo=startlist;
Xif (noofplayers==1) return(0);
X
Xwhile (o!=NULL)
X {
X plot1(o," Uhura : Message from Starfleet Command Sir! ");
X plot2(o,r);
X o=o->next;
X }
X}
X
Xplotstatus(cp,x)
Xregister struct player *cp;
Xint x;
X{
Xcp->stat=x;
Xif ((cp->id==ROMID)||(cp->id==KLINGID)) return(0);
Xposcurs(cp,9,22);
Xswitch(x)
X{
Xcase 0: write(cp->fd,"Com Link :",10); break;
Xcase 1: write(cp->fd,"Prefix No.",10); break;
Xcase 2: write(cp->fd,"RED ALERT ",10); break;
Xcase 3: write(cp->fd," green ",10); break;
Xcase 4: write(cp->fd," damaged! ",10); break;
Xcase 5: write(cp->fd,"auto-pilot",10); break;
Xcase 6: write(cp->fd,"Locking...",10); break;
Xcase 7: write(cp->fd," docked ",10); break;
Xcase 8: write(cp->fd," orbiting ",10); break;
Xcase 9: write(cp->fd," scanning ",10); break;
Xcase 10:write(cp->fd,"On planet ",10); break;
Xcase 11:write(cp->fd,"Help sheet",10); break;
Xcase 12:write(cp->fd,"DEAD!!!!!!",10); break;
Xdefault: break;
X}
X}
X
Xplotcloakingdevice(cp)
Xregister struct player *cp;
X{
Xif ((cp->id==ROMID)||(cp->id==KLINGID)) return(0);
Xposcurs(cp,15,14);
Xif (cp->cloakingdevice)
Xwrite(cp->fd,"on ",3);
Xelse
Xwrite(cp->fd,"off",3);
X}
X
Xplotshields(cp)
Xregister struct player *cp;
X{
Xif ((cp->id==ROMID)||(cp->id==KLINGID)) return(0);
Xposcurs(cp,15,16);
Xif (cp->shields)
Xwrite(cp->fd,"on ",3);
Xelse
Xwrite(cp->fd,"off",3);
X}
X
Xplotenergy(cp)
Xregister struct player *cp;
X{
Xchar energy[5];
X
Xif ((cp->id==ROMID)||(cp->id==KLINGID)) return(0);
Xif (cp->energy>0)
X{
Xsprintf(energy," %4d",cp->energy);
Xposcurs(cp,14,7);
Xwrite(cp->fd,energy,5);
X} else
X{
Xif ((cp->stat<12))
X{
Xplot1(cp," You ran out of energy and life support systems failed ");
Xplot2(cp," Captain. I'm afraid, theres no survivors.You blew it. ");
Xif (cp->reason>0) cp->reason= -2;
Xfinish(cp);
X}
X}
X}
X
Xplotbattleenergy(d)
Xstruct player *d;
X{
Xchar energy[5];
X
Xif ((d->id==ROMID)||(d->id==KLINGID)) return(0);
Xsprintf(energy," %4d",d->energy);
Xposcurs(d,14,7);
Xwrite(d->fd,energy,5);
Xsprintf(energy," %4d",d->maxenergy);
Xposcurs(d,14,9);
Xwrite(d->fd,energy,5);
X}
X
Xplotmaxenergy(cp)
Xregister struct player *cp;
X{
Xchar energy[5];
X
Xif ((cp->id==ROMID)||(cp->id==KLINGID)) return(0);
Xsprintf(energy," %4d",cp->maxenergy);
Xposcurs(cp,14,9);
Xwrite(cp->fd,energy,5);
X}
X
Xplotvelocity(cp)
Xregister struct player *cp;
X{
Xchar velocity[14];
X
Xif ((cp->id==ROMID)||(cp->id==KLINGID)) return(0);
Xsprintf(velocity,"x:%3d y:%3d ",cp->xvel,cp->yvel);
Xposcurs(cp,6,5);
Xwrite(cp->fd,velocity,13);
X}
X
Xplotposition(cp)
Xregister struct player *cp;
X{
Xchar position[14];
X
Xif ((cp->id==ROMID)||(cp->id==KLINGID)) return(0);
Xposcurs(cp,6,3);
Xsprintf(position,"x:%3d y:%3d ",cp->xpos,cp->ypos);
Xwrite(cp->fd,position,13);
X}
X
Xplotphaserbanks(cp)
Xregister struct player *cp;
X{
Xchar phaser[5];
Xchar c;
X
Xif ((cp->id==ROMID)||(cp->id==KLINGID)) return(0);
Xif (cp->weaponselect==0) c='s'; else c=' ';
Xsprintf(phaser,"%c %2d",c,cp->phaserbanks);
Xposcurs(cp,14,18);
Xwrite(cp->fd,phaser,4);
X
Xsprintf(phaser,"%2d",cp->phaserreach);
Xposcurs(cp,7,19);
Xwrite(cp->fd,phaser,2);
Xsprintf(phaser," %2d",cp->maxphaser);
Xposcurs(cp,14,19);
Xwrite(cp->fd,phaser,4);
X}
X
Xplotphotontorpedos(cp)
Xregister struct player *cp;
X{
Xchar photon[5];
Xchar c;
X
Xif ((cp->id==ROMID)||(cp->id==KLINGID)) return(0);
Xif (cp->weaponselect==1) c='s'; else c=' ';
Xsprintf(photon,"%c %2d",c,cp->photontorpedos);
Xposcurs(cp,14,20);
Xwrite(cp->fd,photon,4);
X
Xsprintf(photon,"%2d",cp->photonreach);
Xposcurs(cp,7,21);
Xwrite(cp->fd,photon,2);
Xsprintf(photon," %2d",cp->maxphoton);
Xposcurs(cp,14,21);
Xwrite(cp->fd,photon,4);
X}
X
Xplotscore(cp)
Xregister struct player *cp;
X{
Xchar score[8];
X
Xif ((cp->id==ROMID)||(cp->id==KLINGID)) return(0);
Xsprintf(score," %6d",cp->score);
Xposcurs(cp,9,23);
Xwrite(cp->fd,score,7);
X}
X
X
Xplotdata(cp)
Xregister struct player *cp;
X{
Xif ((cp->id==ROMID)||(cp->id==KLINGID)) return(0);
Xplotvelocity(cp);
Xplotposition(cp);
Xplotenergy(cp);
Xplotmaxenergy(cp);
Xplotcloakingdevice(cp);
Xplotshields(cp);
Xplotphaserbanks(cp);
Xplotphotontorpedos(cp);
Xplotstatus(cp,3);
Xplotscore(cp);
X}
X
X/*
X*routine to redraw the console at anytime
X*/
X
Xredrawconsole(cp)
Xregister struct player *cp;
X{
X if ((cp->id==ROMID)||(cp->id==KLINGID)) return(0);
X clrscreen(cp);
X plotdata(cp);
X drawcross(cp);
X drawconsole(cp);
X}
X
END_OF_FILE
if test 5397 -ne `wc -c <'consoleplots.c'`; then
echo shar: \"'consoleplots.c'\" unpacked with wrong size!
fi
# end of 'consoleplots.c'
fi
if test -f 'cross.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'cross.c'\"
else
echo shar: Extracting \"'cross.c'\" \(5551 characters\)
sed "s/^X//" >'cross.c' <<'END_OF_FILE'
X
X/*******************************************************************************
X********************************************************************************
X********************************************************************************
X
XPERMISSION TO COPY THIS SOFTWARE IS HEREBY GIVEN BY THE AUTHOR PROVIDED THAT
XTHIS LEADING MESSAGE IS INCLUDED IN ALL OF THE RELEVANT SOURCE FILES.
X
X P. SCHMITZ, UNIVERSITY OF KEELE, MAY 1988.
X
X
X********************************************************************************
X********************************************************************************
X*******************************************************************************/
X
X#include "header.h"
X
Xdrawcross(cp)
Xregister struct player *cp;
X{
Xint i;
X
Xfor(i=1;i<10;++i)
X{
Xposcurs(cp,20,i);
Xwrite(cp->fd, " | ",57);
X}
Xposcurs(cp,20,10);
Xwrite(cp->fd, "--------------------------- ---------------------------",57);
Xfor (i=11;i<20;++i)
X{
Xposcurs(cp,20,i);
Xwrite(cp->fd, " | ",57);
X}
Xplotvitals(cp);
X}
X
X
Xplotvitals(cp)
Xregister struct player *cp;
X{
Xint x1,x2,y1,y2,xx1,xx2,yy1,yy2;
Xcp->xvel=0;cp->yvel=0;
Xx1=cp->xpos-28;
Xx2=x1+57;
Xy1=cp->ypos-9;
Xy2=y1+19;
Xplot_screen(cp,x1,x2,y1,y2);
X}
X
X
Xplot_screen(cp,x1,x2,y1,y2)
Xregister struct player *cp;
Xregister int x1,x2,y1,y2;
X{
Xregister int xnew,ynew;
Xregister char c;
X
X int xx;
X
X plotposition(cp);
X
X for (i=y1; i<y2; ++i)
X {
X if ((xp=univ[i])==NULL) continue;
X do
X {
X if (((xx=xp->x)>=x1)&&(xx<=x2))
X {
X l=19-(i-y1);
X k=20+(xx-x1);
X if((k>19)&&(l>0)&&(k<77)&&(l<20))
X {
X poscurs(cp,k,l);
X write(cp->fd,&(xp->c),1);
X }
X }
X if (xx>x2) xp=NULL;
X else
X xp=xp->next_thing;
X } while (xp!=NULL);
X }
X
X player=startlist;
X
X while (player!=NULL)
X {
X if (cp==player)
X {
X player=player->next;
X continue;
X }
Xxnew=player->xpos;
Xynew=player->ypos;
Xif (!(((c=inuniv(xnew,ynew))=='*')||(c=='O')||(c=='.')||(c=='@')))
X {
X if (player->cloakingdevice==OFF)
X {
X if (player->stat<12)
X {
X l=19-(ynew-y1);
X if(((k=20+(xnew-x1))>19)&&(l>0)&&(k<77)&&(l<20))
X {
X poscurs(cp,k,l);
X write(cp->fd,&(player->id),1);
X }
X }
X }
X }
X player=player->next;
X }
X}
X
Xdrawconsole(cp)
Xregister struct player *cp;
X{
Xint i,j;
X
Xposcurs(cp,19,0);
Xwrite(cp->fd,"******************MULTI-PLAYER-STAR-TREK*******************",59);
Xposcurs(cp,19,20);
Xwrite(cp->fd,"********************MESSAGE WINDOW :***********************",59);
Xposcurs(cp,19,23);
Xwrite(cp->fd,"***********************************************************",59);
Xfor (i=1; i<24; ++i) { poscurs(cp,19,i);
X write(cp->fd,"*",1); }
Xfor (i=1; i<24; ++i) { poscurs(cp,77,i);
X write(cp->fd,"*",1); }
Xposcurs(cp,1,0); write(cp->fd,"SHIP'S STATUS :",16);
Xposcurs(cp,1,1); write(cp->fd,"~~~~~~~~~~~~~~~~",16);
Xposcurs(cp,1,3); write(cp->fd,"QUAD:",5);
Xposcurs(cp,1,5); write(cp->fd,"WARP:",5);
Xposcurs(cp,1,7); write(cp->fd,"ENERGY (CU's):",14);
Xposcurs(cp,1,9); write(cp->fd,"MAX. ENERGY :",14);
Xposcurs(cp,1,11);write(cp->fd,"WEAPONS STATUS :",16);
Xposcurs(cp,1,12);write(cp->fd,"~~~~~~~~~~~~~~~~",16);
Xposcurs(cp,1,14);write(cp->fd,"CLOAKING DEV.:",14);
Xposcurs(cp,2,16);write(cp->fd,"SHIELDS :",9);
Xposcurs(cp,1,18);write(cp->fd,"PHASER BANKS:",13);
Xposcurs(cp,1,19);write(cp->fd,"RANGE:",6);
Xposcurs(cp,10,19);write(cp->fd,"MAX:",4);
Xposcurs(cp,1,20);write(cp->fd,"PHOTON TORPS:",13);
Xposcurs(cp,1,21);write(cp->fd,"RANGE:",6);
Xposcurs(cp,10,21);write(cp->fd,"MAX:",4);
Xposcurs(cp,1,22);write(cp->fd,"STATUS:",7);
Xposcurs(cp,1,23);write(cp->fd,"SCORE :",7);
X}
X
Xdisplay_sheet(cp)
Xregister struct player *cp;
X{
Xposcurs(cp,20,1);
Xwrite(cp->fd, "~~~~~~~~~~~~~HELP FUNCTION & COMMAND SUMMARY~~~~~~~~~~~~~",57);
Xposcurs(cp,20,2);
Xwrite(cp->fd, "h,j,k,l => WARP DRIVE: left, down, up, right, movements. ",57);
Xposcurs(cp,20,3);
Xwrite(cp->fd, "y,u,b,n => WARP DRIVE: diagonal movements. s => full stop",57);
Xposcurs(cp,20,4);
Xwrite(cp->fd, " H,J,K,L,Y,U,B,N => Manoevering impulse engine movements ",57);
Xposcurs(cp,20,5);
Xwrite(cp->fd, " o => orbit, i => impulse thrusters to cancel orbit ",57);
Xposcurs(cp,20,6);
Xwrite(cp->fd, " + => Quit, G => beep on/off, R => Redraw Screen ",57);
Xposcurs(cp,20,7);
Xwrite(cp->fd, "d,f => dock/undock, 1..9 => fire weapon, p => weapon sel.",57);
Xposcurs(cp,20,8);
Xwrite(cp->fd, " q => show quadrant, w => show warp, e => show energy ",57);
Xposcurs(cp,20,9);
Xwrite(cp->fd, " c => cloaking device on/off, v => shields on/off ",57);
Xposcurs(cp,20,10);
Xwrite(cp->fd, " t<1,2,3,4> => lock tractor beam, T => show tractor beams",57);
Xposcurs(cp,20,11);
Xwrite(cp->fd, " W => who is playing?, a<1,2,3,4> => auto-pilot to beam ",57);
Xposcurs(cp,20,12);
Xwrite(cp->fd, " C<A> => Com link/send message, P<A> => send Prefix code ",57);
Xposcurs(cp,20,13);
Xwrite(cp->fd, " S<A> => Scan ship on/off (This will show prefix codes.)",57);
Xposcurs(cp,20,14);
Xwrite(cp->fd, " z => beam to/from planet, ? => this help function. ",57);
Xposcurs(cp,20,15);
Xwrite(cp->fd, " Key to command notation : ",57);
Xposcurs(cp,20,16);
Xwrite(cp->fd, " <1,2,3,4> => a number between 1-4 inclusive, ",57);
Xposcurs(cp,20,17);
Xwrite(cp->fd, " <A> => a shipname in the form of a lower case letter ",57);
Xposcurs(cp,20,18);
Xwrite(cp->fd, "NB : If a function doesn't seem to work, you cannot do it",57);
Xposcurs(cp,20,19);
Xwrite(cp->fd, "while you are in that particular status. PRESS ANY KEY ->",57);
X}
X
END_OF_FILE
if test 5551 -ne `wc -c <'cross.c'`; then
echo shar: \"'cross.c'\" unpacked with wrong size!
fi
# end of 'cross.c'
fi
if test -f 'main.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'main.c'\"
else
echo shar: Extracting \"'main.c'\" \(8131 characters\)
sed "s/^X//" >'main.c' <<'END_OF_FILE'
X
X/*******************************************************************************
X********************************************************************************
X********************************************************************************
X
XPERMISSION TO COPY THIS SOFTWARE IS HEREBY GIVEN BY THE AUTHOR PROVIDED THAT
XTHIS LEADING MESSAGE IS INCLUDED IN ALL OF THE RELEVANT SOURCE FILES.
X
X P. SCHMITZ, UNIVERSITY OF KEELE, MAY 1988.
X
X
X********************************************************************************
X********************************************************************************
X*******************************************************************************/
X#include <signal.h>
X#include "files.h"
X#include "header.h"
X
Xcheckmasterpidfile()
X{
Xint rpid,masterpid;
Xchar string[15];
XFILE *ff,*fopen();
X
Xmasterpid=getpid();
Xsprintf(string,"%d",masterpid);
Xif ((ff=fopen(MASTERPIDFILE,"r"))==NULL)
X {
X /*fprintf(stdout,"main.c: Can't read masterpidfile\n");*/
X die();
X } else
X {
X fgets(string,15,ff); /*get pid*/
X fclose(ff);
X }
Xsscanf(string,"%d\n",&rpid);
Xif (rpid!=masterpid)
X {
X /*fprintf(stdout,"main.c: pids not equal!!! %d %d\n",rpid,masterpid);*/
X die();
X }
Xsignal(SIGALRM,checkmasterpidfile);
Xalarm(180);
X}
X
X
X/*the only normal way out of the program*/
Xdie()
X{
Xregister struct player *hh;
X/*fprintf(stderr,"DIE WAS CALLED.\n");*/
X
X hh=startlist;
X while (hh!=NULL) {
X if ((hh->id!=ROMID)&&(hh->id!=KLINGID)) kill(hh->pid,9);
X hh=hh->next;
X }
X/*the only normal way out of the program*/
X exit(0);
X/*the only normal way out of the program*/
X}
X/*the only normal way out of the program*/
X
Xhandler()
X{
X noofsignals++;
X}
X
Xkillcontrol()
X{
Xint f;
X/*return(0); THIS MUST BE PUT IN DURING THE DEVELOPMENTAL PHASE*/
X
Xif ((f=open("/dev/tty",2))!= -1)
X {
X ioctl(f,TIOCNOTTY,0);
X }
X}
X
Xmain()
X{
Xregister struct player *cp;
Xint f,o;
Xregister int x,y,x1,x2,y1,y2,xx1,xx2,yy1,yy2,xold,yold,xnew,ynew;
Xregister char c;
Xregister struct torpedo *torpedo;
Xregister int xx,test;
X
Xtest=1;
Xf=umask(000);
Xkillcontrol();
Xnoofsignals=0;
Xsignal(SIGINT,SIG_IGN);
Xsignal(29,handler);
Xsignal(SIGALRM,checkmasterpidfile);
Xsetupuniverse();
Xstorm=OFF;
Xnoofaliens=0;
Xnoofplayers=0;
Xdebug=OFF;
Xstartlist=NULL;
Xtaillist=NULL;
Xtstartlist=NULL;
Xttaillist=NULL;
Xcp=NULL;
Xputmasterpidintofile();
Xalarm(10);
Xfor (;;)
X{
X/*main iteration loop*/
X while (cp!=NULL)
X {
X if ((cp->id==ROMID)||(cp->id==KLINGID))
X {
X servicealien(cp);
X x=cp->xpos; y=cp->ypos;
X if ((x<58)||(x>899)||(y<19)||(y>899))
X {
X if (x<58) cp->xvel=1;
X if (x>899) cp->xvel= -1;
X if (y<19) cp->yvel=1;
X if (y>899) cp->yvel= -1;
X }
X goto goonlabel;
X }
X cp->clflg=OFF;
X ioctl(cp->fd,FIONREAD,&noofchars);
X if (noofchars>0) processinput(cp,&noofchars);
X if ((cp->stat==5)&&(cp->flyto>=0)&&(cp->flyto<4)) auto_pilot(cp);
X if (cp->stat>=9) goto goonlabel;
X
X /*****************PLOTTING OBJECT STARTS HERE!!!******************/
X
X f=cp->xvel;
X o=cp->yvel;
X test=1;
X x=cp->xpos;
X y=cp->ypos;
X cp->oldxpos=x; cp->oldypos=y;
X xx1=x-28; xx2=xx1+57;
X yy1=y-9; yy2=yy1+19;
X x+=f; y+=o;
X x1=x-28; x2=x1+57;
X y1=y-9; y2=y1+19;
X cp->xpos=x; cp->ypos=y;
X
X if ((cp->stat>5)||((f==0)&&(o==0))) goto plotmoving;
X
X cp->chflg=FLAG;
X
X for (i=yy1; i<yy2; ++i)
X {
X if ((xp=univ[i])==NULL) continue;
X do
X {
X if ((xx=xp->x)>=xx1)
X {
X l=19-(i-yy1);
X if(((k=20+(xx-xx1))>19)&&(k<77)&&(l>0)&&(l<20))
X {
X test=0;
X poscurs(cp,k,l);
X write(cp->fd,
X ((l==10)&&((k<47)||(k>49)))?
X "-":((k==48)&&(l!=10))?"|":" ",1);
X }
X l+=o;
X if(((k-=f)>19)&&(l>0)&&(k<77)&&(l<20))
X {
X poscurs(cp,k,l);
X test=0;
X write(cp->fd,&(xp->c),1);
X }
X }
X
X if (xx>x2)
X xp=NULL;
X else
X xp=xp->next_thing;
X
X } while (xp!=NULL);
X}
X
Xif (test) plotposition(cp);
X
X/*****************************************************************************
X Player plotting starts here!!!!
X*****************************************************************************/
X
Xplotmoving:
X
Xplayer=startlist;
X
Xwhile (player!=NULL)
X{
Xif ((cp==player)||((cp->chflg==0)&&(player->chflg==0)))
X {
X player=player->next;
X continue;
X }
Xxold=player->oldxpos;
Xyold=player->oldypos;
Xxnew=player->xpos;
Xynew=player->ypos;
Xif (inuniv(xold+f,yold+o)<36)
X {
Xif ((player->cloakingdevice==OFF)||(player->clflg))
X {
X l=19-(yold-yy1);
X if(((k=20+(xold-xx1))>19)&&(k<77)&&(l>0)&&(l<20))
X {
X poscurs(cp,k,l);
X write(cp->fd,((l==10)&&((k<47)||(k>49)))?"-":((k==48)&&(l!=10))?"|":" ",1);
X }
X }
X }
Xif (inuniv(xnew,ynew)<36)
X {
X if (player->cloakingdevice==OFF)
X {
X if (player->stat<12)
X {
X l=19-(ynew-y1);
X if(((k=20+(xnew-x1))>19)&&(l>0)&&(k<77)&&(l<20))
X {
X poscurs(cp,k,l);
X write(cp->fd,&(player->id),1);
X }
X }
X }
X }
X player=player->next;
X}
X
X/**************************************************************************
X Torpedo plotting starts here!!
X***************************************************************************/
X
Xtorpedo=tstartlist;
X
Xwhile (torpedo!=NULL)
X{
Xxold=torpedo->oldxpos;
Xyold=torpedo->oldypos;
Xxnew=torpedo->xpos;
Xynew=torpedo->ypos;
Xplayer=torpedo->whofrom;
Xif (((player!=NULL)&&(cp!=player)&&(xold==player->oldxpos)&&
X (yold==player->oldypos)) || ((inuniv(xold,yold)!=NULL)))
X {
X torpedo=torpedo->next;
X continue;
X }
X k=20+(xold-xx1);
X l=19-(yold-yy1);
X if((k>19)&&(k<77)&&(l>0)&&(l<20))
X {
X poscurs(cp,k,l);
Xwrite(cp->fd,((l==10)&&((k<47)||(k>49)))?"-":((k==48)&&(l!=10))?"|":" ",1);
X }
X if (torpedo->life>0)
X {
X l=19-(ynew-y1);
X if(((k=20+(xnew-x1))>19)&&(l>0)&&(k<77)&&(l<20))
X {
X poscurs(cp,k,l);
X write(cp->fd,&(torpedo->weapon),1);
X }
X }
X torpedo=torpedo->next;
X }
X /*****************PLOTTING OBJECTS STOPS HERE!!!******************/
X
Xif ((x<58)||(x>899)||(y<19)||(y>899))
X {
X if (x<58) cp->xvel=1;
X if (x>899) cp->xvel= -1;
X if (y<19) cp->yvel=1;
X if (y>899) cp->yvel= -1;
X } else
X {
X if ((c=inuniv(x,y))!=NULL) collision(cp,c);
X if (((f!=0)||(o!=0))&&((x==450)||(y==450)))
X {
X j=which_sector(cp->xpos,cp->ypos,f,o);
X switch (j)
X {
X case 1:
X {
X plot1(cp," You have just entered Federation space again. ");
X plot2(cp," It's nice to be home. ");
X break;
X }
X case 2:
X {
X plot1(cp,"You have just entered Klingon Space. Remember the klingon");
X plot2(cp,"proverb : Revenge is a dish that is best served cold.....");
X break;
X }
X case 3:
X {
X plot1(cp," You have just entered the Mutara Nebula. ");
X plot2(cp," Here, Shields and Cloaking Devices will not function! ");
X cp->cloakingdevice=OFF;
X if (cp->shields)
X {
X cp->id=(char)(cp->id+32);
X cp->shields=OFF;
X }
X plotshields(cp);
X plotcloakingdevice(cp);
X if (cp->stat<12) cp->chflg=FLAG;
X break;
X }
X case 4:
X {
X plot1(cp," You have just entered the Neutral Zone. ");
X plot2(cp," We are now in violation of treaty Captain!! ");
X break;
X }
X default :
X break;
X } /*switch*/
X }
X }
X
X if ((storm)&&(f==-1)) storm=OFF;
X /*ENERGY CALCULATION*/
X i=cp->cloakingdevice;
X i+=cp->shields;
X j=(abs(f)>abs(o))?abs(f):abs(o);
X
X if (j==0)
X {
X if ((i==0)&&(cp->energy<cp->maxenergy)) ++cp->energy;
X else goto skipenergy;
X } else
X {
X if ((j==1) && (i==0)) goto skipenergy;
X cp->energy -= (i+j);
X }
X
X skipenergy:
X
X if ((cp->energy==75)&&(storm==OFF)) flare();
X if (cp->energy<100) plotenergy(cp);
X /*ENERGY CALCULATION*/
Xgoonlabel:
X if (cp->impulsemove>0) {
X cp->impulsemove=0;
X cp->xvel=0;
X cp->yvel=0;
X }
X if (cp->chflg>0) --(cp->chflg);
X cp=cp->next;
X } /*while cp!=NULL*/
Xremove_finished_players();
Xif (tstartlist!=NULL) move_torpedos();
Xif (noofsignals>0) {
X makenewplayerandjoinhimin();
X --noofsignals;
X }
Xif ((noofplayers==1)&&(noofaliens<MAXALIENS)) makealien();
Xcp=startlist;
X/*main iteration loop*/
X}
X}
X
Xremove_finished_players()
X{
Xstruct player *y;
X
Xy=startlist;
Xwhile (y!=NULL)
X {
X if ((y->stat==12)&&(y->chflg<1))
X remove_player_from_list(y);
X y=y->next;
X }
X}
X
Xflare()
X{
Xregister struct player *x;
X
Xbroadcast("Galactic ion storm commencing. Cloaking devices are off. ");
Xstorm=ON;
Xx=startlist;
Xwhile (x!=NULL)
X {
X x->cloakingdevice=OFF;
X plotcloakingdevice(x);
X x->chflg=FLAG;
X x=x->next;
X }
X}
END_OF_FILE
if test 8131 -ne `wc -c <'main.c'`; then
echo shar: \"'main.c'\" unpacked with wrong size!
fi
# end of 'main.c'
fi
if test -f 'newplayer.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'newplayer.c'\"
else
echo shar: Extracting \"'newplayer.c'\" \(6117 characters\)
sed "s/^X//" >'newplayer.c' <<'END_OF_FILE'
X
X/*******************************************************************************
X********************************************************************************
X********************************************************************************
X
XPERMISSION TO COPY THIS SOFTWARE IS HEREBY GIVEN BY THE AUTHOR PROVIDED THAT
XTHIS LEADING MESSAGE IS INCLUDED IN ALL OF THE RELEVANT SOURCE FILES.
X
X P. SCHMITZ, UNIVERSITY OF KEELE, MAY 1988.
X
X
X********************************************************************************
X********************************************************************************
X*******************************************************************************/
X
X#include "files.h"
X#include "ships.h"
X#include "header.h"
XFILE *f, *fopen();
X
Xputmasterpidintofile()
X{
Xint masterpid;
Xchar string[15];
X
Xmasterpid=getpid();
Xsprintf(string,"%d\n",masterpid);
Xi=creat(MASTERPIDFILE,0666);
Xif ((f=fopen(MASTERPIDFILE,"w"))==NULL)
X {
X die();
X } else
X {
X fputs(string,f); /*write master pid into file*/
X fclose(f);
X }
X}
X
Xfind_player_id()
X{
Xint i;
X
Xif (noofplayers>=10)
X {
X return(0);
X }
Xi=0;
Xwhile ((i<10)&&(players[i]==1)) ++i;
Xplayers[i]=1;
Xreturn(i);
X}
X
Xmakenewplayerandjoinhimin()
X{
Xchar string[80];
Xchar *malloc();
Xstruct player *aa,*xp;
X
Xif (noofplayers==10)
X{
Xunlink(LOCK);
Xreturn(0);
X} else
X{
Xif ((x=open(PLAYERFILE,0))<0)
X{
Xunlink(LOCK);
Xreturn(0);
X}
Xelse
X{
X/* find a free player position */
Xaa=(struct player *)malloc(sizeof(struct player));
X
X/*NOW READ IN THE DATA FROM PLAYERFILE*/
Xi=0;
Xread(x,&c,1);
Xwhile (c!='#')
X {
X if (i>13) {fprintf(stderr,"1:i went out:%d",i); die();}
X aa->terminalfile[i]=c;
X i++;
X read(x,&c,1);
X }
Xi=0;
Xread(x,&c,1);
Xwhile (c!='#')
X {
X if (i>19) {fprintf(stderr,"2:i went out:%d",i); die();}
X aa->cm[i]=c;
X i++;
X read(x,&c,1);
X }
Xi=0;
Xread(x,&c,1);
Xwhile (c!='#')
X {
X if (i>19) {fprintf(stderr,"3:i went out:%d",i); die();}
X aa->cl[i]=c;
X i++;
X read(x,&c,1);
X }
Xi=0;
Xread(x,&c,1);
Xwhile (c!='#')
X {
X if (i>79) {fprintf(stderr,"4:i went out:%d",i); die();}
X string[i]=c;
X i++;
X read(x,&c,1);
X }
Xfor(y=i;y<80;y++) string[i]='\0';
Xaa->shipno=atoi(string);
X
Xi=0;
Xread(x,&c,1);
Xwhile (c!='#')
X {
X if (i>79) {fprintf(stderr,"5:i went out:%d",i); die();}
X string[i]=c;
X i++;
X read(x,&c,1);
X }
Xfor(y=i;y<80;y++) string[i]='\0';
Xaa->pid=atoi(string);
X
Xi=0;
Xread(x,&c,1);
Xwhile (c!='#')
X {
X if (i>79) {fprintf(stderr,"5:i went out:%d",i); die();}
X string[i]=c;
X i++;
X read(x,&c,1);
X }
Xfor(y=i;y<80;y++) string[i]='\0';
Xaa->tty_type=atoi(string);
X
Xclose(x);
X/*NOW READ IN THE DATA FROM PLAYERFILE*/
X
Xaa->terminalfile[13]=' ';
X/*
Xfprintf(stderr,"shipno:%d\npid:%d\ntty_type:%d\n",aa->shipno,aa->pid,aa->tty_type);
Xfprintf(stderr,"cm is :");
Xfor (i=0;i<20;i++) fprintf(stderr,"*%c*",aa->cm[i]);
Xfprintf(stderr,"\ncl is :");
Xfor (i=0;i<20;i++) fprintf(stderr,"*%c*",aa->cl[i]);
Xfprintf(stderr,"\nThats it\n");
Xread(0,&c,1);
X*/
Xif (((aa->fd)=open((aa->terminalfile),2))==-1)
X {
X kill(aa->pid,9);
X free(aa);
X killcontrol();
X } else
X {
X ++noofplayers;
X aa->doneit=0;
X aa->impulsemove=0;
X aa->reason=10;
X aa->id=(char)('a'+find_player_id());
X aa->xpos=230;
X aa->ypos=(int)(rnd(0,5)+675);
X aa->oldxpos=aa->xpos;
X aa->oldypos=aa->ypos;
X aa->beeping=ON;
X aa->maxvel=MAXWARP;
X aa->xvel=0;
X aa->yvel=0;
X aa->chflg=FLAG;
X aa->clflg=OFF;
X aa->stat=3;
X aa->energy=STARTENERGY;
X aa->maxenergy=STARTENERGY;
X aa->phaserbanks=STARTPHASER;
X aa->maxphaser=STARTPHASER;
X aa->photontorpedos=STARTPHOTON;
X aa->maxphoton=STARTPHOTON;
X aa->photonpower=PHOTONPOWER;
X aa->phaserpower=PHASERPOWER;
X aa->photonreach=WEAPONREACH;
X aa->phaserreach=WEAPONREACH;
X aa->weaponselect=0;
X aa->score=0;
X aa->cloakingdevice=OFF;
X aa->shields=OFF;
X for(k=0;k<30;++k)
X aa->planets[k]=0;
X aa->planetno=0;
X for (k=0; k<=3; k++)
X {
X aa->channel[k].enemy=NULL;
X aa->channel[k].xloc=0;
X aa->channel[k].yloc=0;
X }
X aa->flyto= -1;
X broadcast("They advise us that new players are coming into the game.");
X flushbuf(aa);
X addtolist(aa);
X drawcross(aa);
X plotdata(aa);
X drawconsole(aa);
X plot1(aa,"Permission to come aboard granted. Captain on the Bridge.");
X plot2(aa," Welcome to the ");
X poscurs(aa,49,22);
X write(aa->fd,ship[aa->shipno].name,20);
X
X } /*else*/
X} /*else*/
X} /*else*/
Xunlink(PLAYERFILE);
Xunlink(LOCK);
X
X/*BLOW UP ALL ALIENS*/
X
Xif (noofplayers==2)
X {
X xp=startlist;
X while (xp!=NULL)
X {
X if ((xp->id==ROMID)||(xp->id==KLINGID))
X finish(xp);
X xp=xp->next;
X }
X }
X}
X
Xaddtolist(x)
Xstruct player *x;
X{
Xif ((startlist==NULL) && (taillist==NULL))
X{
Xstartlist=x; taillist=x; (startlist->next)=NULL;
X} else
X{
Xx->next=NULL;
Xtaillist->next=x;
Xtaillist=x;
X}
X}
X
Xremove_player_from_list(q)
Xregister struct player *q;
X{
XFILE *f,*fopen();
Xstruct player *a,*b;
Xstruct torpedo *t;
Xchar string[50];
Xint listlength,l,alien;
X
Xalien=0;
Xif ((q->id==ROMID)||(q->id==KLINGID)) alien=1;
X
Xif (alien) goto skipfile;
X
Xwhile ((f=fopen(PLAYERSCOREFILE,"r"))!=NULL)
X {
X fclose(f);
X }
X i=creat(PLAYERSCOREFILE,0666);
X if ((f=fopen(PLAYERSCOREFILE,"w"))==NULL)
X fprintf(stderr,"newplayer.c : Cant open PLAYERSCOREFILE.\n");
X sprintf(string,"%d %d\n",q->reason,q->score);
X fputs(string,f);
X fclose(f);
X
Xkill(q->pid,9); /*this kills the users dummy process*/
X/*make his playerid available again.*/
Xif ((q->id>='A')&&(q->id<='Z')) q->id=(char)((q->id)+32);
Xl=(int)((q->id)-'a');
Xplayers[l]=0;
Xclose(q->fd);
X/*make his playerid available again.*/
X
Xskipfile :
X
Xlistlength=noofplayers+noofaliens;
X
Xif (listlength>1)
X{
Xt=tstartlist;
Xwhile (t!=NULL)
X {
X if (t->whofrom==q) t->whofrom=NULL;
X t=t->next;
X }
X
Xb=startlist;
Xwhile (b!=NULL)
X {
X for (i=0; i<5; i++)
X if (b->channel[i].enemy==q) b->channel[i].enemy=NULL;
X b=b->next;
X }
X
Xif (q==startlist)
X {
X a=startlist;
X startlist=a->next;
X q=NULL;
X free(a);
X } else
X {
X b=startlist;
X while (b->next!=q) b=b->next;
X b->next=q->next;
X if (q==taillist) taillist=b;
X free(q);
X q=NULL;
X }
X
X} else
X{
X startlist=NULL;
X taillist=NULL;
X a=NULL;
X b=NULL;
X free(q);
X q=NULL;
X}
Xif (alien) --noofaliens; else --noofplayers;
Xif (noofplayers==0)
X {
X unlink(MASTERPIDFILE);
X die();
X }
Xkillcontrol();
X}
X
END_OF_FILE
if test 6117 -ne `wc -c <'newplayer.c'`; then
echo shar: \"'newplayer.c'\" unpacked with wrong size!
fi
# end of 'newplayer.c'
fi
if test -f 'orbit.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'orbit.c'\"
else
echo shar: Extracting \"'orbit.c'\" \(6788 characters\)
sed "s/^X//" >'orbit.c' <<'END_OF_FILE'
X
X/*******************************************************************************
X********************************************************************************
X********************************************************************************
X
XPERMISSION TO COPY THIS SOFTWARE IS HEREBY GIVEN BY THE AUTHOR PROVIDED THAT
XTHIS LEADING MESSAGE IS INCLUDED IN ALL OF THE RELEVANT SOURCE FILES.
X
X P. SCHMITZ, UNIVERSITY OF KEELE, MAY 1988.
X
X
X********************************************************************************
X********************************************************************************
X*******************************************************************************/
X#include "header.h"
X#include "planets.h"
X
X
Xupdateship(cp)
Xregister struct player *cp;
X{
Xswitch (cp->planetno)
X{
Xcase 1: cp->phaserreach += 2; plotphaserbanks(cp);
Xbreak;
Xcase 3: cp->energy += 50; cp->maxenergy += 50; plotbattleenergy(cp);
Xbreak;
Xcase 4: cp->maxphoton +=3; plotphotontorpedos(cp);
Xbreak;
Xcase 5: cp->maxvel +=1;
Xbreak;
Xcase 6: cp->phaserpower +=20;
Xbreak;
Xcase 7: cp->phaserbanks=0; cp->photontorpedos=0;
X plotphotontorpedos(cp); plotphaserbanks(cp);
Xbreak;
Xcase 8: cp->maxphaser+=10; plotphaserbanks(cp);
Xbreak;
Xcase 9: cp->photonreach +=3; cp->phaserbanks=cp->maxphaser; cp->photontorpedos=cp->maxphoton;
X plotphotontorpedos(cp); plotphaserbanks(cp);
Xbreak;
Xcase 10: cp->score += 150; cp->maxenergy+=200; plotmaxenergy(cp);
X plotscore(cp);
Xbreak;
Xcase 11: cp->photonpower+=300;
Xbreak;
Xcase 12: cp->phaserpower +=80;
Xbreak;
Xcase 14: cp->maxvel +=1;
Xbreak;
Xcase 15: cp->phaserreach +=2; plotphaserbanks(cp);
Xbreak;
Xcase 16: cp->score+=200; plotscore(cp);
Xbreak;
Xcase 17: cp->phaserpower+=100; plotphaserbanks(cp);
Xbreak;
Xcase 19: cp->score +=50; plotscore(cp);
Xbreak;
Xcase 20: cp->maxphoton+=7; cp->maxphaser+=3;
X plotphotontorpedos(cp); plotphaserbanks(cp);
Xbreak;
Xcase 21:cp->score=0; plotscore(cp);
Xbreak;
Xcase 22: cp->score +=50; plotscore(cp);
Xbreak;
Xcase 23: cp->photonreach +=1; plotphotontorpedos(cp);
Xbreak;
Xcase 24: cp->maxvel+=1;
Xbreak;
Xcase 28: cp->score+=cp->score; plotscore(cp);
X cp->maxphoton+=20; cp->maxphaser+=30;
X cp->photontorpedos+=20; cp->phaserbanks+=30;
X cp->photonreach+=5; cp->phaserreach+=5;
X cp->maxenergy+=300;
X plotbattleenergy(cp);
X plotphotontorpedos(cp); plotphaserbanks(cp);
Xbreak;
Xdefault:
Xbreak;
X} /*switch*/
X}
X
Xnoofplanet(x,y)
X{
Xi=0;
Xwhile (!((plan[i].xpos==x)&&(plan[i].ypos==y))) i++;
Xreturn(i);
X}
X
Xorbit(cp)
Xregister struct player *cp;
X{
Xint decay,orbitingok;
X
Xdecay=OFF;
Xorbitingok=OFF;
Xi=cp->xpos;
Xj=cp->ypos;
X
Xif (((cp->xvel==0) && (cp->yvel==0))&&
X ((inuniv(i+1,j-1)=='O')||
X (inuniv(i+1,j)=='O')||
X (inuniv(i+1,j+1)=='O')||
X (inuniv(i-1,j-1)=='O')||
X (inuniv(i-1,j)=='O')||
X (inuniv(i-1,j+1)=='O')||
X (inuniv(i,j+1)=='O')||
X (inuniv(i,j-1)=='O')))
X decay=ON;
Xif (decay)
X {
X plot1(cp,"Spock : We attempted orbit too close to the planet sir. ");
X plot2(cp,"Most of our energy has been used to keep us in the air. ");
X cp->energy -= 300;
X cp->maxenergy -= 300;
X plotenergy(cp);
X plotmaxenergy(cp);
X return(0);
X }
X
Xif ((cp->xvel==0) && (cp->yvel==0))
X{
Xif(inuniv(i-2,j+2)=='O'){orbitingok=ON;cp->planetno=noofplanet(i-2,j+2);goto label2;}
Xif(inuniv(i-2,j+1)=='O'){orbitingok=ON;cp->planetno=noofplanet(i-2,j+1);goto label2;}
Xif(inuniv(i-2,j)=='O'){orbitingok=ON;cp->planetno=noofplanet(i-2,j);goto label2;}
Xif(inuniv(i-2,j-1)=='O'){orbitingok=ON;cp->planetno=noofplanet(i-2,j-1);goto label2;}
Xif(inuniv(i-2,j-2)=='O'){orbitingok=ON;cp->planetno=noofplanet(i-2,j-2);goto label2;}
Xif(inuniv(i+2,j+2)=='O'){orbitingok=ON;cp->planetno=noofplanet(i+2,j+2);goto label2;}
Xif(inuniv(i+2,j+1)=='O'){orbitingok=ON;cp->planetno=noofplanet(i+2,j+1);goto label2;}
Xif(inuniv(i+2,j)=='O'){orbitingok=ON;cp->planetno=noofplanet(i+2,j);goto label2;}
Xif(inuniv(i+2,j-1)=='O'){orbitingok=ON;cp->planetno=noofplanet(i+2,j-1);goto label2;}
Xif(inuniv(i+2,j-2)=='O'){orbitingok=ON;cp->planetno=noofplanet(i+2,j-2);goto label2;}
Xif(inuniv(i+1,j-2)=='O'){orbitingok=ON;cp->planetno=noofplanet(i+1,j-2);goto label2;}
Xif(inuniv(i,j-2)=='O'){orbitingok=ON;cp->planetno=noofplanet(i,j-2);goto label2;}
Xif(inuniv(i-1,j-2)=='O'){orbitingok=ON;cp->planetno=noofplanet(i-1,j-2);goto label2;}
Xif(inuniv(i+1,j+2)=='O'){orbitingok=ON;cp->planetno=noofplanet(i+1,j+2);goto label2;}
Xif(inuniv(i,j+2)=='O'){orbitingok=ON;cp->planetno=noofplanet(i,j+2);goto label2;}
Xif(inuniv(i-1,j+2)=='O'){orbitingok=ON;cp->planetno=noofplanet(i-1,j+2);goto label2;}
X}
Xlabel2:
Xif (orbitingok==OFF)
X {
X plot1(cp," Spock : Fascinating. I've never attempted to orbit ");
X plot2(cp," a non-existent planet. ");
X } else
X {
X if ((cp->cloakingdevice)||(cp->shields))
X {
X if (cp->shields)
X {
X plot1(cp," ");
X plot2(cp," Orbit while you have your shields are up? Youre kidding!");
X }
X else
X {
X plot1(cp," ");
X plot2(cp," Orbit while you are cloaked? You are optimistic! ");
X }
X } else
X {
X plot1(cp," Sulu : We are now in standard orbit Captain. ");
X plot2(cp,plan[cp->planetno].orbit);
X plotstatus(cp,8);
X }
X }
X}
X
Xunorbit(cp)
Xregister struct player *cp;
X{
Xif ((cp->stat==8) && (cp->xvel==0) && (cp->yvel==0))
X{
Xplot1(cp," Saavik : Aft impulse thrusters 1/2 impulse power ahead. ");
Xplot2(cp," Sulu : Orbit termination completed Captain. ");
Xplotstatus(cp,3);
X} else
X{
Xplot1(cp,"Chekov : We are not in orbit at the moment!Bones : I best");
Xplot2(cp," take you to sick bay and have your brains checked Jim. ");
X}
X}
X
Xnoland(cp)
Xregister struct player *cp;
X{
Xplot1(cp," A protective shield around this planet makes it ");
Xplot2(cp," impossible to beam down sir.This might change. ");
X}
X
Xbeamdown(cp)
Xregister struct player *cp;
X{
Xif (cp->planets[cp->planetno]>0)
X {
X plot1(cp," We have been to this planet already. You cannot ");
X plot2(cp," beam down twice. ");
X return(0);
X }
Xj=cp->planetno;
Xswitch (j)
X{
Xcase 2 : if (cp->planets[17]==0) {noland(cp); return(0); } else break;
Xcase 15 : if (cp->planets[14]==0) {noland(cp); return(0); } else break;
Xcase 19 : if (cp->planets[18]==0) {noland(cp); return(0); } else break;
Xcase 26 : if (cp->planets[25]==0) {noland(cp); return(0); } else break;
Xcase 27 : if (cp->planets[26]==0) {noland(cp); return(0); } else break;
Xcase 28 : if (cp->planets[27]==0) {noland(cp); return(0); } else break;
Xdefault :
X break;
X}
Xplot1(cp," Energizing....................................... ");
Xplot2(cp," ");
Xcp->oldstat=cp->stat;
Xplotstatus(cp,10);
Xcp->planets[j]=1;
Xfor (i=1;i<20;++i)
X {
X poscurs(cp,20,i);
X write(cp->fd,plan[j].land[i-1],57);
X }
X}
END_OF_FILE
if test 6788 -ne `wc -c <'orbit.c'`; then
echo shar: \"'orbit.c'\" unpacked with wrong size!
fi
# end of 'orbit.c'
fi
if test -f 'scan.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'scan.c'\"
else
echo shar: Extracting \"'scan.c'\" \(6206 characters\)
sed "s/^X//" >'scan.c' <<'END_OF_FILE'
X
X/*******************************************************************************
X********************************************************************************
X********************************************************************************
X
XPERMISSION TO COPY THIS SOFTWARE IS HEREBY GIVEN BY THE AUTHOR PROVIDED THAT
XTHIS LEADING MESSAGE IS INCLUDED IN ALL OF THE RELEVANT SOURCE FILES.
X
X P. SCHMITZ, UNIVERSITY OF KEELE, MAY 1988.
X
X
X********************************************************************************
X********************************************************************************
X*******************************************************************************/
X
X#include "ships.h"
X#include "header.h"
X
Xscan(cp,o)
Xregister struct player *cp,*o;
X{
Xchar string[37];
X
Xplot1(cp," Scanning Sir. ");
Xplot2(cp," ");
Xif (o->energy<200)
X{
Xplot1(o," Spock : Captain, we are being exposed to an energy beam ");
Xplot2(o," of unknown constituency. It seems we have been scanned. ");
X}
Xposcurs(cp,20,1);
Xwrite(cp->fd, " ",57);
Xposcurs(cp,20,2);
Xwrite(cp->fd, " ~~~~~~~~~~~~~~~~~~~~~~~~~ ",57);
Xposcurs(cp,20,3);
Xwrite(cp->fd, " Remote Subspace Ship Scan ",57);
Xposcurs(cp,20,4);
Xwrite(cp->fd, " ~~~~~~~~~~~~~~~~~~~~~~~~~ ",57);
Xposcurs(cp,20,5);
Xwrite(cp->fd, " ",57);
Xposcurs(cp,20,6);
Xwrite(cp->fd, " Name of Ship : ",20);
Xswitch (o->id)
X {
X case ROMID :
X write(cp->fd,"Names of Romulan vessels are secret. ",37);
X break;
X case KLINGID :
X write(cp->fd,"Names of Klingon vessels are secret. ",37);
X break;
X default: write(cp->fd,ship[o->shipno].name,37);
X break;
X }
Xposcurs(cp,20,7);
Xwrite(cp->fd, " Registration : ",20);
Xswitch (o->id)
X {
X case ROMID :
X write(cp->fd,"Registrations of Romulans are secret.",37);
X break;
X case KLINGID :
X write(cp->fd,"Registrations of Klingons are secret.",37);
X break;
X default:
X write(cp->fd,ship[o->shipno].registration,37);
X break;
X }
Xposcurs(cp,20,8);
Xwrite(cp->fd, " Class : ",20);
Xswitch (o->id)
X {
X case ROMID :
X write(cp->fd,"Heavy Romulan Battle Cruiser. ",37);
X break;
X case KLINGID :
X write(cp->fd,"Klingon Battle Destroyer Class A. ",37);
X break;
X default:
X write(cp->fd,ship[o->shipno].class,37);
X break;
X }
Xposcurs(cp,20,9);
Xwrite(cp->fd, " Origin : ",20);
Xswitch (o->id)
X {
X case ROMID :
X write(cp->fd,"Romulan Sector. ",37);
X break;
X case KLINGID :
X write(cp->fd,"Klingon empire, klingon sector. ",37);
X break;
X default:
X write(cp->fd,ship[o->shipno].flag,37);
X break;
X }
Xposcurs(cp,20,10);
Xwrite(cp->fd, " No. of crew : ",20);
Xswitch (o->id)
X {
X case ROMID :
X write(cp->fd,"unknown. ",37);
X break;
X case KLINGID :
X write(cp->fd,"unknown. ",37);
X break;
X default:
X write(cp->fd,ship[o->shipno].noofcrew,37);
X break;
X }
Xposcurs(cp,20,11);
Xwrite(cp->fd, " Prefix Code : ",20);
Xswitch (o->id)
X {
X case ROMID :
X write(cp->fd,"unknown. ",37);
X break;
X case KLINGID :
X write(cp->fd,"unknown. ",37);
X break;
X default:
X write(cp->fd,ship[o->shipno].prefixcode,37);
X break;
X }
Xposcurs(cp,20,12);
Xwrite(cp->fd, " Current Pos. : ",20);
Xsprintf(string,"%3d %3d ",o->xpos,o->ypos);
Xwrite(cp->fd,string,37);
Xposcurs(cp,20,13);
Xwrite(cp->fd, " Current Warp : ",20);
Xsprintf(string,"%3d %3d ",o->xvel,o->yvel);
Xwrite(cp->fd,string,37);
Xposcurs(cp,20,14);
Xwrite(cp->fd, " Energy : ",20);
Xswitch (o->id)
X {
X case ROMID :
X sprintf(string,"unknown. ");
X break;
X case KLINGID :
X sprintf(string,"unknown. ");
X break;
X default:
X sprintf(string," %4d ",o->energy);
X break;
X }
Xwrite(cp->fd,string,37);
Xposcurs(cp,20,15);
Xwrite(cp->fd, " Max. Energy : ",20);
Xswitch (o->id)
X {
X case ROMID :
X sprintf(string,"unknown. ");
X break;
X case KLINGID :
X sprintf(string,"unknown. ");
X break;
X default:
X sprintf(string," %4d ",o->maxenergy);
X break;
X }
Xwrite(cp->fd,string,37);
Xposcurs(cp,20,16);
Xwrite(cp->fd, " Phaser shots : ",20);
Xswitch (o->id)
X {
X case ROMID :
X sprintf(string,"unknown. ");
X break;
X case KLINGID :
X sprintf(string,"unknown. ");
X break;
X default:
X sprintf(string," %4d ",o->phaserbanks);
X break;
X }
Xwrite(cp->fd,string,37);
Xposcurs(cp,20,17);
Xwrite(cp->fd, " Phaser range : ",20);
Xswitch (o->id)
X {
X case ROMID :
X sprintf(string,"Far enough to get you!! ");
X break;
X case KLINGID :
X sprintf(string,"Far enough to get you!! ");
X break;
X default:
X sprintf(string," %4d ",o->phaserreach);
X break;
X }
Xwrite(cp->fd,string,37);
Xposcurs(cp,20,18);
Xwrite(cp->fd, " Photon shots : ",20);
Xswitch (o->id)
X {
X case ROMID :
X sprintf(string,"unknown. ");
X break;
X case KLINGID :
X sprintf(string,"unknown. ");
X break;
X default:
X sprintf(string," %4d ",o->photontorpedos);
X break;
X }
Xwrite(cp->fd,string,37);
Xposcurs(cp,20,19);
Xwrite(cp->fd, " Photon range : ",20);
Xswitch (o->id)
X {
X case ROMID :
X sprintf(string,"Too far for comfort. ");
X break;
X case KLINGID :
X sprintf(string,"Too far for comfort. ");
X break;
X default:
X sprintf(string," %4d ",o->photonreach);
X break;
X }
Xwrite(cp->fd,string,37);
X}
X
END_OF_FILE
if test 6206 -ne `wc -c <'scan.c'`; then
echo shar: \"'scan.c'\" unpacked with wrong size!
fi
# end of 'scan.c'
fi
if test -f 'ships.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'ships.c'\"
else
echo shar: Extracting \"'ships.c'\" \(10125 characters\)
sed "s/^X//" >'ships.c' <<'END_OF_FILE'
X
X/*******************************************************************************
X********************************************************************************
X********************************************************************************
X
XPERMISSION TO COPY THIS SOFTWARE IS HEREBY GIVEN BY THE AUTHOR PROVIDED THAT
XTHIS LEADING MESSAGE IS INCLUDED IN ALL OF THE RELEVANT SOURCE FILES.
X
X P. SCHMITZ, UNIVERSITY OF KEELE, MAY 1988.
X
X
X********************************************************************************
X********************************************************************************
X*******************************************************************************/
X
X#include "ships.h"
X
Xstruct ships ship[]=
X {
X "USS Enterprise ",
X "N.C.C. 1701 ",
X "Constellation Class Starship ",
X "United Federation of Planets ",
X "400 ",
X "16050 ",
X "September 8, 2264 ",
X
X "USS Yorktown ",
X "N.C.C. 1702 ",
X "Constellation Class Starship ",
X "United Federation of Planets ",
X "400 ",
X "17820 ",
X "September 9, 2265 ",
X
X "SS Sierkowsky ",
X "N.C.C. 2021 ",
X "Galactic Supernova Research vessel ",
X "United Federation of Planets ",
X "400 ",
X "16540 ",
X "September 9, 2265 ",
X
X "USS Reliant ",
X "N.C.C. 1864 ",
X "Intercept vessel ",
X "United Federation of Planets ",
X "200 ",
X "16039 ",
X "August 19, 2287 ",
X
X "USS Enterprise ",
X "N.C.C. 1701/A ",
X "Constellation Class Starship ",
X "United Federation of Planets ",
X "400 ",
X "09099 ",
X "May 20, 2288 ",
X
X "USS Enterprise ",
X "N.C.C. 1701/D ",
X "Galaxy Class Starship ",
X "United Federation of Planets ",
X "1012 Crew families of mixed races ",
X "17014 ",
X "Stardate 41025.5 ",
X
X "USS Grissom ",
X "N.C.C. 1603 ",
X "Intergalactic Research vessel ",
X "United Federation of Planets ",
X "200 ",
X "18899 ",
X "May 20, 2288 ",
X
X "USS Hood ",
X "N.C.C. 1801 ",
X "Scientific research vessel ",
X "United Federation of Planets ",
X "150 ",
X "08088 ",
X "June 1, 2088 ",
X
X "USS Excelsior ",
X "NX - 2000 ",
X "Experimental Transwarp drive Starship",
X "United Federation of Planets ",
X "600 ",
X "98989 ",
X "September 2088 ",
X
X "USS Kobayashi Maru ",
X "N.C.C. 1804 ",
X "Intergalactic Freighter ",
X "United Federation of Planets ",
X "400 ",
X "10112 ",
X "June 2088 ",
X
X "SS Columbia ",
X "N.C.C. 1699 ",
X "Constellation class ",
X "United Federation of Planets ",
X "400 ",
X "23221 ",
X "December 2218 ",
X
X "USS Valiant ",
X "N.C.C. 1103 ",
X "Galactic survey vessel ",
X "United Federation of Planets ",
X "200 ",
X "01210 ",
X "November 2220 ",
X
X "USS Antares ",
X "N.C.C. 900 ",
X "Cargo vessel ",
X "United Federation of Planets ",
X "50 ",
X "98787 ",
X "January 2198 ",
X
X "USS Archon ",
X "N.C.C. 588 ",
X "exploration vessel ",
X "United Federation of Planets ",
X "250 ",
X "12765 ",
X "january 2128 ",
X
X "USS Constellation ",
X "N.C.C. 1628 ",
X "Constellation Class ",
X "United Federation of Planets ",
X "400 ",
X "12655 ",
X "March 2267 ",
X
X "SS Beagle ",
X "N.C.C. 102 ",
X "exploration vessel ",
X "United Federation of Planets ",
X "12 ",
X "08776 ",
X "April 2133 ",
X
X "USS Farragut ",
X "N.C.C. 1677 ",
X "Constellation Class ",
X "United Federation of Planets ",
X "400 ",
X "52578 ",
X "Febuary 2228 ",
X
X "USS Intrepid ",
X "N.C.C. 1678 ",
X "Constellation Class ",
X "United Federation of Planets ",
X "400 ",
X "86254 ",
X "July 2228 ",
X
X "USS Horizon ",
X "N.C.C. 99 ",
X "experimental space exploration vessel",
X "United Federation of Planets ",
X "75 ",
X "56745 ",
X "August 2121 ",
X
X "USS Excalibur ",
X "N.C.C. 1634 ",
X "Constellation Class ",
X "United Federation of Planets ",
X "400 ",
X "67293 ",
X "December 2219 ",
X
X "USS Exceter ",
X "N.C.C. 1532 ",
X "Constellation Class ",
X "United Federation of Planets ",
X "400 ",
X "25142 ",
X "December 2209 ",
X
X "USS Defiant ",
X "N.C.C. 1592 ",
X "Constellation Class ",
X "United Federation of Planets ",
X "400 ",
X "51587 ",
X "June 2240 ",
X
X "USS Aurora ",
X "N.C.C. 1244 ",
X "Heavy Cruiser ",
X "United Federation of Planets ",
X "1200 ",
X "93923 ",
X "October 2200 ",
X
X "USS Ariel ",
X "N.C.C. 1709 ",
X "Science vessel ",
X "United Federation of Planets ",
X "245 ",
X "36217 ",
X "1st May 2289 ",
X
X "USS Galileo ",
X "N.C.C. 1701/7 ",
X "Suttlecraft of N.C.C. 1701 ",
X "United Federation of Planets ",
X "5 ",
X "Shuttles do not have prefix codes. ",
X "January 2228 ",
X
X "HMS Bounty ",
X "unknown ",
X "Klingon Battle Cruiser ",
X "Klingon Empire ",
X "10 ",
X "n/a ",
X "unknown ",
X
X "SS Botany Bay ",
X "n/a ",
X "human cargo vessel ",
X "Earth ",
X "15 ",
X "n/a ",
X "late 20th Century ",
X
X "Khar ",
X "unknown ",
X "Romulan Battle Cruiser ",
X "Romulan Empire ",
X "350 ",
X "n/a ",
X "unknown ",
X
X "Kor ",
X "unknown ",
X "Klingon Battle Cruiser ",
X "Klingon Empire ",
X "370 ",
X "n/a ",
X "unknown ",
X
X "Klothos ",
X "n/a ",
X "Klingon Battle Cruiser ",
X "Klingon Empire ",
X "approx. 800 ",
X "n/a ",
X "unknown ",
X
X "Bird of Prey ",
X "n/a ",
X "Klingon Battle Cruiser ",
X "Klingon Empire ",
X "450 ",
X "n/a ",
X "unknown "
X
X }; /*Phew!*/
X
END_OF_FILE
if test 10125 -ne `wc -c <'ships.c'`; then
echo shar: \"'ships.c'\" unpacked with wrong size!
fi
# end of 'ships.c'
fi
echo shar: End of archive 3 \(of 4\).
cp /dev/null ark3isdone
MISSING=""
for I in 1 2 3 4 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 4 archives.
rm -f ark[1-9]isdone
else
echo You still need to unpack the following archives:
echo " " ${MISSING}
fi
## End of shell archive.
exit 0