[comp.sources.games] v10i004: gb3 - Galactic Bloodshed, an empire-like war game [Ver. 2.0], Part04/14

billr@saab.CNA.TEK.COM (Bill Randle) (06/02/90)

Submitted-by: VANCLEEF@mps.ohio-state.edu
Posting-number: Volume 10, Issue 4
Archive-name: gb3/Part04
Supersedes: GB2: Volume 7, Issue 44-51



#! /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 14)."
# Contents:  server/land.c server/load.c server/name.c
#   server/planet.list
# Wrapped by billr@saab on Fri Jun  1 11:53:33 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'server/land.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'server/land.c'\"
else
echo shar: Extracting \"'server/land.c'\" \(18841 characters\)
sed "s/^X//" >'server/land.c' <<'END_OF_FILE'
X/*
X** Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky, 
X** smq@ucscb.ucsc.edu, mods by people in GB_copyright.h.
X** Restrictions in GB_copyright.h.
X**
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/dock
X*/
X
X#include "GB_copyright.h"
X#define EXTERN extern
X#include "vars.h"
X#include "ships.h"
X#include "races.h"
X#include "buffers.h"
X#include <signal.h>
X#include <math.h>
X
Xint land_sectdata,land_shdata,land_pdata, land_racedata;
Xint land_stdata;
X
Xland(Playernum,APcount, argn,args, Assault)
Xint Playernum;
Xint APcount;
Xint argn;
Xchar args[MAXARGS][COMMANDSIZE];
Xint Assault;	/* unfriendly land */
X{
Xchar c;
Xshiptype *s,*s2,*s3;
Xplanettype *p;
Xsectortype *sect;
Xplacetype where;
Xracetype *alien;
Xboolean Land=0,Dock=0,cont,planetmod=0,sectmod=0;
Xint boarders,oldspopn,olds2popn,dam,dam2,booby,
X	numdest=0,ship2no,shipno,x= -1,y= -1,i,mask;
Xint old2owner,sh, sh3;
Xint sowner, s2owner, casualties, casualties2;
Xfloat fuel,bstrength,b2strength,pris;
Xdouble Dist;
X
Xland_sectdata = land_shdata = land_pdata = NEUTRAL_FD;
X
X
X	sscanf(args[1]+(args[1][0]=='#'),"%d",&shipno);
X
X
Xfree(Race);
Xopenracedata(&land_racedata);
Xgetrace(land_racedata, &Race, Playernum); 
Xclose_file(land_racedata);
X
X openshdata(&land_shdata);
X  if (!getship(land_shdata, &s, shipno)) {
X      notify(Playernum, "The ship wasn't found.\n");
Xclose_file(land_shdata);
X	return;
X  }
Xclose_file(land_shdata);
X  if (testship(Playernum,s, shipno)) {
X      notify(Playernum, "Illegal format.\n");
X	return;
X	}
X
X  if (s->is_docked) {
X	sprintf(buf,"Ship #%d is already docked.\n",shipno);
X		notify(Playernum, buf);
X	return;
X  }
X
X
X  if (s->whatorbits==LEVEL_UNIV) {
X     if (!enufAP(Playernum,Sdata.AP[Playernum-1], APcount)) {
X	return;
X	} 
X } else
X     if (!enufAP(Playernum,Stars[s->storbits]->AP[Playernum-1], APcount)) { 
X	return;
X	}
X
X        if(args[0][0]=='l')
X		sscanf(args[2],"%d,%d",&x,&y); /* landing on a sector */
X	else
X		sscanf(args[2]+(args[2][0]=='#'),"%d",&ship2no);
X
X  if (args[0][0]=='l') {
X	/* the command was 'land', don't need to get stuff */
X    where.level = LEVEL_PLAN;
X    where.snum = s->storbits;
X    where.pnum = s->pnumorbits;
X    where.err = 0;
X  } else {	
X
X    where = Getplace(Playernum,args[2], 1);
X    if (where.err) {
X	return;
X	}
X  }
X
X  if (where.level==LEVEL_PLAN)
X	Land = 1;
X  else if (where.level==LEVEL_SHIP)
X	Dock = 1;
X  else {
X	sprintf(buf,"Your ship is not equipped to do that!\n");
X	notify(Playernum, buf);
X	return;
X  }
X
X
X  if (Dock) {
X
X	ship2no = where.shipno;
X	s2 = where.shipptr;
X	free(where.shipptr);	/* re-get ship cuz it wasn't locked */
Xopenshdata(&land_shdata);
X     	if (!getship(land_shdata, &s2, ship2no)) {
X	    close_file(land_shdata);
X	    return;
X		}
X	close_file(land_shdata);
X	
X	if ( !(s->type == STYPE_FIGHTER && s2->type == STYPE_CARRIER) ) {
X	   if (s2->is_docked && !Assault) {
X		sprintf(buf,"ship #%d is already docked.\n",ship2no);
X			notify(Playernum, buf);
X		return;
X	   }
X	sprintf(buf,"Distance to %s #%d: %.2f.\n", s2->name, ship2no,
X  		Dist = sqrt((double)Distsq(s2->xpos, s2->ypos, 
X			s->xpos, s->ypos ) ) );
X		notify(Playernum, buf);
X	if (Dist > DIST_TO_LAND) {
X	     sprintf(buf,"Ship #%d must be %.2f or closer to ship #%d.\n",
X			shipno, DIST_TO_LAND, ship2no);
X		notify(Playernum, buf);
X		return;
X	}
X
X	fuel = 0.05 + Dist * 0.25 * (Assault ? 2.0 : 1.0);
X	sprintf(buf,"This maneuver will take %.2f fuel (of %.2f.)\n\n",fuel,s->fuel);
X		notify(Playernum, buf);
X	if (fuel > s->fuel) {
X		sprintf(buf,"Not enough fuel.\n");
X			notify(Playernum, buf);
X		return;
X	}
X
X	if (Assault) {
X	openracedata(&land_racedata);
X		getrace(land_racedata, &alien, s2->owner);
X	close_file(land_racedata);
X
X	sscanf(args[3],"%d",&boarders);
X		if (boarders > MIN(s->popn, Max_crew(s2))
X		    || boarders <= 0) {
X			sprintf(buf,"Illegal number of boarders (max can be %d).\n",
X				MIN(s->popn, Max_crew(s2)));
X			notify(Playernum, buf);
X			return;
X		}
X		old2owner = s2->owner;
X		s->popn -= boarders;
X		s->mass -= boarders * Race->mass;
X		sprintf(buf,"Boarding strength :%.2f       Defense strength: %.2f.\n", 
X		   bstrength = 0.1 * boarders * log10(Race->fighters
X			* (Race->tech+1.0)
X	 	        * Size(s) * 1 + 10)
X			* .01 * (100 - s->damage),
X		/* 1 is dummy armor */
X
X		   b2strength = 0.1* s2->popn * log10(alien->fighters
X			* (alien->tech+1.0)
X	 		* Size(s2) * (Armor(s2)+1) + 10)
X			* .01 * (100 - s2->damage)
X				);
X	notify(Playernum, buf);
X
X	}
X
X
X	 /* the ship moves into position, regardless of success of attack */
X	s->fuel -= fuel;
X	s->mass -= fuel * MASS_FUEL;
X
X	s->xpos = s2->xpos + rposneg();		/* either -1 or 1 */
X	s->ypos = s2->ypos + int_rand(-1,1);
X
X	if (Assault) {
X/* if the assaulted ship is docked, undock it first */
X	if(s2->is_docked && s2->whatdest==LEVEL_SHIP) {
X	    openshdata(&land_shdata);
X	    getship(land_shdata, &s3, s2->destshipno);
X	    s3->is_docked = 0;
X	    s3->whatdest = LEVEL_UNIV;
X	    s3->destshipno = 0;
X	    putship(land_shdata, s3, s2->destshipno);
X	    close_file(land_shdata);
X	    free(s3);
X	    s2->is_docked = 0;
X	    s2->whatdest = LEVEL_UNIV;
X	    s2->destshipno = 0;
X	}
X		 /* nuke both populations, ships */
Xif(b2strength) {	/* otherwise the ship surrenders */
X		casualties = MIN(boarders, int_rand(0,
X		       round_rand((float)boarders * b2strength / bstrength)));
X		boarders -= casualties;
X
X	        dam = MIN(100, int_rand(0, round_rand(25. * b2strength/bstrength)));
X		s->damage = MIN(100, s->damage+dam);
X		if (s->damage >= 100) {
X			s->popn = 0;
X			kill_ship(s);
X			}			
X
X		   casualties2 = MIN(s2->popn, int_rand(0,
X	       		 round_rand((float)s2->popn * bstrength / b2strength)));
X		   s2->popn -= casualties2;
X		   s2->mass -= casualties2 * alien->mass;
X			/* (their mass) */
X		   dam2 = MIN(100, int_rand(0,round_rand(25. * bstrength/b2strength)));
X		   s2->damage = MIN(100, s2->damage+dam2);
X		   if ( s2->damage >= 100) {
X			s2->popn = 0;
X			kill_ship(s2);
X			}
X} else {
X	s2->popn = 0;
X/* do booby traps */
X		 /* check for boobytrapping */
X		if (!Max_crew(s2) && s2->destruct > 0)
X			booby = MIN(100, int_rand(0,round_rand(
X				     log1p((double)s2->destruct)*50)));
X
X	}
X
X		   if ((s2->popn == 0) &&  s->is_alive && s2->is_alive) {
X				/* we got 'em */
X			s->is_docked = 1;
X			s->whatdest = LEVEL_SHIP;
X			s->destshipno = ship2no;
X
X			s2->is_docked = 1;
X			s2->whatdest = LEVEL_SHIP;
X			s2->destshipno = shipno;
X			old2owner = s2->owner;
X			s2->owner = Playernum;
X			s2->popn = boarders;
X			s2->mass += boarders * Race->mass;	/* our mass */
X		   } else {		/* retreat */
X			s->popn += boarders;
X			s->mass += boarders * Race->mass;
X		   }
X
X	} else {
X		s->is_docked = 1;
X		s->whatdest = LEVEL_SHIP;
X		s->destshipno = ship2no;
X
X		s2->is_docked = 1;
X		s2->whatdest = LEVEL_SHIP;
X		s2->destshipno = shipno;
X	}
X
X	s->notified = s2->notified = 0;
X	   openshdata(&land_shdata);
X	putship(land_shdata, s, shipno);
X	putship(land_shdata, s2, ship2no);
X	   free(s2);
X	   close_file(land_shdata);
X	if (Assault) {
X/* races find out about each other */
X	alien->translate[Playernum-1] = MIN(alien->translate[Playernum-1]+5, 100);
X	Race->translate[s2->owner-1] = MIN(Race->translate[s2->owner-1]+5, 100);
Xsowner = s->owner;
Xs2owner = s2->owner;
X		sprintf(telegram_buf,"%s #%d ASSAULTED by ",
X			Shipnames[s2->type], ship2no);
X	         sprintf(buf,"%s #%d [%d] at %s\n", 
X			Shipnames[s->type], shipno, s->owner, prin_ship_orbits(s2));
X			str_cat(telegram_buf, buf);
X		sprintf(buf,"Your damage: %d%%, theirs: %d%%.\n", dam2, dam);
X			str_cat(telegram_buf, buf);
X		if (!Max_crew(s2) && s2->destruct) {
X		       sprintf(buf,"(Your boobytrap gave them %.0f%% damage.)\n",
X				booby);
X			str_cat(telegram_buf, buf);
X			sprintf(buf,"Their boobytrap gave you %.0f%% damage!)\n",
X				booby);
X			notify(Playernum, buf);
X		}
X		sprintf(buf,"Damage taken:  You: %d%% (now %d%%)\n", dam, s->damage);
X			notify(Playernum, buf);
Xif(!s->is_alive) {
X  sprintf(buf,"              YOUR SHIP WAS DESTROYED!!!\n");
X			notify(Playernum, buf);
X  sprintf(buf,"              Their ship DESTROYED!!!\n");
X		str_cat(telegram_buf, buf);
X}
X		sprintf(buf,"              Them: %d%% (now %d%%)\n",dam2,s2->damage);
X			notify(Playernum, buf);
Xif(!s2->is_alive) {
X  sprintf(buf,"              Their ship DESTROYED!!!  Boarders are dead.\n");
X			notify(Playernum, buf);
X  sprintf(buf,"              YOUR SHIP WAS DESTROYED!!!\n");
X		str_cat(telegram_buf, buf);
X}
X		if (s->is_alive) {
X			if (s2->owner==Playernum) {
X				sprintf(buf,"CAPTURED!\n");
X					str_cat(telegram_buf, buf);
X				sprintf(buf,"VICTORY! the ship is yours!\n");
X					notify(Playernum, buf);
X				if (boarders) {
X				  sprintf(buf,"%d boarders move in.\n", boarders);
X					notify(Playernum, buf);
X					}
X
X	Race->translate[s2owner-1] = MIN(Race->translate[s2owner-1]+25, 100);
X
X			} else if(s2->popn) {
X				sprintf(buf,"The boarding was repulsed; try again.\n");
X					notify(Playernum, buf);
X				sprintf(buf,"You fought them off!\n");
X					str_cat(telegram_buf, buf);
X			}
X		} else {
X			sprintf(buf,"The assault was too much for your bucket of bolts.\n");
X					notify(Playernum, buf);
X			sprintf(buf,"The assault was too much for their ship..\n");
X				str_cat(telegram_buf, buf);
X		}
X		if (s2->is_alive) {
X			if (!boarders) {
X				sprintf(buf,"Oh no! They killed your boarding party to the last man!\n");
X					notify(Playernum, buf);
X	alien->translate[sowner-1] = MIN(alien->translate[sowner-1]+25, 100);
X			}
X
X			if (!s->popn) {
X				sprintf(buf,"You killed all their crew!\n");
X				str_cat(telegram_buf, buf);
X			} 
X		} else {
X			sprintf(buf,"The assault weakened their ship too much!\n");
X				notify(Playernum, buf);				
X			sprintf(buf,"Your ship was weakened too much!\n");
X				str_cat(telegram_buf, buf);
X		}
X		sprintf(buf,"Casualties: Yours: %d     Theirs: %d\n", casualties2, casualties);
X			str_cat(telegram_buf, buf);
X		sprintf(buf,"Crew casualties: Yours: %d     Theirs: %d\n", casualties, casualties2);
X			notify(Playernum, buf);
X			if(!notify(old2owner, telegram_buf))
X			    push_message(TELEG_PLAYER_AUTO, old2owner, telegram_buf);
Xopenracedata(&land_racedata);
Xputrace(land_racedata, Race);
Xputrace(land_racedata, alien);
Xclose_file(land_racedata);
X
X	} else {
X		sprintf(buf,"ship #%d docked with ship #%d.\n",shipno, ship2no);
X			notify(Playernum, buf);
X		}
X
X	} else {
X		/* docking fighters with a carrier */
X
X	if(s->whatorbits==LEVEL_PLAN)
X		{
X     openpdata(&land_pdata);
X     getplanet(land_pdata, &p, Stars[s->storbits]->planetpos[s->pnumorbits]);
X
X	sh = p->ships;
X	if(sh == shipno){
X		p->ships = s->nextship;
X		putplanet(land_pdata, p, Stars[s->storbits]->planetpos[s->pnumorbits]);
X	    } else {
Xopenshdata(&land_shdata);
X	    while(sh != shipno){
X		getship(land_shdata, &s3, sh);
X		sh3 = sh;
X		sh = s3->nextship;
X	  }
X	  s3->nextship = s->nextship;
X	  if(sh3 == ship2no)s2->nextship = s3->nextship;
X	  putship(land_shdata, s3, sh3);
X	  close_file(land_shdata);
Xfree(s3);
X}
X      close_file(land_pdata);
X		}
X
X
X	if(s->whatorbits==LEVEL_STAR)
X		{
X     openstardata(&land_stdata);
X     getstar(land_stdata, &Stars[s->storbits], s->storbits);
X
X	sh = Stars[s->storbits]->ships;
X	if(sh == shipno){
X		Stars[s->storbits]->ships = s->nextship;
X	putstar(land_stdata, Stars[s->storbits], s->storbits);
X			} else {
X	openshdata(&land_shdata);
X	while(sh != shipno){
X     	getship(land_shdata, &s3, sh);
X	sh3 = sh;
X	sh = s3->nextship;
X    }
X	s3->nextship = s->nextship;
X	if(sh3 == ship2no)s2->nextship = s3->nextship;
X
X	putship(land_shdata, s3, sh3);
X	close(land_shdata);
X	free(s3);
X    }
X
X     close_file(land_stdata);
X		}
X
X
X		s->fuel -= fuel;
X		s->mass -= fuel * MASS_FUEL;
X		s->is_docked = 1;
X		s->whatdest = LEVEL_SHIP;
X		s->whatorbits = LEVEL_UNIV;
X		s->destshipno = ship2no;
X		s->nextship = 0;
X
X		s->xpos = s2->xpos;
X		s->ypos = s2->ypos;
X
X		s->object.number = s2->object.number;
X		s->object.number4 = 1; /* docked with carrier */
X
X		 /* remove fighter from upper level linked list */
X		s2->object.number = shipno;
X		s2->object.number4 += 1; /* number of fighters docked */
X		s2->mass += s->mass;
X
X		s->notified = s2->notified = 0;
X	openshdata(&land_shdata);
X	putship(land_shdata, s, shipno);
X		putship(land_shdata, s2, ship2no);
X	free(s2);
X	close(land_shdata);
X    }
X
X  } else {	/* docking with a planet */
X
X     if (s->whatorbits!=LEVEL_PLAN) {
X	sprintf(buf,"%s #%d doesn't orbit a planet.\n", Shipnames[s->type],
X		shipno);
X		notify(Playernum, buf);
X	return;
X     }
X     if (Assault && s->popn < 1) {
X	sprintf(buf,"The assaulting ship must have >= 1 crew.\n");
X		notify(Playernum, buf);
X	return;
X     }
X
X    if(s->storbits != Dir[Playernum-1].snum || s->pnumorbits != Dir[Playernum-1].pnum)
X    	{
X	sprintf(buf,"Wrong scope!\n");
X		notify(Playernum, buf);
X	return;
X	}
X
X
X     openpdata(&land_pdata);
X     getplanet(land_pdata, &p, Stars[s->storbits]->planetpos[s->pnumorbits]);
X     close_file(land_pdata);
X     
X     sprintf(buf,"Planet /%s/%s has gravity field of %.2f.\n", Stars[s->storbits]->name,
X	Stars[s->storbits]->pnames[s->pnumorbits], gravity(p));
X		notify(Playernum, buf);
X
X     sprintf(buf,"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		notify(Playernum, buf);
X
X     if (Dist > DIST_TO_LAND) {
X        sprintf(buf,"Ship #%d must be %.3g or closer to the planet (%.2f).\n",shipno, DIST_TO_LAND, Dist);
X		notify(Playernum, buf);
X	return;
X     }
X
X     fuel = 0.05 + logscale((int)s->mass)*gravity(p) * LAND_GRAV_MASS_FACTOR + Assault;
X
X     if (fuel < s->fuel) {
X  	if (!Shipdata[s->type][ABIL_CANLAND] && !Dock) {
X		sprintf(buf,"This ship is not equipped to land.\n");
X		notify(Playernum, buf);
X		return;
X  	}
X  	if (!speed_rating(s)) {
X		sprintf(buf,"This ship is not rated for maneuvering.\n");
X		notify(Playernum, buf);
X		return;
X  	}
X  	if (!Dock && (s->resource > Max_resource(s)
X	    || s->fuel > Max_fuel(s)
X	    || s->popn > Max_crew(s)
X	    || s->destruct > Max_destruct(s))) {
X		sprintf(buf,"Ship is too overloaded to land.\n");
X		notify(Playernum, buf);
X		return;
X  	}
X     }
X
X     sprintf(buf,"That maneuver costs %.2f fuel (of %.2f).\n",fuel, s->fuel);
X		notify(Playernum, buf);
X
X     if (s->fuel < fuel) {
X	  sprintf(buf,"NOT ENOUGH FUEL ");
X		notify(Playernum, buf);
X		return;
X     }
X
X     cont = 1;
X     do {
X
X	if(x < 0 || y < 0 || x > p->Maxx || y > p->Maxy) {
X		sprintf(buf,"Illegal coordinates.\n");
X			notify(Playernum, buf);
X			return;
X			}
X	opensectdata(&land_sectdata);
X	getsector(land_sectdata,&sect,p->sectormappos+(y*p->Maxx+x)*sizeof(sectortype));
X	close_file(land_sectdata);
X       if(s->type != OTYPE_TERRA) {
X       if (Race->likes[sect->des] == 0.0 && !sect->is_wasted) {
X	sprintf(buf,"The ship is not built to land on that sector.\n");
X		notify(Playernum, buf);
X	return;
X       }
X       if (sect->is_wasted) {
X	sprintf(buf,"Warning: That sector is a wasteland!\n");
X		notify(Playernum, buf);
X       }
X     }
X       if (Assault) {
X	    if (sect->owner==Playernum) {
X		sprintf(buf,"You cannot assault your own sector.\n");
X		notify(Playernum, buf);
X		return;
X	    } else if (sect->popn > 0) {
X		sprintf(buf,"The assaulted sector must have no population.\n");
X		notify(Playernum, buf);
X		return;
X	    }
X       } else if (sect->owner && sect->owner!=Playernum) {
X	openracedata(&land_racedata);
X	 getrace(land_racedata, &alien, sect->owner);
X	close_file(land_racedata);
X
X       if(!(isset(Race->allied, sect->owner) && 
X	    isset(alien->allied, Playernum))) {
X	sprintf(buf,"You are not mutually allied with %s.\n", alien->name);
X		notify(Playernum, buf);
X	return;
X      } else {
X	sprintf(buf,"You have landed on allied sector (%s).\n",alien->name);
X		notify(Playernum, buf);
X      }
X       }
X       if (!cont)
X	free(sect);
X
X
X     } while (!cont);
X
X     if (s->fuel < fuel) {
X
X
X	kill_ship(s);
Xopenshdata(&land_shdata);
X	putship(land_shdata, s, shipno);
X	close(land_shdata);
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(Playernum,&where, &where, 0, p, x, y, Dist, 100.,
X			round_rand(log1p((double)s->mass)*2+(float)s->destruct/3.), 1);
X	  sprintf(buf,"BOOM!! Ship #%d crashes on sector %d,%d with blast radius of %d.\n",
X		shipno, x, y, numdest);
X		notify(Playernum, buf);
X
X	  exit(0);
X	}
X
X     } else {
X  
X   
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==0 && 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	  s->popn = 1;
X	  sect->owner = Playernum;
X	  p->info[Playernum-1].numsectsowned++;
X       }
X     }
X     s->notified = 0;	/* reset notification */
Xopenshdata(&land_shdata);
X     putship(land_shdata, s, shipno);
X  close_file(land_shdata);
X
X  }
X
X
X
X  if (s->whatorbits==LEVEL_UNIV)
X	  deductAPs(Playernum,APcount, 0, 1);
X  else
X	  deductAPs(Playernum,APcount, s->storbits, 0);
X
X
X  if (!Dock) {
X      if (planetmod) {
X	  openpdata(&land_pdata);
X	  putplanet(land_pdata,p,Stars[s->storbits]->planetpos[s->pnumorbits]);
X      close_file(land_pdata);
X      }
X   /* */
Xopensectdata(&land_sectdata);
X      if (sectmod && !numdest)
X	  putsector(land_sectdata,sect,p->sectormappos+(y*p->Maxx+x)*sizeof(sectortype));
X      close_file(land_sectdata);
X      free(sect);
X
X	/* send telegs to anyone there */
X	  if (Assault) {
X		  sprintf(telegram_buf,"Planet /%s/%s ",
X			Stars[s->storbits]->name,
X			Stars[s->storbits]->pnames[s->pnumorbits]);
X		  sprintf(buf,"ASSAULTED by %s #%d on sector %.0f,%.0f!!\n", 
X			Shipnames[s->type], shipno, s->xpos, s->ypos);
X			str_cat(telegram_buf, buf);
X	  } else {
X		  sprintf(telegram_buf,"%s #%d observed landing on sector %.0f,%.0f, planet /%s/%s.\n",
X			Shipnames[s->type], shipno, s->xpos,s->ypos,Stars[s->storbits]->name,
X			Stars[s->storbits]->pnames[s->pnumorbits]);
X			str_cat(telegram_buf, buf);
X	  }
X	  for (i=1; i<=Numraces(); i++)
X		if (p->info[i-1].numsectsowned && i!=Playernum) {
X			notify(i, telegram_buf);
X			}
X   free(p);
X
X  	  sprintf(buf,"%s #%d %s landed on planet.\n",Shipnames[s->type],
X		 shipno,s->name);
X		notify(Playernum, buf);
X  }
X
Xopenracedata(&land_racedata);
Xputrace(land_racedata, Race);
Xclose(land_racedata);
X
X  free(s);
X
X}
X
X
END_OF_FILE
if test 18841 -ne `wc -c <'server/land.c'`; then
    echo shar: \"'server/land.c'\" unpacked with wrong size!
fi
# end of 'server/land.c'
fi
if test -f 'server/load.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'server/load.c'\"
else
echo shar: Extracting \"'server/load.c'\" \(15077 characters\)
sed "s/^X//" >'server/load.c' <<'END_OF_FILE'
X/*
X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky, 
X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h.
X * Restrictions in GB_copyright.h.
X *
X *  load.c -- load/unload stuff
X */
X
X#include "GB_copyright.h"
X#define EXTERN extern
X#include "vars.h"
X#include "ships.h"
X#include "races.h"
X#include "buffers.h"
X#include <signal.h>
X
Xint load_shdata,load_pdata,load_sectdata, load_racedata;
X
X
Xload(Playernum,APcount, argn,args)
Xint Playernum;
Xint APcount;
Xint argn;
Xchar args[MAXARGS][COMMANDSIZE];
X{
Xboolean jett=0,sh=0,diff=0;
Xint first=1,proc,Mod=0,lolim,uplim, shipno,amt;
Xint test;
Xint transfercrew;
Xchar commod, buff[128], bufr[128], bufd[128], bufc[128];
Xshiptype *s,*s2;
Xplanettype *p;
Xsectortype *sect;
X
X    load_shdata = load_pdata = load_sectdata = NEUTRAL_FD;
X
X	sscanf(args[1]+(args[1][0]=='#'),"%d",&shipno);
X
X    openshdata(&load_shdata);
Xif (!getship(load_shdata,&s,shipno)) {
X    close_file(load_shdata);
X	return;
X    }
Xclose_file(load_shdata);
Xif (s->owner!=Playernum || !s->is_alive) {
X	DontOwnErr(Playernum,shipno);
X	sprintf(buf,"(%d)\n",s->owner);
X		notify(Playernum, buf);
X	free(s);
X	return;
X    }
X    if (!s->active) {
X	sprintf(buf,"%s #%d is irradiated and inactive.\n", Shipnames[s->type],shipno);
X		notify(Playernum, buf);
X	free(s);
X	return;
X    }
X
Xfree(Race);
Xopenracedata(&load_racedata);
Xgetrace(load_racedata, &Race, Playernum);
Xclose_file(load_racedata);
X
X    if (s->whatorbits==LEVEL_UNIV) {
X    	if (!enufAP(Playernum,Sdata.AP[Playernum-1], APcount))
X		free(s);
X    } else 
X	if (!enufAP(Playernum,Stars[s->storbits]->AP[Playernum-1], APcount)) {
X		free(s);
X		return;
X	}
X
X   
X    proc = 0;
X
X    
X    if (s->type == OTYPE_TRANSDEV && s->object.number > 0) {
X	openshdata(&load_shdata);
X	if (!getship(load_shdata,&s2, s->object.number)) {
X		sprintf(buf,"The hopper seems to be blocked.\n");
X		notify(Playernum, buf);
X		close_file(load_shdata);
X		return;
X	}
X	close_file(load_shdata);
X	if (!s2->is_alive) {
X		sprintf(buf,"The target device does not exist.\n");
X		notify(Playernum, buf);
X		return;
X	}
X	if (s2->type!=OTYPE_TRANSDEV || !s2->on) {
X	sprintf(buf,"s2->type = %d\n",s2->type);
X		notify(Playernum, buf);
X	sprintf(buf,"OTYPE_TRANSDEV = %d\n",OTYPE_TRANSDEV);
X		notify(Playernum, buf);
X
X	sprintf(buf,"s2->on = %d\n",s2->on);
X		notify(Playernum, buf);
X		sprintf(buf,"The target device is not receiving.\n");
X		notify(Playernum, buf);
X		return;
X	}
X    } else if (!s->is_docked) {
X	if (s->type==OTYPE_TRANSDEV) {
X		sprintf(buf,"It does not seem to work in zero-g environments.\n");
X		notify(Playernum, buf);
X		return;
X	}
X	sprintf(buf,"%s #%d is not landed.\n",is_object(s)?"object":"ship",shipno);
X		notify(Playernum, buf);
X		return;
X    } else {
X	if (s->whatdest==LEVEL_PLAN)
X		{
X		sprintf(buf,"Ship #%d at %.0f,%.0f\n", shipno, s->xpos, s->ypos);
X		notify(Playernum, buf);
X  			if(s->storbits != Dir[Playernum-1].snum || s->pnumorbits != Dir[Playernum-1].pnum)
X					{
X					sprintf(buf,"Wrong scope!\n");
X					notify(Playernum, buf);
X					return;
X					}
X		} else {
X			openshdata(&load_shdata);
X		if (!getship(load_shdata, &s2, s->destshipno) 
X			|| !s2->is_alive 
X			|| !s->object.number4 &&
X			  !(s2->is_docked && s2->whatdest==LEVEL_SHIP 
X			  && s2->destshipno==shipno) ) {
X				/* the ship it was docked with died or
X				   undocked with it or something. */
X			s->is_docked = 0;
X			s->whatdest = LEVEL_UNIV;
X			putship(load_shdata, s, shipno);
X			close_file(load_shdata);
X			free(s);
X			sprintf(buf,"ship #%u is not docked.\n", s->destshipno);
X				notify(Playernum, buf);
X			return;
X		    }
X		close(load_shdata);
X		sprintf(buf,"Ship #%d docked with %s #%d\n", shipno, 
X				Shipnames[s2->type], s->destshipno);
X			notify(Playernum, buf);
X		sh = 1;
X		if (s2->owner!=Playernum) {
X			sprintf(buf,"Player %d owns that ship.\n", s2->owner);
X				notify(Playernum, buf);
X			diff = 1;
X		}
X	}
X    }
X
X
X commod = args[2][0];
X	if(argn>3)
X		    amt = atoi(args[3]);
X	else
X		    amt = 0;
X	
X    if (!jett && !sh) {
X    	openpdata(&load_pdata);
X    	getplanet(load_pdata,&p,Stars[Dir[Playernum-1].snum]->planetpos[Dir[Playernum-1].pnum]);
X	close_file(load_pdata);
X    }
X
X       if (!jett && !sh && commod=='c') {
X    	opensectdata(&load_sectdata);
X    	getsector(load_sectdata, &sect, p->sectormappos 
X			+ ( (int)s->ypos*p->Maxx+(int)s->xpos) * sizeof(sectortype) );
X	close_file(load_sectdata);
X    }
X
X    switch (commod) {
X
X	case 'c': if (jett) {
X			uplim = 0;
X			lolim = -s->popn;
X		  } else
X		    if (sh) {
X		    	uplim = diff ? 0 : MIN(s2->popn, 
X				  Max_crew(s) - s->popn);
X			lolim = diff ? 0 : - MIN(s->popn, 
X				  Max_crew(s2) - s2->popn);
X		    } else {
X		    	uplim = MIN(sect->popn, 
X				  Max_crew(s) - s->popn);
X			lolim = -s->popn;
X		    }
X		  proc = 1;
X		  break;
X
X	case 'd': if (jett) {
X			uplim = 0;
X			lolim = -s->destruct;
X		  } else
X		    if (sh) {
X		    	uplim = diff ? 0 : MIN(s2->destruct, 
X				 Max_destruct(s) - s->destruct);
X			lolim = -MIN(s->destruct, 
X				 Max_destruct(s2) - s2->destruct);
X		    } else {
X		    	uplim = MIN(p->info[Playernum-1].destruct,
X				 Max_destruct(s) - s->destruct);
X			lolim = -s->destruct;
X		    }
X		  proc = 1;
X		  break;
X
X	case 'f': if (jett) {
X			uplim = 0;
X			lolim = -(int)s->fuel;
X		  } else
X		    if (sh) {
X		    	uplim = diff ? 0.0 : MIN((int)s2->fuel, 
X				 Max_fuel(s) - (int)s->fuel);
X			lolim = - MIN((int)s->fuel, 
X				 Max_fuel(s2) - (int)s2->fuel);
X		    } else {
X		    	uplim = MIN((int)p->info[Playernum-1].fuel,
X				 Max_fuel(s) - (int)s->fuel);
X			lolim = -(int)s->fuel;
X		    }
X		  proc = 1;
X		  break;
X
X	case 'r': if (jett) {
X			uplim = 0;
X			lolim = -s->resource;
X		  } else
X		    if (sh) {
X		    	if (s->type==STYPE_SHUTTLE)
X			  uplim = diff ? 0 : s2->resource;
X			else
X			  uplim = diff ? 0 : MIN(s2->resource, 
X				   Max_resource(s) - s->resource);
X			if (s2->type==STYPE_SHUTTLE)
X			  lolim = -s->resource;
X			else
X			  lolim = - MIN(s->resource, 
X				   Max_resource(s2) - s2->resource);
X		    } else {
X		    	uplim = MIN(p->info[Playernum-1].resource,
X				 Max_resource(s) - s->resource);
X			lolim = -s->resource;
X		    }
X		  proc = 1;
X		  break;
X
X	default:
X		notify(Playernum, "No such commodity valid.\n");
X		return;
X      }
X
Xif(amt<lolim || amt>uplim) {
X	sprintf(buf, "you can only transfer between %d and %d.\n", lolim, uplim);
X	notify(Playernum, buf);
X	return;
X	}
X
Xif(amt==0) 
X	amt = uplim;
X
X    switch (commod) {
X
X      case 'c': if (!jett) {
X			if (sh) {
X				s2->popn -= amt;
X				s2->mass -= amt*Race->mass;
X				transfercrew = 1;
X			} else
X			  if(sect->owner && sect->owner != Playernum) {
X	       	    sprintf(buf,"That sector is already occupied by another player!\n");
X				notify(Playernum, buf);
X		    transfercrew = 0;
X		  	   } else { 
X		    transfercrew = 1;
X			     if (!sect->popn && amt<0) {
X				p->info[Playernum-1].numsectsowned++;
X				sect->owner = Playernum;
X				sprintf(buf,"sector %.0f,%.0f COLONIZED.\n",s->xpos,s->ypos);
X				notify(Playernum, buf);
X		  	   }
X		  	   sect->popn -= amt;
X		  	   p->popn -= amt;
X		  	   if (sect->popn==0) {
X				p->info[Playernum-1].numsectsowned--;
X				sect->owner = 0;
X				sprintf(buf,"sector %.0f,%.0f evacuated.\n",s->xpos,s->ypos);
X				notify(Playernum, buf);
X			      }
X			   }
X		  }
X	  if(transfercrew) {
X		  sprintf(buf,"crew complement of ship #%d is now %u.\n", 
X			shipno, s->popn+amt);
X				notify(Playernum, buf);
X		  s->popn += amt;
X		  s->mass += amt*Race->mass;
X		  Mod = 1;
X		}
X	  break;
X
X	case 'd': s->destruct += amt;
X		  s->mass += amt*MASS_DESTRUCT;
X		sprintf(buf, "%d destruct transferred.\n", amt);
X		notify(Playernum, buf);
X		  if (!Max_crew(s)) {
X			sprintf(buf,"\n%s #%d ",Shipnames[s->type], shipno);
X				notify(Playernum, buf);
X			if (s->destruct) {
X			     sprintf(buf,"now boobytrapped.\n");
X			} else {
X			     sprintf(buf,"no longer boobytrapped.\n");
X			 }
X				notify(Playernum, buf);
X			}
X
X		  if (sh) {
X			s2->destruct -= amt;
X			s2->mass -= amt*MASS_DESTRUCT;
X		  } else if (!jett)
X		  	p->info[Playernum-1].destruct -= amt;
X
X		  Mod = 1;
X		  break;
X
X	case 'f': s->fuel += amt*1.0;
X		  s->mass += amt*MASS_FUEL;
X		sprintf(buf, "%d fuel transferred.\n", amt);
X		notify(Playernum, buf);
X
X		  if (sh) {
X			s2->fuel -= amt*1.0;
X			s2->mass -= amt*MASS_FUEL;
X		  } else if (!jett)
X		  	p->info[Playernum-1].fuel -= amt*1.0;
X
X		  Mod = 1;
X		  break;
X
X	case 'r': s->resource += amt;
X		  s->mass += amt*MASS_RESOURCE;
X		sprintf(buf, "%d resources transferred.\n", amt);
X		notify(Playernum, buf);
X
X		  if (sh) {
X			s2->resource -= amt;
X			s2->mass -= amt*MASS_RESOURCE;
X		  } else if (!jett)
X		  	p->info[Playernum-1].resource -= amt;
X
X		  Mod = 1;
X		  break;
X
X	default:
X	   notify(Playernum, "No such commodity.\n");
X	   return;
X	break;
X    }
X    openshdata(&load_shdata);
X    putship(load_shdata,s,shipno);
X    close_file(load_shdata);
X    	if (s->type==OTYPE_TRANSDEV && s->object.number > 0) {
X
X	   sprintf(buf,"Zap\07!\n");	 	/* ^G */
X				notify(Playernum, buf);
X
X	   	/* send stuff to other ship (could be transport device) */
X	   if (s->resource ) {
X		s2->mass += s->resource * MASS_RESOURCE;
X		s2->resource += s->resource;
X
X		sprintf(buf,"%d resources transferred.\n", s->resource);
X				notify(Playernum, buf);
X		sprintf(bufr, "%d Resources\n",s->resource);
X
X		s->mass -= s->resource * MASS_RESOURCE;
X		s->resource  -= s->resource;
X	   } else
X		bufr[0] = '\0';
X	   if (s->fuel) {
X		s2->fuel += s->fuel;
X		s2->mass += s->fuel * MASS_FUEL;
X
X		sprintf(buf,"%g fuel transferred.\n", s->fuel);
X				notify(Playernum, buf);
X		sprintf(buff, "%g Fuel\n",s->fuel);
X
X		s->mass -= s->fuel * MASS_FUEL;
X		s->fuel -= s->fuel;
X	   } else
X		buff[0] = '\0';
X	   if (s->destruct) {
X		s2->mass += s->destruct * MASS_DESTRUCT;
X		s2->destruct += s->destruct;
X
X		sprintf(buf,"%d destruct transferred.\n", s->destruct);
X				notify(Playernum, buf);
X		sprintf(bufd, "%d Destruct\n",s->destruct);
X
X		s->mass -= s->destruct * MASS_DESTRUCT;
X		s->destruct -= s->destruct;
X	   } else
X		bufd[0] = '\0';
X	   if (s->popn) {
X		s2->mass += s->popn * Race->mass;
X		s2->popn += s->popn;
X
X		sprintf(buf,"%d popn transferred.\n", s->popn);
X				notify(Playernum, buf);
X		sprintf(bufc, "%d %s\n",s->destruct,Race->Thing?"tons of biomass" : "population");
X
X		s->mass -= s->popn * Race->mass;
X		s->popn -= s->popn;
X	   } else
X		bufc[0] = '\0';
X
X         if (s2->owner!=s->owner) {
X	   sprintf(telegram_buf,"BULLETIN!\n\n Audio-vibatory-physio-molecular transport device #");
X	   sprintf(buf,"%d just gave your ship #%d the following:\n", shipno, s->object.number);
X		str_cat(telegram_buf, buf);
X		str_cat(telegram_buf, bufr);
X		str_cat(telegram_buf, bufd);
X		str_cat(telegram_buf, buff);
X		str_cat(telegram_buf, bufc);
X		notify(s2->owner, telegram_buf);
X         }
X
X	   openshdata(&load_shdata);
X	   putship(load_shdata,s,shipno);
X	   putship(load_shdata, s2, s->object.number);
X	   close_file(load_shdata);
X
X    } else if (sh) {
X		/* ship to ship transfer, non-transport device */
X
X	openshdata(&load_shdata);
X	putship(load_shdata,s2,s->destshipno);
X	close_file(load_shdata);
X
X	buff[0] = bufr[0] = bufd[0] = bufc[0] = '\0';
X	switch (commod) {
X		case 'r':
X			sprintf(buf,"%d resources transferred.\n", amt);
X				notify(Playernum, buf);
X			sprintf(bufr, "%d Resources\n",amt);
X			break;
X		case 'f':
X			sprintf(buf,"%d fuel transferred.\n", amt);
X				notify(Playernum, buf);
X			sprintf(buff, "%d Fuel\n",amt);
X			break;
X		case 'd':
X			sprintf(buf,"%d destruct transferred.\n", amt);
X				notify(Playernum, buf);
X			sprintf(bufd, "%d Destruct\n",amt);
X			break;
X		case 'c':
X			sprintf(buf,"%d popn transferred.\n", amt);
X				notify(Playernum, buf);
X			sprintf(bufc, "%d %s\n",amt,Race->Thing?"tons of biomass" : "population");
X			break;
X		default:
X			break;
X	 }
X
X
X         if (s2->owner!=s->owner) {
X	   sprintf(telegram_buf, "BULLETIN!\n\n Audio-vibatory-physio-molecular transport device #");
X	   sprintf(buf,"%d just gave your ship #%d the following:\n", shipno, s->object.number);
X		str_cat(telegram_buf, buf);
X		str_cat(telegram_buf, bufr);
X		str_cat(telegram_buf, bufd);
X		str_cat(telegram_buf, buff);
X		str_cat(telegram_buf, bufc);
X		notify(s2->owner, telegram_buf);
X         }
X     }
X
X    if (!jett && !sh) {
X      if (commod=='c') {
X	  opensectdata(&load_sectdata);
X	  putsector(load_sectdata,sect,p->sectormappos + ( (int)s->ypos*p->Maxx+(int)s->xpos) * sizeof(sectortype) );
X    	close_file(load_sectdata);
X	free(sect);
X    }
X      
X      openpdata(&load_pdata);
X       putplanet(load_pdata,p,Stars[Dir[Playernum-1].snum]->planetpos[Dir[Playernum-1].pnum]);
X       close_file(load_pdata);
X       free(p);
X     }
X
X    if (Mod && first) {
X         first = 0;
X         if (s->whatorbits==LEVEL_UNIV)
X		deductAPs(Playernum,APcount, 0, 1);	/* ded from sdata */
X         else 
X		deductAPs(Playernum,APcount, s->storbits, 0);
X
X    }
X
X}
X
X
Xtransfer(Playernum,APcount, argn,args)
Xint Playernum;
Xint APcount;
Xint argn;
Xchar args[MAXARGS][COMMANDSIZE];
X{
Xint Mod = 0, transfer_fd, player, give;
Xplanettype *planet;
Xchar commod=0;
Xracetype *r;
X
X        if (Dir[Playernum-1].level != LEVEL_PLAN) {
X	  sprintf(buf,"You need to be in planet scope to do this.\n");
X	  notify(Playernum, buf);
X	  return;
X	      }
X
X
X	if (!enufAP(Playernum,Stars[Dir[Playernum-1].snum]->AP[Playernum-1], APcount))
X	        return;
X
X	GetPlayer(args[1], &player, &r);
X
Xif(player < 0 || player > Numraces() ) {
X  sprintf(buf,"No such player.\n");
X		notify(Playernum, buf);
X  return;
X	}
X
X    openpdata(&transfer_fd);
X    getplanet(transfer_fd, &planet, Stars[Dir[Playernum-1].snum]->planetpos[Dir[Playernum-1].pnum]);
X	close_file(transfer_fd);
X
X	sscanf(args[2],"%c",&commod);
X        give = atoi(args[3]);
X
Xif(give < 0) {
X	notify(Playernum, "You must specify a positive amount.\n");
X	return;
X	}
X
Xswitch(commod) {
X    case 'r' :
X       if(give > planet->info[Playernum-1].resource)
X	{
X	  sprintf(buf,"You don't have %d on this planet.\n",give);
X		notify(Playernum, buf);
X	} else {
X	  planet->info[Playernum-1].resource -= give;
X	  planet->info[player-1].resource += give;
X	  sprintf(buf,"%d resources transferred to player #%d\n",give,player);
X		notify(Playernum, buf);
X	}
X      break;
X    case 'f' :
X      if(give > planet->info[Playernum-1].fuel)
X	{
X	  sprintf(buf,"You don't have %d fuel on this planet.\n",give);
X		notify(Playernum, buf);
X	} else {
X	  planet->info[Playernum-1].fuel -= give;
X	  planet->info[player-1].fuel += give;
X	  sprintf(buf,"%d fuel transferred to player #%d\n",give,player);
X		notify(Playernum, buf);
X	}
X      break;
X    case 'd' :
X      if(give > planet->info[Playernum-1].destruct)
X	{
X	  sprintf(buf,"You don't have %d destruct on this planet.\n",give);
X	  notify(Playernum, buf);
X      } else {
X	  planet->info[Playernum-1].destruct -= give;
X	  planet->info[player-1].destruct += give;
X	  sprintf(buf,"%d destruct transferred to player #%d\n",give,player);
X		notify(Playernum, buf);
X	}
X      break;
X    default :
X      sprintf(buf,"What?\n");
X		notify(Playernum, buf);
X    }
Xopenpdata(&transfer_fd);
X    putplanet(transfer_fd, planet, Stars[Dir[Playernum-1].snum]->planetpos[Dir[Playernum-1].pnum]);
X    close_file(transfer_fd);
XMod = 1;
X    if (Mod)
X		deductAPs(Playernum,APcount, Dir[Playernum-1].snum, 0);
X
X}
X
END_OF_FILE
if test 15077 -ne `wc -c <'server/load.c'`; then
    echo shar: \"'server/load.c'\" unpacked with wrong size!
fi
# end of 'server/load.c'
fi
if test -f 'server/name.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'server/name.c'\"
else
echo shar: Extracting \"'server/name.c'\" \(14775 characters\)
sed "s/^X//" >'server/name.c' <<'END_OF_FILE'
X/*
X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky, 
X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h.
X * Restrictions in GB_copyright.h.
X *
X * name.c -- rename something to something else
X* announce.c -- make announcements in the system you currently in.
X*			You must be inhabiting that system for your message to sent.
X*			You must also be in that system (and inhabiting) to receive announcements.
X* page.c -- send a message to a player requesting his presence in a system. 
X*/
X
X#include "GB_copyright.h"
X#define EXTERN extern
X#include "vars.h"
X#include "races.h"
X#include "ships.h"
X#include "buffers.h"
X#include <ctype.h>
X#include <signal.h>
X#include <strings.h>
X#include <time.h>
Xint name_shdata,name_stardata, name_racedata, name_pdata;
X
Xchar msg[1024];
Xstruct tm *current_tm;/* for watching for next update */
Xlong clk;
X
Xgive(Playernum, APcount, argn, args)
Xint Playernum;
Xint APcount;
Xint argn;
Xchar args[MAXARGS][COMMANDSIZE];
X{
Xint who, sh;
Xshiptype *ship;
Xplanettype *planet;
Xracetype *alien;
X
Xfree(Race);
Xopenracedata(&name_racedata);
Xgetrace(name_racedata, &Race, Playernum);
Xclose_file(name_racedata);
X
XGetPlayer(args[1], &who, &alien);
X   if (who <= 0) {
X	sprintf(buf,"No such player.\n");
X		notify(Playernum, buf);
X	return;
X   }
X
X      /* check to see if both players are mutually allied */
Xif(!(isset(Race->allied, who) && isset(alien->allied, Playernum))) {
X      notify(Playernum, "You two are not mutually allied.\n");
X      return;
X}
Xsscanf(args[2]+(args[2][0]=='#'), "%d", &sh);
X
X		openshdata(&name_shdata);
X		if(!getship(name_shdata, &ship, sh)) {
X		    notify(Playernum, "Illegal ship number.\n");
X		    close_file(name_shdata);
X		    return;
X		}
X                if(ship->owner != Playernum || !ship->is_alive) {
X		    DontOwnErr(Playernum, sh);
X		    free(ship);
X		    close_file(name_shdata);
X		    return;
X		}
Xif(ship->type == STYPE_POD) {
X    notify(Playernum, "You cannot change the ownership of spore pods.\n");
X    			free(ship);
X		    close_file(name_shdata);
X		    return;
X}
X
Xif(ship->popn && !Race->God) {
X	notify(Playernum, "You can't give this ship away while it has crew on board.\n");
X	free(ship);
X	close_file(name_shdata);
X	return;
X	}
X
Xswitch(ship->whatorbits) { 
X	case LEVEL_UNIV:
X		if(!enufAP(Playernum, Sdata.AP[Playernum-1], APcount))
X			return;
X		break;
X	default:
X		if (!enufAP(Playernum,Stars[Dir[Playernum-1].snum]->AP[Playernum-1], APcount))
X			return;
X		break;
X	}
X
Xship->owner = who;
Xputship(name_shdata, ship, sh);
Xclose_file(name_shdata);
X
X/* set inhabited/explored bits */
Xswitch(ship->whatorbits) {
X  case LEVEL_UNIV:
X    break;
X  case LEVEL_STAR:
X    free(Stars[ship->storbits]);
X    openstardata(&name_stardata);
X    getstar(name_stardata, &(Stars[ship->storbits]), ship->storbits);
X    setbit(Stars[ship->storbits]->inhabited, who);
X    setbit(Stars[ship->storbits]->explored, who);
X    putstar(name_stardata, Stars[ship->storbits], ship->storbits);
X    close_file(name_stardata);
X    break;
X  case LEVEL_PLAN:
X    free(Stars[ship->storbits]);
X    openstardata(&name_stardata);
X    getstar(name_stardata, &(Stars[ship->storbits]), ship->storbits);
X    setbit(Stars[ship->storbits]->inhabited, who);
X    setbit(Stars[ship->storbits]->explored, who);
X    putstar(name_stardata, Stars[ship->storbits], ship->storbits);
X    close_file(name_stardata);
X    openpdata(&name_pdata);
X    getplanet(name_pdata, &planet, Stars[ship->storbits]->planetpos[ship->pnumorbits]);
X    planet->info[who-1].explored = 1;
X    putplanet(name_pdata, planet, Stars[ship->storbits]->planetpos[ship->pnumorbits]);
X    close_file(name_pdata);
X    break;
X  default:
X    notify(Playernum, "Something wrong with this ship's scope.\n");
X	free(ship);
X    return;
X    break;
X}
X
Xswitch(ship->whatorbits) { 
X	case LEVEL_UNIV:
X		deductAPs(Playernum, APcount, 0, 1);
X			return;
X		break;
X	default:
X		deductAPs(Playernum,APcount, Dir[Playernum-1].snum, 0);
X		break;
X	}
X
X
Xnotify(Playernum, "Owner changed.\n");
Xsprintf(buf, "%s [%d] gave you %s #%d at %s.\n", Race->name, Playernum,
X	Shipnames[ship->type], sh, prin_ship_orbits(ship));
Xnotify(who, buf);
Xpush_message(TELEG_PLAYER_AUTO, who, buf);
X
X                    free(ship);
X}
X
X
Xpage(Playernum, APcount0, argn, args)
Xint Playernum;
Xint APcount0;
Xint argn;
Xchar args[MAXARGS][COMMANDSIZE];
X{
Xint i, who, to_block, dummy, APcount;
Xracetype *alien;
X
XAPcount = APcount0;
Xto_block = 0;
Xif(!strcmp(args[1], "block", strlen(args[1]))) {
X    to_block = 1;
X    notify(Playernum, "Paging alliance block.\n");
X} else {
X   GetPlayer(args[1], &who, &alien);
X   if (who <= 0) {
X	sprintf(buf,"No such player.\n");
X		notify(Playernum, buf);
X	return;
X   }
XAPcount *= !alien->God;
X}
X
Xfree(Race);
Xopenracedata(&name_racedata);
Xgetrace(name_racedata, &Race, Playernum); 
Xclose_file(name_racedata);
X
X	switch(Dir[Playernum-1].level) {
X		case LEVEL_UNIV:
X			sprintf(buf, "You can't make pages at universal scope.\n");
X			notify(Playernum, buf);
X			break;
X		default:
X			free(Stars[Dir[Playernum-1].snum]);
X			openstardata(&name_stardata);
X		getstar(name_stardata, &Stars[Dir[Playernum-1].snum], Dir[Playernum-1].snum);
X			close_file(name_stardata);
X			if (!enufAP(Playernum,Stars[Dir[Playernum-1].snum]->AP[Playernum-1], APcount)) {
X			return;
X		}
X
X		sprintf(buf, "%s page(s) you from the %s star system.\n",
X			Race->name, Stars[Dir[Playernum-1].snum]->name);
X		if(to_block) {
X		  dummy = (Blocks[Playernum-1].invite &
X			      Blocks[Playernum-1].pledge);
X		  for(i=1; i<=Numraces(); i++)
X		      if(isset(dummy, i) && i!=Playernum)
X			  notify(i, buf);
X	      } else
X			notify(who, buf);
X
X			notify(Playernum, "Request sent.\n");
X			break;
X		}
X	deductAPs(Playernum, APcount, Dir[Playernum-1].snum, 0);
X}
X
Xsend_message(Playernum, APcount0, argn, args)
Xint Playernum;
Xint APcount0;
Xint argn;
Xchar args[MAXARGS][COMMANDSIZE];
X{
Xint who, i, j, to_block, dummy, APcount;
Xracetype *alien;
X
X    APcount = APcount0;
X
Xto_block = 0;
Xif(!strcmp(args[1], "block", strlen(args[1]))) {
X    to_block = 1;
X    notify(Playernum, "Sending message to alliance block.\n");
X} else {
XGetPlayer(args[1], &who, &alien);
X   if (who <= 0) {
X	sprintf(buf,"No such player.\n");
X		notify(Playernum, buf);
X	return;
X   }
XAPcount *= !alien->God;
X}
X
Xfree(Race);
Xopenracedata(&name_racedata);
Xgetrace(name_racedata, &Race, Playernum); 
Xclose_file(name_racedata);
X
X	switch(Dir[Playernum-1].level) {
X		case LEVEL_UNIV:
X			sprintf(buf, "You can't send messages from universal scope.\n");
X			notify(Playernum, buf);
X			break;
X		default:
X			free(Stars[Dir[Playernum-1].snum]);
X			openstardata(&name_stardata);
X		getstar(name_stardata, &Stars[Dir[Playernum-1].snum], Dir[Playernum-1].snum);
X			close_file(name_stardata);
X			if (!enufAP(Playernum,Stars[Dir[Playernum-1].snum]->AP[Playernum-1], APcount)) {
X			return;
X		}
X
X/* send the message */
X	sprintf(msg, "From %s [%d]: ", Race->name, Playernum);
X	       
X/* put the message together */
X		for(j=2; j < argn; j++)	
X			{
X			sprintf(buf, "%s ", args[j]);
X			strcat(msg, buf);			
X			}
X/* post it */
X		sprintf(buf, "%s has sent you a telegram. Use `read' to read it.\n", Race->name);
X		if(to_block) {
X		  dummy = (Blocks[Playernum-1].invite &
X			      Blocks[Playernum-1].pledge);
X		  Num_races = Numraces();
X		  for(i=1; i<=Num_races; i++)
X		      if(isset(dummy, i) && i!=Playernum) {
X		          push_message(Playernum, i, msg); 
X			  notify(i, buf);
X		      }
X		      } else {
X		  push_message(Playernum, who, msg); 
X		  notify(who, buf);
X	      }
X
X			notify(Playernum, "Message sent.\n");
X
X     if(!to_block) {
X/* translation modifier increases */
X	alien->translate[Playernum-1] = MIN(alien->translate[Playernum-1]+2, 100);
X	openracedata(&name_racedata);
X	putrace(name_racedata, alien);	
X	close_file(name_racedata);
X               }
X			break;
X		    }
X
XdeductAPs(Playernum, APcount, Dir[Playernum-1].snum, 0);
X}
X
Xread_messages(Playernum, APcount, argn, args)
Xint Playernum;
Xint APcount;
Xint argn;
Xchar args[MAXARGS][COMMANDSIZE];
X{
Xint i;
Xteleg_read(Playernum);
X}
X
X
Xannounce(Playernum, APcount, argn, args, broadcast)
Xint Playernum;
Xint APcount;
Xint argn;
Xchar args[MAXARGS][COMMANDSIZE];
Xint broadcast;
X{
Xint i, j;
X
Xfree(Race);
Xopenracedata(&name_racedata);
Xgetrace(name_racedata, &Race, Playernum); 
Xclose_file(name_racedata);
X
Xswitch(Dir[Playernum-1].level) {
X	case LEVEL_UNIV:
X		sprintf(buf, "You can't make announcements at universal scope.\n");
X			notify(Playernum, buf);
X		break;
X	default:
X		free(Stars[Dir[Playernum-1].snum]);
X		openstardata(&name_stardata);
X		getstar(name_stardata, &Stars[Dir[Playernum-1].snum], Dir[Playernum-1].snum);
X		close_file(name_stardata);
X		if (!enufAP(Playernum,Stars[Dir[Playernum-1].snum]->AP[Playernum-1], APcount)) {
X			return;
X		}
X	if(!(!!isset(Stars[Dir[Playernum-1].snum]->inhabited, Playernum) || Race->God)) {
X			sprintf(buf, "You do not inhabit this system or have diety privileges.\n");
X			notify(Playernum, buf);
X			return;
X		}
X
Xif(!broadcast)
X	sprintf(msg, "%s : ", Race->name);
Xelse
X	sprintf(msg, "Interstellar broadcast from %s :", Race->name);
X
X	Num_races = Numraces();
X
X		for(j=1; j < argn; j++)	
X			{
X			sprintf(buf, "%s ", args[j]);
X			strcat(msg, buf);			
X			}
X			strcat(msg, "\n");
X
X	for(i=1; i<=Num_races; i++) 
X		if(i != Playernum) {
X		free(Race);
X	openracedata(&name_racedata);
X		getrace(name_racedata, &Race, i); 
X	close_file(name_racedata);
X
X	if(broadcast || (Dir[i-1].level != LEVEL_UNIV && (Dir[i-1].snum == Dir[Playernum-1].snum) 
X			&&  (!!isset(Stars[Dir[Playernum-1].snum]->inhabited, i) || Race->God)))
X			notify(i, msg);
X	}
X
X		break;
X	}
X
X	deductAPs(Playernum,APcount, Dir[Playernum-1].snum, 0);
X}
X
Xname(Playernum,APcount, argn,args)
Xint Playernum;
Xint APcount;
Xint argn;
Xchar args[MAXARGS][COMMANDSIZE];
X{
Xchar *ch;
Xregister int i, s, spaces;
Xboolean check=0;
Xshiptype *ship;
Xstartype *star;
Xplanettype *p;
Xchar string[1024];
Xchar temp[128];
X
Xname_stardata = NEUTRAL_FD;
X
Xfree(Race);
Xopenracedata(&name_racedata);
Xgetrace(name_racedata, &Race, Playernum);
Xclose_file(name_racedata);
X
Xif(!isalnum(args[2][0]) || argn < 3) {
X		notify(Playernum, "Illegal name format.\n");
X		return;
X		}
X
Xsprintf(buf, "%s", args[2]);
X		for(i=3; i < argn; i++)	
X			{
X			sprintf(temp, " %s", args[i]);
X			strcat(buf, temp);			
X			}
X
Xsprintf(string, "%s", buf);
X
X	i=strlen(args[0]);
X
X  	/* make sure there are no ^'s or '/' in name, 
X		also make sure the name has at least 1 character in it */
X  ch = string;
X  spaces = 0;
X  while (*ch!='\0') {
X	  check |= ((!isalnum(*ch) && !(*ch==' ')) || (*ch=='/') );
X	  ch++;
X	  if(*ch==' ') spaces++;
X	}
X
X	if(spaces==strlen(buf)) {				/* keep a player */
X		notify(Playernum, "Illegal name.\n");
X		return;
X		}
X
X  if (strlen(buf) < 1 || check) {
X	sprintf(buf, "Illegal name %s.\n", check ? "form" : "length" );
X		notify(Playernum, buf);
X	return;
X  }
X
X        if (!strncmp(args[1],"ship",i)) {
X		if(Dir[Playernum-1].level == LEVEL_SHIP) {
X		openshdata(&name_shdata);
X		getship(name_shdata, &ship, Dir[Playernum-1].shipno);
X
X		sprintf(ship->name, "%s", buf);
X		putship(name_shdata, ship, Dir[Playernum-1].shipno);
X		close_file(name_shdata);
X			notify(Playernum, "Name set.\n");
X			free(ship);
X			return;
X		} else {
X			notify(Playernum, "You have to 'cs' to a ship to name it.\n");
X			return;
X		}
X        } else if (!strncmp(args[1],"class",i)) {
X		if(Dir[Playernum-1].level == LEVEL_SHIP) {
X		openshdata(&name_shdata);
X		getship(name_shdata, &ship, Dir[Playernum-1].shipno);
X	if(ship->type != OTYPE_FACTORY) {
X		notify(Playernum, "You are not at a factory!\n");
X		free(ship);
X		close_file(name_shdata);
X		return;
X		}
X	if(ship->on) {
X		notify(Playernum, "This factory is already on line.\n");
X		free(ship);
X		close_file(name_shdata);
X		return;
X		}
X
X		sprintf(ship->class, "%s", buf);
X		putship(name_shdata, ship, Dir[Playernum-1].shipno);
X		close_file(name_shdata);
X			notify(Playernum, "Class set.\n");
X			free(ship);
X			return;
X		} else {
X			notify(Playernum, "You have to 'cs' to a factory to name the ship class.\n");
X			return;
X		}
X        } else if (!strncmp(args[1], "block", i)) {
X/* name your alliance block */
X	sprintf(Blocks[Playernum-1].name, "%s", args[2]);
X	Putblock(Blocks);
X	notify(Playernum, "Done.\n");
X	}else if (!strncmp(args[1],"star",i)) {
X
X		if(Dir[Playernum-1].level == LEVEL_STAR) {
X
X		if (!Race->God) {
X			notify(Playernum, "Only dieties may name a star.\n");
X			return;
X		}
X
X/* got to get all stars, to stop cheaters */
X			openstardata(&name_stardata);
X			for (s=0; s<Sdata.numstars; s++) {
X			    free(Stars[s]);
X			    getstar(name_stardata, &Stars[s], s);
X				}
X			close_file(name_stardata);
X
X			for(s=0; s<Sdata.numstars; s++) {
X				if(s!=Dir[Playernum-1].snum)
X					if(!strcmp(Stars[s]->name, buf, strlen(Stars[s]->name)))
X						{
X			notify(Playernum, 
X				"Thats not fair trying to name a star that! 50 APs deducted for cheating!!!\n");
X						return;
X						}
X				}
X
X
X/* check to see if there are any other stars with this name - stops cheaters */
X	
X
Xsprintf(Stars[Dir[Playernum-1].snum]->name, "%s", buf);
X			openstardata(&name_stardata);
X			putstar(name_stardata, Stars[Dir[Playernum-1].snum], 
X			Dir[Playernum-1].snum);
X		close_file(name_stardata);
X		} else {
X			notify(Playernum, "You have to 'cs' to a star to name it.\n");
X			return;
X		}
X        } else if (!strncmp(args[1],"planet",i)) {
X		if(Dir[Playernum-1].level == LEVEL_PLAN) {
X		    free(Stars[Dir[Playernum-1].snum]);
X		    openstardata(&name_stardata);
X			getstar(name_stardata, &Stars[Dir[Playernum-1].snum], Dir[Playernum-1].snum);
X			close_file(name_stardata);
X
X			if (!Race->God && !MostAPs(Playernum,Stars[Dir[Playernum-1].snum])) {
X	  notify(Playernum,"You don't have the most AP's in that system.\n");
X		return;
X			}
X
Xfor(s=0; s<Stars[Dir[Playernum-1].snum]->numplanets; s++)
X			if(!strcmp(Stars[Dir[Playernum-1].snum]->pnames[s], buf, 
X				strlen(Stars[Dir[Playernum-1].snum]->pnames[s])))
X				{
X				notify(Playernum, 
X					"Sorry, that name is already taken. 50 APs deducted for cheating!!!\n");
X				return;
X				}
X
X
Xsprintf(Stars[Dir[Playernum-1].snum]->pnames[Dir[Playernum-1].pnum], "%s", buf);
X			openstardata(&name_stardata);
X			putstar(name_stardata, Stars[Dir[Playernum-1].snum],  Dir[Playernum-1].snum);
X			close_file(name_stardata);
X		deductAPs(Playernum, APcount, Dir[Playernum-1].snum, 0);
X
X		} else {
X			notify(Playernum, "You have to 'cs' to a planet to name it.\n");
X			return;
X		}
X        } else if (!strncmp(args[1],"race",i)) {
Xsprintf(Race->name, "%s", buf);
Xif(Playernum==1) Race->God = 1; /* for careless dieties*/
X	openracedata(&name_racedata);
X		putrace(name_racedata, Race);
X	close_file(name_racedata);
X
X	} else {
X		notify(Playernum, "I don't know what you mean.\n");
X		return;
X	}	
X
X}
X
X
Xint MostAPs(Playernum,s)
Xint Playernum;
Xstartype *s;
X{
X register int i,t = 0;
X
X  for (i=0; i<MAXPLAYERS; i++)
X     if (s->AP[i] >= t)
X	  t = s->AP[i];
X
X  return (s->AP[Playernum-1] == t);
X
X}
X
X
END_OF_FILE
if test 14775 -ne `wc -c <'server/name.c'`; then
    echo shar: \"'server/name.c'\" unpacked with wrong size!
fi
# end of 'server/name.c'
fi
if test -f 'server/planet.list' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'server/planet.list'\"
else
echo shar: Extracting \"'server/planet.list'\" \(2235 characters\)
sed "s/^X//" >'server/planet.list' <<'END_OF_FILE'
X
XArioch
XAmaterasu
XAzagthoth
XAnacreon
XAegea
XAnsu
XApaosha
XAnubis
XAziDahak
XArcturus
XBaezelbub
XBaal
XBeholder
XBadb
XBakongo
XBali
XBenkei
XBoreas
XBushido
XCharondar
XCthulhu-vec
XColchis
XCirrus
XCanan
XCastor
XChancay
XCh'eng-huang
XChi'ih-yu
XChuai
XConiraya
XCelephais
XDis
XDorcas
XDagan
XDannaura
XDawn
XDevadatta
XDharma
XDinka
XDjanggawul
XDorus
XDoula
XDruj
XDwarka
XDyaus
XEa
XEnkindu
XErishkegal
XErech
XEdjo
XEhecatl
XEkpe
XEnlil
XEphialtes
XEpigoni
XEshu
XEstanatleh
XEurytion
XFalcha
XFreedom
XFomori
XFebrus
XFeiLien
XFonLegba
XFortuna
XFourthWorld
XFreyja
XFreyr
XFu-hsi
XFujin
XGaia
XGrunbunde
XGandarewa
XGaokerena
XGathas
XGerd
XGeryon
XGilgamesh
XGinnungagap
XGlispa
XGranis
XGungnir
XHalloway
XHarry'sWorld
XHalvec
XHal
XHadad
XHaoma
XHaroeris
XHathor
XHebe
XHector
XHei-tiki
XHoder
XHorae
XHotei
XHyksos
XInnana
XIshtar
XIoue
XIacchos
XIllyria
XIrkalla
XIswar
XIulus
XIxbalanque
XIzahami
XJackal
XJove
XJade
XJamsid
XJanus
XJataka
XJocasta
XJurojin
XKeshvar
XKhwanirath
XKol
XKachinas
XKalki
XKamakura
XKadath
XKaraja
XKettoi
XKhepri
XKirin
XKishijoten
XK'unLun
XKunmanggur
XKuya-Shonin
XKythamil
XLeng
XLevithan
XLuntag
XLaindjung
XLaoTzu
XLapiths
XLares
XLeinster
XLodbrok
XLotan
XLungshan
XLuyia
XLycurgus
XLarnok
XMorrigan
XMacha
XMaenads
XMandara
XManitou
XMarduk
X(Mashyane
XMashye)
XMegara
XMenrua
XMetis
XMjollnir
XMulungu
XNyarlathotep
XNessus
XNewBeginnings
XNuada
XNebo
XNinhursag
XNinigi
XNuba
XNu-kua
XNyambe
XNyx
XObolus
XOkokanoffee
XOeneus
XOhrmazd
XOjin
XOkesa
XOkuninushi
XOlifat
XOrchomenus
XOro
XOrunila
XOtus
XPlanetX
XPlanet10
XPleides
XPachacutil
XPandavas
XP'an-ku
XParshya
XParvati
XPatala
XPek
XPelops
XPrithivi
XPtolemy
XQuagKeep
XQuirnok
XQaQwaai
XQuetzalcoatl
XQuimbaya
XQuipus
XQuirinus
XRagnar
XRuhe
XRadha
XRagnarok
XRashnu
XRata
XRegia
XRhpisort
XRudra
XRukmini
XRustam
XRyobu
XR'lyeh
XSecundus
XSolaria
XSakra
XSalacia
XSappedon
XSati
XSemele
XShantak
XSrishok
XShapash
XSiddhartha
XSuga
XSugriva
XSurya
XSwarga
XTekeli-li
XTerminus
XTrantor
XTigra-nog'th
XTadanobu
XT'aishan
XTammuz
XTare
XTantrus
XTarturus
XTethys
XThinis
XTiki
XTi'i
XTjinimin
XTrisala
XTrashtri
XTsathoggua
XUnok
XUrech
XUkaipu
XUpuaut
XUrth
XUrsharabi
XUxmal
XUtnapishtim
XVilee
XVirag
XVanir
XVasuki
XVedas
XVedies
XVega
XVigari
XVirgil
XVirginus
XVishtaspa
XVohuManuh
XVucu-Caquix
XWampum
XWaura
XWawalag
XWalla
XYarnek
XYog-sothoth
XYamotodake
XYami
XYangtse
XYggdrasil
XYima
XYmir
XYu
XYucatan
XYumCaax
XYu-ti
XYaddith
XYuggoth
XZahak
XZapana
XZapaotek
XZoroaster
XZethus
XZocho
XZurvan
END_OF_FILE
if test 2235 -ne `wc -c <'server/planet.list'`; then
    echo shar: \"'server/planet.list'\" unpacked with wrong size!
fi
# end of 'server/planet.list'
fi
echo shar: End of archive 4 \(of 14\).
cp /dev/null ark4isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 14 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0