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

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

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



#! /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 6 (of 7)."
# Contents:  Docs/build.doc Docs/declare.doc Docs/help.doc
#   Docs/orbit.doc Docs/order.doc Docs/profile.doc Docs/scope.doc
#   Docs/survey.doc GB.c MANIFEST.BAK autoreport.c autoshoot.c
#   declare.c launch.c max.c mobiliz.c more.c perm.c prof.c scrap.c
#   shipdata.h telegram.c
# Wrapped by billr@saab on Wed Apr 26 14:41:37 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Docs/build.doc' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Docs/build.doc'\"
else
echo shar: Extracting \"'Docs/build.doc'\" \(2003 characters\)
sed "s/^X//" >'Docs/build.doc' <<'END_OF_FILE'
XBUILD			Galactic Bloodshed		BUILD
X
X
XNAME
X  [1] build -- construct a ship
X
XSYNTAX
X	build [type]
X
XDESCRIPTION
X  build enables the user to construct a ship provided there are enough
Xresources to do so.
X
X  If the ship type is not specified, build will prompt for one.  At this
Xpoint typing a '?' will produce a list of the different ship types, their
Xcapabilities, and their resource cost in the 'cost' column.  Ships are
Xidentified by their letter.
X
X  If there are enough resources, and there are not too many ships already
Xin orbit or landed on the planet, build will now ask the sector on which
Xthe player wishes to construct the ship.  This sector must belong to him
Xand be a flat area (not mountainous).
X
X  At this point the resource point cost will be deducted from the player's
Xstockpiles, and build will attempt to crew and fuel the ship as it is
Xconstructed.  If there are not enough people on that sector to crew the
Xship, one token crewmember will be placed there.
X
X  A short explanation of ship capabilities:
X
Xltr              ship  carg armr dstcap guns  mass fuelcap mintech cost ^crew
X s            Shuttle    10    1      2    1    10      20      15   50    25
X
X ltr: Ship letter used to identfy the ship.  This is the letter you must
X	type in to choose that ship.
X ship: A short name for that type of ship.
X carg: Maximum cargo (resources) the ship can carry (see ``load'').
X armr: Resistance to damage.  A straight ratio; the higher, the better.
X dstcap: Maximum destructive capacity (weapons) the ship can carry.
X guns: Amount of destructive capacity the ship can fire at once.
X mass: Weight of the ship (in Standard Units).  Heavier ships move slower.  This
X	value changes as things are loaded/unloaded on the ship.
X fuelcap: Maximum fuel the ship can carry.
X mintech: You must be at this tech or above to build the ship.
X cost: Amount of resource points required to build.
X ^crew: Maximum number of crew (or tons of biomass) the ship can carry.
X
X
X
XSEE ALSO
X load, stock, report, ship
X
END_OF_FILE
if test 2003 -ne `wc -c <'Docs/build.doc'`; then
    echo shar: \"'Docs/build.doc'\" unpacked with wrong size!
fi
# end of 'Docs/build.doc'
fi
if test -f 'Docs/declare.doc' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Docs/declare.doc'\"
else
echo shar: Extracting \"'Docs/declare.doc'\" \(1607 characters\)
sed "s/^X//" >'Docs/declare.doc' <<'END_OF_FILE'
XDECLARE			Galactic Bloodshed		DECLARE
X
X
XNAME
X  [1] declare -- state relations with other players
X 
XSYNTAX
X      declare 
X
XDESCRIPTION
X
X  The friction between two disparate races competing for the same limited
Xresources may be such that no matter what diplomatic means exist between
Xthem (telegram), conflict may still ensue.  
X
X  To facilitate this, a player may declare his/her race's intentions toward
Xother players in the game, whether allied, neutral, or at war.
X
X  When invoked, a prompt will ask how he wishes his relations to be with that 
Xplayer, and the player number.  This will be in effect until the user changes
Xhis/her mind.
X
X  A state of war affects planetary and interstellar conflict in different ways.
XFor example, if a player shares a planet with another, migration from sector 
Xto sector will halt upon reaching the sectors belonging to the other player
Xif the players are neutral toward each other or allied.  If they are at war,
Xhowever, the sectors will be contested.  Lives will be lost on both sides, and
Xsectors are likely to be damaged.
X
X  Likewise, ship-to-ship conflict is likely between races that are at war.  
XWhen a ship comes in range of another ship belonging to a player with which
Xthe first ship's owning player is at war, it will fire, generally once per
Xturn, until the enemy ship is disabled, out of range, or the war called off.
X
X  Allies are prompted before firing on one another, and ships/planets fired
Xupon by allies will not fire back (they wish to avoid a diplomatic incident,
Xuntil otherwise ordered by the user).
X
X
X
XSEE ALSO
X  telegram, order, fire, attack
X
END_OF_FILE
if test 1607 -ne `wc -c <'Docs/declare.doc'`; then
    echo shar: \"'Docs/declare.doc'\" unpacked with wrong size!
fi
# end of 'Docs/declare.doc'
fi
if test -f 'Docs/help.doc' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Docs/help.doc'\"
else
echo shar: Extracting \"'Docs/help.doc'\" \(2026 characters\)
sed "s/^X//" >'Docs/help.doc' <<'END_OF_FILE'
XGalactic.Bloodshed commands:
X
X
X () or none -required arguments. []-optional arguments.
X xlow:xhi,ylow:yhi-means a range of sectors from xlow to xhi, and ylow to
X	yhi.  also legal: x,y xlow:xhi,y x,ylow:yhi
X path : a scope path; separated by '/'. ex: /sol/Earth means system sol, planet
X	 Earth; ../Mars means the scope above you, planet (or star for that 
X	 matter) Mars.  these may be abbreviated.  Substitute ':' for the
X	 current scope you are in for any command. 'path' can be substituted 
X	 with '#(shipno)' for many commands.
X
X
Xsurvey [xlow:xhi,ylow:yhi] -- look at survey on range of sectors or planet
X		or star.
X
Xbuild -- build a ship/object.
X
Xscrap -- turn a ship/object into scrap.
X
Xcs ([:]|[/]|[..]|[planetname]|[starname]|[/] etc.) -- change scope (..=up one;
X			':'=current scope; <name> down to planet or star.)
X
Xdeclare -- state relations (alliance, neutrality, war) to other players.
X
Xfire [ ( [#shipnum]|[path] ) ( [#shipnum2]|[path2] ) ] -- fire from 
X		ship #[shipnum] or planet [path], at ship #[shipnum2]
X		or planet [path2].
X
Xload [ (#shipnum) (commodity) (amt) ] -- load/unload amount of commodity from 
X			ship.
X
Xlaunch [#shipnum] -- take off a ship.
X
Xland [#shipnum] -- land a ship.
X
Xmobilize xlow:xhi,ylow:yhi [invest] -- build up military readiness in 
X		sectors, using [invest] resources.
X
Xmap [path] -- look at sector map.
X
Xname -- rename an object
X
Xnavigate [#shipnumber] [path] -- order ship to move.
X	navigate #shipno path -- move that ship to path
X	navigate path -- order all ships in scope to path
X	navigate  -- navigate all ships in scope to path (prompted)
X
Xorbit [path] -- graphic representation of ship and planet positions
X
Xzoom (amount) | (numerator/denominator) -- zoom in/out for orbit display
X
Xorder [ #shipnum ] -- send orders to ships
X
Xprofile -- racial profile
X
Xstock [#shipnumber] -- ship report
X
Xread -- read telegram messages
X
Xreport [#shipnumber] -- navigational ship report
X
Xtelegram [ playername | player# ] -- send a message to another player
X
Xquit -- quit
X
X? -- this file
END_OF_FILE
if test 2026 -ne `wc -c <'Docs/help.doc'`; then
    echo shar: \"'Docs/help.doc'\" unpacked with wrong size!
fi
# end of 'Docs/help.doc'
fi
if test -f 'Docs/orbit.doc' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Docs/orbit.doc'\"
else
echo shar: Extracting \"'Docs/orbit.doc'\" \(2154 characters\)
sed "s/^X//" >'Docs/orbit.doc' <<'END_OF_FILE'
X
XORBIT			Galactic Bloodshed			ORBIT
X
X
XNAME
X  [0] orbit -- Graphic representation of objects in current scope
X
XSYNOPSIS
X       orbit [-n] [-S] [-p] [-s] [-ship/planet number] [path]
X
XDESCRIPTION
X
X  Orbit gives a visual map of all stars, planets, and ships in the scope
Xof ``path'' or the current scope if none is specified.  You cannot map an
Xarea that has not been visited by one of your ships.
X
X  If ``path'' is the root, ``orbit'' will show all the stars in the game,
Xand all ships travelling in interstellar space that belong to the player.
X
X  If ``path'' is a star, orbit will display the solar system there
Xwith its star in the center and orbiting planets around it, plus all ships
Xthat are the player's (or can be detected).
X
X  If ``path'' is a planet orbit will display that planet and orbiting
Xships.
X
X  If ``path'' is in the form ``#shipnum'' orbit will display a map of 
Xwhichever system or planet the ship is at.
X
X  If no path has been specified, the current scope is used, and display will
Xbe centered around the current ``lastx,lasty'' coordinates.  These coordinates
Xrepresent the x,y location of the last scope the player was in.  For instance,
Xif a player types the following:
X
X [xx] / >cs #5/..
X [yy] / Sol / Sol-III >orbit
X
X  The orbit display will be centered around the location of ship #5.
X
X  When no path is specified, the zoom factor comes into play as well.  Display
Xwill appear larger or smaller according to the zoom factor (1.0 being normal).
XIf there is a specified path argument to orbit, zoom and last coordinates are
Xnot dealt with.  (It is as if they are 0,0 and 1.0, respectively.)
X
X
X  OPTIONS
X
X  when invoking ``orbit'' the options given (except for ``-(number)'') can be 
Xeither in the form "-pSs" or spread out as in "-p -S -s -3".
X
X
X  -p : If this option is set, ``orbit'' will not display planet names.
X
X  -S : Do not display star names.
X
X  -s : Do not display ships.
X
X  -(number) : Do not display that #'d ship or planet (should it obstruct
X		the view of another object).  Stars or planets are numbered
X		sequentially from 1, while ships can be referenced by their
X		ship number.
X
X
XSEE ALSO
X  map, cs, scope, zoom
X
END_OF_FILE
if test 2154 -ne `wc -c <'Docs/orbit.doc'`; then
    echo shar: \"'Docs/orbit.doc'\" unpacked with wrong size!
fi
# end of 'Docs/orbit.doc'
fi
if test -f 'Docs/order.doc' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Docs/order.doc'\"
else
echo shar: Extracting \"'Docs/order.doc'\" \(2707 characters\)
sed "s/^X//" >'Docs/order.doc' <<'END_OF_FILE'
XORDER		Galactic Bloodshed		ORDER
X
X
XNAME
X  [1] order -- give ships standing orders
X
XSYNTAX
X  order [#shipnum]
X
XDESCRIPTION
X  ``order'' gives standing orders to the ship specified.  If no ship
Xis specified, ``order'' will prompt for the orders of all ships at and below
Xthe current scope.  The program will prompt for changes in orders in
Xeach case.
X
X  Currently the orders that can be changed are:
X
X  (d)estination -- The ship will attempt to move towards the star/planet
X	specified.
X
X  (s)peed -- Setting of 0,1,2, or 3.  
X  	Multiplier constants used in the game are (indexed by the speed):
X	 float SpeedConsts[] = { 0.0, 0.80, 1.0, 1.2, 1.3 };
X	 float FuelConsts[] =  { 0.0, 0.75, 1.0, 1.3, 1.4 };
X
X  The following two orders can not be made on space mirror ships:
X
X    (m)ove -- The ship will attempt to move towards/away from
X	any ships it spots that belong to the player number specified.
X	If the number appears on the screen, the ship is ordered to move
X	toward/away from ships belonging to that player.
X
X    (t)owards/away -- qualifier to move towards/away from specified ships.
X
X    (i)f bigger/smaller -- qualifier for the above ship orders.  If the
X	'towards' qualifier is set, this qualifier, if activated, will
X	cause the ship to move towards only ships that it outguns.  If the
X	'away' qualifier is set, this qualifier will cause the ship to move
X	away only from ships that outgun it (and make no moves at all with
X	ships it outguns).  It can also be set to move do both at once.
X
X    (b)ombard -- if bombard is on and the ship is in orbit around a planet,
X	the ship will fire at the planet targetting at sectors belonging to
X	players indicated in the ``fire at'' orders.
X
X  The following two orders can only be made to space mirrors:
X
X    (a)im at -- change focus to the named object (0.3 fuel for maneuvering.)
X	Space mirrors can only have effect on objects within the same
X	solar system.  Ships being focused on will take a certain amount
X	of damage per turn, and planets will experience a temperature change
X	corresponding to the intensity.
X
X    (i)ntensity -- change degree of focus for a space mirror.
X
X
X  Action Points are deducted from the root and each star.  No more than
Xthe normal AP cost will be deducted from the root or each star, no matter
Xhow many ship's orders are changed in each.
X
X  Ships that are landed or docked cannot be given orders.
X
X  To give orders to an object (other than a ship), the object number must
Xbe specified, i.e. ``order #n'', where n is the number of some valid object.
XObjects can be given orders whether landed or not, and the valid orders which
Xcan be given, can be quite different from those given to regular ships.
X
X
XSEE ALSO
X scope, actionpoints
X
END_OF_FILE
if test 2707 -ne `wc -c <'Docs/order.doc'`; then
    echo shar: \"'Docs/order.doc'\" unpacked with wrong size!
fi
# end of 'Docs/order.doc'
fi
if test -f 'Docs/profile.doc' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Docs/profile.doc'\"
else
echo shar: Extracting \"'Docs/profile.doc'\" \(2610 characters\)
sed "s/^X//" >'Docs/profile.doc' <<'END_OF_FILE'
XPROFILE			Galactic Bloodshed		PROFILE
X
X
XNAME
X  [0] profile -- racial profile
X  
XSYNTAX
X      profile
X
XDESCRIPTION
X  This command prints out a short summary of your race's major characteristics.
XA short explanation of the profile follows:
X
XThe Thing -- This means your race is mesomorphic, like John Carpenter's 'The
X	Thing'.  You will receive certain bonuses, such as a high birthrate,
X	above-average fighting ability (as well as the ability to absorb your
X	enemies' population), and the ability to grow and launch spore pods;
X	but you will also have a very low intelligence.
X
XInfection/birth rate -- the rate at which your people reproduce themselves.
X	If this value is .5, each turn (resources willing) your population
X	will increase by 1.5.
X
X# of sexes -- This is the minimum population a planetary sector must have
X	before the population will increase.  Colonies with fewer than this
X	amount will not be successful.  Example: human beings must have at
X	least two members to be a successful colony, while members of the
X	Cetellan race ("Literature", by Robert Chansky, in 
X	~smq/public/alien.pornography) must have at least 35.
X
XTechnology -- This represents the technological achievement of your people.
X	Certain types of ships cannot be built without the appropriate
X	technology.
X
XAvg Intelligence -- This is the average IQ (human standard scale) of the
X	members of your race.  Technology will increase by IQ/100 each turn.
X
XMass -- The average weight of individual members of your race (in Standard 
X	Units).  This is used in mass exchanges in ships (i.e., a heavier
X	ship moves more slowly for the same amount of fuel) in the ``load''
X	command.
X
XMetabolism -- The speed at which your race ``operates''.  A higher metabolism
X	means your race produces commodities at a correspondingly higher
X	rate.
X
XAdventurists -- This has to do with migration of your race across the 
X	face of a planet.  It represents the percentage of the population
X	that wish to move elsewhere.  More sedentary races will have
X	a lower value, while energetic, conquering races (like 'The Thing')
X	will have a higher value.
X
Xdefault scope -- The scope changed to when the user types ``cs''.
X
Xplanetary conditions -- This is a list of the atmospheric and temperature
X	conditions perferred by your race.  A planet that deviates from
X	these conditions by a sufficient amount will be unlivable by your
X	race.  Planetary conditions are displayed with the ``survey'' command.
X
XRelations with other races -- The current relations with each player is
X	displayed: neutrality, alliance, or war.
X
X
X
XSEE ALSO
X  build, load, cs, survey, declare
X
END_OF_FILE
if test 2610 -ne `wc -c <'Docs/profile.doc'`; then
    echo shar: \"'Docs/profile.doc'\" unpacked with wrong size!
fi
# end of 'Docs/profile.doc'
fi
if test -f 'Docs/scope.doc' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Docs/scope.doc'\"
else
echo shar: Extracting \"'Docs/scope.doc'\" \(1569 characters\)
sed "s/^X//" >'Docs/scope.doc' <<'END_OF_FILE'
Xscope			Galactic Bloodshed			scope
X
X
XCONCEPT: scope
X
X  Scope represents the ``operative scope'' of certain commands.  The
Xoperative scope (displayed along with AP's in the user's prompt, and changed
Xwith ``cs'') is similar to the tree-like directory level structure found in
Xmost computer systems, with the ``root'' directory being a ``universal''
Xscope followed by the various stars followed by the planets orbiting these
Xstars.  The scope can also represent a single ship.
X
X  Commands are effected by the scope in a different manner than that which
Xmost operating systems treat their directory structure.  For example, if
Xthe current scope is that of a star, the command ``navigate'', if given with
Xno arguments, will prompt for a destination for each ship orbiting that
Xstar and each planet in that system.  If the scope was the ``universal''
Xscope, navigate would prompt for each ship everywhere that the player
Xowns.
X
X  Many commands will not work at all in certain scopes.
X
X  The syntax of a scope, when prompted for, is thus:
X
X	path = ``:'' | ``#shipnum'' | ``/path'' | ``../path'' | name | 
X		 ``path/name''
X
X  The shell will interpret a ``:'' as meaning the object of the current
Xscope (star, planet, ship, etc).
X
X  A ``/'' at the beginning of the string represents the root.
X
X  A ``..'' or ``.'' represents the scope just above the current scope.
X
X  ``#shipnum'' represents that ship.  A number by itself will be
Xinterpreted as meaning a star or planet name.
X
X  Specifying a name means to move to that star or planet.
X
X
XSEE ALSO
X  cs, navigate, actionpoints
X
END_OF_FILE
if test 1569 -ne `wc -c <'Docs/scope.doc'`; then
    echo shar: \"'Docs/scope.doc'\" unpacked with wrong size!
fi
# end of 'Docs/scope.doc'
fi
if test -f 'Docs/survey.doc' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Docs/survey.doc'\"
else
echo shar: Extracting \"'Docs/survey.doc'\" \(2497 characters\)
sed "s/^X//" >'Docs/survey.doc' <<'END_OF_FILE'
XSURVEY			Galactic Bloodshed			SURVEY
X
X
XNAME
X  [0] survey -- more detailed survey of planet, sector, ship, star
X
XSYNOPSIS
X	survey [xlow:xhi,ylow:yhi]
X
XDESCRIPTION
X  survey gives a different report depending on what scope it is used on.
XThe possible scopes are ship, planet, and star.
X
XCensus on sector
X
X   x,y des eff mob frt res popn ^popn
X   5,7  x   20  50  45  25  80   196
X
X  x,y: map coordinates on sector
X  des: designation of sector (land, water, etc)
X  eff: efficiency (%age it is built up) of the sector
X  mob: % mobilization of the citizens in that sector
X  frt: fertility of the sector (supports people)
X  res: resource deposits in the sector
X  popn: population of the sector
X  ^popn: maximum population the sector can support
X
XCensus on planet
X
X   gravity   x,y absolute     x,y relative to Sol
X    1.00     -24222,5424           -324,755
X
X  gravity: gravity of the planet (relative to Earth normal)
X  x,y absolute: coordinates relative to the Center of the Universe
X  x,y relative..: coordinates relative to the planet's primary
X
X  	======== planetary conditions: ========
X  Gives the atmospheric concentrations of certain key elements in the
X    planet's atmosphere: Oxygen, CO2, Methane, Hydrogen, Nitrogen, Helium,
X    Sulfur, surface temperature, normal temperature (without artificial
X    influencing factors like space mirrors), and 'Other'.  The 'Total 
X    planetary compatibility' is the difference between the weighted sum 
X    of each of these characteristics and the preferences of the player 
X    (expressed in parentheses after each characteristic).
X
X  fuel_stock  resource_stock dest_pot.   popltn    ^popltn
X      173             92       101       1158       2901
X
X  x,y: the x,y coordinates of the planet relative to its star
X  fuel_stock: fuel the player has managed to stockpile on the planet
X  resource_stock: stockpiled resources on the planet
X  dest_pot: stockpiled destructive potential on the planet (weapons)
X  popltn: total population of living beings
X  ^popltn: maximum number of living beings the planet can support
X	(inhabited sectors only)
X
XCensus on star
X
X  Locn: x,y coordinates of the star from the Center of the Universe
X  gravity: gravitational influence
X  stability: Stability of the star.  As stability approaches 100, the star
X	will become more and more unstable.  The player must have a technology
X	of 3 or more to determine the stability.
X
X
XCensus on ship #n
X
X   Same as the command 'ship #n'
X
XSEE ALSO
X   ship, report, map, weapons, mobilize
END_OF_FILE
if test 2497 -ne `wc -c <'Docs/survey.doc'`; then
    echo shar: \"'Docs/survey.doc'\" unpacked with wrong size!
fi
# end of 'Docs/survey.doc'
fi
if test -f 'GB.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'GB.c'\"
else
echo shar: Extracting \"'GB.c'\" \(2079 characters\)
sed "s/^X//" >'GB.c' <<'END_OF_FILE'
X/*
X * Galactic Bloodshed (Robert Chansky, smq@b)
X *	GB.c --
X *	  main loop, prints instructions, grabs command line from 
X *	  standard output, executes command.
X */
X
X
X#include "vars.h"
X#include "races.h"
X#include <curses.h>
X#include <sys/stat.h>
Xstruct stat buf;
X#include <signal.h>
X#include <strings.h>
X#include <pwd.h>
Xstruct passwd *passwd;
X#include <setjmp.h>
Xjmp_buf main_jenv;
Xint God = 0;
X
Xextern char telegram_file[50];
X
Xmain()
X{
Xint notified=0,s,i;
Xchar c,commstr[MAXCOMMSTRSIZE];
Xint maim_handler();
Xint maim_stardata;
X
X
X	setegid(PLAYER_GROUP_ID);
X
X	srandom(getpid());
X	initscr();
X
X	printf("Galactic Bloodshed ver %s\ntype 'help' for help.\n", VERS);
X
X	openstardata(&maim_stardata);
X	  getsdata(maim_stardata,&Sdata);
X
X	for (s=0; s<Sdata.numstars; s++)
X		getstar(maim_stardata,&(Stars[s]),s);
X	close(maim_stardata);
X
X	passwd = getpwuid(geteuid());
X	if (!strcmp(passwd->pw_name, PLAYER_GOD)) {
X		God = 1;
X		printf("Login as what player? ");
X		scanf("%s",commstr);
X		getchr();
X	} else sprintf(commstr,"%s", getlogin() );
X	i = Getracenum(commstr);
X
X	if (!i) enroll(commstr);
X	 else getrace(&Race,i);
X	Playernum = Race->Playernum;
X	if (God)
X		printf("Logging in as player %d.\n",Playernum);
X
X	docommand("cs");	/* chdir to home scope */
X	Dir.zoom = 1.0;
X
X	setjmp(main_jenv);	/* set up environment for jump if error */
X
X	sprintf(telegram_file, "%s.%d", TELEGRAMFL, Playernum);
X		  /* used in several routines, + each csh command */
X
X	do  {
X	    signal(SIGINT, maim_handler );
X
X	    stat(telegram_file, &buf);
X	    if (buf.st_size > notified) {
X		  printf("\nYou have telegram(s) waiting.\n\n");
X		  notified = buf.st_size;
X	    }
X
X	    printf("%s",Dir.prompt);
X	    i = 0;
X	    while ((c=getchr()) != '\n' && i<MAXCOMMSTRSIZE)
X	         commstr[i++] = c;
X	    commstr[i] = '\0';
X	    if (*commstr==EOF) {
X		clearerr(stdin);
X		*commstr = '\0';
X	    }
X
X	} while (docommand(commstr));
X
X	endwin();
X
X
X/*	printf("\nhalelujah!\n\n");*/
X}
X
Xmaim_handler(sig, code/*, scp*/)
Xint sig,code;
X/*void *scp;	/* supposed to be struct sigcontext */
X{
X putchar('\n');
X longjmp(main_jenv,1);
X}
END_OF_FILE
if test 2079 -ne `wc -c <'GB.c'`; then
    echo shar: \"'GB.c'\" unpacked with wrong size!
fi
# end of 'GB.c'
fi
if test -f 'MANIFEST.BAK' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'MANIFEST.BAK'\"
else
echo shar: Extracting \"'MANIFEST.BAK'\" \(3134 characters\)
sed "s/^X//" >'MANIFEST.BAK' <<'END_OF_FILE'
X   File Name		Archive #	Description
X-----------------------------------------------------------
X Docs                       1	
X Docs/actionpoints.doc      7	
X Docs/assault.doc           7	
X Docs/autoreport.doc        5	
X Docs/build.doc             6	
X Docs/cs.doc                7	
X Docs/declare.doc           6	
X Docs/dock.doc              7	
X Docs/examine.doc           7	
X Docs/fire.doc              7	
X Docs/help.doc              6	
X Docs/land.doc              7	
X Docs/launch.doc            7	
X Docs/load.doc              7	
X Docs/makeuniv.doc          7	
X Docs/map.doc               5	
X Docs/mobilize.doc          7	
X Docs/name.doc              7	
X Docs/object.doc            7	
X Docs/orbit.doc             6	
X Docs/order.doc             6	
X Docs/overview.doc          2	
X Docs/profile.doc           6	
X Docs/read.doc              6	
X Docs/report.doc            7	
X Docs/scope.doc             6	
X Docs/scrap.doc             7	
X Docs/ship.doc              7	
X Docs/stock.doc             7	
X Docs/survey.doc            6	
X Docs/tactical.doc          7	
X Docs/telegram.doc          7	
X Docs/undock.doc            7	
X Docs/zoom.doc              6	
X GB.6                       3	
X GB.c                       6	
X MANIFEST                   1	
X Makefile                   5	
X README                     1	
X autoreport.c               6	
X autoshoot.c                6	
X build.c                    4	
X cs.c                       5	
X daemon.c                   7	
X declare.c                  6	
X docommand.c                5	
X doplanet.c                 1	
X dosector.c                 3	
X doship.c                   1	
X doturn.c                   4	
X doturn.h                   7	
X enrol.c                    5	
X exam.dat                   5	
X examine.c                  7	
X files.h                    7	
X files_rw.c                 1	
X files_shl.c                3	
X fire.c                     2	
X fix.c                      2	
X get4args.c                 7	
X getplace.c                 4	
X help.c                     7	
X land.c                     3	
X launch.c                   6	
X load.c                     3	
X makeplanet.c               2	
X makeuniv.c                 4	
X map.c                      5	
X max.c                      6	
X misc.c                     7	
X mobiliz.c                  6	
X more.c                     6	
X moveship.c                 3	
X name.c                     5	
X orbit.c                    1	
X order.c                    2	
X overview.nr                5	
X perm.c                     7	
X planet.list                4	
X power.c                    7	
X power.h                    7	
X prof.c                     6	
X races.h                    7	
X rand.c                     7	
X read_teleg.c               4	
X rst.c                      4	
X scrap.c                    6	
X shipdata.h                 6	
X ships.h                    5	
X shlmisc.c                  5	
X shootblast.c               4	
X sizes.c                    7	
X survey.c                   3	
X teleg_send.c               6	
X telegram.c                 6	
X tweakables.h               4	
X vars.h                     5	
X zoom.c                     7	
END_OF_FILE
if test 3134 -ne `wc -c <'MANIFEST.BAK'`; then
    echo shar: \"'MANIFEST.BAK'\" unpacked with wrong size!
fi
# end of 'MANIFEST.BAK'
fi
if test -f 'autoreport.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'autoreport.c'\"
else
echo shar: Extracting \"'autoreport.c'\" \(1811 characters\)
sed "s/^X//" >'autoreport.c' <<'END_OF_FILE'
X
X/*
X * Galactic Bloodshed (Robert Chansky, smq@b)
X * autoreport.c -- tell server to generate a report for each planet
X */
X
X#include "vars.h"
X#include "tweakables.h"
X#include "ships.h"
X
Xautoreport(APcount, argn,args)
Xint APcount;
Xint argn;
Xchar args[MAXARGS][COMMANDSIZE];
X{
Xplanettype *p;
Xplacetype place;
Xint autoreport_pdata,autoreport_sectdata;
X
Xif (argn==1) {   /* no args */
X if (Dir.level==LEVEL_PLAN) {
X  openpdata(&autoreport_pdata);
X  getplanet(autoreport_pdata,&p,Stars[Dir.snum]->planetpos[Dir.pnum]);
X  if (p->info[Playernum-1].autorep)
X	p->info[Playernum-1].autorep = 0;
X  else
X	p->info[Playernum-1].autorep = TELEG_MAX_AUTO;
X
X  putplanet(autoreport_pdata, p, Stars[Dir.snum]->planetpos[Dir.pnum]);
X  close(autoreport_pdata);
X  printf("Autoreport on %s is now %s.\n",Stars[Dir.snum]->pnames[Dir.pnum],
X	p->info[Playernum-1].autorep ? "on" : "off");
X  free(p);
X /* } else if (Dir.level==LEVEL_SHIP) {
X  openshdata(&autoreport_shdata);
X  getship(autoreport_shdata, [ ship-> autoreport field not specified yet]
X  */
X } else {
X	  printf("scope must be a planet or ship.\n");
X	  return(1);
X   	}
X} else if (argn==2) {     /* argn==2, place specified */
X  place = Getplace(args[1], 0);
X  if (place.level==LEVEL_PLAN) {
X     openpdata(&autoreport_pdata);
X     getplanet(autoreport_pdata,&p,Stars[Dir.snum]->planetpos[Dir.pnum]);
X     printf("Autoreport on %s is now %s.\n",Stars[Dir.snum]->pnames[Dir.pnum],
X	  p->info[Playernum-1].autorep ? "on" : "off");
X     p->info[Playernum-1].autorep = !p->info[Playernum-1].autorep;
X     putplanet(autoreport_pdata, p, Stars[Dir.snum]->planetpos[Dir.pnum]);
X     close(autoreport_pdata);
X     free(p);
X } else {
X	  printf("scope must be a planet or ship.\n");
X	  return(1);
X   	}
X } else if (argn>2) {
X 	printf("autoreport: error in args.\n");
X	return(1);
X   }
X
X}
END_OF_FILE
if test 1811 -ne `wc -c <'autoreport.c'`; then
    echo shar: \"'autoreport.c'\" unpacked with wrong size!
fi
# end of 'autoreport.c'
fi
if test -f 'autoshoot.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'autoshoot.c'\"
else
echo shar: Extracting \"'autoshoot.c'\" \(2512 characters\)
sed "s/^X//" >'autoshoot.c' <<'END_OF_FILE'
X/*
X * Galactic Bloodshed (Robert Chansky, smq@b)
X * autoshoot() -- shoot <-> retaliate routine
X * Bombard() -- ship bombards planet
X */
X
X
X#include "vars.h"
X#include "ships.h"
X#include "races.h"
Xextern int Shipdata[NUMSTYPES][NUMABILS];
Xextern bool Nuked[MAXPLAYERS];	/* who was nuked on the planet/ship */
Xextern char telegram_buf[];
Xextern racetype *races[];
X
X
X/* ship #shipno bombards planet, then sends telegrams alerting whom it
X *	may concern.
X */
XBombard(ship,shipno,planet)
Xshiptype *ship;
Xplanettype *planet;
X{
Xint x,y,oldown,radius,found=0;
Xchar buf[200];
X
X /* look for someone to bombard-check for war */
X  Getxysect(planet,0,0,1);	/* reset */
X  while (Getxysect(planet,&x,&y,0) && !found)
X	if (isset(races[ship->owner]->atwar, Sector(*planet,x,y).owner))
X		found=1;
X  if (!found) {
X   /* no one we are at war with. find someone neutral
X      (owner 0 will work, too, but not already bombed)*/
X    Getxysect(planet,0,0,1);	/* reset */
X    while (Getxysect(planet,&x,&y,0) && !found)
X	if (isclr(races[ship->owner]->allied, Sector(*planet,x,y).owner) && Sector(*planet,x,y).owner!=ship->owner && Sector(*planet,x,y).popn>0)
X		found=1;
X  }
X  if (found) {
X    oldown = Sector(*planet,x,y).owner;
X	/* do some bombarding here... */
X    teleg_add("",telegram_buf);
X    sprintf(buf,"REPORT: ship #%d\n",shipno);
X    teleg_add(buf,telegram_buf);
X    sprintf(buf,"%s #%d reports bombing of planet /%s/%s,\n",Shipnames[ship->type],x,Stars[ship->storbits]->name,Stars[ship->storbits]->pnames[ship->pnumorbits]);
X    teleg_add(buf,telegram_buf);
X    sprintf(buf,"sector %d,%d (owner %d) for a blast radius of %d.\n",x,y,oldown,radius);
X    teleg_add(buf,telegram_buf);
X    teleg_send(TELEG_PLAYER_AUTO, ship->owner, telegram_buf);
X    teleg_add("",telegram_buf);
X    sprintf(buf,"ALERT from planet /%s/%s\n",Stars[ship->storbits]->name,Stars[ship->storbits]->pnames[ship->pnumorbits]);
X    teleg_add(buf,telegram_buf);
X    sprintf(buf,"%s #%d Bombarded sector %d,%d for a blast radius of %d.\n",Shipnames[ship->type],shipno,x,y,radius);
X    teleg_add(buf,telegram_buf);
X    teleg_send(TELEG_PLAYER_AUTO, oldown, telegram_buf);
X  } else {
X    teleg_add("",telegram_buf);
X    sprintf(buf,"Report from %s #%d\n",Shipnames[ship->type],shipno);
X    teleg_add(buf,telegram_buf);
X    sprintf(buf,"Planet /%s/%s has been saturation bombed.\n",Stars[ship->storbits]->name,Stars[ship->storbits]->pnames[ship->pnumorbits]);
X    teleg_add(buf,telegram_buf);
X    teleg_send(TELEG_PLAYER_AUTO, ship->owner, telegram_buf);
X  }
X
X}
END_OF_FILE
if test 2512 -ne `wc -c <'autoshoot.c'`; then
    echo shar: \"'autoshoot.c'\" unpacked with wrong size!
fi
# end of 'autoshoot.c'
fi
if test -f 'declare.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'declare.c'\"
else
echo shar: Extracting \"'declare.c'\" \(1876 characters\)
sed "s/^X//" >'declare.c' <<'END_OF_FILE'
X/* 
X** Galactic Bloodshed (Robert Chansky, smq@b)
X** declare.c -- declare alliance, neutrality, war, the basic thing.
X*/
X
X#include "vars.h"
X#include "races.h"
X#include <signal.h>
X#include <ctype.h>
X#include <setjmp.h>
Xextern jmp_buf main_jenv;
X
Xdeclare(APcount, argn,args)
Xint APcount;
Xint argn;
Xchar args[MAXARGS][COMMANDSIZE];
X{
Xvoid declare_handler();
Xchar str[RNAMESIZE];
Xracetype *alien;
Xint n;
X
X   signal(SIGINT, declare_handler);
X
X     /* look in sdata for APs first */
X   if (Sdata.AP[Playernum] >= APcount)  /* enufAPs would print something */
X	   deductAPs(APcount, 0, 1);
X     /* otherwise use current star */
X   else if (Dir.level==LEVEL_STAR && Dir.level==LEVEL_PLAN) {
X       if (enufAP(Stars[Dir.snum]->AP, APcount) )
X	   deductAPs(APcount, Dir.snum, 0);
X   } else {
X	   printf("You don't have enough AP's (%d)\n",APcount);
X	   declare_handler();
X   }
X
X   printf("declare with which player? ");
X   scanf("%25[^\n]", str);
X   getchr();
X   GetPlayer(str, &n, &alien);
X   if (n == -1) {
X	printf("No such player.\n");
X	return;
X   }
X
X   printf("declare alliance, neutrality, or war on %s (%d)? ", alien->name, n);
X   scanf("%25s",str);
X
X   switch (*str) {
X	case 'a':
X		setbit(Race->allied, n);
X		clrbit(Race->atwar, n);
X		if (int_rand(0,100) >= 96)
X			printf("But would you want your sister to marry one?\n");
X		else
X			printf("Good for you.\n");
X		break;
X	case 'n':
X		clrbit(Race->allied, n);
X		clrbit(Race->atwar, n);
X		printf("Done.\n");
X		break;
X	case 'w':
X		setbit(Race->atwar, n);
X		clrbit(Race->allied, n);
X		if (int_rand(0,100) >= 96)
X			printf("Your enemies flaunt their secondary male reproductive glands in your\ngeneral direction.\n");
X		else
X			printf("Give 'em hell!\n");
X		break;
X	default:
X		declare_handler();
X		break;
X   }
X   putrace(Race);
X
X}
X
X
X
Xvoid declare_handler(sig, code, scp)
Xint sig,code;
Xstruct sigcontext *scp;
X{
X longjmp(main_jenv,1);
X}
END_OF_FILE
if test 1876 -ne `wc -c <'declare.c'`; then
    echo shar: \"'declare.c'\" unpacked with wrong size!
fi
# end of 'declare.c'
fi
if test -f 'launch.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'launch.c'\"
else
echo shar: Extracting \"'launch.c'\" \(3227 characters\)
sed "s/^X//" >'launch.c' <<'END_OF_FILE'
X
X
X/*
X * Galactic Bloodshed (Robert Chansky, smq@b)
X *  launch.c -- launch or undock a ship
X */
X
X#include "vars.h"
X#include "ships.h"
X#include <setjmp.h>
Xextern jmp_buf main_jenv;
X#include <signal.h>
Xextern char Shipltrs[];
Xextern char *Shipnames[];
X
Xint launch_shdata,launch_pdata;
X
X
Xlaunch(APcount, argn,args)
Xint APcount;
Xint argn;
Xchar args[MAXARGS][COMMANDSIZE];
X{
Xint launch_handler();
Xshiptype *s;
Xplanettype *p;
Xbool planet=0;
Xint shipno,o;
Xfloat fuel;
X
Xlaunch_shdata = launch_pdata = NEUTRAL_FD;
Xsignal(SIGINT, launch_handler);
X
X  if (argn!=2) {
X	printf("Launch what ship #");
X	scanf("%d",&shipno);
X	getchr();
X  } else {
X	o = (args[1][0]=='#');
X	sscanf(args[1]+o,"%d",&shipno);
X  }
X  openshdata(&launch_shdata);
X  if (!getship(launch_shdata, &s, shipno)) {
X	launch_handler();
X  }
X  if (s->owner!=Playernum) {
X	DontOwnErr(shipno);
X	launch_handler();
X  }
X  if (!can_move(s)) {
X	printf("One of those cannot be launched.\n");
X	launch_handler();
X  }
X  if (s->rad) {
X	printf("%s irradiated and inactive.\n", Shipnames[s->type]);
X	launch_handler();
X  }
X  if (!enufAP(Stars[s->storbits]->AP, APcount)) 
X	land_handler();
X  if (!s->is_docked) {
X	printf("Ship #%d is not landed or docked.\n",shipno);
X	launch_handler();
X  }
X
X  s->is_docked = 0;
X  s->whatdest = LEVEL_UNIV;	/* no destination */
X
X  /* if (s->whatdest==LEVEL_SHIP) {
X  	if (s->whatorbits==LEVEL_UNIV)
X  		deductAPs(APcount, 0, 1);
X  	else
X  		deductAPs(APcount, s->storbits, 0);
X     } else { */
X
X  planet = 1;
X	/* adjust x,ypos to absolute coords */
X  openpdata(&launch_pdata);
X  getplanet(launch_pdata, &p, Stars[s->storbits]->planetpos[s->pnumorbits]);
X  if (p->is_explored)		/* no alteration of the planet unless this.. */
X  	close(launch_pdata);
X
X  printf("Planet /%s/%s has gravity field of %.2f\n", Stars[s->storbits]->name,
X	Stars[s->storbits]->pnames[s->pnumorbits], gravity(p));
X   /* alter sector location of ship x,y to stellar coords x,y */
X  s->xpos = Stars[s->storbits]->xpos + p->xpos + 
X				int_rand(-DIST_TO_LAND/2,DIST_TO_LAND/2);
X  s->ypos = Stars[s->storbits]->ypos + p->ypos + 
X				int_rand(-DIST_TO_LAND/2,DIST_TO_LAND/2);
X
X   /* subtract fuel from ship */
X  fuel = gravity(p) * s->mass * LAUNCH_GRAV_MASS_FACTOR;
X  if (s->fuel < fuel) {
X	printf("Ship #%d does not have enough fuel! (%.1f)\n",shipno, fuel);
X	launch_handler();
X  }
X  s->fuel -= fuel;
X  s->mass -= fuel * MASS_FUEL;
X
X  deductAPs(APcount, s->storbits, 0);
X
X  free(p);
X /* } */
X  if (s->type == OTYPE_CANIST)
X	s->orders.object.number = 20;	/* canister dissapates after 20 turns */
X
X  putship(launch_shdata, s, shipno);
X  close(launch_shdata);
X
X  if (!p->is_explored) {
X		/* not yet explored by owner; space exploration causes the
X		   player to see a whole map */
X	p->is_explored = 1;
X  	putplanet(launch_pdata,p,Stars[s->storbits]->planetpos[s->pnumorbits]);
X  	close(launch_pdata);
X  }
X
X  if (planet)
X  	printf("%s #%d launched from planet,", Shipnames[s->type], shipno);
X  else
X	printf("%s #%d undocked from ship,", Shipnames[s->type], shipno);
X  printf(" using %.1f fuel.\n",fuel);
X  if (s->type == OTYPE_CANIST)
X	printf("A thick cloud of dust envelops your planet.\n");
X
X  free(s);
X}
X
X
Xlaunch_handler()
X{
X close(launch_pdata);
X close(launch_shdata);
X longjmp(main_jenv,1);
X}
END_OF_FILE
if test 3227 -ne `wc -c <'launch.c'`; then
    echo shar: \"'launch.c'\" unpacked with wrong size!
fi
# end of 'launch.c'
fi
if test -f 'max.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'max.c'\"
else
echo shar: Extracting \"'max.c'\" \(1577 characters\)
sed "s/^X//" >'max.c' <<'END_OF_FILE'
X/*
X * Galactic Bloodshed (Robert Chansky, smq@b)
X * max() -- return how many people one sector can support
X * Distmap() -- map-oriented distance that does not look square
X * compatibility() -- return how much race is compatible with planet
X * gravity() -- return gravity for planet
X * prin_ship_orbits() -- prints place ship orbits
X */
X
X#include "vars.h"
X#include "races.h"
X#include "ships.h"
X#include <math.h>
X
Xint maxsupport(p)
Xregister sectortype *p;
X{
X return(
X	(int)(powscale(p->eff)*FACTOR_FERT_SUPPORT*p->fert+p->fert + 1)
X       );
X}
X
X
X
Xint Distmap(x,y,x2,y2)
Xregister int x,y,x2,y2;
X{
X return( round_rand(fabs((double)x-x2) + fabs( (double)y-y2)*(RATIOXY*0.5) ) );
X}
X
X
Xfloat compatibility(planet, race)
Xplanettype *planet;
Xracetype *race;
X{
X register int i,add;
X register float sum=1.0;
X
X	/* step through and report compatibility of each planetary gas */
X  for (i=TEMP; i<=OTHER; i++) {
X	add = ((float)planet->conditions[i] - race->conditions[i]);
X	sum *= 1.0 - (abs(add)/100.0);
X  }
X  return sum * (100-planet->conditions[TOXIC]);
X
X}
X
X
X
Xfloat gravity(p)
Xplanettype *p;
X{
X return (float)p->Maxx * p->Maxy * GRAV_FACTOR;
X}
X
X
X
Xchar Dispshiporbits_buf[PLACENAMESIZE+13];
X
Xchar *prin_ship_orbits(s)
Xshiptype *s;
X{
X
X  switch (s->whatorbits) {
X	case LEVEL_UNIV:
X		sprintf(Dispshiporbits_buf,"-");
X		break;
X	case LEVEL_STAR:
X		sprintf(Dispshiporbits_buf,"/%s", Stars[s->storbits]->name);
X		break;
X	case LEVEL_PLAN:
X		sprintf(Dispshiporbits_buf,"/%s/%s", 
X			Stars[s->storbits]->name,
X			Stars[s->storbits]->pnames[s->pnumorbits]);
X		break;
X  }
X  return Dispshiporbits_buf;
X}
END_OF_FILE
if test 1577 -ne `wc -c <'max.c'`; then
    echo shar: \"'max.c'\" unpacked with wrong size!
fi
# end of 'max.c'
fi
if test -f 'mobiliz.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mobiliz.c'\"
else
echo shar: Extracting \"'mobiliz.c'\" \(1973 characters\)
sed "s/^X//" >'mobiliz.c' <<'END_OF_FILE'
X/*
X * Galactic Bloodshed (Robert Chansky, smq@b)
X * mobilize.c -- persuade people to build military stuff.
X *    Sectors that are mobilized produce Destructive Potential in
X *    proportion to the % they are mobilized.  they are also more
X *    damage-resistant.
X */
X
X#include "vars.h"
X#include <signal.h>
X#include <setjmp.h>
X#include <ctype.h>
Xextern jmp_buf main_jenv;
Xint mobilize_sectdata,mobilize_pdata;
X
Xmobilize(APcount, argn, args)
Xint APcount, argn;
Xchar args[MAXARGS][COMMANDSIZE];
X{
Xint owned=0,x,y,sum_mob=0;
Xsectortype *s;
Xplanettype *p;
Xint mobilize_handler();
X
Xmobilize_pdata = mobilize_sectdata = NEUTRAL_FD;
Xsignal(SIGINT, mobilize_handler);
X
Xif (argn>1) {
X	printf("usage: mobilize\n");
X	return;
X}
Xif (Dir.level!=LEVEL_PLAN) {
X	printf("scope must be a planet.\n");
X	return;
X}
Xif (!enufAP(Stars[Dir.snum]->AP, APcount))
X	mobilize_handler();
X
X openpdata(&mobilize_pdata);
X getplanet(mobilize_pdata,&p,Stars[Dir.snum]->planetpos[Dir.pnum]);
X
X
X opensectdata(&mobilize_sectdata);
X getsmap(mobilize_sectdata,Smap,p->sectormappos,p->Maxx*p->Maxy);
X close(mobilize_sectdata);
X
X
X for (y=0; y<p->Maxy; y++)
X   for (x=0; x<p->Maxx; x++) {
X	s = &Sector(*p,x,y);
X	if (s->owner==Playernum) {
X		sum_mob += s->mobilization;
X		owned++;
X	}
X    }
X
X p->info[Playernum-1].numsectsowned = owned;
X
X printf("(cost:%.3f resource points / 1 mobilization pt.)\n", MOB_COST);
X printf("Number of sectors owned: %d.\n",owned);
X printf("   Average mobilization: %.1f.\n",(float)sum_mob / owned);
X printf(" Old mobilization quota: %u.\n",p->info[Playernum-1].mob_set);
X printf("              New quota: ");
X
X if ( isdigit(x=getchr())) {
X	ungetc(x,stdin);
X	scanf("%d",&sum_mob);
X	getchr();
X	p->info[Playernum-1].mob_set = sum_mob;
X	putplanet(mobilize_pdata,p,Stars[Dir.snum]->planetpos[Dir.pnum]);
X }
X close(mobilize_pdata);
X
X free(p);
X
X}
X
Xmobilize_handler(sig, code, scp)
Xint sig,code;
Xstruct sigcontext *scp;
X{
X close(mobilize_pdata);
X close(mobilize_sectdata);
X longjmp(main_jenv,1);
X}
END_OF_FILE
if test 1973 -ne `wc -c <'mobiliz.c'`; then
    echo shar: \"'mobiliz.c'\" unpacked with wrong size!
fi
# end of 'mobiliz.c'
fi
if test -f 'more.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'more.c'\"
else
echo shar: Extracting \"'more.c'\" \(1655 characters\)
sed "s/^X//" >'more.c' <<'END_OF_FILE'
X
X#include <stdio.h>
X#include <sys/file.h>
X#include <sgtty.h>
X
X
Xchar *doc_directory = "/b/o/therat/k";
X
Xmain(c, v)
Xint c;
Xchar **v;
X{
X	while (*(++v))
X		doc(*v);
X}
X
Xdoc(s)
Xchar *s;
X{
X	char filename[128], tmpfile[128];
X	int fd, pid;
X	long t;
X
X	sprintf(filename, "%s/%s.Z", doc_directory, s);
X	/* could stat the file here to make sure it's there */
X
X	time(&t);
X	sprintf(tmpfile, "/usr/tmp/#GBtrash%05d", (t >> 4) & 0x7fff);
X	fd = open(tmpfile, O_CREAT | O_WRONLY | O_TRUNC, 0600);
X	if (fd < 0) {
X		fprintf(stderr, "doc(): %s: ", filename);
X		perror("open failed");
X		return;
X	}
X
X	switch (pid = fork()) {
X		case -1 :
X			perror("doc(): fork for zcat failed");
X			break;
X
X		case 0 :
X			dup2(fd, 1);
X			execl("/usr/ucb/zcat", "zcat", filename, 0);
X			perror("doc(): execl for zcat failed");
X
X		default :
X			while (wait(0) != pid)
X				;
X	}
X
X	close(fd);
X	page(tmpfile);
X	unlink(tmpfile);
X}
X
Xpage(file)
Xchar *file;
X{
X	char buf[4096];
X	FILE *fp;
X	int line;
X
X	fp = fopen(file, "r");
X	if (!fp) {
X		fprintf(stderr, "page(): %s: ", file);
X		perror("open failed");
X		return;
X	}
X
X	while (fgets(buf, sizeof(buf), fp)) {
X		++line;
X		fputs(buf, stdout);
X		if (line == 23) {
X			char ch;
X
X			fputs(" -- more -- ", stdout);
X			fflush(stdout);
X			do
X				ch = get_a_char();
X			while (ch != ' ');
X			fputs("\b\b\b\b\b\b\b\b\b\b\b\b            \b\b\b\b\b\b\b\b\b\b\b\b", stdout);
X			line = 0;
X		}
X	}
X	fclose(fp);
X}
X
Xget_a_char()
X{
X	struct sgttyb foo, bar;
X	char c;
X
X	ioctl(0, TIOCGETP, &foo);
X	bar = foo;
X	foo.sg_flags |= CBREAK;
X	foo.sg_flags &= ~ECHO;
X	ioctl(0, TIOCSETN, &foo);
X
X	c = getchar();
X/* 	while (!read(0, &c, 1)) */
X/* 		; */
X
X
X	ioctl(0, TIOCSETN, &bar);
X
X	return c;
X}
X
END_OF_FILE
if test 1655 -ne `wc -c <'more.c'`; then
    echo shar: \"'more.c'\" unpacked with wrong size!
fi
# end of 'more.c'
fi
if test -f 'perm.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'perm.c'\"
else
echo shar: Extracting \"'perm.c'\" \(988 characters\)
sed "s/^X//" >'perm.c' <<'END_OF_FILE'
X
X/*
X * Galactic Bloodshed (Robert Chansky, smq@ucscb.ucsc.edu)
X * perm.c -- randomly permute a sector list
X */
X
X#include "vars.h"
X
Xstruct map {
X	char x,y;
X} xymap[(MAX_X+1) * (MAX_Y+1)];
X
X
X/* make a random list of sectors. */
XPermuteSects(planet)
Xplanettype *planet;
X{
Xregister int i,j,x,y;
Xstruct map sw;
X
X  for (i=x=y=0; i < planet->Maxy*planet->Maxx; i++) {
X	xymap[i].x = x;
X	xymap[i].y = y;
X	if (++x >= planet->Maxx)
X		x=0,y++;
X  }
X  for (i=0; i<planet->Maxy*planet->Maxx; i++) {
X  	sw = xymap[i];
X	xymap[i] = xymap[j = int_rand(0,planet->Maxy*planet->Maxx - 1)];
X	xymap[j] = sw;
X  }
X
X}
X
X
X/* get the next x,y sector in the list.  if r=1, reset the counter.
X**  increments the counter & returns whether or not this reset it to 0.
X*/
X
Xint Getxysect(p,x,y,r)
Xreg planettype *p;
Xreg int *x,*y,r;
X{
X  static int getxy,max;
X
X  if (r) {
X	getxy = 0;
X	max = p->Maxx * p->Maxy;
X  } else {
X	  *x = xymap[getxy].x;
X	  *y = xymap[getxy].y;
X	  if (++getxy > max)
X		getxy = 0;
X  }
X  return getxy;
X}
END_OF_FILE
if test 988 -ne `wc -c <'perm.c'`; then
    echo shar: \"'perm.c'\" unpacked with wrong size!
fi
# end of 'perm.c'
fi
if test -f 'prof.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'prof.c'\"
else
echo shar: Extracting \"'prof.c'\" \(1760 characters\)
sed "s/^X//" >'prof.c' <<'END_OF_FILE'
X
X/*
X * Galactic Bloodshed (Robert Chansky, smq@b)
X * prof.c -- print out racial profile
X */
X
X#include "vars.h"
X#include "races.h"
X
Xprofile(APcount, argn,args)
Xint APcount;
Xint argn;
Xchar args[MAXARGS][COMMANDSIZE];
X{
X int i, numraces;
X
X
X printf("---==** Racial profile for %s (player %d) **==---\n\n",Race->name,
X		Race->Playernum);
X if (Race->Thing)
X	printf("Your race is like \"The Thing\".\n");
X printf("%srate:%.1f\n",Race->Thing ? "Infection " : "Birth",Race->birthrate);
X printf("# of sexes: %d\n", Race->number_sexes);
X printf("Technology: %.1f\n",Race->tech);
X printf("Avg Intelligence: %u\n",Race->IQ);
X printf("mass:%.2f\n",Race->mass);
X printf("metabolism:%.1f\n",Race->metabolism);
X printf("adventurists:%.2f%%\n",Race->nonhomebodies*100.0);
X printf("default scope: / %s / %s.\n",Stars[Race->homesystem]->name,
X		Stars[Race->homesystem]->pnames[Race->homeplanetnum] );
X
X  printf("planetary conditions preferred by %s:\n", Race->name);
X  printf("    temperature: %d\n", Temp(Race->conditions[TEMP]) );
X  printf(" atmosphere concentrations:\n");
X  printf("    methane %02d%%    oxygen %02d%%\n",
X		Race->conditions[METHANE], Race->conditions[OXYGEN] );
X  printf("        CO2 %02d%%  hydrogen %02d%%\n", 
X		Race->conditions[CO2], Race->conditions[HYDROGEN] );
X  printf("   nitrogen %02d%%    sulfur %02d%%\n",
X		Race->conditions[NITROGEN], Race->conditions[SULFUR] );
X  printf("     helium %02d%%     other %02d%%\n", 
X		Race->conditions[HELIUM], Race->conditions[OTHER]);
X
X printf("\nRelations with other races:\nPlayer	relation\n");
X numraces = Numraces();
X   for (i=1; i<= numraces; i++)
X	if (i!=Race->Playernum)
X		printf("%2d	%s\n", i, isset( Race->atwar, i) ? "war!" :
X				       isset( Race->allied, i) ? "alliance" :
X				       "neutral" );
X
X}
END_OF_FILE
if test 1760 -ne `wc -c <'prof.c'`; then
    echo shar: \"'prof.c'\" unpacked with wrong size!
fi
# end of 'prof.c'
fi
if test -f 'scrap.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'scrap.c'\"
else
echo shar: Extracting \"'scrap.c'\" \(2326 characters\)
sed "s/^X//" >'scrap.c' <<'END_OF_FILE'
X
X/*
X * Galactic Bloodshed (Robert Chansky, smq@ucscb.ucsc.edu)
X * scrap.c -- turn a ship to junk
X */
X
X#include "vars.h"
X#include "ships.h"
X#include <signal.h>
X#include <curses.h>
X#include <setjmp.h>
Xextern jmp_buf main_jenv;
Xextern int Shipdata[NUMSTYPES][NUMABILS];
Xextern int Ignore_filelocks;
Xint scrap_shdata, scrap_pdata;
X
X
Xscrap(APcount, argn,args)
Xint APcount;
Xint argn;
Xchar args[MAXARGS][COMMANDSIZE];
X{
Xplanettype *planet;
Xsectortype *sect;
Xshiptype *s;
Xint i,shfdata,mask,shipno,scrapval;
Xint scrap_handler();
X
X
Xscrap_shdata = scrap_pdata = NEUTRAL_FD;
Xsignal(SIGINT, scrap_handler);
X
X
X if (argn<2) {
X	printf("ship #");
X	scanf("%d",&shipno);
X	getchr();
X } else
X	sscanf(args[1] + ((*args[1]=='#') ? 1 : 0), &shipno);
X
X openshdata(&scrap_shdata);
X if (!getship(scrap_shdata,&s,shipno)) {
X	scrap_handler();
X }
X if (s->owner!=Playernum || s->is_dead) {
X	DontOwnErr(shipno);
X	free(s);
X	scrap_handler();
X }
X if ( !(s->is_docked && s->whatdest==LEVEL_PLAN)) {
X	printf("%s #%d is not landed.\n",Shipnames[s->type], shipno);
X	free(s);
X	scrap_handler();
X }
X if (!enufAP(Stars[s->storbits]->AP, APcount)) {
X	printf("Not enough AP's (%d).\n",APcount);
X	return;
X }
X
X openpdata(&scrap_pdata);
X getplanet(scrap_pdata, &planet, Stars[s->storbits]->planetpos[s->pnumorbits]);
X
X scrapval = Shipdata[s->type][ABIL_COST] * .75 + s->resource;
X
X tty_on();
X printf("%s #%d:original cost: %d\n",
X	Shipnames[s->type], shipno, Shipdata[s->type][ABIL_COST]);
X printf("         scrap value%s: %d. Junk (y/n)?",
X	s->resource ? "(with stockpile) " : "", scrapval);
X
X if (getchr()!='y') {
X 	tty_off();
X	putchr('\n');
X	scrap_handler();
X }
X
X deductAPs(APcount, s->storbits, 0);
X
X tty_off();
X puts("\njunked.\n");
X
X for (i=0; i<MAXPSHIPS; i++)
X	if (planet->shipnums[i] == shipno) {	
X		planet->shipnums[i] = 0;
X		planet->numships--;
X	}
X
X openshfdata(&shfdata);
X destroyship(shfdata, shipno);
X close(shfdata);
X
X planet->info[Playernum-1].resource += scrapval;
X planet->info[Playernum-1].destruct += s->destruct;
X planet->info[Playernum-1].fuel += s->fuel;
X
X putplanet(scrap_pdata, planet, Stars[s->storbits]->planetpos[s->pnumorbits]);
X close(scrap_pdata);
X
X putship(scrap_shdata,s,shipno);
X close(scrap_shdata);
X free(s);
X
X sigsetmask(mask);	/* reset mask */
X}
X
X
X
Xscrap_handler()
X{
X close(scrap_shdata);
X close(scrap_pdata);
X longjmp(main_jenv,1);
X}
END_OF_FILE
if test 2326 -ne `wc -c <'scrap.c'`; then
    echo shar: \"'scrap.c'\" unpacked with wrong size!
fi
# end of 'scrap.c'
fi
if test -f 'shipdata.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'shipdata.h'\"
else
echo shar: Extracting \"'shipdata.h'\" \(2640 characters\)
sed "s/^X//" >'shipdata.h' <<'END_OF_FILE'
X/*
X * Galactic Bloodshed (Robert Chansky, smq@b)
X */
X
Xchar Shipltrs[]={ 'p','s','c','b','d','f','g','e','t','S','D','M','%','#',
X		  '+','m','A','C','V','^',' ','E','Y','B','G','[' };
X
Xint Shipdata[NUMSTYPES][NUMABILS] = {
X  /* cargo destcap guns  fuelcap  mintech  crew  armr cost  mass mv swtch*/
X/*sp*/1,      0,     0,     20,    1,     1,      1,  10,   5,   1, 0,
X/*sh*/10,     2,     1,     20,	   15,    25,     1,  50,   10,  1, 0,
X/*cs*/1,      2,     1,     1,     10,    0,      3,  20,   4,   1, 0,
X/*bt*/35,     200,   10,    100,   140,   70,     10, 500,  20,  1, 0,
X/*de*/10,     100,   5,     80,	   70,    50,     6,  200,  10,  1, 0,
X/*fi*/1,      30,    4,     10,	   65,    1,      40, 80,   5,   1, 0,
X/*cg*/1000,   1000,  1,     1000,  65,    1000,   3,  400,  25,  1, 0,
X/*ex*/1,      1,     1,     30,	   25,    1,      3,  100,  8,   1, 0,
X/*ta*/15,     10,    1,     5000,  65,    50,     3,  400,  20,  1, 0,
X/*st*/5000,   250,   35,    500,   20,    1000,   9,  400,  50,  1, 0,
X/*Dr*/100,    500,   40,    500,   250,   60,     10, 600,  25,  1, 0,
X/*Mi*/5000,   600,   35,    5000,  350,   1000,   20, 500,  20,  1, 0,
X/*Cr*/10000,  10000, 100,   10000, 700,   10000,  50, 400,  10,  1, 0,
X/*GD*/50000,  50000, 50000, 50000, 1000,  50000,  100,100,  1,   1, 0,
X/*sm*/0,      10,    0,     6,     30,    0,      1,  35,   15,  1, 1,
X/*mr*/200,    10,    1,     20,    50,    15,     1,  200,  100, 1, 0,
X/*Ap*/0,      0,     0,     0,     80,    10,     1,  150,  40,  0, 1,
X/*Cd*/0,      0,     0,     1,     40,    0,      1,  20,   5,   1, 0,
X/*VN*/20,     0,     0,     35,    30,    0,      1,  15,   15,  1, 1,
X/*pb*/0,      20,    0,     5,     300,   0,      1,  100,  5,   1, 1,
X/*cd*/0,      10,    0,     0,     250,   0,      1,  25,   6,   0, 1,
X/*AY*/0,      10,    0,     0,     90,    0,      1,  25,   6,   0, 0,
X/*Bw*/0,      10,    0,     0,     80,    0,      1,  25,   6,   0, 1,
X/*Gr*/0,      10,    0,     0,     80,    0,      1,  25,   6,   0, 0,
X/*TD*/1000,   1000,  0,     1000,  220,   1000,   1,  800,  80,  0, 1
X};
X
Xchar *Shipnames[NUMSTYPES] = {
X   "Spore pod",
X   "Shuttle",
X   "Comsat",
X   "Battleship",
X   "Destroyer",
X   "Fighter",
X   "Cargo ship",
X   "Explorer",
X   "Tanker",
X   "Station",
X   "Dreadnaught",
X   "Mithril Ship",
X   "Crystal Ship",
X   "GODSHIP",
X   "Space mine",
X   "Space mirror",
X   "Atmosph processor",
X   "Canister of dust",
X   "V.Neumann machine",
X   "*Planet bomb",
X   "*cloaking device",
X   "*emotion suppressor",
X   "*Amulet of Yendor",
X   "*biological weapon",
X   "*gamma ray laser",
X   "audio-vibatory-\n   physio-molecular\n   transport device"
X};
END_OF_FILE
if test 2640 -ne `wc -c <'shipdata.h'`; then
    echo shar: \"'shipdata.h'\" unpacked with wrong size!
fi
# end of 'shipdata.h'
fi
if test -f 'telegram.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'telegram.c'\"
else
echo shar: Extracting \"'telegram.c'\" \(2602 characters\)
sed "s/^X//" >'telegram.c' <<'END_OF_FILE'
X/*
X * Galactic Bloodshed (Robert Chansky, smq@b)
X *  telegram.c -- send a telegram to user
X */
X
X#include "vars.h"
X#include "races.h"
X#include "ships.h"
X#include <ctype.h>
X#include <signal.h>
X#include <strings.h>
X#include <setjmp.h>
Xextern jmp_buf main_jenv;
Xextern char telegram_buf[AUTO_TELEG_SIZE];
X
Xtelegram(APcount, argn,args)
Xint APcount;
Xint argn;
Xchar args[MAXARGS][COMMANDSIZE];
X{
Xracetype *alien;
Xplacetype where;
Xplanettype *pl;
Xint c,i,numraces,recp = -1;
Xbool Place = 0;
Xchar telefl[50], tbuf[200], tmbuf[40], r[RNAMESIZE];
Xint telegram_pdata,telegram_handler();
X
X
X  signal(SIGINT, telegram_handler);
X
X  if (!enufAP(Sdata.AP,APcount) && Dir.level!=LEVEL_UNIV 
X		&& !enufAP(Stars[Dir.snum]->AP,APcount) )
X	telegram_handler();
X
X  if (argn<2) {		/* recipient not specified */
X	printf("To whom/where? ");
X	scanf("%[^\n]",r);
X	getchr();
X  } else
X	strncpy(r,args[1],RNAMESIZE);
X
X
X  if (r[0] == '/' || r[0]=='#' || r[0]=='.' || r[0]==CHAR_CURR_SCOPE) {
X    Place = 1;
X    where = Getplace(r,1);
X    if (where.err)
X	telegram_handler();
X  } else {
X    GetPlayer(r, &recp, &alien);
X    if ( recp == -1) {
X	  printf("Player does not exist.\n");
X	  telegram_handler();
X    }
X  }
X
X  printf("Enter telegram for %s,\n  ending with ctrl-D.\n\n", 
X			Place ? Dispplace(&where) : alien->name );
X
X  printf("Subject : ");
X  teleg_add("", telegram_buf);
X  if (Place) {
X	sprintf(tbuf, "Message received at %s%s.\n", 
X		where.level==LEVEL_SHIP ? "ship " : "", Dispplace(&where) );
X	teleg_add(tbuf, telegram_buf);
X  }
X  i = 0;
X  while ( (c=getchr()) != EOF) {
X	  ungetc(c,stdin);
X	  scanf("%199[^\n]", tbuf);
X	  getchr();
X	  i += strlen(tbuf);
X	  teleg_add(tbuf, telegram_buf);
X  	  printf("%d : ",TELEGRAM_SIZE - i );
X  }
X  
X	/* send it */
X  if (!Place)
X	  teleg_send(Playernum, recp, telegram_buf);
X  else
X     switch (where.level) {
X	case LEVEL_STAR:
X	        for (i=1; i<MAXPLAYERS; i++)
X		  if (isset(Stars[where.snum]->inhabited,i))
X		     teleg_send(Playernum, i, telegram_buf);
X		break;
X	case LEVEL_PLAN:
X		openpdata(&telegram_pdata);
X		getplanet(telegram_pdata, &pl, Stars[where.snum]->planetpos[where.pnum]);
X		close(telegram_pdata);
X		for (i=1; i<MAXPLAYERS; i++)
X			if (pl->info[i-1].numsectsowned)
X			     teleg_send(Playernum, i, telegram_buf);
X		break;
X	case LEVEL_SHIP:
X		teleg_send(Playernum, where.shipptr->owner, telegram_buf);
X		break;
X    	case LEVEL_UNIV:
X		printf("We're sorry, no one is there to receive your call.\n");
X		break;
X    }
X
X	/* get rid of ctrl-D problem */
X  clearerr(stdin);
X
X  printf("\nMessage delivered.\n");
X
X}
X
X
Xtelegram_handler(sig, code, scp)
X{
X longjmp(main_jenv,1);
X}
END_OF_FILE
if test 2602 -ne `wc -c <'telegram.c'`; then
    echo shar: \"'telegram.c'\" unpacked with wrong size!
fi
# end of 'telegram.c'
fi
echo shar: End of archive 6 \(of 7\).
cp /dev/null ark6isdone
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