[comp.sources.games] v06i056: GB - Galactic Bloodshed, an empire-like war game, Part05/07

games@tekred.CNA.TEK.COM (04/27/89)

Submitted-by: Robert Chansky <smq@ssyx.ucsc.edu>
Posting-number: Volume 6, Issue 56
Archive-name: GB/Part05



#! /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 5 (of 7)."
# Contents:  Docs/autoreport.doc Docs/map.doc Makefile cs.c docommand.c
#   enrol.c exam.dat map.c name.c overview.nr ships.h shlmisc.c vars.h
# Wrapped by billr@saab on Wed Apr 26 14:41:36 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Docs/autoreport.doc' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Docs/autoreport.doc'\"
else
echo shar: Extracting \"'Docs/autoreport.doc'\" \(838 characters\)
sed "s/^X//" >'Docs/autoreport.doc' <<'END_OF_FILE'
XAUTOREPORT		Galactic Bloodshed		AUTOREPORT
X
X
XNAME
X  [0] autoreport -- designate a report to be sent each turn
X
XSYNOPSIS
X       autoreport [path]
X
XDESCRIPTION
X
X  ``Autoreport'', when used on a planet, will cause a report to be generated
Xeach turn concerning that planet: what resources were used, what had been
Xconstructed, the increase (or decrease) in population, how many sectors had
Xbeen conquered, etc.  If ``path'' is not specified, autoreport will apply
Xitself to the current scope.
X
X  The report generated is sent to the user's telegram file.
X
X  Autoreport is disabled after 7 turns, at which point it must be renewed.
XThis feature is to prevent telegrams from accumulating in the files of players
Xwho never seem to read them.
X
X  If automatic reporting is already designated for that planet, it will be
Xdeactivated from then on.
X
X
END_OF_FILE
if test 838 -ne `wc -c <'Docs/autoreport.doc'`; then
    echo shar: \"'Docs/autoreport.doc'\" unpacked with wrong size!
fi
# end of 'Docs/autoreport.doc'
fi
if test -f 'Docs/map.doc' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Docs/map.doc'\"
else
echo shar: Extracting \"'Docs/map.doc'\" \(4081 characters\)
sed "s/^X//" >'Docs/map.doc' <<'END_OF_FILE'
X
XMAP			Galactic Bloodshed			MAP
X
X
XNAME
X  [0] map -- Cartesian coordinate map of planet's surface
X
XSYNOPSIS
X  map [path]
X
XDESCRIPTION
X  The map command gives a sector map of the planet in [path].  If [path]
Xis not a planet, map will instead use orbit (see orbit).  You cannot map
Xa planet that has not been explored by you.
X
X
X  These are the different types of terrain:
X
X   '-' -- Unexplored wilderness or undeveloped land
X   '^' -- Mountainous area (more resources, less fertility)
X   '.' -- Area containing water
X   '~' -- Gas (such as might be on a gas giant planet)
X   '%' -- Wasteland (uninhabitable)
X   ' ' -- (Under certain circumstances the sector may be blank)
X
X
X  In addition are the designations that map gives the player:
X
X   'x' -- Area owned by the player
X   '?' -- Area owned by another player
X   'sbdfgetz' -- a ship of that type is landed on the sector
X   '|' -- Area that has been developed to 100% efficiency (steel plated)
X
X
X--------------- THE PLANETS -----------------
X
X  There are four basic types of planets.
X
XEarth-type
X
X   00000000001111111111222222222233333333
X   01234567890123456789012345678901234567
X 1 %%%%.%%%%.%%%.%%%%%%.%%%%%.%%%%%..%%%%
X 2 .%-..%.--.%%..-...%----%.....%-%--%.%.
X 3 ..--^---.....-.-^^^---------------.-..
X 4 ..-^--.-.......-----.-------------.-..
X 5 ..-..-.......--....-..--^^^^------.-..
X 6 ......--......---------..---.---^--.-.
X 7 .....^---.....------^--...-....--^^...
X 8 .....^--........---^-........-...-..-.
X 9 ......^-.........--^-..........--^-...
X10 %...%%%-....%....%.-..%..%%%...%-.-%%.
X11 %.%%%%%%.%%%%%%%.%%%%.%%%%%%%%.%%%%%%%
X        Sample Earth- type planet
X
X  Continents are generated randomly by the game, and approximate real growth
Xof islands by geologic processes.  On the average, sectors closer to water
Xhave greater fertility than sectors farther away, which have greater
Xresource deposits.
X
X
XGas Giant Type
X
X  This type of planet is mostly a large ball of uninhabitable gas.
XThey do not have many resources but they are useful; for instance any ship
Xorbiting a gas giant can gain fuel by 'skimming' it's surface of hydrogen
X(provided its race has developed hydrogen fusion for fuel.)  
X
X   000000000011111111112222222222333333333344444444444
X   012345678901234567890123456789012345678901234567890
X 1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.~~~~~
X 2 ~~~~~~~~~~.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~........~~~~~~~~~~~~
X 4 ...................................................
X 5 ~~~~~~~~~~~~~~~~~~~~~~~~~.................~~~~~~~~~
X 6 ~~~~~~.~~~~~~~~~~.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X 7 ~~~~~~~~~~.~~~~~~~~~~~~~~~~~~~.~~~~~~~~~~~.~~~~~~~~
X 8 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X 9 ~~~~~~~~~~~~~~~~~~...............~~~~~~~~~~~~~~~~~~
X10 ...................................................
X11 ~~~~~~~~~~~~~~~~~~~~~~~~~~...............~~~~~~~~~~
X12 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.~~~~~~~~~~~~~~.~~~~~
X               Sample gasgiant planet
X
X  Notice the narrow bands streaked across the surface; this represents
Xbands of weather across the face of an actual gas giant planet.
X
X
XAirless or Asteroidal Type
X
X  These are planets too small to hold an atmosphere, or have had it
Xstripped off by natural or artificial disaster.  They consist of land
Xand/or mountainous sectors, with high resource deposits and comparatively
Xlow fertility.  Both types contain large craters in them from
Xmeteorite impacts, while asteroidal bodies often appear in unusual shapes
X(i.e. not exactly square).
X
X   00000000001111111111222                       000000
X   01234567890123456789012                       012345
X 1 ^^^^^-^^^^^^^-^^^^^^^^^                     1 -^^^-^
X 2 ^^^-^^^^^^^^---^^-^^^^^                     2 ^^^-^^
X 3 -^^^^-----^^^-^^^^^^^--                     3 ^^^^-^
X 4 --^^---^---^^^-^^^-^--^                     4 -^^-^^
X 5 -^^-^------^^^^^^^^^^--                     5 -^^^^^
X 6 -^^^^^----^^-^^^^^-^^^-                     6 ^-^-^-
X 7 ^^-^^^^^^^^^^^^^^^^^^^^
X    Sample Airless type                  Sample Asteroid type
X
X
XSEE ALSO
X  orbit, cs, scope
X
END_OF_FILE
if test 4081 -ne `wc -c <'Docs/map.doc'`; then
    echo shar: \"'Docs/map.doc'\" unpacked with wrong size!
fi
# end of 'Docs/map.doc'
fi
if test -f 'Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(3491 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X# Galactic Bloodshed (Robert Chansky, smq@b)
X# Makefile		(modified by billr@saab.cna.tek.com, 4/26/89)
X
XUV = VER_4.3
X#UV = VER_4.2
XCFLAGS = -D$(UV) -pipe -g
X#-D$(UV) -O
X
X# destination directories
X# GLIB should match the directory in the PATH macro of files.h
XGBIN = /usr/games
XGLIB = /usr/games/lib/GB
X
X# objects for shell
XSHOBJS =  getplace.o	\
X	read_teleg.o	\
X	autoreport.o	\
X	shootblast.o	\
X	docommand.o	\
X	telegram.o	\
X	mobiliz.o	\
X	shlmisc.o	\
X	moveship.o	\
X	doplanet.o	\
X	autoshoot.o	\
X	dosector.o	\
X	doturn.o	\
X	doship.o	\
X	zoom.o		\
X	perm.o		\
X	survey.o	\
X	enrol.o		\
X	prof.o		\
X	GB.o		\
X	name.o		\
X	fire.o		\
X	land.o		\
X	map.o		\
X	max.o		\
X	cs.o		\
X	fix.o		\
X	rst.o		\
X	misc.o		\
X	help.o		\
X	rand.o		\
X	load.o		\
X	scrap.o		\
X	build.o		\
X	order.o		\
X	orbit.o		\
X	power.o		\
X	launch.o	\
X	declare.o	\
X	examine.o	\
X	get4args.o	\
X	teleg_send.o	\
X	files_rw.o	\
X	files_shl.o
X
X
X# depend on vars.h only
XVOBJS =  getplace.o	\
X	mobiliz.o	\
X	shlmisc.o	\
X	survey.o	\
X	enrol.o		\
X	prof.o		\
X	zoom.o		\
X	max.o		\
X	GB.o		\
X	perm.o		\
X	telegram.o	\
X	docommand.o	\
X	read_teleg.o
X
X#depend on races.h and vars.h
XROBJS = doplanet.o	\
X	makeplanet.o	\
X	autoshoot.o	\
X	dosector.o	\
X	declare.o	\
X	survey.o	\
X	enrol.o		\
X	prof.o		\
X	GB.o		\
X	cs.o		\
X	fix.o		\
X	max.o		\
X	map.o		\
X	name.o		\
X	fire.o		\
X	power.o		\
X	doturn.o	\
X	doship.o	\
X	telegram.o	\
X	makeuniv.o	\
X	read_teleg.o
X
X# depend on ships.h
XSHIPOBJS = autoreport.o	\
X	shootblast.o	\
X	makeplanet.o	\
X	examine.o	\
X	launch.o	\
X	build.o		\
X	order.o		\
X	fire.o		\
X	land.o		\
X	map.o		\
X	max.o		\
X	cs.o		\
X	fix.o		\
X	rst.o		\
X	load.o		\
X	name.o		\
X	scrap.o		\
X	orbit.o		\
X	doturn.o	\
X	doship.o	\
X	doplanet.o	\
X	moveship.o	\
X	autoshoot.o	\
X	files_shl.o
X
X# depend on files.h
XFOBJS =	files_shl.o 	\
X	teleg_send.o 	\
X	makeuniv.o	\
X	shlmisc.o 	\
X	doturn.o 	\
X	enrol.o 	\
X	help.o 		\
X	GB.o 		\
X	power.o 	\
X	examine.o
X
X
X# dont depend on anything
XNOOBJS = get4args.o	\
X	misc.o		\
X	help.o		\
X	rand.o		\
X	daemon.o	\
X	teleg_send.o	\
X	files_rw.o
X
X
X# objects for daemon
XDOBJS = shootblast.o	\
X	autoshoot.o	\
X	doplanet.o	\
X	doturn.o	\
X	daemon.o	\
X	rand.o		\
X	max.o		\
X	perm.o		\
X	misc.o		\
X	doship.o	\
X	dosector.o	\
X	moveship.o	\
X	teleg_send.o	\
X	files_rw.o	\
X	files_shl.o
X
X
Xall: GB makeuniv 
X#GB_daemon 
X#mor
X
X# the shell 
XGB : ${SHOBJS}
X	cc -o GB ${SHOBJS} -lcurses -ltermcap -lm
X${ROBJS}: races.h
X${VOBJS}: vars.h
X${SHIPOBJS}: vars.h ships.h
X${FOBJS}: files.h
Xmoveship.o : vars.h ships.h shipdata.h
Xdoturn.o doplanet.o power.o doship.o files_shl.o makeuniv.o : power.h
X#sizes : vars.h ships.h races.h
X#	cc sizes.c
X
X
X# make data files program
Xmakeuniv : makeuniv.o makeplanet.o rand.o perm.o
X	cc -o makeuniv makeuniv.o makeplanet.o rand.o perm.o -lm
X
X
X# the daemon
XGB_daemon : ${DOBJS}
X	cc -o GB_daemon ${DOBJS}  -lm
Xdoturn.o doship.o doplanet.o : doturn.h
X
X# more clone
Xmor : more.c
X	cc -o mor more.c -lcurses -ltermcap
X
Xchmod:
X	cd $(GLIB)
X	chmod ag+xs GB
X	chmod g+rwx Docs Docs/* Data Data/* Data/Tele/*
X	chmod g+r exam.dat
X#	chmod ga+rwx Data Data/* Data/Tele/*
X
Xstart:
X	cd $(GLIB)
X	/bin/rm -f Data/spitup
X	GB_daemon \>\& Data/spitup
X
Xclean:
X	/bin/rm -rf GB makeuniv GB_daemon *.o Data core a.out
X
Xclear:
X	/bin/rm -rf *.o core a.out Data
X
Xshar:
X	uncompress Docs/*
X	/bin/mv -f Docs/* .
X	shar -c README Makefile *.doc *.h *.c planet.list exam.dat > GB.shar
X
X# install the game
X
Xinstall:
X	make
X	cp GB $(GBIN)
X	-mkdir $(GLIB)
X	cp exam.dat $(GLIB)
X	-mkdir $(GLIB)/Docs
X	-cp Docs/* $(GLIB)/Docs
X	-compress $(GLIB)/Docs/*
X	make clear
X	makeuniv < planet.list
X	make chmod
X
END_OF_FILE
if test 3491 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'cs.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'cs.c'\"
else
echo shar: Extracting \"'cs.c'\" \(4317 characters\)
sed "s/^X//" >'cs.c' <<'END_OF_FILE'
X/*
X * Galactic Bloodshed (Robert Chansky, smq@b)
X *  cs.c -- change scope operand (directory)
X */
X
X#include "vars.h"
X#include "ships.h"
X#include "races.h"
X
Xcs(APcount, argn,args)
Xint APcount;
Xint argn;
Xchar args[MAXARGS][COMMANDSIZE];
X{
X placetype where;
X planettype *planet;
X shiptype *s;
X int cs_shdata,cs_pdata;
X
X if (argn==1) {
X	/* chdir to def scope */
X  Dir.level = Race->deflevel;
X  Dir.snum = Race->defsystem;
X  Dir.pnum = Race->defplanetnum;
X  Dir.shipno = 0;
X  Dir.lastx = Dir.lasty = 0.0;
X  docommand("cs :");	/* trick -- adjust prompt */
X  return;
X } else if (argn==2) {
X	/* chdir to specified scope */
X
X  where = Getplace(args[1],0);	/* do not ignore the fact that you've not
X					explored the place */
X  if (where.err) {
X	printf("cs: bad scope.\n");
X	Dir.lastx = Dir.lasty = 0.0;
X	return;
X  }
X
X	/* fix lastx, lasty coordinates */
X
X  switch (Dir.level) {
X	case LEVEL_UNIV:
X		Dir.lastx = Dir.lasty = 0.0;
X		break;
X	case LEVEL_STAR:
X		if (where.level==LEVEL_UNIV) {
X			Dir.lastx = Stars[Dir.snum]->xpos;
X			Dir.lasty = Stars[Dir.snum]->ypos;
X		} else
X			Dir.lastx = Dir.lasty = 0.0;
X		break;
X	case LEVEL_PLAN:
X		openpdata(&cs_pdata);
X		getplanet(cs_pdata,&planet,Stars[Dir.snum]->planetpos[Dir.pnum]);
X		close(cs_pdata);
X		if (where.level==LEVEL_STAR && where.snum==Dir.snum) {
X			Dir.lastx = planet->xpos;
X			Dir.lasty = planet->ypos;
X		} else if (where.level==LEVEL_UNIV) {
X			Dir.lastx = Stars[Dir.snum]->xpos + planet->xpos;
X			Dir.lasty = Stars[Dir.snum]->ypos + planet->ypos;
X		} else
X			Dir.lastx = Dir.lasty = 0.0;
X		free(planet);
X		break;
X	case LEVEL_SHIP:
X		openshdata(&cs_shdata);
X		getship(cs_shdata, &s, Dir.shipno);
X		close(cs_shdata);
X		if (!s->is_docked) {
X		 switch (where.level) {
X		   case LEVEL_UNIV:
X			Dir.lastx = s->xpos;
X			Dir.lasty = s->ypos;
X			break;
X		   case LEVEL_STAR:
X			if (s->whatorbits>=LEVEL_STAR && s->storbits==where.snum) {
X				/* we are going UP from the ship.. change last*/
X				Dir.lastx = s->xpos - Stars[s->storbits]->xpos;
X				Dir.lasty = s->ypos - Stars[s->storbits]->ypos;
X			} else
X				Dir.lastx = Dir.lasty = 0.0;
X			break;
X		   case LEVEL_PLAN:
X			if (s->whatorbits==LEVEL_PLAN && s->storbits==where.snum
X				   && s->pnumorbits==where.pnum) {
X				/* same */
X				openpdata(&cs_pdata);
X				getplanet(cs_pdata,&planet,Stars[s->storbits]->planetpos[s->pnumorbits]);
X				close(cs_pdata);
X				Dir.lastx = s->xpos - Stars[s->storbits]->xpos - planet->xpos;
X				Dir.lasty = s->ypos - Stars[s->storbits]->ypos - planet->ypos;
X				free(planet);
X			} else
X				Dir.lastx = Dir.lasty = 0.0;
X			break;
X		   case LEVEL_SHIP:
X			Dir.lastx = Dir.lasty = 0.0;
X			break;
X		   default:
X			break;
X		 }
X		} else
X			Dir.lastx = Dir.lasty = 0.0;
X		free(s);
X		break;
X	default:
X		break;
X  }
X
X  Dir.level = where.level;
X  Dir.snum = where.snum;
X  Dir.pnum = where.pnum;
X  Dir.shipno = where.shipno;
X
X   /* fix prompt */
X      switch (Dir.level) {
X    	case LEVEL_UNIV:
X		sprintf(Dir.prompt," [%02d] / >",Sdata.AP[Playernum]);
X		break;
X    	case LEVEL_STAR:
X  		sprintf(Dir.prompt," / [%02d] %s >",
X			Stars[Dir.snum]->AP[Playernum],
X			Stars[Dir.snum]->name);
X		break;
X	case LEVEL_SHIP:
X		switch (where.shipptr->whatorbits) { 	/* what orbits around */
X		    case LEVEL_UNIV:
X			sprintf(Dir.prompt," [%02d] / #%d >",
X				Stars[Dir.snum]->AP[Playernum],
X				where.shipno);
X			break;
X    		    case LEVEL_STAR:
X  			sprintf(Dir.prompt," / [%02d] %s / #%d >",
X				Stars[Dir.snum]->AP[Playernum],
X				Stars[Dir.snum]->name,
X				where.shipno);
X			break;
X		    case LEVEL_PLAN:
X			sprintf(Dir.prompt," / [%02d] %s / %s / #%d >",
X				Stars[Dir.snum]->AP[Playernum],
X				Stars[Dir.snum]->name,
X				Stars[Dir.snum]->pnames[Dir.pnum],
X				where.shipno);
X			break;
X		}
X		free(where.shipptr);
X		break;
X	case LEVEL_PLAN:
X		sprintf(Dir.prompt," / [%02d] %s / %s >",
X			Stars[Dir.snum]->AP[Playernum],
X			Stars[Dir.snum]->name,
X			Stars[Dir.snum]->pnames[Dir.pnum]);
X		break;
X	default: break;
X      }
X } else if (argn==3 && args[1][1]=='d') {
X	/* make new def scope */
X  where = Getplace(args[2],0);
X  if (!where.err) {
X	Race->homelevel = where.level;
X	Race->homesystem = where.snum;
X	Race->homeplanetnum = where.pnum;
X	putrace(Race);
X	docommand("cs");	/* chdir to home scope */
X	printf("New home system is %s\n",Dispplace(&where));
X  } else {
X	printf("cs: bad home system.\n");
X	return;
X  }
X }
X}
END_OF_FILE
if test 4317 -ne `wc -c <'cs.c'`; then
    echo shar: \"'cs.c'\" unpacked with wrong size!
fi
# end of 'cs.c'
fi
if test -f 'docommand.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'docommand.c'\"
else
echo shar: Extracting \"'docommand.c'\" \(3492 characters\)
sed "s/^X//" >'docommand.c' <<'END_OF_FILE'
X/*
X * Galactic Bloodshed (Robert Chansky, smq@b)
X * docommand.c  --  figures out what command it is and the arguments, 
X * executes the command via the proper subroutine
X */
X
X#include "vars.h"
X#include <strings.h>
X#include <ctype.h>
Xextern int God;
X
Xint docommand(commstring)
Xchar commstring[];
X{
Xint i,argn=0;
Xbool parse_exit=0;
Xchar args[MAXARGS][COMMANDSIZE];
Xchar *string;
X
X	string=commstring;	/* make pointers the same */
X	while (!parse_exit) {
X	    i=0;
X	    while ( !isspace(*string) && (*string!='\0') && (i<COMMANDSIZE) )
X		args[argn][i++]=(*string++);
X	    args[argn][i]='\0';
X	    /*printf("arg %d |%s|\n",argn,args[argn]);*/
X	    while ((*string)==' ') string++;
X	    if ( (*string=='\0') || (argn>=MAXARGS)) parse_exit=1;
X	    argn++;
X	}
X	for (i=argn; i<MAXARGS; i++)
X		args[i][0]='\0';
X
X	if (args[0][0]=='\0')   /* just pressed return */
X		return(1);	/* go back and wait again */
X	i=strlen(args[0]);
X	if (!strncmp(args[0],"quit",i)) return(0);  /* quit game */
X				/* return quit status */
X	else if (!strncmp(args[0],"autoreport",i)) autoreport(0,argn,args);
X	else if (!strncmp(args[0],"build",i)) build(2,argn,args);
X	else if (!strncmp(args[0],"survey",i)) survey(0,argn,args);
X	else if (!strncmp(args[0],"cs",i)) cs(0,argn,args);
X	else if (!strncmp(args[0],"assault",i)) land(2,argn,args,1);
X	else if (!strncmp(args[0],"dock",i)) land(1,argn,args,0);
X	else if (!strncmp(args[0],"fire",i)) fire(2,argn,args);
X	else if (!strncmp(args[0],"help",i)) help(0,argn,args);
X	else if (!strncmp(args[0],"land",i)) land(1,argn,args,0);
X	else if (!strncmp(args[0],"launch",i)) launch(1,argn,args);
X	else if (!strncmp(args[0],"load",i)) load(1,argn,args);
X	else if (!strncmp(args[0],"map",i)) map(0,argn,args);
X	else if (!strncmp(args[0],"mobilize",i)) mobilize(2,argn,args);
X	else if (!strncmp(args[0],"name",i)) name(2,argn,args);
X	else if (!strncmp(args[0],"orbit",i)) orbit(0,argn,args);
X	else if (!strncmp(args[0],"order",i)) order(1,argn,args);
X	else if (!strncmp(args[0],"profile",i)) profile(0,argn,args);
X	else if (!strncmp(args[0],"read",i)) teleg_read(0,argn,args);
X	else if (!strncmp(args[0],"report",i)) rst(0,argn,args,0);
X	else if (!strncmp(args[0],"stock",i)) rst(0,argn,args,1);
X	else if (!strncmp(args[0],"tactical",i)) rst(0,argn,args,2);
X	else if (!strncmp(args[0],"ship",i)) rst(0,argn,args,3);
X	else if (!strncmp(args[0],"object",i)) rst(0,argn,args,4);
X	else if (!strncmp(args[0],"power",i)) power(0,argn,args);
X	else if (!strncmp(args[0],"telegram",i)) telegram(2,argn,args);
X	else if (!strncmp(args[0],"undock",i)) launch(1,argn,args);
X	else if (!strncmp(args[0],"declare",i)) declare(1,argn,args);
X	else if (!strncmp(args[0],"scrap",i)) scrap(1,argn,args);
X	else if (!strncmp(args[0],"examine",i)) examine(1,argn,args);
X	else if (!strncmp(args[0],"zoom",i)) zoom(0,argn,args);
X#if SHELL_DOTURN
X		/* only do this if compiler option to save disk space.. */
X			/* only owning player can do turns */
X	else if (!strncmp(args[0],"doturn",i)) {
X			if (God) {
X				doturn(1);	/* from shell */
X				docommand("cs :");
X			}
X			else printf("You are not empowered to do that.\n");
X	}
X#endif
X			/* only owning player can use fix */
X	else if (!strncmp(args[0],"fix",i)) {
X			if (God) {
X				fix(argn,args);
X				docommand("cs :");
X			}
X			else printf("You are not empowered to do that.\n");
X	} else 
X	       printf("'%s':illegal command error(%d).\n",args[0],*args[0]);
X		/* grab extraneous return chars if there are any */
X
X	return(1);  /*  main() knows user is not quitting  */
X}
END_OF_FILE
if test 3492 -ne `wc -c <'docommand.c'`; then
    echo shar: \"'docommand.c'\" unpacked with wrong size!
fi
# end of 'docommand.c'
fi
if test -f 'enrol.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'enrol.c'\"
else
echo shar: Extracting \"'enrol.c'\" \(4360 characters\)
sed "s/^X//" >'enrol.c' <<'END_OF_FILE'
X/*
X * Galactic Bloodshed (Robert Chansky, smq@b)
X * enrol.c -- initializes to owner one sector and planet. 
X */
X
X#include "vars.h"
X#include "races.h"
X#include <strings.h>
X#include <errno.h>
Xextern int errno;
X
X
Xenroll(loginname)
Xchar *loginname;
X{
Xregister int x,y;
Xint plnum,star=0,found=0,i,j,enroll_pdata,enroll_sectdata,enroll_stardata;
Xchar str[COMMANDSIZE], c;
Xbool or;
Xplanettype *planet;
Xsectortype *s;
XFILE *fd, *teledata;
X
X
Xif ( (plnum = Numraces()) >= MAXPLAYERS) {
X	printf("there are already %d players. No more allowed.\n",plnum);
X	exit(-1);
X}
X	/* find first earthtype planet */
Xfor (star=0; !found && star<Sdata.numstars; star++ ) {
X or = 0;
X for (j = 0; j < howmanybytes(MAXPLAYERS); j++ )
X	or |= Stars[star]->explored[j];
X	  /* make sure no one has explored the star */
X if (!or) {
X 	openpdata(&enroll_pdata);
X 	for (i=0; !found && i<Stars[star]->numplanets; i++ ) {
X   		getplanet(enroll_pdata,&planet,Stars[star]->planetpos[i]);
X   		if ( !(found = (planet->type==TYPE_EARTH)) ) free(planet);
X 	}
X 	close(enroll_pdata);
X }
X}
X
Xif (found) {
X found=0;
X
X printf("There is still space for player %d.",++plnum );
X printf("\n\tenroll(y/n)\?");
X
X c = getchr(); 
X if (c!='y') {
X	printf("why did you come here, then?\n");
X	exit(0);
X }
X getchr();
X
X Race = Malloc(racetype);
X Bzero(*Race);
X
X printf("Enter a name for your race:");
X dots(RNAMESIZE);
X scanf("%[^\n]",str); 
X getchr();
X strncpy(Race->name, str, RNAMESIZE);
X
X fd = fopen(PLAYERDATAFL,"a");
X fprintf(fd,"%s\n",loginname );
X fclose(fd);
X
X Playernum = Race->Playernum = plnum;
X printf("You are player %d.\n",Race->Playernum);
X Race->homelevel = Race->deflevel = LEVEL_PLAN;
X Race->homesystem = Race->defsystem = star-1;
X Race->homeplanetnum = Race->defplanetnum = i-1;
X
X	/* make conditions preferred by your people set to (more or less) 
X	   those of the planet : higher the concentration of gas, the higher
X	   percentage difference between planet and race */
X for (j=0; j<=OTHER; j++)
X	Race->conditions[j] = planet->conditions[j]; /*+ int_rand( round_rand(-planet->conditions[j]*2.0), round_rand(planet->conditions[j]*2.0) )*/
X
X
X for (j=0; j<MAXPLAYERS; j++)
X   /* messages from autoreport, berserkers are decodable */
X	if (j==Playernum || j==1)
X		Race->translate[j] = 100;	/* you can talk to own race */
X	else
X		Race->translate[j] = 1;
X
X opensectdata(&enroll_sectdata);
X getsmap(enroll_sectdata,Smap,planet->sectormappos,planet->Maxx*planet->Maxy);
X while (!found) {
X   x=int_rand(1,planet->Maxx-1);
X   y=int_rand(1,planet->Maxy-1);
X   s = &Smap[y*planet->Maxx+x];
X   if (s->des==DES_LAND || s->des==DES_MOUNT && !s->is_wasted) {
X
X	printf("Your race has been created on sector %d,%d on\n",x,y);
X	printf("Planet %d of star %s.\n",i+1,Stars[star-1]->name);
X
X	planet->info[Playernum-1].numsectsowned = 1;
X	planet->is_explored = 0;
X	planet->info[Playernum-1].explored = 1;
X	/*planet->info[Playernum-1].autorep = 1;*/
X
X
X	openstardata(&enroll_stardata);
X	getstar(enroll_stardata,&Stars[star-1],star-1);
X	setbit(Stars[star-1]->explored,Playernum);
X	setbit(Stars[star-1]->inhabited,Playernum);
X	Stars[star-1]->AP[Playernum] = 5;
X	putstar(enroll_stardata,Stars[star-1],star-1);
X	close(enroll_stardata);
X
X	Race->tech = 0;
X	Race->overbirthrate = float_rand() * 0.01;
X		/* your race is like "the Thing" */
X	if (Race->Thing = !int_rand(0,10) ) {
X		Race->mass = 1.0;
X		Race->birthrate = float_rand()*0.25 + 0.55;
X		Race->fighters = int_rand(7,9);
X		Race->IQ = int_rand(30,60);
X		Race->nonhomebodies = 0.99;
X		Race->number_sexes = 1;
X		Race->metabolism = float_rand() * 0.25 + 0.52;
X	} else {
X		Race->birthrate = float_rand()*0.25 + 0.25;
X		Race->mass = 0.5 + 1.5 * float_rand();
X		Race->fighters = int_rand(1,3)+int_rand(1,3);
X		Race->IQ = int_rand(103,220);
X		Race->nonhomebodies = 0.70 + float_rand()*0.20;
X		Race->metabolism = float_rand() * 0.25 + 0.875;
X		Race->number_sexes = int_rand(1,int_rand(2,int_rand(3,9)));
X	}
X	s->owner=Playernum;
X	s->popn = planet->popn = STARTINGPOPN;
X	s->fert=100;
X	s->eff=10;
X
X	putsector(enroll_sectdata,s,planet->sectormappos+(y*planet->Maxx+x)*sizeof(sectortype));
X	close(enroll_sectdata);
X	openpdata(&enroll_pdata);
X	putplanet(enroll_pdata,planet,Stars[star-1]->planetpos[i-1]);
X	close(enroll_pdata);
X	putrace(Race);
X
X
X	/* chdir to your new home planet */
X	docommand("cs");
X
X	found=1;
X   }
X }
X} else {
X  printf("no more room!  You may not enroll.\n");
X  exit(-1);
X}
X}
END_OF_FILE
if test 4360 -ne `wc -c <'enrol.c'`; then
    echo shar: \"'enrol.c'\" unpacked with wrong size!
fi
# end of 'enrol.c'
fi
if test -f 'exam.dat' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'exam.dat'\"
else
echo shar: Extracting \"'exam.dat'\" \(4376 characters\)
sed "s/^X//" >'exam.dat' <<'END_OF_FILE'
X~
XSpore pod
X	This is a small seed pod grown by a mesomorphic race.  On reaching its
Xdestination, solar warming will cause it to explode, showering spores across 
Xthe system which have a chance of reaching some of the planets in that system.
X~
XShuttle
X	This is a small, short-range spacecraft, intended for interplanetary
Xexploration and for shuttling things between ground and orbit.
X~
XComsat
X	This is a useless hunk of orbiting metal.
X~
XBattleship
X	With its high armor class, this ship works well for general-purpose 
Xassaults.
X~
XDestroyer
X	This is a well-protected and fast light cruiser, suitable for
Xescort.
X~
XFighter
X	A small fuel capacity and high armor class makes this ship ideal
Xfor in-system combat.
X~
XCargo ship
X	This is a long-range interstellar transport craft, with little
Xweapons or armor.
X~
XExplorer
X	This is a small and fast long-range exploration craft with almost no
Xweapons capacity but some armor.
X~
XTanker
X	This ship can carry large amounts of fuel; it can also receive more
Xfuel by orbiting a gas giant.
X~
XStation
X	This is a platform on which can be built other ships. (not yet,
Xthough)
X~
XDreadnaught
X	This is a well-armored but large (and slow) interstellar warship.
X~
XMithril Ship
X	A mysterious elven cloak surrounds this ship.
X~
XCrystal Ship
X	This is a beautiful lattice structure, constantly shifting.  It is
Xalso quite tough.
X~
XGODSHIP
X	This entity pulsates, throbs with power.  Don't mess with it.
X~
XSpace mirror
X	This is a large plane of reflecting material, suitable for altering 
Xthe ambient temperature of a planet if aimed at one.  Intensity can also
Xbe modified.  The mirror also has attitude jets for maneuvering.  
X~
XAtmosphere processor
X	This is a large machine (of the type in _Aliens_) that sucks in
Xthe atmosphere of a planet, converting it to the type of air preferred by its
Xowner.  This process has a cost of 4 fuel units per turn.
X~
XCanister of dust
X	This is a small canister of light-absorbing dust.  When launched it
Xwill spread into the atmosphere of the planet, lowering its ambient
Xtemperature.  This can be used to terraforming purposes, when the temperature
Xis too high for comfort.
X~
XV.Neumann machine
X	This machine exists to construct copies of itself.  This it will do,
Xresources permitting.  It seems capable of stealing resources from other 
Xplayers in the game, as well as manufacturing its own.  Von Neumann machines 
Xprefer to travel in wolfpacks of 30-50, and, unlike other ships, are capable
Xof making their own decisions.  First-generation Von Neumann machines can
Xbe ordered by the building player, but second-generation machines (built by 
Xother VN's) cannot be.
X~
XPlanet bomb
X	This device, when detomated, can destroy a planet.
X	This is a non-functional device.
X~
XSpace mine
X	This device is a proximity mine, exploding on contact with enemy
Xships and showering them with deadly radiation.  It gives damage appropriate
Xto the amount of destructive capacity it is carrying.  Affected ships, when
Xirradiated, become immobile for a certain amount of time; each turn, an 
Xaffected ship's crew is reduced by 20%.
X	The mine can be armed/disarmed with order, and its trigger radius 
X(0 <= trigger radius <= 200) also altered with the order command.  
X~
Xcloaking device
X	This device uses an amount of fuel every turn to render whatever
Xcarries it invisible.  The higher the tech of the owning player, the greater
Xcloak radius, until whole systems can be cloaked.
X	This is a non-functional device.
X~
Xemotion suppressor
X	This device, when activated, suppresses rebellion and dissent among
Xthe affected population, whether ship or planet.  When activated on a planet,
Xall fighting will stop.
X	This is a non-functional device.
X~
XAmulet of Yendor
X	This is a brilliant necklace of obvious power.
X	This is a non-functional device.
X~
Xbiological weapon
X	When detonated, this device triggers a virus that proceeds to wipe
Xout the population of a planet, provided the population is of the target race it
Xis set to infect.
X	This is a non-functional device.
X~
Xgamma ray laser
X	This is a non-functional device.
X~
Xaudio-vibatory-physio-molecular transport device
X	This device has a hopper for the loading of material.  When it detects
Xthe presence of something in the hopper, it will transport this material into
Xthe hopper of its target device.  This process takes fuel.  The target device
Xcan be specified with the order command.
X~
END_OF_FILE
if test 4376 -ne `wc -c <'exam.dat'`; then
    echo shar: \"'exam.dat'\" unpacked with wrong size!
fi
# end of 'exam.dat'
fi
if test -f 'map.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'map.c'\"
else
echo shar: Extracting \"'map.c'\" \(4455 characters\)
sed "s/^X//" >'map.c' <<'END_OF_FILE'
X/*
X * Galactic Bloodshed (Robert Chansky, smq@b)
X *  map.c -- display sector map of current planet
X */
X
X#include "vars.h"
X#include "ships.h"
X#include "races.h"
Xextern float compatibility();
Xextern int Ignore_filelocks;
Xchar desshow();
X
Xmap(APcount, argn,args)
Xint APcount;
Xint argn;
Xchar args[MAXARGS][COMMANDSIZE];
X{
Xint map_pdata;
Xplanettype *p;
Xplacetype where;
X
X   where=Getplace(args[1],0);
X   if (where.err) return;
X
X   if (where.level==LEVEL_PLAN) {
X  	openpdata(&map_pdata);
X  	getplanet(map_pdata,&p,Stars[where.snum]->planetpos[where.pnum]);
X  	close(map_pdata);
X
X  	show_map(p,1);	/* 1 means display data */
X
X  	free(p);
X
X	if (Stars[where.snum]->stability > 50)
X		printf("WARNING! This planet's primary is unstable.\n");
X
X   } else {
X	Dir.lastx = Dir.lasty = 0.0;
X	orbit(APcount, argn,args);	/* make orbit map instead */
X   }
X
X}
X
X
X
Xshow_map(p, show)
Xplanettype *p;
Xregister int show;
X{
Xregister int x,y,i,f;
Xint map_sectdata,map_shdata;
Xshiptype *s;
Xchar shiplocs[MAX_X][MAX_Y];
X
X  bzero((char *)shiplocs, sizeof(shiplocs));
X  Ignore_filelocks = 1;
X
X  opensectdata(&map_sectdata);
X  getsmap(map_sectdata,Smap,p->sectormappos,p->Maxx*p->Maxy);
X  close(map_sectdata);
X
X  openshdata(&map_shdata);
X  for (i=0; i<MAXPSHIPS; i++)
X    if (p->shipnums[i]) {
X      getship(map_shdata,&s, p->shipnums[i]);
X      if (s->is_docked && s->whatdest==LEVEL_PLAN)
X	shiplocs[(int)s->xpos][(int)s->ypos] = Shipltrs[s->type];
X      free(s);
X    }
X  close(map_shdata);
X
X  Ignore_filelocks = 0;
X
X  printf("   ");
X  for (x=0; x<p->Maxx; x++) 
X	printf("%d",x/10);
X  if (show)
X  	printf("  Sects %s: %d", Race->Thing ? "covered" : "owned", 
X			p->info[Playernum-1].numsectsowned);
X  printf("\n   ");
X  for (x=0; x<p->Maxx; x++) 
X	printf("%d",x%10);
X  if (show) { 
X	int i,f=0;
X	  printf("  Aliens:");
X	  if (p->is_explored || Race->tech >= TECH_EXPLORE) {
X		  for (i=1; i<MAXPLAYERS; i++)
X			if (p->info[i-1].numsectsowned && i!=Playernum) {
X			   f=1;
X			   printf("%c%d", isset(Race->atwar,i) ? '*' : ' ', i);
X			}
X		  if (!f) printf("(none)");
X	  } else printf("???");
X  }
X  putchr('\n');
X
X  for (y=0; y<p->Maxy; y++) {
X     printf("%2d ",y);
X     for (x=0; x<p->Maxx; x++) {
X	if (shiplocs[x][y])
X		putchr(shiplocs[x][y]);
X	else
X	    	putchr(desshow(p, x, y));
X     }
X     if (show)
X       switch (y) {	/* give stockpile info */
X        case 0: printf("| Combat readiness:  %u", p->info[Playernum-1].comread);
X	      break;
X        case 1: printf("| Compatibility:   %.2f",compatibility(p,Race));
X	      break;
X        case 3:printf("| Resource stockpile:%u",p->info[Playernum-1].resource);
X	      break;
X        case 4: printf("| Fuel stockpile:    %u",p->info[Playernum-1].fuel);
X	      break;
X        case 5:printf("| Destruct cap:      %u",p->info[Playernum-1].destruct);
X	      break;
X        case 6:printf("| %s:  %u (%u)", Race->Thing ? "Tons of biomass" : 
X				"Total Population", p->popn, p->maxpopn);
X	      break;
X        /*case 7: 
X	      break;
X        case 8: 
X	      break;
X        case 9: 
X	      break;
X        case 10: 
X	      break;*/
X        default: printf("|");
X	      break;
X       }
X  putchr('\n');
X  }
X
X
X}
X
X
Xchar desshow(p,x,y)
Xregister planettype *p;
Xregister int x,y;
X{
Xregister sectortype *s;
X
Xs = &Smap[y*p->Maxx+x];
X
X	/*  owned by you */
Xif (s->owner==Playernum) {
X
X  if (s->is_wasted) 
X	return(CHAR_OWNED_WASTELAND);
X  if (s->VN)
X	return(Shipltrs[OTYPE_VN]);
X   switch (s->des) {
X     	case DES_SEA: return(CHAR_OWNED_SEA);
X     	case DES_LAND: return(Race->Thing ? CHAR_OWNED_THING : CHAR_OWNED_LAND);
X     	case DES_MOUNT: return(Race->Thing ? CHAR_OWNED_THING : CHAR_OWNED_MOUNT);
X     	case DES_GAS: return(CHAR_GAS);
X     	case DES_PLATED: return(CHAR_PLATED);
X     	default: return('!');
X   }
X
X	/* un-owned by anybody */
X
X} else if (!s->owner) {
X if (s->VN)
X	return Shipltrs[OTYPE_VN];
X if (!p->is_explored && Race->tech < TECH_EXPLORE) {
X	if ( !( (x>0 && (s-1)->owner==Playernum) ||
X	     (x<p->Maxx-1 && (s+1)->owner==Playernum) || 
X	     (y>0 && (s-p->Maxx)->owner==Playernum) ||
X	     (y<p->Maxy-1 && (s+p->Maxx)->owner==Playernum) ) )
X			return CHAR_CLOAKED;
X }
X if (s->is_wasted) 
X	return(CHAR_WASTELAND);
X  switch (s->des) {
X     case DES_SEA: return(CHAR_SEA);
X     case DES_LAND: return(CHAR_UNOWNED_LAND);
X     case DES_MOUNT: return(CHAR_MOUNT);
X     case DES_GAS: return(CHAR_GAS);
X     case DES_PLATED: return(CHAR_PLATED);
X     default: return('!');
X  }
X
X	/* different owner */
X
X} else
X    return CHAR_DIFFOWNED;
X
X}
END_OF_FILE
if test 4455 -ne `wc -c <'map.c'`; then
    echo shar: \"'map.c'\" unpacked with wrong size!
fi
# end of 'map.c'
fi
if test -f 'name.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'name.c'\"
else
echo shar: Extracting \"'name.c'\" \(3488 characters\)
sed "s/^X//" >'name.c' <<'END_OF_FILE'
X/*
X * Galactic Bloodshed (Robert Chansky, smq@b)
X * name.c -- rename something to something else
X */
X
X#include "vars.h"
X#include "races.h"
X#include "ships.h"
X#include <ctype.h>
X#include <signal.h>
X#include <setjmp.h>
X#include <strings.h>
Xextern jmp_buf main_jenv;
Xint name_shdata,name_stardata;
X
Xname(APcount, argn,args)
Xint APcount;
Xint argn;
Xchar args[MAXARGS][COMMANDSIZE];
X{
Xplanettype *p;
Xplacetype where;
Xchar st[COMMANDSIZE],*ch;
Xregister int i;
Xbool check=0;
Xint name_handler();
X
Xname_stardata = NEUTRAL_FD;
Xsignal(SIGINT, name_handler);
X
X  if (argn==1) {   /* no args */
X    printf("Rename: ");
X    scanf("%[^\n]",st);
X    getchr();
X  } else sscanf(args[1],"%s",st);
X  if (!strcmp(st,"race")) {
X	if (!enufAP(Sdata.AP, APcount));
X	/*free(Race);
X	getrace(&Race, Race->Playernum);*/
X	printf("Change racial name %s to:",Race->name);
X	dots(RNAMESIZE);
X	scanf("%[^\n]",Race->name);
X	getchr();
X	putrace(Race);
X	deductAPs(APcount, 0, 1);
X	return;
X  }
X  where = Getplace(st,0);
X  if (where.err) {
X	printf("Not found.\n");
X	return;
X  } else if (where.level==LEVEL_SHIP) {
X	printf("You cannot name a ship.\n");
X	return;
X  }
X
X  printf("Rename %s%s to:", (where.level==LEVEL_SHIP) ? 
X				"ship " : "" , Dispplace(&where) );
X  dots(NAMESIZE);	/* make a bunch of dots */
X  scanf("%20[^\n]",st);		/* change "20" if NAMESIZE altered */
X  getchr();
X  ch = st;
X  while (*ch!='\0')
X	  check |= (iscntrl(*ch) || (*(ch++)=='/') );
X		/* make sure there are no ^'s or '/' in name */
X  if (strlen(st) < 1 || check) {
X	printf("Illegal name %s.\n", check ? "form" : "length" );
X	name_handler();
X  }
X  switch (where.level) {
X     case LEVEL_STAR:
X	openstardata(&name_stardata);
X	free(Stars[where.snum]);
X	getstar(name_stardata, &Stars[where.snum], where.snum);
X	if (!enufAP(Stars[where.snum]->AP, APcount))
X		name_handler();
X	 /* can't name the place if you don't have the most AP's */
X	if (!MostAPs(Stars[where.snum])) {
X		printf("You don't have the most AP's in that system.\n");
X		name_handler();
X	}
X	strncpy(Stars[where.snum]->name,st,NAMESIZE-1);
X	putstar(name_stardata, Stars[where.snum], where.snum);
X	close(name_stardata);
X	deductAPs(APcount, where.snum, 0);
X	break;
X
X     case LEVEL_PLAN:
X	openstardata(&name_stardata);
X	free(Stars[where.snum]);
X	getstar(name_stardata, &Stars[where.snum], where.snum);
X	if (!MostAPs(Stars[where.snum])) {
X		printf("You don't have the most AP's in that system.\n");
X		name_handler();
X	}
X	strncpy(Stars[where.snum]->pnames[where.pnum],st,NAMESIZE-1);
X	putstar(name_stardata, Stars[where.snum], where.snum);
X	close(name_stardata);
X	deductAPs(APcount, where.snum, 0);
X	break;
X
X    /*case LEVEL_SHIP:
X	/* shipptr already gotten */
X	/*if (where.shipptr->owner!=Playernum || where.err) {
X		printf("Name: bad ship #.\n");
X		DontOwnErr(where.shipno);
X		name_handler();
X	}
X	strncpy(where.shipptr->name,st,NAMESIZE-1);
X	openshdata(&name_shdata);
X	putship(name_shdata, where.shipptr, where.shipno);
X	close(name_shdata);
X	if (where.shipptr->whatorbits==LEVEL_UNIV)
X		deductAPs(APcount, 0, 1);
X	else 
X		deductAPs(APcount, where.shipptr->storbits, 0);
X	break;*/
X
X     case LEVEL_UNIV:
X     default:
X	printf("You can't do that.\n");
X	return;
X  }
X  docommand("cs :");	/* trick */
X}
X
X
Xint MostAPs(s)
Xstartype *s;
X{
X register int i,t = 0;
X
X  for (i=0; i<MAXPLAYERS; i++)
X     if (s->AP[i] > s->AP[t])
X	  t = i;
X
X  return (t == Playernum);
X
X}
X
X
Xname_handler(sig, code, scp)
Xint sig,code;
Xstruct sigcontext *scp;
X{
X close(name_stardata);
X close(name_shdata);
X longjmp(main_jenv,1);
X}
X
END_OF_FILE
if test 3488 -ne `wc -c <'name.c'`; then
    echo shar: \"'name.c'\" unpacked with wrong size!
fi
# end of 'name.c'
fi
if test -f 'overview.nr' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'overview.nr'\"
else
echo shar: Extracting \"'overview.nr'\" \(4706 characters\)
sed "s/^X//" >'overview.nr' <<'END_OF_FILE'
X
X
X
X
X.ce 100
XGalactic Bloodshed
X(working title)
X
X
Xby
X
XRobert Chansky
X.ce 0
X.bp
X.pp
XOverview
X.pp
XThis game was originally inspired by the Unix wargame Empire.  In Empire
Xconquest is represented by the amount of territory a player occupies as
Xwell as the resources and workforces he posesses.  Galactic Bloodshed is
Xmuch the same in these respects, as are many other games.
X.pp
XBut, where Empire takes place on one world, Galactic Bloodshed employs
Xmany seperate worlds for players to explore and exploit.  In this way the
Xgame is more versatile than Empire, and there are many more avenues to
Xexplore in game development.  Finance, 
Xcooperation and war (of course),
Xdevelopment of technology,
Xand randomizing factors will all be important areas of the game.
X.pp
XWhile free trade would ordinarily be difficult in a simulation
Xconstrained by the mechanics of interstellar travel, Galactic Bloodshed
Xwill circumvent this by introducing various 'shortcuts' to travel.  Among
Xthese are FTL vehicles, instantaneous transport devices, and a smaller-than-
Xscale travel distance for starships.  Another factor to stimulate free
Xtrade is the economic leverage inherent in the disparate races and
Xcultures that arise from evolution (or creation, whichever you happen to
Xbelieve [more on this later]).  Thus goods such as priceless art
Xtreasures, examples of fiction, technological discoveries, new strains of
Xfood animals, etc.(the list is endless) can all be carried in a starship
Xof limited capacity.  
XCommunication is possible between races via long-distance radio
X(telegrams).  Opportunities for profit can be utilized by any player.
X.pp
XWhile the game is designed primarily to be peaceful in intent (the name is
Xsarcastic), it is necessary that there also be an alternative to friendly
Xcompetition.  Thus war and conflict are born.  In addition to trade
Xcargoes a ship can also carry destructive capacity.  this can represent
Xanything from nuclear weaponry to propaganda, and when unloaded it can be
Xdevastating to its intended target.  Ships, planets, and people all can be
Xmobilized to preserve their culture's manifest destiny while curbing another's
Xexpansionist imperialism.
X.pp
XThe above so far is assuming that each culture in the game develops along
Xthe lines that our own seems to be.
XThis view is a narrow one considering the disparity of even the
Xone known planet we have to model.
XThe technologically dominant European culture of Earth arose merely by chance, 
Xand it is equally possible that another, differently motivated culture
Xcould have come about in its place -- a culture that, perhaps, uses the
Xprinciples of magic, mind power, or prayer to influence its environment in the 
Xsame way that machines and such are used today.  We have only theoretical
Xexperience with such methods, but they are nevertheless applicable to the
Xworkings of the game.  Instead of developing newer and better machines
Xthese cultures may explore the possibilities of more complicated and
Xpowerful spells, a greater unity of the mind and the body, or a
Xtranscendant understanding of God.  Lasers and nuclear weapons clash with 
Xthe concentrated might of a racial mind, while
Xthe magic spells of another culture might vy with the power of a god.
X.pp
XIt is possible for any game to become unbalanced, as one player becomes
Xmore experienced in the game and forces the others to extinction.  This
Xcan easily happen with Galactic Bloodshed as well.  Randomizing factors
Xare necessary to keep the game balanced, without reducing
Xplayability as well.  I introduce Berserkers, wandering death machines 
Xattempting to
Xdestroy all life, as one such option.  These devices can be randomly
Xcreated anywhere (or alternatively built at a central base which could
Xserve as a quest to destroy for the players) to deal crippling blows at
Ximportant supply routes.  They can be directed anywhere, or programmed to
Xmove randomly or towards the most advantaged player.  But this is not the
Xonly option; many factors can contribute to keeping players on their toes.
XSomeone may invent a supernova device (effectively ending the game...) and
Xuse it on your system;  a viral plague may break out;  A gamma-ray laser
Xaimed at one of your planets may render its population nearly sterile;  Rival
Xsupernatural beings may choose your territory in which to 'duke it out';
Xyour scientists may invent a self-reproducing machine which immediately
Xproceeds to convert all the resources of your system into copies of itself.
XAny number of things may happen.
X.pp
XProgress on Galactic Bloodshed so far has been fairly steady; and I hope to 
Xhave a working multi-player copy
Xof the game (ver 0.9) up by the beginning of the summer.
X
X	Robert Paul Chansky
X
END_OF_FILE
if test 4706 -ne `wc -c <'overview.nr'`; then
    echo shar: \"'overview.nr'\" unpacked with wrong size!
fi
# end of 'overview.nr'
fi
if test -f 'ships.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'ships.h'\"
else
echo shar: Extracting \"'ships.h'\" \(4131 characters\)
sed "s/^X//" >'ships.h' <<'END_OF_FILE'
X/*
X * Galactic Bloodshed (Robert Chansky, smq@b)
X */
X
X#define NUMSTYPES 	(25+1)
X
X#define STYPE_POD	0
X#define STYPE_SHUTTLE 	1
X#define STYPE_COMSAT	2
X#define STYPE_BATTLE 	3
X#define STYPE_DESTROYER 4
X#define STYPE_FIGHTER 	5
X#define STYPE_CARGO 	6
X#define STYPE_EXPLORER 	7
X#define STYPE_TANKER 	8
X#define STYPE_STATION 	9
X#define STYPE_DREADNT	10
X#define STYPE_MITHRIL	11
X#define STYPE_CRYSTAL	12
X#define STYPE_GOD	13
X#define STYPE_MINE	14
X#define STYPE_MIRROR	15
X
X#define OTYPE_TERRA	16
X#define OTYPE_CANIST	17
X#define OTYPE_VN	18
X#define OTYPE_PLBOMB	19
X#define OTYPE_CLOAK	20
X#define OTYPE_SUPPRESS	21
X#define OTYPE_AMULET	22
X#define OTYPE_BIOW	23
X#define OTYPE_GR	24
X#define OTYPE_TRANSDEV	25
X
X#define NUMABILS 	11	/* 0 - 10 */
X
X#define ABIL_CARGO 	0
X/*#define ABIL_STEALTH 	1*/
X#define ABIL_DESTCAP 	1
X#define ABIL_GUNS 	2
X#define ABIL_FUELCAP 	3
X#define ABIL_TECH 	4
X#define ABIL_MAXCREW 	5
X#define ABIL_ARMOR 	6
X#define ABIL_COST 	7
X#define ABIL_MASS 	8
X#define ABIL_CANMOVE	9
X#define ABIL_HASSWITCH	10
X
X#define TOWARDS 1	/* 0 is neither */
X#define AWAY 2
X#define BOTH 3
X
Xtypedef struct ship shiptype;
Xtypedef struct orders ordertype;
Xtypedef struct place placetype;
X
Xstruct orders {		/* standing orders for ships, planets */
X    /*char moves[howmanybytes(MAXPLAYERS)];	/* whom to move towards/away */
X    /*unsigned speed : 4;		/* what speed has been ordered */
X    /*unsigned towards : 2;			/* move towards, away */
X    /*unsigned biggerthan : 1;	/* move away from ships bigger than you */
X    unsigned bombard : 1;	/* bombard planet we're on */
X};
X
Xstruct ship {
X    float xpos,ypos;
X    float fuel,mass;
X    /*char name[NAMESIZE];*/
X    /*us abils[NUMABILS-2];	/* only certain abilities are kept track*/
X    unsigned short destshipno;		/* destination ship # */
X    union {
X    	ordertype o;		/* standing orders for ship */
X	struct a {		/* if the ship is a Space Mirror */
X		short shipno;	/* aimed at what ship */
X		char snum;		/* aimed at what star */
X		percent intensity;		/* intensity of aiming */
X		unsigned pnum : BITS_MAXPLANETS;  /* aimed at what planet */
X		unsigned level : 2;	/* aimed at what level */
X	} aimed_at;
X	struct o2 {
X		short number;	/* for misc functions */
X		short number2;	/* again */
X		unsigned on : 1;	/* on or off */
X	} object;
X    } orders;
X    char storbits;		/* what star # orbits */
X    char deststar;		/* destination star */
X    unsigned destpnum : BITS_MAXPLANETS;	/* destination planet */
X    unsigned pnumorbits : BITS_MAXPLANETS;	/* # of planet if orbiting */
X    unsigned damage : 7;		/* amt of damage */
X    unsigned rad : 7;			/* irradiated */
X    unsigned destruct : 16;	 	/* stuff it's carrying */
X    unsigned resource : 16;
X    unsigned popn : 16;			/* crew */
X    unsigned owner : BITS_MAXPLAYERS;	/* owner of ship */
X    unsigned speed : 3;		/* what speed to travel at */
X    /*unsigned augmented : 4;	/* # of times augmented (max 10) ? */
X    unsigned whatdest : 2;	/* where going (same as Dir) */
X    unsigned whatorbits : 2;	/* where orbited (same as Dir) */
X    unsigned type : 5;		/* what type ship is */
X    unsigned is_cloaked : 1;	/* 1 bit: is cloaked ship */
X    unsigned is_sheep : 1;	/* 1 bit: is under influence of mind control */
X    unsigned is_docked : 1;	/* 1 bit: is landed on a planet or docked */
X    unsigned notified : 1; 	/* 1bit: has been notified of something */
X    unsigned is_dead : 1;	/* 1 bit: is destroyed ship */
X    unsigned is_examined : 1;	/* 1 bit: has been examined */
X};
X
Xstruct place {		/* used in function return for finding place */
X    char snum;
X    char pnum;
X    short shipno;
X    shiptype *shipptr;
X    unsigned level : 2;	/* .level: same as Dir */
X    unsigned err : 1;		/* if error */
X};
X
X /* whether ship is an object or not */
X#define is_object(s) ((s)->type > STYPE_MIRROR)
X /* can takeoff & land, is mobile, etc. */
X#define can_move(s) (Shipdata[(s)->type][ABIL_CANMOVE])
X /* has an on/off switch */
X#define has_switch(s) (Shipdata[(s)->type][ABIL_HASSWITCH])
X
Xextern placetype Getplace();
Xextern char *Dispplace(),*Dispshiporbits();
Xextern int Shipdata[NUMSTYPES][NUMABILS];
Xextern char Shipltrs[];
Xextern char *Shipnames[];
END_OF_FILE
if test 4131 -ne `wc -c <'ships.h'`; then
    echo shar: \"'ships.h'\" unpacked with wrong size!
fi
# end of 'ships.h'
fi
if test -f 'shlmisc.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'shlmisc.c'\"
else
echo shar: Extracting \"'shlmisc.c'\" \(3300 characters\)
sed "s/^X//" >'shlmisc.c' <<'END_OF_FILE'
X/*
X * Galactic Bloodshed (Robert Chansky, smq@b)
X *  miscellaneous stuff included in the shell
X */
X
X#include "vars.h"
X#include "races.h"
X#include <signal.h>
X#include <ctype.h>
X#include <stdio.h>
X
X
XDontOwnErr(shipno)
Xregister int shipno;
X{
X  printf("You don't own ship #%d.\n",shipno);
X}
X
X
Xint enufAP(AP, x)
Xchar *AP;
Xregister int x;
X{
X register int blah;
X
X if (blah = (AP[Playernum] < x) ) {
X	printf("You don't have %d action points there.\n", x);
X }
X return (!blah);
X}
X
X
Xint Getracenum(login)
Xchar *login;
X{
X register int i = 0;
X char s[LOGIN_NAME_SIZE];
X FILE *fd;
X
X fd = fopen(PLAYERDATAFL, "r");
X s[0] = '\0';
X
X while (!feof(fd) && strcmp(s,login) ) {
X   i++;
X   fscanf(fd,"%s",s);
X }
X fclose(fd);
X return( (strcmp(s,login)) ? 0 : i );
X}
X
X
X/* returns player # from string containing that players name or #. */
X
XGetPlayer(name, rnum, race)
Xchar *name;
Xint *rnum;
Xracetype **race;
X{
Xint numraces;
Xregister int i,l;
X
X	numraces = Numraces();
X	*rnum = 0;
X
X	if (isdigit(*name)) {
X		if ( (*rnum = atoi(name)) < 1 || *rnum > numraces) {
X			*rnum = -1;
X			return;
X		} else {
X			printf(" player %d\n",*rnum);
X			getrace(race, *rnum);
X			return;
X		}
X	} else {
X		l = strlen(name);
X		for (i=1; !(*rnum) && i<=numraces; i++) {
X			getrace(race, i);
X			if (!strncmp(name, (*race)->name, l)) {
X				printf(" player %d\n",i);
X				*rnum = i;
X				return;
X			} else
X				free(*race);
X		}
X	}
X}
X
X
Xint deductAPs(n, snum, sdata)
Xint n, snum;
Xint sdata;	/* whether or not sdata is involved */
X{
X int deductAPs_stardata, mask;
X
X if (n) {
X
X  mask = sigblock(SIGINT|SIGQUIT|SIGSTOP);
X	/* keep people from cheating */
X
X  openstardata(&deductAPs_stardata);
X
X  if (!sdata) {
X     free(Stars[snum]);
X     getstar(deductAPs_stardata, &Stars[snum], snum);
X
X     if (Stars[snum]->AP[Playernum] >= n)
X	     Stars[snum]->AP[Playernum] -= n;
X     else {
X	Stars[snum]->AP[Playernum] = 0;
X	printf("WHOA!  You cheater!  Oooohh!  OOOOH!\n  I'm tellllllllliiiiiiinnnnnnnnnggggggggg!!!!!!!\n");
X	exit(-1);
X     }
X
X     putstar(deductAPs_stardata, Stars[snum], snum);
X
X     if (Dir.level!=LEVEL_UNIV && Dir.snum == snum) {
X         /* fix the prompt */
X       sprintf(Dir.prompt + 4, "%02d", Stars[snum]->AP[Playernum]);
X       Dir.prompt[6] = ']';		/* fix bracket (made '\0' by sprintf)*/
X     }
X  } else {
X     getsdata(deductAPs_stardata,&Sdata);
X     Sdata.AP[Playernum] -= n;
X     	if (Sdata.AP[Playernum] < 0)
X	     Sdata.AP[Playernum] = 0;
X     putsdata(deductAPs_stardata,&Sdata);
X
X     if (Dir.level==LEVEL_UNIV) {
X       sprintf(Dir.prompt + 2, "%02d", Sdata.AP[Playernum]);
X       Dir.prompt[3] = ']';
X     }
X  }
X  close(deductAPs_stardata);
X  sigsetmask(mask);
X }
X
X}
X
X
X
XGetMapSector(pl, x, y)
Xplanettype *pl;
Xint *x, *y;
X{
X char c;
X
X *x = -1;
X
X do {
X   printf(" what sector (0-%d,0-%d,'?' for map): ",pl->Maxx-1,pl->Maxy-1);
X   while ( !(isdigit(c=getchr()) || c=='?' || c=='-') )
X	;
X	/*if (isdigit(c) || c=='-')
X		ungetc(c,stdin);*/
X   	if (c=='?') {
X		getchr();		/* get \n */
X		show_map(pl,0);		/* don't show extraneous data */
X   	} else if (isdigit(c) || c=='-') {
X		ungetc(c,stdin);
X   		scanf("%d,%d", x, y);
X		getchr();
X   	}
X } while ((*x)<0 || (*x)>=pl->Maxx || (*y)<0 || (*y)>=pl->Maxy);
X
X}
X
X
X
Xvoid dots(i)
Xregister int i;
X{
Xregister int j;
X
X  for (j=0; j<i; j++)
X	putchar('.');
X  for (j=0; j<i; j++)
X	putchar('\010');
X}
X
END_OF_FILE
if test 3300 -ne `wc -c <'shlmisc.c'`; then
    echo shar: \"'shlmisc.c'\" unpacked with wrong size!
fi
# end of 'shlmisc.c'
fi
if test -f 'vars.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'vars.h'\"
else
echo shar: Extracting \"'vars.h'\" \(4632 characters\)
sed "s/^X//" >'vars.h' <<'END_OF_FILE'
X/*
X * Galactic Bloodshed (Robert Chansky, smq@b)
X *  main bunch of variables 
X */
X
X/* bit routines stolen from UNIX <sys/param.h> */
X#define	setbit(a,i)	((a)[(i)/8] |= 1<<((i)%8))
X#define	clrbit(a,i)	((a)[(i)/8] &= ~(1<<((i)%8)))
X#define	xbit(a,i)	((a)[(i)/8] ^= (1<<((i)%8)))
X#define	isset(a,i)	((a)[(i)/8] & (1<<((i)%8)))
X#define	isclr(a,i)	(((a)[(i)/8] & (1<<((i)%8))) == 0)
X#define	howmanybytes(x)	(((x)+7)/8)
X
X#define Bzero(x)  bzero( (char *)&(x), sizeof(x) )
X#define Malloc(x) (x *)malloc( sizeof(x) )
X
X#include "tweakables.h"
X#include <sys/types.h>
X#include <sys/file.h>
X#include <stdio.h>
X
X
X#define LEVEL_UNIV 0
X#define LEVEL_STAR 1
X#define LEVEL_PLAN 2
X/*#define LEVEL_MOON 3*/
X#define LEVEL_SHIP 3
X
X#define MAXPLAYERS 30
X#define BITS_MAXPLAYERS 5	/* # bits req'd to represent */
X
Xtypedef char bool;	/* 1 or 0 */
Xtypedef unsigned char percent;	/* 0-100 */
Xtypedef unsigned long ul;
Xtypedef unsigned short us;
Xtypedef struct sector sectortype;
Xtypedef struct planet planettype;
Xtypedef struct star startype;
X
X
Xstruct plinfo {				/* planetary stockpiles */
X      unsigned fuel : 17;		/* fuel for powering things */
X      unsigned destruct : 17;   	/* destructive potential */
X      unsigned resource : 17;		/* resources in storage */
X      unsigned numsectsowned : 10;
X      unsigned comread : 7;		/* combat readiness */
X      unsigned mob_set : 7;		/* mobilization target */
X      /*unsigned quota_resource : 7;
X      unsigned quota_destruct : 7;
X      unsigned quota_fuel : 7;*/
X      unsigned explored : 1;		/* 1 bit: explored by each player */
X      unsigned autorep : 3;		/* player wants autoreport */
X      unsigned spied_on : 1;		/* spied on */
X};
X
Xstruct sector {
X    unsigned eff : 7;		/* efficiency (0-100) */
X    unsigned resource : 8;
X    unsigned fert : 7;		/* max popn is proportional to this */
X    unsigned popn : 10;
X    unsigned mobilization : 7;	/* percent popn is mobilized for war */
X    unsigned owner : BITS_MAXPLAYERS;	/* owner of place */
X    unsigned is_wasted : 1;	/* 1 bit: is a wasted sector */
X    /*unsigned is_cloaked : 1;	/* 1 bit: is cloaked sector */
X    unsigned des : 3;		/* kind of land the place is */
X    unsigned VN : 1;		/* has a VN machine on it */
X};
X
X
Xstruct planet {
X    float xpos,ypos;		/* x,y relative to orbit */
X    char conditions[TOXIC+1]; /* atmospheric conditions for terraforming */
X    /*int nummoons;*/
X    /*int moonpos[MAXMOONS];	/* filepos moons or ast around it */
X    short shipnums[MAXPSHIPS];	/* ship #'s that orbit it */
X    percent numships;		/* # of ships there are */
X    percent Maxx,Maxy;		/* size of map */
X    int sectormappos;		/* file posn for sector map */
X    struct plinfo info[MAXPLAYERS-1]; 	/* planetary stockpiles */
X    unsigned popn : 20;
X    unsigned maxpopn : 20;			/* maximum population */
X    unsigned slaved_to : BITS_MAXPLAYERS;	/* owner of place */
X    /*unsigned is_sheep : 1;	/* 1 bit: is emotion suppressed */
X    unsigned type : 2;		/* what type planet is */
X    unsigned expltimer : 3;	/* timer for explorations */
X    unsigned is_explored : 1;	/* is explored by owner */
X};
X
Xstruct star {
X    float xpos,ypos;
X    char stability;		/* how close to nova it is */
X    char name[NAMESIZE];
X    char numplanets;		/* # of same */
X    char pnames[MAXPLANETS][NAMESIZE]; /* names of planets */
X    int planetpos[MAXPLANETS]; 		/* file posns of planets */
X    char numships;		/* get rid of this */
X    short shipnums[MAXSSHIPS];	/* what ships are orbiting */
X    float gravity;		/* attraction of star in "Standards". */
X    char explored[howmanybytes(MAXPLAYERS)];	/* who's been here */
X    char inhabited[howmanybytes(MAXPLAYERS)];	/* who lives here now */
X    char AP[MAXPLAYERS];	/* action pts alotted */
X    unsigned nova_stage : 4;		/* stage of nova */
X    /*unsigned is_cloaked : 1;	/* pl is cloaked */
X};
X
X
X
X	/* this data will all be read at once */
Xstruct data {
X    int numstars;		/* # of stars */
X    int numships;		/* # of ships floating around */
X    short shipnums[MAXUSHIPS];
X    char AP[MAXPLAYERS];	/* Action pts for each player */
X} Sdata;
X
Xstruct directory {
X    unsigned level : 2;		/* what directory level */
X    int snum;		/* what star system obj # (level=0) */
X    int pnum;		/* number of planet */
X    int shipno;		/* # of ship */
X    /*int moon;		/* ptr to moon of planet obj # (lev=2)*/
X    char prompt[NAMESIZE+NAMESIZE+NAMESIZE+5];	/* just to be safe */
X    float lastx, lasty, zoom;	/* last coords for zoom */
X} Dir;
X
X
Xsectortype Smap[(MAX_X+1)*(MAX_Y+1) + 1];
X
Xstartype *Stars[NUMSTARS];
X
Xint Playernum;		/* what player you are */
X
Xextern float powscale(),logscale(),float_rand(),gravity();
Xchar *malloc();
END_OF_FILE
if test 4632 -ne `wc -c <'vars.h'`; then
    echo shar: \"'vars.h'\" unpacked with wrong size!
fi
# end of 'vars.h'
fi
echo shar: End of archive 5 \(of 7\).
cp /dev/null ark5isdone
MISSING=""
for I in 1 2 3 4 5 6 7 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 7 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