[comp.sources.games] v07i047: GB2 - Galactic Bloodshed, an empire-like war game [Ver. 1.0], Part04/08

billr@saab.CNA.TEK.COM (Bill Randle) (07/19/89)

Submitted-by: VANCLEEF@mps.ohio-state.edu
Posting-number: Volume 7, Issue 47
Archive-name: GB2/Part04



#! /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 4 (of 8)."
# Contents:  Docs/mobilize.doc build.c dosector.c files_shl.c land.c
#   moveship.c rst.c
# Wrapped by billr@saab on Thu Jul  6 07:39:50 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Docs/mobilize.doc' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Docs/mobilize.doc'\"
else
echo shar: Extracting \"'Docs/mobilize.doc'\" \(1333 characters\)
sed "s/^X//" >'Docs/mobilize.doc' <<'END_OF_FILE'
XMOBILIZE		Galactic Bloodshed			MOBILIZE
X
X
XNAME
X  mobilize [1] -- Increase military mobilization in sectors
X
XSYNOPSIS
X    mobilize
X
XDESCRIPTION
X
X  This command sets quotas for mobilization in sectors, for the production
Xof ``destructive capacity'' which represents weapons in GB.
X
X  The ``mobilization'' of a sector represents its military readiness; the
Xgreater the percentage (up to 100), the higher the mobilization.  
XSectors that are mobilized produce quantities of destructive capacity
Xaccording to the degree of mobilization, the amount of population, and the
Xamount of resource deposits in the sector.
X
X  As a side effect, Because the sectors being mobilized have to be hardened
Xand citizens given training in the military arts, the sector will become
Xmuch more resistant to any attack than an un-mobilized one.  
X
X  This command only sets a quota, it does not do any actual work.  
XMobilization will be built up by the citizenry a small amount at a time
X(the rate will be proportional to the population of each sector and
Xthe resource deposits there) as the population works to organize things
Xand set up factories and shelters and so forth.  Each mobilization point
Xon each sector costs 0.1 resource points to produce.  This amount is
Xdeducted from the resource points available on the planet.
X
X
XSEE ALSO
X map, census, fire
END_OF_FILE
if test 1333 -ne `wc -c <'Docs/mobilize.doc'`; then
    echo shar: \"'Docs/mobilize.doc'\" unpacked with wrong size!
fi
# end of 'Docs/mobilize.doc'
fi
if test -f 'build.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'build.c'\"
else
echo shar: Extracting \"'build.c'\" \(8680 characters\)
sed "s/^X//" >'build.c' <<'END_OF_FILE'
X/*
X * Galactic Bloodshed (Robert Chansky, smq@ucscb.ucsc.EDU)
X * build -- build a ship
X */
X
X#include "vars.h"
X#include "ships.h"
X#include "races.h"
X#include <curses.h>
X#include <setjmp.h>
X#include <signal.h>
Xextern jmp_buf main_jenv;
Xextern int God;
Xint build_shdata,build_pdata,build_sectdata;
X
X
Xbuild(APcount, argn,args)
Xint APcount;
Xint argn;
Xchar args[MAXARGS][COMMANDSIZE];
X{
Xint j,i,x= -1 ,y= -1 ,shipno, mask;
Xint picked=0;
Xchar c,shipc;
Xplanettype *planet;
Xsectortype *sect;
Xshiptype s,*dirship;
XFILE *fd;
Xint build_handler();
X
X
Xbuild_shdata = build_pdata = build_sectdata = NEUTRAL_FD;
Xsignal(SIGINT, build_handler);
X
X if (Dir.level==LEVEL_PLAN) {
X	if (!enufAP(Stars[Dir.snum]->AP, APcount))
X		build_handler();
X 	else {
X     		openpdata(&build_pdata);
X     		getplanet(build_pdata,&planet,Stars[Dir.snum]->planetpos[Dir.pnum]);
X	}
X } else if (Dir.level==LEVEL_SHIP) {
X	openshdata(&build_shdata);
X	if (!getship(build_shdata, &dirship, Dir.shipno)) {
X		printf("Illegal dir value.\n");
X		build_handler();
X	}
X	if (testship(dirship, Dir.shipno))
X		build_handler();
X	if (dirship->type != STYPE_HABITAT && dirship->type!=STYPE_CARGO && dirship->type!=STYPE_SHUTTLE &&
X			dirship->type!=STYPE_ASS && dirship->type!=STYPE_STATION) {
X		printf("This ship cannot be used to construct other ships.\n");
X		build_handler();
X	}
X	if (dirship->is_docked) {
X		if (dirship->whatdest==LEVEL_PLAN)
X			printf("This ship is landed.\n");
X		else
X			printf("There is already a ship docked here (#%d).\n",
X					dirship->destshipno);
X		build_handler();
X	}
X
X	 /* check stars, sdata for APs */
X 	if (dirship->whatorbits==LEVEL_UNIV) {
X	 	if (!enufAP(Sdata.AP, APcount))
X			build_handler();
X 	} else if (dirship->whatorbits==LEVEL_STAR) {
X	 	if (!enufAP(Stars[dirship->storbits]->AP, APcount))
X			build_handler();
X	}
X
X } else {
X	printf("You can't build anything here.\n");
X	build_handler();
X }
X
X
X
X  do {
X
X   if (argn==1) {
X	   tty_on();
X	   printf("Build what ship type (? for help):");
X	   shipc = getchr(); putchr('\n');
X   } else
X	shipc = args[1][0];
X
X   if (shipc=='?') {
X
X     printf("\n Help on what ship type (? again for complete list):");
X     shipc = getchr(); putchr('\n');
X
X     if (shipc=='?') {
X
X       printf("ltr              ship  carg armr dstcap guns  mass fcap tech ^crew speed cost\n");
X       for (i=0; i<NUMSTYPES; i++)
X	  if (Race->tech >= Shipdata[i][ABIL_TECH] || God)
X	    if ((i==STYPE_POD && Race->Thing) || i!=STYPE_POD)
X	      printf(" %c %18s %5d%5d%7d%5d%6d%5d%5d%5d%6d%6d\n",
X		  Shipltrs[i], Shipnames[i],
X		  Shipdata[i][ABIL_CARGO], Shipdata[i][ABIL_ARMOR],
X		  Shipdata[i][ABIL_DESTCAP],
X		  Shipdata[i][ABIL_GUNS], Shipdata[i][ABIL_MASS],
X		  Shipdata[i][ABIL_FUELCAP], Shipdata[i][ABIL_TECH],
X		  Shipdata[i][ABIL_MAXCREW], Shipdata[i][ABIL_SPEED], 
X		  Shipdata[i][ABIL_COST] );
X     } else {
X	/* description of an individual object, ala' examine */
X	i = 0;
X        while ((Shipltrs[i]!=shipc) && (i<NUMSTYPES)) 
X		i++;
X
X        if (i<0 || i>=NUMSTYPES || (i==STYPE_POD && !Race->Thing)
X	    || (Race->tech < Shipdata[i][ABIL_TECH] && !God) )
X		printf("You can't examine that ship type (yet).\n");
X	else {
X    	   if ((fd=fopen(EXAM_FL, "r"))==NULL) {
X		perror(EXAM_FL);
X    	   } else {
X   	      /* look through ship data file */
X    	      for (j=0; j<=i; j++)
X       	         while (fgetc(fd) != '~') ;
X		   /* give report */
X    	      while ((c=fgetc(fd)) != '~')
X		   putchr(c);
X    	      fclose(fd);
X	   }
X	}
X     }
X   } else {
X    i=0;
X    while ((Shipltrs[i]!=shipc) && (i<NUMSTYPES)) i++;
X    picked = 1;
X    if (i>=NUMSTYPES || (i==STYPE_POD && !Race->Thing) ) {
X	printf("Illegal ship letter.\n");
X	picked = 0;
X    } else if (Race->tech < Shipdata[i][ABIL_TECH]) {
X	printf("You don't have enough technology to build one of those.\n");
X	if (!God)
X		picked = 0;
X    } else if (!Shipdata[i][ABIL_CANLAND] && Dir.level!=LEVEL_SHIP) {
X	printf("You can't build a %s on a planet.\n", Shipnames[i]);
X	picked = 0;
X    } else if (i==OTYPE_TOXWC && Dir.level!=LEVEL_PLAN) {
X	printf("There is no toxic waste to dispose of here.\n");
X	picked = 0;
X    }
X    if (!picked && argn>1)
X	build_handler();
X   }
X
X  } while (!picked);
X  tty_off();
X
X
X	/* check for resource availability */
X
X     if (Dir.level==LEVEL_PLAN) {
X	 if (planet->info[Playernum-1].resource < Shipdata[i][ABIL_COST]) {
X		printf("not enough resources in stock.\n");
X		free(planet);
X		build_handler();
X	 }
X     } else if (dirship->resource < Shipdata[i][ABIL_COST]) {
X	printf("not enough resources on this ship.\n");
X	build_handler();
X     }
X
X
X	/* find sector to build on (if planet) */
X
X     if (Dir.level!=LEVEL_SHIP)
X	do {
X
X	   if (argn>1)
X		sscanf(args[argn-1], "%d,%d", &x, &y);
X	   else
X     	   	printf("Build %s on planet %s,", Shipnames[i],
X	   		  		Stars[Dir.snum]->pnames[Dir.pnum] );
X	   GetMapSector(planet, &x, &y);
X
X	   opensectdata(&build_sectdata);
X	   getsector(build_sectdata, &sect, planet->sectormappos+(y*planet->Maxx+x)*sizeof(sectortype) );
X	   close(build_sectdata);
X	   if (sect->owner!=Playernum) {
X		printf("You don't own that sector.\n");
X		if (argn>1)
X			build_handler();
X		exit(0);
X	   }
X	   free(sect);
X
X      	} while ( sect->owner != Playernum );
X
X		/* keep people from fucking up the data files */
X	mask = sigblock(SIGINT | SIGQUIT | SIGSTOP);
X
X
X 	Bzero(s);
X
X	s.type = i;
X	if (Dir.level!=LEVEL_SHIP) {
X		s.xpos = (float)x;
X		s.ypos = (float)y;
X	} else {
X		s.xpos = dirship->xpos + 1.0;
X		s.ypos = dirship->ypos;
X	}
X
X	s.speed = 0;
X/*	s.speed = MAX(2, Shipdata[s.type][ABIL_SPEED]); */
X	 	/* starting speed default */
X	s.owner = Playernum;
X	s.mass = (float)Shipdata[i][ABIL_MASS];
X	s.fuel = s.destruct = s.resource = 0;
X	s.is_docked = 1;
X	if (Dir.level==LEVEL_SHIP) {
X		s.whatdest = LEVEL_SHIP;
X		s.destshipno = Dir.shipno;
X		s.whatorbits = dirship->whatorbits;
X	} else {
X			/* docked on the planet */
X		s.whatorbits = LEVEL_PLAN;
X		s.whatdest = LEVEL_PLAN;
X		s.deststar = Dir.snum;
X		s.destpnum = Dir.pnum;
X	}
X	s.storbits = Dir.snum;
X	s.pnumorbits = Dir.pnum;
X	s.rad = 0;
X	if (Shipdata[s.type][ABIL_MAXCREW]==0 || s.type==OTYPE_TRANSDEV)
X		s.damage = 0;
X	else
X		s.damage = 50;
X
X	if (has_switch(&s)) {
X		s.on = 0;
X	}
X	switch (s.type) {
X	    case OTYPE_VN:
X		s.orders.object.number = 1;	/* one of them */
X		s.orders.object.number2 = 1;	/* we have an assignment */
X		s.on = 1;
X		break;
X	    case STYPE_MINE:
X		s.orders.object.number = 100;	/* trigger radius */
X		printf("Mine disarmed.\nTrigger radius set to 100.\n");
X		break;
X	    case OTYPE_TRANSDEV:
X		printf("Receive OFF.  Change with order.\n");
X		break;
X	    case OTYPE_AP:
X		printf("Processor OFF.\n");
X		break;
X	    case OTYPE_TOXWC:
X		printf("Toxin concentration of the planet was %d,",
X				planet->conditions[TOXIC]);
X		if (planet->conditions[TOXIC] > 20) {
X			planet->conditions[TOXIC] -= 20;
X			s.orders.object.number = 20;
X		} else {
X			s.orders.object.number = planet->conditions[TOXIC];
X			planet->conditions[TOXIC] = 0;
X		}
X		printf(" now %d.\n",planet->conditions[TOXIC]);
X		break;
X	    case OTYPE_STELE:
X	    case OTYPE_GTELE:
X		printf("Telescope range is %.2f.\n", tele_range(Race,&s));
X		break;
X	    default:
X		break;
X	}
X
X
X		/* deduct resource cost */
X
X	if (Dir.level==LEVEL_PLAN)
X		planet->info[Playernum-1].resource -= Shipdata[i][ABIL_COST];
X	else
X		dirship->resource -= Shipdata[i][ABIL_COST];
X
X
X		/* check for dead ships in the data files */
X
X	if (Dir.level==LEVEL_SHIP)
X		Locks(1);
X	else
X		openshdata(&build_shdata);
X
X	if ( (shipno = getdeadship(build_shdata)) == -1) {
X			/* otherwise recycle topmost dead ship in data file. */
X			/* no dead ships to recycle */
X		shipno = Numships(build_shdata) + 1;
X	}
X
X	printf("%s #%d is %s %.0f,%.0f.\n", Shipnames[s.type], shipno,
X		Dir.level==LEVEL_SHIP ? "at" : "on sector", s.xpos,s.ypos);
X
X		/* insert ship into planet's orbit */
X	if (Dir.level==LEVEL_PLAN) {
X		 /* built on planet */
X		 /* next ship on list */
X		s.nextship = planet->ships;
X		planet->ships = shipno;
X		putplanet(build_pdata,planet,Stars[Dir.snum]->planetpos[Dir.pnum]);
X		close(build_pdata);
X	        free(planet);
X	} else {	/* was built on a ship -- insert after that ship */
X
X		s.nextship = dirship->nextship;
X		dirship->nextship = shipno;
X
X		dirship->is_docked = 1;
X		dirship->whatdest = LEVEL_SHIP;
X		dirship->destshipno = shipno;
X		putship(build_shdata, dirship, Dir.shipno);
X		free(dirship);
X	}
X
X	putship(build_shdata,&s,shipno);
X	close(build_shdata);
X
X    Locks(0);
X    if (Dir.level==LEVEL_SHIP && dirship->whatorbits==LEVEL_UNIV)
X	    deductAPs(APcount, 0, 1);
X    else
X	    deductAPs(APcount, Dir.snum, 0);
X
X    sigsetmask(mask);
X
X}
X
X
X
Xbuild_handler()
X{
X tty_off();
X Locks(0);
X close(build_shdata);
X close(build_pdata);
X close(build_sectdata);
X longjmp(main_jenv,1);
X}
END_OF_FILE
if test 8680 -ne `wc -c <'build.c'`; then
    echo shar: \"'build.c'\" unpacked with wrong size!
fi
# end of 'build.c'
fi
if test -f 'dosector.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'dosector.c'\"
else
echo shar: Extracting \"'dosector.c'\" \(7374 characters\)
sed "s/^X//" >'dosector.c' <<'END_OF_FILE'
X/*
X * Galactic Bloodshed (Robert Chansky, smq@b)
X *  dosector.c 
X *  dosector() -- do spread, produce, stuff like that, on a sector.
X *  explore()  -- mark sector and surrounding sectors as having been explored.
X */ 
X
X#include "vars.h"
X#include "races.h"
X#include "ships.h"
X#include "doturn.h"
X#include <math.h>
Xextern float avg_mob[MAXPLAYERS];
Xextern char sects_gained[MAXPLAYERS], sects_lost[MAXPLAYERS];
Xextern bool Claims;
X
X		/* produce stuff in sector */
Xproduce(planet,s)
Xreg planettype *planet;
Xreg sectortype *s;
X{
Xreg float factor;
Xreg int eff;
Xreg struct plinfo *pinf;
Xreg int new;
X
X
X	 factor = logscale(s->popn) * s->resource * races[s->owner]->metabolism;
X
X	 pinf = &planet->info[s->owner-1];
X
X	 prod_fuel[s->owner] = round_rand( s->eff * factor * FUEL_PRODUCTION
X		  * ((planet->type==TYPE_GASGIANT)* 4+1) );
X
X	 prod_res[s->owner] = round_rand( s->eff * factor * RESOURCE_PRODUCTION 
X		  * ((planet->type==TYPE_ASTEROID) * 1 + 1) * (100 - s->mobilization)/100.);
X
X	 prod_destruct[s->owner] = round_rand( s->eff * factor * DEST_PRODUCTION
X		  * ((planet->type==TYPE_ASTEROID) * 1 + 1) * s->mobilization /100.);
X
X
X	     /* deplete resources for making weapons - removed by gvc*/
X	 tot_resdep = 0;
X
X		/* increase mobilization to planetary quota */
X	 if (s->mobilization < pinf->mob_set)
X		if (pinf->resource + prod_res[s->owner] > 0) {
X			s->mobilization++;
X			prod_res[s->owner] -= round_rand(MOB_COST);
X			prod_mob++;
X	 	}
X
X
X
X	  /* add mobilization to get average mobilization */
X	 avg_mob[s->owner] += s->mobilization;
X
X
X	  /* do efficiency */
X	 if (s->eff<100) {
X	   if (!s->eff) {
X		prod_eff += s->eff = 1;
X	   } else {
X	     prod_eff += 
X		(eff = round_rand(races[s->owner]->metabolism*s->popn*EFF_PROD/100.0));
X		if (s->eff+eff >= 100) {
X			s->eff=100;	/* dont go past 100%*/
X			prod_eff -= s->eff+eff-100;
X			s->des = DES_PLATED;
X		} else 
X			s->eff += eff;
X	   }
X	}
X
X	  /* add population to sector */
X	 if (s->popn >= races[s->owner]->number_sexes)
X	       s->popn += round_rand((float)s->popn * races[s->owner]->birthrate
X			* Compat[s->owner] / 100.0 
X			* (50.0 - planet->conditions[TOXIC]) / 50.0 );
X	 else
X		s->popn = round_rand(s->popn * .099);
X
X}
X
X
X/*
X * spread population to surrounding sects. 
X *
X *	the way people move depends on the population of the planet unless 
X *	NO_SLIDING_SCALE_AUTOMOVE is set (again for reasons of computer 
X *	power).  Otherwise, the populace will automatically migrate to all 
X *	available surrounding areas if the planetary population is less than
X *	POPN_MOVE_SCALE_1, to either north-south or east-west areas if the
X *	population is less than POPN_MOVE_SCALE_2, and to only one adjacent
X *	random sector if it is greater.
X */
X
X
Xspread(pl,s,x,y)
Xreg planettype *pl;
Xreg sectortype *s;
Xreg int x,y;
X{
Xreg int peep;
X
Xif (pl->is_sheep)
X	return;		/* no one wants to go anywhere */
X
X   /* peep == number of people who want to move */
Xif (s->amoeba || (peep = round_rand((float)s->popn * races[s->owner]->nonhomebodies)) ) {
X if (pl->type==TYPE_GASGIANT && s->des==DES_GAS && !int_rand(0,20)) {
X	 /* random 'wind' sweeps people in this sector, somewhere else */
X	  reg int x2,y2;
X	  sectortype *s2,s3;
X	/* huh.  For some reason, this seems to mess up the next planet's
X	   sector map. */
X	/*x2 = int_rand(0,pl->Maxx-1);
X	y2 = int_rand(1,pl->Maxy-2);
X	printf(" wind: %d,%d to %d,%d\n",x,y,x2,y2);
X	s2 = &Sector(*pl,x2,y2);
X	if (s2->des==DES_GAS) {
X		s3 = *s2; 
X		*s2 = *s; 
X		*s = s3;
X	}*/
X } else {
X
X#if NO_SLIDING_SCALE_AUTOMOVE
X if (pl->popn < POPN_MOVE_SCALE_1) {
X#endif
X	Migrate2(pl,x+1,y,s,peep/4);
X	Migrate2(pl,x-1,y,s,peep/4);
X	Migrate2(pl,x,y+1,s,peep/4);
X	Migrate2(pl,x,y-1,s,peep/4);
X#if NO_SLIDING_SCALE_AUTOMOVE
X }
X else if (pl->popn < POPN_MOVE_SCALE_2) {
X   x2 = int_rand(-1,1);
X   y2 = (!x2) ? rposneg() : 0;	 /* 1/3 chance of migrating n-s*/
X	Migrate2(pl,x+x2,y+y2,s,peep/2);   
X	Migrate2(pl,x-x2,y-y2,s,peep/2);
X			/* migrate to destination, from source */
X } else {
X	Migrate2(pl, x + rposneg(), y + rposneg(), s, peep);
X }
X
X#endif
X }
X}
X
X}
X
X
X
XMigrate2(planet,xd,yd,ps,people)
Xplanettype *planet;
Xreg int xd,yd;
Xsectortype *ps;
Xreg int people;
X{
Xreg sectortype *pd;
X
X	/* attempt to migrate beyond screen, or too many people */
X if (ps->popn <= people || (yd>=planet->Maxy) || (yd<0) ) 
X	return;	
X
X if (xd<0) 
X	xd=planet->Maxx-1;
X else if (xd>=planet->Maxx) 
X	xd=0;
X
X pd = &Sector(*planet,xd,yd);
X
X if (ps->amoeba) {	/* amoebae (almost) always win. */
X	if ( (pd->popn && !int_rand(0,races[pd->owner]->fighters))
X	    || (!pd->popn && !int_rand(0,3)) ) {
X		pd->amoeba = 1;
X		pd->popn = 0;
X		pd->owner = 1;
X	}
X } else {
X
X	/* check for planetary compatibility */
X   if (people <= races[ps->owner]->number_sexes || 
X	float_rand()*100.0 > Compat[ps->owner] * races[ps->owner]->likes[pd->des]) {
X	/*printf("%d,%d incomp C %.2f,l %.f-- returning\n",xd,yd,Compat[ps->owner],races[ps->owner]->likes[pd->des]);*/
X
X	return;
X
X   }
X
X   if ( (ps->owner==pd->owner || !pd->owner) && !pd->is_wasted && !pd->amoeba) {
X
X 	if (!pd->owner) {
X		printf("claiming %d,%d (%d): %d\n",xd,yd,ps->owner,people);
X        	pd->popn += people;
X        	ps->popn -= people;
X		pd->owner = ps->owner;
X		tot_captured++;
X		if (Sectinfo[xd][yd].done)
X			planet->info[pd->owner-1].numsectsowned++;
X		Claims = 1;
X 	} else if (pd->owner==ps->owner) {
X        	pd->popn += people;
X        	ps->popn -= people;
X	} else if (isset(races[ps->owner]->atwar, pd->owner) || races[ps->owner]->Thing) {
X			/* we are at war with them; do land combat */
X		reg float dfac;
X
X		ps->popn -= round_rand(((float)ps->popn * pd->mobilization * 
X			planet->info[pd->owner-1].comread + races[pd->owner]->fighters*20)/200.0);
X		dfac = ( (float)pd->popn * ps->mobilization * 
X			planet->info[ps->owner-1].comread + races[pd->owner]->fighters*20)/200.0;
X		printf(" att %d lost %g people of %d.\n",ps->owner,
X			((float)ps->popn * pd->mobilization * 
X			planet->info[pd->owner-1].comread + races[pd->owner]->fighters*20)/200.0, pd->popn);
X		if (pd->popn - dfac <= 0.0) {
X			    /* the invasion was successful */
X			if (races[ps->owner]->Thing) {
X				 /* mesos absorb the bodies of enemies */
X				pd->popn += MIN(people, ps->popn);
X				ps->popn -= MIN(people, ps->popn);
X			} else {
X				pd->popn = MIN(people, ps->popn);
X				ps->popn -= MIN(people, ps->popn);
X			}
X			sects_lost[pd->owner]++;
X			sects_gained[ps->owner]++;
X			pd->owner = ps->owner;
X			pd->eff *= 0.75;
X			pd->mobilization *= 0.75;
X			tot_captured++;
X			printf(" sec %d,%d CAPTURED",xd,yd);
X		} else 
X		   pd->popn -= round_rand(dfac);
X			
X		printf(" def %d lost %g people of %d,",pd->owner,
X			((float)pd->popn * ps->mobilization * 
X			planet->info[ps->owner-1].comread + races[pd->owner]->fighters*20)/200.0, pd->popn);
X 	}
X   }
X
X  }
X
X}
X
X
X/* mark sectors on the planet as having been "explored." for sea exploration
X	on earthtype planets.  */
X
Xexplore(planet, s, x, y, p)
Xreg planettype *planet;
Xreg sectortype *s;
Xreg int x,y,p;
X{
Xreg int d;
X
X	/* explore sectors surrounding sectors currently explored. */
X if (Sectinfo[x][y].explored) {
X
X    Sectinfo[mod(x-1,planet->Maxx,d)][y].explored = p;
X    Sectinfo[mod(x+1,planet->Maxx,d)][y].explored = p;
X    if (y==0) {
X	Sectinfo[x][1].explored = p;
X    } else if (y==planet->Maxy-1) {
X	Sectinfo[x][y-1].explored = p;
X    } else {
X	Sectinfo[x][y-1].explored = Sectinfo[x][y+1].explored = p;
X    }
X 
X } else if (s->owner==p)
X	Sectinfo[x][y].explored = p;
X
X}
END_OF_FILE
if test 7374 -ne `wc -c <'dosector.c'`; then
    echo shar: \"'dosector.c'\" unpacked with wrong size!
fi
# end of 'dosector.c'
fi
if test -f 'files_shl.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'files_shl.c'\"
else
echo shar: Extracting \"'files_shl.c'\" \(8061 characters\)
sed "s/^X//" >'files_shl.c' <<'END_OF_FILE'
X/*
X * Galactic Bloodshed (Robert Chansky, smq@b)
X *  disk input/output routines & msc stuff
X *    all read routines lock the data they just accessed (the file is not
X *    closed).  write routines close and thus unlock that area.
X *
X *  openstardata(&fd),openpdata(&fd),openshdata(&fd),opensectdata(&fd)
X *     		-- open different files, return file descriptors
X *  getsdata(fd,&Sdata) -- get root dir for univ
X *  getrace(**racetype,racenum) -- get race from disk
X *  getstar(fd,**startype,starnum) -- gets star from disk
X *  getplanet(fd,**planettype,filepos) -- gets planet from disk
X *  getsector(fd,**sectortype,filepos) -- gets 1 sect from disk
X *  getsmap(fd,*sectortype,planet) -- gets sector map from disk
X *  getship(fd,**shiptype,shipnum) -- gets ship from disk
X *  putsdata(fd,&Sdata) -- put root dir for univ
X *  putrace(*racetype) -- put race to disk
X *  putstar(fd,*startype,starnum) -- put star to disk
X *  putplanet(fd,*planettype,filepos) -- put planet to disk
X *  putsector(fd,*sectortype,filepos) -- write sector to disk
X *  putsmap(fd,*sectortype,*planet) -- put smap to disk
X *  putship(fd,*shiptype,shipnum) -- put ship to disk
X *  int Numships(fd) -- return highest ship # from file
X *  getdeadship(fd, &filepos) -- filepos of next dead ship from shipfreedatafile
X *  makeshipdead(shipnum) -- kill a ship
X *  int Getracenum(char *) -- return race # from login list
X *  int Numraces() -- return # of races that exist right now
X *  Putpower() -- puts Power struct to disk for power command
X */
X
X#include "vars.h"
X#include "ships.h"
X#include "races.h"
X#include "power.h"
X#include <strings.h>
X#include <sys/stat.h>
X#include <signal.h>
X#include <errno.h>
Xextern int errno;
Xint sys_nerr;
Xchar *sys_errlist[];
X
X
Xopenstardata(fd)
Xint *fd;
X{
X /*printf(" openstardata\n");*/
X if ( (*fd = open(STARDATAFL, O_RDWR, 0777)) < 0) {
X	  perror("openstardata");
X	  printf("unable to open %s\n",STARDATAFL);
X	  exit(-1);
X }
X}
X
X
Xopenshdata(fd)
Xint *fd;
X{
X if ( (*fd = open(SHIPDATAFL, O_RDWR, 0777)) < 0) {
X	  perror("openshdata");
X	  printf("unable to open %s\n",SHIPDATAFL);
X	  exit(-1);
X }
X /*printf("openshdata %d\n",*fd);*/
X}
X
X
Xopenpdata(fd)
Xint *fd;
X{
X if ( (*fd = open(PLANETDATAFL, O_RDWR, 0777)) < 0) {
X	  perror("openpdata");
X	  printf("unable to open %s\n",PLANETDATAFL);
X	  exit(-1);
X }
X /*printf("openpdata %d\n",*fd);*/
X}
X
X
Xopensectdata(fd)
Xint *fd;
X{
X /*printf(" opensectdata\n");*/
X if ( (*fd = open(SECTORDATAFL, O_RDWR, 0777)) < 0) {
X	  perror("opensectdata");
X	  printf("unable to open %s\n",SECTORDATAFL);
X	  exit(-1);
X }
X}
X
X
X
X
Xgetsdata(fd,S)
Xint fd;
Xstruct stardata *S;
X{
X  Fileread(fd,(char *)S, sizeof(struct stardata), STARDATAFL, 0 );
X}
X
X
Xgetrace(r,rnum)
Xracetype **r;
Xint rnum;
X{
Xint fd;
X *r = (racetype *)malloc(sizeof(racetype));
X if ( (fd = open(RACEDATAFL, O_RDWR, 0777)) < 0) {
X	  perror("openrdata");
X	  printf("unable to open %s\n",RACEDATAFL);
X	  exit(-1);
X }
X /*printf(" getrace rnum %d posn %d.\n",rnum,(rnum-1)*sizeof(racetype) );*/
X Fileread(fd, (char *)*r, sizeof(racetype), RACEDATAFL,
X			(rnum-1)*sizeof(racetype) );
X close(fd);
X}
X
X
Xgetstar(fd,s,star)
Xint fd;
Xstartype **s;
Xint star;
X{
X *s = (startype *)malloc(sizeof(startype));
X Fileread(fd,(char *)*s, sizeof(startype), STARDATAFL, 
X	(int)(sizeof(Sdata)+star*sizeof(startype)) );
X}
X
X
Xgetplanet(fd,p,filepos)
Xint fd;
Xplanettype **p;
Xint filepos;
X{
X *p = (planettype *)malloc(sizeof(planettype));
X Fileread(fd,(char *)*p, sizeof(planettype), PLANETDATAFL, filepos );
X /*printf(" getplanet pointer=%x, smappos=%d\n",*p,(*p)->sectormappos);*/
X}
X
X
Xgetsector(fd,s,filepos)
Xint fd;
Xsectortype **s;
Xint filepos;
X{
X *s = (sectortype *)malloc(sizeof(sectortype));
X Fileread(fd,(char *)*s, sizeof(sectortype), SECTORDATAFL, filepos );
X}
X
X
Xgetsmap(fd,map,p)
Xint fd;
Xsectortype *map;
Xplanettype *p;
X{
X /*printf(" getting map posn %d\n", p->sectormappos);*/
X Fileread(fd,(char *)map, p->Maxx * p->Maxy * sizeof(sectortype), 
X	SECTORDATAFL, p->sectormappos);
X}
X
X
Xint getship(fd,s,shipnum)
Xint fd;
Xshiptype **s;
Xint shipnum;
X{
X struct stat buf;
X
X fstat(fd,&buf);
X if (buf.st_size / sizeof(shiptype) < shipnum) {
X	printf("Illegal ship number %d\n",shipnum);
X	return 0;
X } else {
X 	*s = (shiptype *)malloc(sizeof(shiptype));
X 	Fileread(fd, (char *)*s, sizeof(shiptype), SHIPDATAFL,
X					(shipnum-1)*sizeof(shiptype) );
X	return 1;
X }
X}
X
X
X/* gets the ship # listed in the top of the file SHIPFREEDATAFL. this
X** might have no other uses besides build().
X**  also locks the fd in shipdata.
X*/
Xint getdeadship(shipdata)
Xint shipdata;
X{
X struct stat buf;
X short shnum;
X int fd,lerr,lockt = NUM_TIMES_TO_WAIT_FOR_LOCK;
X
X while ((lerr=flock(shipdata, LOCK_SH|LOCK_EX|LOCK_NB ))== -1 && errno==EWOULDBLOCK) {
X	if (!lockt--) {
X		printf("too long. exit.\n");
X		exit(-1);
X	}
X	printf("getdeadship waiting on %s lock...\n",SHIPDATAFL);
X	sleep(2);
X }
X if (lerr<0 && errno!=EWOULDBLOCK) {
X	perror("getdeadship");
X	exit(-1);
X }
X
X stat(SHIPFREEDATAFL,&buf);
X
X if (buf.st_size) {
X  	if ( (fd = open(SHIPFREEDATAFL, O_RDWR, 0777)) < 0) {
X	  	perror("getdeadship");
X	  	printf("unable to open %s\n",SHIPFREEDATAFL);
X	  	exit(-1);
X  	}
X		/* put topmost entry in fpos */
X	Fileread(fd, (char *)&shnum, sizeof(short), SHIPFREEDATAFL, 
X			buf.st_size - sizeof(short) );
X		/* erase that entry, since it will now be filled */
X	ftruncate(fd, (long)(buf.st_size-sizeof(short)) );
X	close(fd);
X	if (shnum == 0)shnum=-1;
X
X	return (int)shnum;
X } else
X	return -1;
X}
X
X
X
Xputsdata(fd,S)
Xint fd;
Xstruct stardata *S;
X{
X  Filewrite(fd,(char *)S, sizeof(struct stardata), STARDATAFL, 0 );
X}
X
X
Xputrace(r)
Xracetype *r;
X{
X int fd;
X
X if ( (fd = open(RACEDATAFL, O_WRONLY, 0777)) < 0) {
X	  perror("openrdata");
X	  printf("unable to open %s\n",RACEDATAFL);
X	  exit(-1);
X }
X Filewrite(fd,(char *)r, sizeof(racetype), RACEDATAFL, 
X		(r->Playernum-1)*sizeof(racetype) );
X close(fd);
X /*printf(" putrace pl#%d posn %d\n",r->Playernum,(r->Playernum-1)*sizeof(racetype) );*/
X}
X
X
Xputstar(fd,s,snum)
Xint fd;
Xstartype *s;
Xint snum;
X{
X  Filewrite(fd,(char *)s, sizeof(startype), STARDATAFL, 
X		(int)(sizeof(Sdata)+snum*sizeof(startype)) );
X}
X
Xputplanet(fd,p,filepos)
Xint fd;
Xplanettype *p;
Xint filepos;
X{
X Filewrite(fd,(char *)p, sizeof(planettype), PLANETDATAFL, filepos );
X}
X
Xputsector(fd,s,filepos)
Xint fd;
Xsectortype *s;
Xint filepos;
X{
X Filewrite(fd,(char *)s, sizeof(sectortype), SECTORDATAFL, filepos );
X}
X
X
Xputsmap(fd,map,p)
Xint fd;
Xsectortype *map;
Xplanettype *p;
X{
X Filewrite(fd, (char *)map,
X	p->Maxx * p->Maxy * sizeof(sectortype), SECTORDATAFL, p->sectormappos);
X}
X
Xputship(fd,s,shipnum)
Xint fd;
Xshiptype *s;
Xint shipnum;
X{
X Filewrite(fd,(char *)s, sizeof(shiptype), SHIPDATAFL, 
X		(shipnum-1)*sizeof(shiptype) );
X}
X
X
Xint Numraces()
X{
X struct stat buf;
X
X stat(RACEDATAFL,&buf);
X return( (int)(buf.st_size / sizeof(racetype)) );
X}
X
X
X
Xint Numships(fd)	 /* return number of ships */
X{
X struct stat buf;
X int lerr;
X
X	/* check for locks on the fd and lock */
X while ((lerr=flock(fd, LOCK_SH|LOCK_EX|LOCK_NB ))== -1 && errno==EWOULDBLOCK){
X	printf("waiting on %s lock..\n",SHIPDATAFL);
X	sleep(1);
X }
X if (lerr== -1 && errno !=EACCES) {
X	printf("weird error.\n");
X	perror("numships");
X }
X fstat(fd,&buf);
X /*printf("numships %d\n",(int)(buf.st_size / sizeof(shiptype)) );*/
X return( (int)(buf.st_size / sizeof(shiptype)) );
X}
X
X
X
X
X/* 
X** writes the ship to the dead ship file at its end.
X*/
Xmakeshipdead(shipnum)
Xint shipnum;
X{
X int fd;
X us shipno;
X struct stat buf;
X
X  shipno = shipnum;	/* conv to u_short */
X
X  if ( (fd = open(SHIPFREEDATAFL, O_WRONLY, 0777)) < 0) {
X	  perror("openshfdata");
X	  printf("unable to open %s\n",SHIPFREEDATAFL);
X	  exit(-1);
X  }
X
X  printf("ship #%u destroyed.\n", shipno);
X	/* write the ship # at the very end of SHIPFREEDATAFL */
X  fstat(fd,&buf);
X  Filewrite(fd,(char *)&shipno, sizeof(shipno), SHIPFREEDATAFL, buf.st_size );
X
X}
X
X
X
XPutpower(p)
Xstruct power p[MAXPLAYERS];
X{
Xint power_fd;
X
X if ( (power_fd = open(POWFL, O_RDWR, 0777)) < 0) {
X	  perror("open power data");
X	  printf("unable to open %s\n",POWFL);
X	  exit(-1);
X }
X write(power_fd, (char *)p, sizeof(*p)*MAXPLAYERS );
X close(power_fd);
X}
END_OF_FILE
if test 8061 -ne `wc -c <'files_shl.c'`; then
    echo shar: \"'files_shl.c'\" unpacked with wrong size!
fi
# end of 'files_shl.c'
fi
if test -f 'land.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'land.c'\"
else
echo shar: Extracting \"'land.c'\" \(8171 characters\)
sed "s/^X//" >'land.c' <<'END_OF_FILE'
X/*
X** Galactic Bloodshed (Robert Chansky, smq@b)
X**  land.c -- land a ship
X**  also.... dock -- dock a ship w/ another ship 
X**  and..... assault -- a very un-PC version of land
X*/
X
X#include "vars.h"
X#include "ships.h"
X#include "races.h"
X#include <setjmp.h>
X#include <signal.h>
X#include <math.h>
Xextern jmp_buf main_jenv;
X#include <signal.h>
X
Xint land_sectdata,land_shdata,land_pdata;
Xextern char telegram_buf[AUTO_TELEG_SIZE];
X
X
Xland(APcount, argn,args, assault)
Xint APcount;
Xint argn;
Xchar args[MAXARGS][COMMANDSIZE];
Xint assault;	/* unfriendly land */
X{
Xint land_handler();
Xchar c;
Xshiptype *s,*s2;
Xplanettype *p;
Xsectortype *sect;
Xplacetype where;
Xbool dock,cont,planetmod=0,sectmod=0;
Xint numdest=0,ship2no,shipno,x= -1,y= -1,i,mask;
Xfloat fuel;
Xdouble Dist;
Xchar buf[200];
X
Xland_sectdata = land_shdata = land_pdata = NEUTRAL_FD;
Xsignal(SIGINT, land_handler);
X
X  dock = (args[0][0]=='d') ? 1 : 0;	/* 1st argument is "dock" */
X
X  if (argn==1) {
X	printf("%s what ship #", assault ? "ASSAULT" : 
X					(dock ? "dock" : "land") );
X	scanf("%d",&shipno);
X	getchr();
X  } else {
X	i = (args[1][0]=='#');
X	sscanf(args[1]+i,"%d",&shipno);
X  }
X  openshdata(&land_shdata);
X  if (!getship(land_shdata, &s, shipno)) {
X	land_handler();
X  }
X  if (assault && dock) {
X	printf("You can't assault on a ship.\n");
X	land_handler();
X  }
X
X  if (testship(s, shipno))
X	land_handler();
X
X  if (s->is_docked) {
X	printf("Ship #%d is already docked.\n",shipno);
X	land_handler();
X  }
X  if (!speed_rating(s)) {
X	printf("This ship is not rated for maneuvering.\n");
X	land_handler();
X  }
X  if (!dock && s->resource > Shipdata[s->type][ABIL_CARGO]) {
X	printf("Ship #%d is too overloaded to land.\n",shipno);
X	land_handler();
X  }
X
X
X  if (s->whatorbits==LEVEL_UNIV) {
X     if (!enufAP(Sdata.AP, APcount)) 
X	land_handler();
X  } else
X     if (!enufAP(Stars[s->storbits]->AP, APcount)) 
X	land_handler();
X
X
X  if (dock) {
X
X     	printf("dock %s #%d with what ship #", Shipnames[s->type], shipno);
X     	scanf("%d", &ship2no);
X     	Locks(1);
X     	if (!getship(land_shdata, &s2, ship2no))
X	   	land_handler();
X     	Locks(0);
X
X	if (s2->is_docked) {
X		printf("ship #%d is already docked.\n",ship2no);
X		land_handler();
X	}
X	printf("Distance to ship #%d: %.2f.\n", ship2no,
X  		Dist = sqrt((double)Distsq(s2->xpos, s2->ypos, 
X			s->xpos, s->ypos ) ) );
X	if (Dist > DIST_TO_LAND) {
X	     printf("Ship #%d must be %.2f or closer to ship #%d.\n",
X			shipno, DIST_TO_LAND, ship2no);
X	     land_handler();
X	}
X
X	fuel = 0.05 + Dist * 0.5;
X	printf("This maneuver will take %g fuel (of %.2f.)\n",fuel,s->fuel);
X	if (fuel > s->fuel) {
X		printf("Not enough fuel.\n");
X		land_handler();
X	}
X	s->fuel -= fuel;
X	s->mass -= fuel * MASS_FUEL;
X	s->is_docked = 1;
X	s->whatdest = LEVEL_SHIP;
X	s->destshipno = ship2no;
X	s->xpos = s2->xpos + 1.0;
X	s->ypos = s2->ypos;
X
X	s2->is_docked = 1;
X	s2->whatdest = LEVEL_SHIP;
X	s2->destshipno = shipno;
X	putship(land_shdata, s2, ship2no);
X
X	printf("ship #%d docked with ship #%d.\n",shipno, ship2no);
X
X  } else {	/* docking with a planet */
X
X     if (assault && s->popn < 1) {
X	printf("The assaulting ship must have more than 1 crew.\n");
X	land_handler();
X     }
X     openpdata(&land_pdata);
X     getplanet(land_pdata, &p, Stars[s->storbits]->planetpos[s->pnumorbits]);
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
X     printf("Distance to planet: %.2f.\n",
X  	Dist = sqrt((double)Distsq(Stars[s->storbits]->xpos + p->xpos, 
X  		      Stars[s->storbits]->ypos + p->ypos, 
X  		      s->xpos, s->ypos ) )
X  	);
X
X     if (Dist > DIST_TO_LAND) {
X        printf("Ship #%d must be %.3g or closer to the planet (%.2f).\n",shipno, DIST_TO_LAND, Dist);
X        land_handler();
X     }
X
X     fuel = 0.05 + logscale(s->mass)*gravity(p) * LAND_GRAV_MASS_FACTOR + assault;
X
X     printf("That maneuver will cost you %.2f fuel (of %.2f).\n",fuel, s->fuel);
X
X     if (s->fuel < fuel) {
X	  tty_on();
X	  printf("NOT ENOUGH FUEL-- continue? (y/n) ");
X	  putchr(c = getchr());
X	  if (c != 'y') {
X		land_handler();
X	  }
X     }
X     tty_off();
X
X     cont = 1;
X     do {
X       if (argn>2)
X	   sscanf(args[argn-1], "%d,%d", &x,&y);
X       else
X       	   printf("%s on",(s->fuel < fuel) ? "CRASH" : 
X			(assault ? "assault" : "land") );
X       GetMapSector(p, &x, &y);
X	opensectdata(&land_sectdata);
X	getsector(land_sectdata,&sect,p->sectormappos+(y*p->Maxx+x)*sizeof(sectortype));
X       if (Race->likes[sect->des] == 0.0) {
X	printf("The ship is not built to land on that sector.\n");
X	cont = 0;
X	exit(0);
X       }
X       if (sect->is_wasted) {
X	printf("Warning: That sector is a wasteland!\n");
X/*	cont = 0; */
X       }
X       if (assault) {
X	    if (sect->owner==Playernum) {
X		printf("You cannot assault your own sector.\n");
X		cont = 0;
X	exit(0);
X	    } else if (sect->popn > 0) {
X		printf("The assaulted sector must have no population.\n");
X		cont = 0;
X	exit(0);
X	    }
X       } else if (sect->owner!=0 && sect->owner!=Playernum) {
X	printf("You can't land on someone else's sector.\n");
X	cont = 0;
X	exit(0);
X       }
X       if (!cont) {
X	close(land_sectdata);
X	free(sect);
X       }
X
X     } while (!cont);
X
X     mask = sigblock(SIGINT | SIGQUIT | SIGSTOP);
X
X     if (s->fuel < fuel) {
X
X
X	kill_ship(s);
X	putship(land_shdata, s, shipno);
X	free(s);
X
X	if (!fork()) {
X		/* fork off a child process to do damage */
X	  where.level = LEVEL_PLAN;
X	  where.snum = s->storbits;
X	  where.pnum = s->pnumorbits;
X
X	  /* first "where" is dummy-- just checks to see if it's a GR
X	     laser; we don't need it */
X	  numdest = blast(&where, where, p, x, y, Dist, (int)(s->mass/15+s->destruct/3), 1);
X	  printf("BO\007OM!! Ship #%d crashes on sector %d,%d with blast radius of %d.\n",
X		shipno, x, y, numdest);
X
X	  exit(0);
X	}
X
X     } else {
X     	s->xpos = (float)x;
X     	s->ypos = (float)y;
X
X     	s->fuel -= fuel;
X     	s->mass -= fuel * MASS_FUEL;
X     	s->is_docked = 1;
X     	s->whatdest = LEVEL_PLAN;	/* no destination */
X     	s->deststar = s->storbits;
X     	s->destpnum = s->pnumorbits;
X
X     	if (assault) {
X		/* assault on planet increases combat readiness, */
X		/* but only if we aren't already well-established there */
X	  if (!p->info[Playernum-1].numsectsowned && p->info[Playernum-1].comread < 50) {
X		p->info[Playernum-1].comread = 100;
X		p->info[Playernum-1].mob_set = 100;
X		sect->mobilization = 100;
X		sect->is_wasted = 0;
X	  }
X	  sectmod = planetmod = 1;
X	   /* unload some people onto the sector */
X	  sect->popn = s->popn-1;
X	  s->mass -= (s->popn-1) * Race->mass;
X	  sect->owner = Playernum;
X	  p->info[Playernum-1].numsectsowned++;
X	  s->popn = 1;
X       }
X     }
X
X  }
X
X  if (s->whatorbits==LEVEL_UNIV)
X	  deductAPs(APcount, 0, 1);
X  else
X	  deductAPs(APcount, s->storbits, 0);
X
X  s->notified = 0;	/* reset notification */
X  putship(land_shdata, s, shipno);
X  close(land_shdata);
X
X  if (!dock) {
X      if (planetmod) {
X	  putplanet(land_pdata,p,Stars[s->storbits]->planetpos[s->pnumorbits]);
X      }
X      close(land_pdata);
X      free(p);
X
X      if (sectmod && !numdest)
X	  putsector(land_sectdata,sect,p->sectormappos+(y*p->Maxx+x)*sizeof(sectortype));
X      close(land_sectdata);
X      free(sect);
X
X	/* send telegs to anyone there */
X	  teleg_add("",telegram_buf);
X	  if (assault) {
X		  sprintf(buf,"BULLETIN!\n\nPlanet /%s/%s ", 
X			Stars[s->storbits]->name,
X			Stars[s->storbits]->pnames[s->pnumorbits]);
X		  teleg_add(buf,telegram_buf);
X		  sprintf(buf,"ASSAULTED by %s #%d on sector %.0f,%.0f!!\n", 
X			Shipnames[s->type], shipno, s->xpos, s->ypos);
X	  } else {
X		  sprintf(buf,"Bulletin...\n\nShip #%d observed ",shipno);
X		  teleg_add(buf,telegram_buf);
X		  sprintf(buf,"landing on sector %.0f,%.0f, planet /%s/%s.\n",
X			s->xpos,s->ypos,Stars[s->storbits]->name,
X			Stars[s->storbits]->pnames[s->pnumorbits]);
X	  }
X	  teleg_add(buf,telegram_buf);
X	  for (i=1; i<MAXPLAYERS; i++)
X		if (p->info[i-1].numsectsowned && i!=Playernum)
X		     teleg_send(TELEG_PLAYER_AUTO, i, telegram_buf);
X
X
X  	  printf("ship #%d landed on planet.\n",shipno);
X  }
X
X  sigsetmask(mask);
X
X  free(s);
X
X}
X
X
X
Xland_handler()
X{
X close(land_pdata);
X close(land_shdata);
X close(land_sectdata);
X Locks(0);
X longjmp(main_jenv,1);
X}
END_OF_FILE
if test 8171 -ne `wc -c <'land.c'`; then
    echo shar: \"'land.c'\" unpacked with wrong size!
fi
# end of 'land.c'
fi
if test -f 'moveship.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'moveship.c'\"
else
echo shar: Extracting \"'moveship.c'\" \(8342 characters\)
sed "s/^X//" >'moveship.c' <<'END_OF_FILE'
X/*
X * Galactic Bloodshed (Robert Chansky, smq@b)
X *  moveship -- moves specified ship according to its orders.
X *	also deducts fuel from the ship's stores.
X */
X
X
X#include "vars.h"
X#include "ships.h"
X#include "races.h"
X#include "doturn.h"
X#include "shipdata.h"
Xextern shiptype **ships;
Xextern planettype *planets[NUMSTARS][MAXPLANETS];
X#include <math.h>
X
Xextern char telegram_buf[AUTO_TELEG_SIZE];
X  /* amount to move for each dir level. I arrived on these #'s only after
X	hours of dilligent tweaking */
X  /* amount to move for each directory level  */
Xfloat MoveConsts[] = { 3500.0, 300.0, 20.0 };
X  /* amnt to move for each ship speed level (ordered) */
Xfloat SpeedConsts[] = { 0.0, 1.26, 1.73, 1.90, 1.96, 1.98};
X  /* amount of fuel it costs to move at speed level */
Xfloat FuelConsts[] =  { 0.0, 0.5, 1.0, 1.5, 2.0, 2.5 };
X
X
XMoveship(shipno,s)
Xint shipno;
Xshiptype *s;
X{
X double heading,stardist,movedist,truedist,dist,xdest,ydest,sn,cs;
X char buf[200];
X float fuse,mfactor;
X int destlevel,deststar=0,destpnum=0;
X bool move_err = 0;
X shiptype *dsh;
X startype *ost,*dst;
X planettype *opl,*dpl;
X
X
X printf("moving ship #%d\n",shipno);
X
X if (speed_rating(s) && !s->is_docked && !s->is_dead && s->whatdest!=LEVEL_UNIV) {
X
X    /* subtract fuel from the ship */
X   fuse = FuelConsts[s->speed] * FUEL_USE;
X
X   if (s->fuel < fuse) {
X	  /* ship is out of fuel; do whatever it is to do */
X	if (!s->notified) {
X	  s->notified = 1;
X	  teleg_add("",telegram_buf);	/* clear telegram buffer */
X	  sprintf(buf,"Telecomm from %s #%d\n\n",Shipnames[s->type],shipno);
X	  teleg_add(buf,telegram_buf);
X	  sprintf(buf,"%s #%d is out of fuel at %s\n", Shipnames[s->type],
X				shipno, prin_ship_orbits(s));
X	  teleg_add(buf,telegram_buf);
X	  teleg_send(TELEG_PLAYER_AUTO, s->owner, telegram_buf);
X	}
X	return;
X   }
X
X
X/*******   move the ship towards dest ******/
X
X
X
X   switch (s->whatdest) {
X      case LEVEL_STAR:
X	 destlevel = LEVEL_STAR;
X	 deststar = s->deststar;
X	 xdest = Stars[deststar]->xpos;
X	 ydest = Stars[deststar]->ypos;
X	 break;
X      case LEVEL_PLAN:
X	 destlevel = LEVEL_PLAN;
X	 deststar = s->deststar;
X	 destpnum = s->destpnum;
X	 xdest = Stars[deststar]->xpos + planets[deststar][destpnum]->xpos;
X	 ydest = Stars[deststar]->ypos + planets[deststar][destpnum]->ypos;
X	 break;
X      case LEVEL_SHIP:
X	 dsh = ships[s->destshipno];
X	 destlevel = dsh->whatorbits;
X	 deststar = dsh->storbits;
X	 destpnum = dsh->pnumorbits;
X	 xdest = dsh->xpos;
X	 ydest = dsh->ypos;
X	 break;
X      default:
X	 printf("wow, seriously bad error.\n");
X	 return;
X	 break;
X   }
X   dst = Stars[deststar];
X   ost = Stars[s->storbits];
X   dpl = planets[deststar][destpnum];
X   opl = planets[s->storbits][s->pnumorbits];
X
X
X/*  update new xpos,ypos */
X   heading = atan2( xdest-s->xpos, 
X	((ydest - s->ypos)==0.0) ? 0.000001 : (ydest-s->ypos) );
X   mfactor = SpeedConsts[s->speed] * MoveConsts[s->whatorbits] 
X						/ (logscale((int)s->mass) );
X
X
X   truedist = movedist = sqrt( Distsq(s->xpos, s->ypos, xdest, ydest));
X
X
X    /* keep from ending up in the middle of the system. */
X	/* Change the distance so that we
X	   don't go all the way into the system. */
X   if (s->whatorbits==LEVEL_UNIV ||
X	  (destlevel==LEVEL_STAR && s->storbits!=deststar) ||
X	  (destlevel==LEVEL_PLAN && s->storbits!=deststar) &&
X	   truedist >= SYSTEMSIZE)
X   	movedist -= SYSTEMSIZE * 0.90;
X   else if (destlevel==LEVEL_PLAN && s->whatorbits==LEVEL_STAR &&
X		s->storbits==deststar && truedist >= PLORBITSIZE)
X	 /* we're in a system, don't go all the way into a planetary
X	    orbit */
X	movedist -= PLORBITSIZE * 0.90;
X
X
X   if (s->whatdest==LEVEL_SHIP && s->owner!=ships[s->destshipno]->owner
X	&& !isset(races[s->owner]->allied, ships[s->destshipno]->owner)
X   	   && truedist > SYSTEMSIZE*2.0) {
X	  /* (an allied ship lets you follow it..) */
X	  /* we lost sight of the destination ship. */
X	  /* should change SYSTEMSIZE*2.0 to calculated gun range.. */
X	s->whatdest = LEVEL_UNIV;
X	teleg_add("",telegram_buf);
X   	sprintf(buf,"Telecomm from ship #%d at %s\n\n", 
X				shipno, prin_ship_orbits(s));
X   	teleg_add(buf,telegram_buf);
X   	sprintf(buf,"%s #%d lost sight of destination ship #%d.\n", 
X				Shipnames[s->type],shipno,s->destshipno);
X   	teleg_add(buf,telegram_buf);
X   	teleg_send(TELEG_PLAYER_AUTO, s->owner, telegram_buf);
X	return;
X   }
X
X
X   if (truedist > DIST_TO_LAND) {
X   	s->fuel -= fuse;
X   	s->mass -= fuse * MASS_FUEL;
X
X		/* dont overshoot */
X	sn = sin(heading);
X	cs = cos(heading);
X   	xdest = sn * mfactor;
X   	ydest = cs * mfactor;
X    	if (hypot(xdest, ydest) > movedist) {
X		xdest = sn * movedist;
X		ydest = cs * movedist;
X	}
X   	s->xpos += xdest;
X   	s->ypos += ydest;
X   }
X
X/*****  check if far enough away from object it's orbiting to break orbit *****/
X
X  if (s->whatorbits==LEVEL_PLAN) {
X	 printf("dist from orbts planet is %lf\n",
X		dist = sqrt( Distsq(s->xpos, s->ypos, 
X			ost->xpos+opl->xpos, ost->ypos+opl->ypos ) ) );
X	 if (dist > PLORBITSIZE) {
X		s->whatorbits = LEVEL_STAR;
X	 	printf("ship #%d departed from planet /%s/%s.\n",shipno, ost->name, ost->pnames[s->pnumorbits]);
X	 }
X
X   } else if (s->whatorbits==LEVEL_STAR) {
X	 printf("star orbits dist is %lf\n",dist = sqrt( Distsq(s->xpos, 
X	    s->ypos, ost->xpos, ost->ypos ) ) );
X	 if (dist > SYSTEMSIZE) {
X		s->whatorbits = LEVEL_UNIV;
X	 	printf("ship #%d departed from system %s.\n",shipno, ost->name);
X	 }
X   }
X
X	/*******   check for arriving at destination *******/
X
X   if (destlevel==LEVEL_STAR || (destlevel==LEVEL_PLAN
X	&& !(s->whatorbits!=LEVEL_UNIV && s->storbits==deststar) ) ) {
X       		/* not in same star system as deststar */
X
X	 stardist = sqrt(Distsq(s->xpos,s->ypos,dst->xpos,dst->ypos));
X	 printf("dist from dest syst is %g\n",stardist);
X	 if (stardist <= SYSTEMSIZE) {
X	   if (s->type == STYPE_POD)
X		s->notified = 1;	/* signal to explode */
X	    /* mark as explored & inhabited by that player */
X	   setbit(dst->explored, s->owner);
X	   setbit(dst->inhabited, s->owner);
X	   printf(" ship #%d arrived at system %s.\n",shipno,dst->name);
X	   s->whatorbits = LEVEL_STAR;
X	   s->storbits = deststar;
X	   if (destlevel == LEVEL_STAR) {
X		  teleg_add("",telegram_buf);
X		  sprintf(buf,"Telecomm from ship #%d\n\n",shipno);
X		  teleg_add(buf,telegram_buf);
X		  sprintf(buf,"%s #%d arrived at system %s.\n",
X			   Shipnames[s->type], shipno, prin_ship_orbits(s));
X		  teleg_add(buf,telegram_buf);
X		  teleg_send(TELEG_PLAYER_AUTO, s->owner, telegram_buf);
X		/* clear orders if the ship is not headed to a planet in
X		   this system */
X	   	  s->whatdest = LEVEL_UNIV;
X	   }
X	 }
X
X   } else if ( destlevel==LEVEL_PLAN && 
X		 (s->whatorbits!=LEVEL_UNIV && deststar==s->storbits  &&
X		!(s->whatorbits==LEVEL_PLAN && s->pnumorbits==destpnum)) ) {
X	/* headed for a planet in the same system, & not already there.. */
X
X	 printf("dist from target planet is %lf\n",movedist );
X	 if (movedist<=PLORBITSIZE) {
X		 /* mark planet as explored by that player */
X	   dpl->info[s->owner-1].explored = 1;
X		 /* mark sun as explored too, if the ship might have bypassed it
X		    (we are trying to be thorough here) */
X	   setbit(dst->explored, s->owner);
X	   setbit(dst->inhabited, s->owner);
X	   s->whatorbits = LEVEL_PLAN;
X	   s->pnumorbits = destpnum;	
X
X	   teleg_add("",telegram_buf);
X	   sprintf(buf,"Telecomm from ship #%d\n\n",shipno);
X	   teleg_add(buf,telegram_buf);
X	   sprintf(buf,"%s #%d arrived at planet %s.\n",Shipnames[s->type],
X				shipno, prin_ship_orbits(s));
X	   teleg_add(buf,telegram_buf);
X	   if (s->type==STYPE_ASS)
X		teleg_add("\nEnslavement of the planet is now possible.\n",
X			telegram_buf);
X	   teleg_send(TELEG_PLAYER_AUTO, s->owner, telegram_buf);
X
X 	   printf("%s #%d arrived at planet /%s/%s.\n", Shipnames[s->type],
X		shipno, ost->name, ost->pnames[s->pnumorbits]);
X	 }
X
X  } 
X
X }
X
X}
X
X
X
X/* 
X * insert the ship into wherever it's supposed to be.
X *  this is done every turn, for every ship; as a bonus it puts them in
X *  alphabetical order.
X */
Xinsert_sh(sdata, star, pl, s, shipno)
Xstruct stardata *sdata;
Xstartype *star;
Xplanettype *pl;
Xshiptype *s;
Xint shipno;
X{
X
X if (!s->is_dead)
X    switch (s->whatorbits) {
X	case LEVEL_UNIV:
X		s->nextship = sdata->ships;
X		sdata->ships = (us)shipno;
X		break;
X	case LEVEL_STAR:
X		s->nextship = star->ships;
X		star->ships = (us)shipno;
X		break;
X	case LEVEL_PLAN:
X		s->nextship = pl->ships;
X		pl->ships = (us)shipno;
X		break;
X	default:
X		break;
X    }
X
X}
END_OF_FILE
if test 8342 -ne `wc -c <'moveship.c'`; then
    echo shar: \"'moveship.c'\" unpacked with wrong size!
fi
# end of 'moveship.c'
fi
if test -f 'rst.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'rst.c'\"
else
echo shar: Extracting \"'rst.c'\" \(8283 characters\)
sed "s/^X//" >'rst.c' <<'END_OF_FILE'
X/*
X * Galactic Bloodshed (Robert Chansky, smq@ssyx)
X *  ship -- report -- stock -- tactical -- stuff on ship
X */
X
X#define REPORT	0
X#define STOCK	1
X#define TACTICAL 2
X#define SHIP	3
X#define OBJECT	4
X
X#define PLANET 1
X
X#include <math.h>
X#include "vars.h"
X#include "ships.h"
X#include "races.h"
Xextern char Shipltrs[];
Xextern int God;
Xstatic bool Object,Ship,Stock,Report,Tactical,first;
X
Xextern float Kill_factor();
X
Xstruct reportdata {
X	unsigned type : 1;	/* ship or planet */
X	shiptype *s;
X	planettype *p;
X	short n;
X	unsigned char star,pnum;
X	float x,y;
X};
X
Xint Num_ships;
X
Xrst(APcount, argn,args,Rst)
Xint APcount;
Xint argn;
Xchar args[MAXARGS][COMMANDSIZE];
Xint Rst;
X{
X int shdata,shipno;
X reg int shn,i;
X struct reportdata *rd;
X
X Num_ships = 0;
X first = 1;
X switch (Rst) {
X	case REPORT:	Report = 1;
X			Object = Stock = Ship = Tactical = 0;
X			break;
X	case STOCK:	Stock = 1;
X			Object = Report = Ship = Tactical = 0;
X			break;
X	case TACTICAL:	Tactical = 1;
X			Object = Report = Ship = Stock = 0;
X			break;
X	case SHIP:	Ship = Report = Stock = Tactical = 1;
X			Object = 0;
X			break;
X	case OBJECT:	Object = Report = Stock = Tactical = 1;
X			Ship = 0;
X			break;
X }
X
X openshdata(&shdata);
X rd = (struct reportdata *)malloc(sizeof(struct reportdata) * Numships(shdata) +
X	Sdata.numstars * (MAXPLANETS+1));
X		/* (one list entry for each ship, planet in universe) */
X close(shdata);
X
X if (argn==2) {
X   sscanf(args[1] + (*args[1]=='#'),"%d",&shipno);
X   openshdata(&shdata);
X   Getrship(shdata,rd, shipno);
X   close(shdata);
X   ship_report(rd,0);		/* first ship report */
X
X } else
X
X  switch (Dir.level) {
X   case LEVEL_UNIV:
X	  openshdata(&shdata);
X	  shn = Sdata.ships;
X	  while (shn) {
X	      Getrship(shdata,rd, shn);
X	      shn = rd[Num_ships-1].s->nextship;
X	  }
X	  close(shdata);
X      for (i=0; i<Sdata.numstars; i++)
X        star_getrships(rd,i);
X      for (i=0; i<Num_ships; i++)
X        ship_report(rd,i);
X      break;
X   case LEVEL_STAR:
X      star_getrships(rd,Dir.snum);
X      for (i=0; i<Num_ships; i++)
X        ship_report(rd,i);
X      break;
X   case LEVEL_PLAN:
X      plan_getrships(rd, Dir.snum, Dir.pnum);
X      for (i=0; i<Num_ships; i++)
X        ship_report(rd,i);
X      break;
X   case LEVEL_SHIP:
X      openshdata(&shdata);
X      Getrship(shdata,rd, Dir.shipno);
X      close(shdata);
X      ship_report(rd,0);		/* first ship report */
X      break;
X  }
X
X  Free_shiplist(rd);
X
X}
X
X
Xship_report(rd,indx)
Xstruct reportdata rd[];
Xint indx;
X{
X shiptype *s;
X planettype *p;
X int shipno;
X reg int i;
X placetype where;
X char orb[PLACENAMESIZE];
X float Dist;
X 
X	/* last ship gotten from disk */
X  s = rd[indx].s;
X  p = rd[indx].p;
X  shipno = rd[indx].n;
X
X
X	/* launched canister, non-owned ships don't show up */
X  if ( (rd[indx].type==PLANET && p->info[Playernum-1].numsectsowned)
X      || (rd[indx].type!=PLANET && s->owner==Playernum && 
X	!(s->type==OTYPE_CANIST && !s->is_docked) && !s->is_dead) ) {
X
X
X   if (rd[indx].type!=PLANET && Stock) {
X    if (first) {
X      printf("  #   mass res  ^res  dest ^dest   fuel ^fuel  crew ^crew dock\n");
X      if (!Ship && !Object)
X	      first=0;
X    }
X    /*if (is_object(s) == Object)*/
X     if (s->owner == Playernum || God) {
X      printf("%3d %c%5.1f%4u%6d%6u%6d%7.1f%6d%6u%6d%5s",
X	shipno, Shipltrs[s->type], s->mass,
X	s->resource, Shipdata[s->type][ABIL_CARGO],
X	s->destruct, Shipdata[s->type][ABIL_DESTCAP],
X	s->fuel, Shipdata[s->type][ABIL_FUELCAP],
X	s->popn, Shipdata[s->type][ABIL_MAXCREW],
X	(s->is_docked) ? ((s->whatdest==LEVEL_PLAN) ? "land" : "dock") :"    ");
X      if (s->type==OTYPE_VN) 
X	printf(" * %d",s->orders.object.number);
X      if (s->rad)
X	printf(" INACTIVE(%d)",s->rad);
X      putchr('\n');
X
X    }
X   }
X   if (rd[indx].type!=PLANET && Report) {
X         if (first) {
X		 printf("  #    own crew dam dest  fuel speed              orbits           destination\n");
X		 if (!Ship && !Object)
X		      first=0;
X	 }
X
X	if (s->owner == Playernum || God) {
X	 /*if (is_object(s) == Object) */
X 	  printf("%3d %c%5u%4u%4u%5u%7.1f%4u%5s%20s%20s",
X		shipno, Shipltrs[s->type],
X		s->owner, s->popn, s->damage, s->destruct, s->fuel, s->speed, 
X		(s->is_docked) ? ( (s->whatdest==LEVEL_SHIP) ? "dock" 
X			: "land") : "    ",
X		prin_ship_orbits(s), prin_ship_dest(s) );
X         if (s->type==OTYPE_VN) printf("* %d",s->orders.object.number);
X      if (s->rad)
X	printf(" INACTIVE(%d)",s->rad);
X         putchr('\n');
X
X	}
X   }
X
X   if (Tactical) {
X
X	printf("\n  # typ GUNS dest  fuel dam    x,y abs         x,y rel    orbits\n");
X
X	if (rd[indx].type==PLANET) {
X		/* tac report from planet */
X		printf("(planet)%4d%5u%6u    %7.0f,%-7.0f %7.0f,%-7.0f%10s\n",
X			PLAN_FIRE_LIM, p->info[Playernum-1].destruct,
X			p->info[Playernum-1].fuel,
X			rd[indx].x , rd[indx].y, p->xpos, p->ypos,
X			Stars[rd[indx].star]->pnames[rd[indx].pnum]);
X
X	} else {
X
X 	  where.level = s->whatorbits;
X 	  where.snum = s->storbits;
X 	  where.pnum = s->pnumorbits;
X	  sprintf(orb, "%.30s", Dispplace(&where));
X	  printf("%3d  %c%6d%5u%6.1f%4u%7.0f,%-7.0f %7.0f,%-7.0f%10s",
X		shipno, Shipltrs[s->type], Shipdata[s->type][ABIL_GUNS],
X		s->destruct, s->fuel, s->damage, 
X		s->xpos, s->ypos, s->xpos-rd[indx].x, s->ypos-rd[indx].y, orb );
X	  if (s->type == OTYPE_VN)
X		printf(" * %d", s->orders.object.number);
X          if (s->rad)
X		printf(" INACTIVE(%d)",s->rad);
X	  putchr('\n');
X
X	}
X
X		/* tactical display */
X	printf("           Tac display:  # own typ     rng    %%dam %%dam given\n");
X	for (i=0; i<Num_ships; i++) {
X	   if (i!=indx && (Dist = sqrt(Distsq(rd[indx].x, rd[indx].y, 
X				rd[i].x, rd[i].y))) < gun_range(Race, NULL))
X	      if (rd[i].type==PLANET) {
X		/* tac report at planet */
X		   printf("             %13s(planet)%8.1f      %13.1f\n", 
X			Stars[rd[i].star]->pnames[rd[i].pnum], Dist, 
X			Kill_factor(Dist, rd[indx].type==PLANET ? PLAN_FIRE_LIM
X					: Shipdata[s->type][ABIL_GUNS])
X					* FACTOR_DESTPLANET );
X	      } else {
X			/* tac report at ship */
X
X		if (rd[i].s->owner!=Playernum) {
X		   printf("           %15d%4d  %c%9.1f%8u%11.1f%%",
X			rd[i].n, rd[i].s->owner, Shipltrs[rd[i].s->type], Dist,
X			rd[i].s->damage,
X			Kill_factor(Dist, rd[indx].type==PLANET ? PLAN_FIRE_LIM
X				: Shipdata[s->type][ABIL_GUNS]) / 
X				(float)Shipdata[rd[i].s->type][ABIL_ARMOR]);
X		   if (rd[i].s->type==OTYPE_VN)
X			printf(" * %d", rd[i].s->orders.object.number);
X		   putchr('\n');
X		}
X	      }
X	}
X   }
X
X
X  }
X
X}
X
X
X
Xplan_getrships(rd,snum,pnum)
Xstruct reportdata rd[];
Xint snum, pnum;
X{
X reg int i,shn;
X planettype *p;
X int shdata,pdata;
X
X openpdata(&pdata);
X  Locks(1);
X   getplanet(pdata, &rd[Num_ships].p, Stars[snum]->planetpos[pnum]);
X  Locks(0);
X close(pdata);
X p = rd[Num_ships].p;
X	/* add this planet into the ship list */
X rd[Num_ships].star = snum;
X rd[Num_ships].pnum = pnum;
X rd[Num_ships].type = PLANET;
X rd[Num_ships].n = 0;
X rd[Num_ships].x = Stars[snum]->xpos + p->xpos;
X rd[Num_ships].y = Stars[snum]->ypos + p->ypos;
X    Num_ships++;
X
X if (p->info[Playernum-1].explored) {
X
X   openshdata(&shdata);
X   shn = p->ships;
X   while (shn) {
X	Getrship(shdata, rd, shn);
X		/* add offsets for docked ships */
X	if (rd[Num_ships-1].s->is_docked && 
X			rd[Num_ships-1].s->whatdest==LEVEL_PLAN) {
X		rd[Num_ships-1].x += Stars[snum]->xpos + p->xpos;
X		rd[Num_ships-1].y += Stars[snum]->ypos + p->ypos;
X	}
X	shn = rd[Num_ships-1].s->nextship;
X   }
X   close(shdata);
X }
X free(p);
X
X}
X
X
X
Xstar_getrships(rd,snum)
Xstruct reportdata rd[];
Xint snum;
X{
X reg int shn;
X int i,shdata;
X
X if (isset(Stars[snum]->inhabited, Playernum)) {
X   openshdata(&shdata);
X   shn = Stars[snum]->ships;
X   while (shn) {
X	Getrship(shdata, rd, shn);
X	shn = rd[Num_ships-1].s->nextship;
X   }
X   close(shdata);
X   for (i=0; i<Stars[snum]->numplanets; i++)
X     plan_getrships(rd, snum, i);
X }
X}
X
X
X/* get a ship from the disk and add it to the ship list we're maintaining. */
XGetrship(shdata,rd, shipno)
Xint shdata,shipno;
Xstruct reportdata rd[];
X{
Xint noerr;
X
X   Locks(1);
X    noerr = getship(shdata,&rd[Num_ships].s,shipno);
X   Locks(0);
X   rd[Num_ships].type = 0;
X   rd[Num_ships].n = shipno;
X   rd[Num_ships].x = rd[Num_ships].s->xpos;
X   rd[Num_ships].y = rd[Num_ships].s->ypos;
X   if (noerr)
X	Num_ships++;
X}
X
X
X
XFree_shiplist(rd)
Xstruct reportdata rd[];
X{
X reg int i;
X
X for (i=0; i<Num_ships; i++)
X	if (rd[i].type==PLANET)
X		free(rd[i].p);
X	else
X		free(rd[i].s);
X
X free(rd);
X}
END_OF_FILE
if test 8283 -ne `wc -c <'rst.c'`; then
    echo shar: \"'rst.c'\" unpacked with wrong size!
fi
# end of 'rst.c'
fi
echo shar: End of archive 4 \(of 8\).
cp /dev/null ark4isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 8 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