home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
games
/
volume10
/
gb3
/
part03
< prev
next >
Wrap
Internet Message Format
|
1990-06-08
|
56KB
Path: uunet!zephyr.ens.tek.com!tekred!saab!billr
From: billr@saab.CNA.TEK.COM (Bill Randle)
Newsgroups: comp.sources.games
Subject: v10i003: gb3 - Galactic Bloodshed, an empire-like war game [Ver. 2.0], Part03/14
Message-ID: <5694@tekred.CNA.TEK.COM>
Date: 1 Jun 90 19:05:44 GMT
Sender: news@tekred.CNA.TEK.COM
Lines: 1853
Approved: billr@saab.CNA.TEK.COM
Submitted-by: VANCLEEF@mps.ohio-state.edu
Posting-number: Volume 10, Issue 3
Archive-name: gb3/Part03
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 3 (of 14)."
# Contents: Docs/vessels.doc server/doplanet.c server/order.c
# server/ships.h
# Wrapped by billr@saab on Fri Jun 1 11:53:32 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Docs/vessels.doc' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'Docs/vessels.doc'\"
else
echo shar: Extracting \"'Docs/vessels.doc'\" \(369 characters\)
sed "s/^X//" >'Docs/vessels.doc' <<'END_OF_FILE'
XVESSELS Galactic Bloodshed VESSELS
X
X
XNAME
X [0] vessels -- describe the various ships that players may
X build during the game.
X
XSYNTAX
X vessels
X
XDESCRIPTION
X This command allows users to examine the various types
Xof ships that can be built during the game. This enters the same
Xhelp facility used with the 'build' command.
X
X
XSEE ALSO
X build, examine
X
X
END_OF_FILE
if test 369 -ne `wc -c <'Docs/vessels.doc'`; then
echo shar: \"'Docs/vessels.doc'\" unpacked with wrong size!
fi
# end of 'Docs/vessels.doc'
fi
if test -f 'server/doplanet.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'server/doplanet.c'\"
else
echo shar: Extracting \"'server/doplanet.c'\" \(21893 characters\)
sed "s/^X//" >'server/doplanet.c' <<'END_OF_FILE'
Xint Sectormappos;
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 * doplanet.c -- do one turn on a planet.
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 "doturn.h"
X#include "power.h"
X#include "buffers.h"
X#include <math.h>
X
Xextern float compatibility();
X
X /* types of accidents that can occur on a toxic planet. */
Xchar *Accidents_uninhab[] = {
X /* on water sectors */
X "Widespread waste spill",
X "Ecological instability",
X /* on land sectors */
X "Massive volcanic eruptions",
X "Ecological instability",
X /* on mountain sectors */
X "Massive volcanic eruptions",
X "Ecological instability",
X /* gas sectors */
X "Lethal toxin concentration",
X "Ecological instability",
X /* ice */
X "Leak in isolated chemical plant",
X "Continental warming cause glacial melting",
X /* plate */
X "Nuclear accident",
X "Untended nuclear plant explodes"
X};
X
Xchar *Accidents_inhab[] = {
X "Nuclear accident",
X "Terrorists trigger nuclear weapon",
X "Release of toxic waste",
X "Weapons dump explosion",
X "Massive starvation",
X "Virus epidemic",
X "famine",
X "starvation",
X "Widespread cultist suicide",
X "Atomic experiment gone wrong",
X "Great Hrung collapse"
X};
X
X
Xint doplanet(starnum,planet, planetnum)
Xint starnum;
Xplanettype *planet;
Xint planetnum;
X{
Xint shipno,x,y,nukex,nukey;
Xint o=0,j;
Xchar *nukem;
Xreg int i;
Xsectortype *p;
Xshiptype *ship;
Xfloat madd,fadd;
Xint sectdata,timer=20;
Xint oldplanetpopn, oldplanetmaxpopn;
Xboolean allmod=0,allexp=0;
Xchar buf[200];
X
XSectormappos = planet->sectormappos;
Xcheck(planet,0);
Xif (!StarsInhab[starnum])
X return 0; /* no one's here now */
X
Xif (Stinfo[starnum][planetnum].inhab) {
X/* printf(" getting sectmap pos %d\n",planet->sectormappos); */
X opensectdata(§data);
X getsmap(sectdata,Smap,planet);
X close_file(sectdata);
X
X PermuteSects(planet);
X bzero((char *)Sectinfo, sizeof(Sectinfo) );
X}
X
X
X
Xcheck(planet,1);
X shipno = planet->ships;
X
X while (shipno) {
X
X if ( ((ship = ships[shipno])!=NULL) && ship->is_alive && !ship->rad) {
X
X if ( !(ship->is_docked && ship->whatdest==LEVEL_PLAN)) {
X /* add fuel to ships orbiting gas giants */
X if (planet->type == TYPE_GASGIANT) {
X if (ship->type == STYPE_TANKER) {
X fadd = FUEL_GAS_ADD_TANKER;
X madd = FUEL_GAS_ADD_TANKER*MASS_FUEL;
X } else if (ship->type == STYPE_HABITAT) {
X fadd = FUEL_GAS_ADD_HABITAT;
X madd = FUEL_GAS_ADD_HABITAT*MASS_FUEL;
X } else {
X fadd = FUEL_GAS_ADD;
X madd = FUEL_GAS_ADD*MASS_FUEL;
X }
X if (ship->fuel + fadd > Max_fuel(ship)) {
X madd -= (Max_fuel(ship) - (ship->fuel+fadd))*MASS_FUEL;
X fadd = Max_fuel(ship)-(ship->fuel+fadd);
X }
X ship->fuel += fadd;
X ship->mass += madd;
X }
X }
X
X if (ship->type == OTYPE_VN || (ship->type==OTYPE_BERS && !ship->destruct)) {
X /* Von Neumann machine/unarmed Berserker */
X planet_doVN(ship,shipno,planet);
X } else if (ship->type == OTYPE_TERRA) { /* terraforming device. */
X
X if (ship->fuel >= (float)FUEL_COST_TERRA) {
X
X if (ship->on &&
X ((ship->whatdest == LEVEL_PLAN) && ship->is_docked)) {
X
X /* move, and then terraform. */
X
X if (ship->xpos >= (planet->Maxx-1) && ship->object.number > 0)
X ship->xpos = 0.0;
X else if (ship->xpos <= 0.0 && ship->object.number < 0)
X ship->xpos = (planet->Maxx-1);
X else
X ship->xpos += ship->object.number;
X
X if (ship->ypos <= 0.0 && ship->object.number2 < 0)
X ship->object.number2 = -ship->object.number2;
X else if (ship->ypos >= (planet->Maxy-1) && ship->object.number2 > 0)
X ship->object.number2 = -ship->object.number2;
X
X ship->ypos += ship->object.number2;
X
X {
X sectortype *s;
X s = &Sector(*planet,(int)ship->xpos,(int)ship->ypos);
X if (s->des != DES_GAS &&
X (int_rand(1,100) <= (((100-ship->damage) *
X ship->popn)/Max_crew(ship)))) {
X /* gas sectors can't be terraformed. */
X s->des = races[ship->owner-1]->likesbest;
X s->eff *= 0.5;
X s->mobilization *= 0.5;
X s->resource *= 0.7;
X /*s->popn *= 0.5;*/ /* ?? not sure bout this */
X s->popn = 0;
X s->owner = 0;/* i AM sure about this :) */
X ship->fuel -= (float)FUEL_COST_TERRA;
X ship->mass -= FUEL_COST_TERRA*MASS_FUEL;
X if (planet->conditions[TOXIC]<100)
X planet->conditions[TOXIC] += random()&01;
X }
X }
X
X }
X } else if (!ship->notified) {
X char teleg2_buf[1000];
X ship->notified = 1;
X msg_OOF(ship, shipno, teleg2_buf);
X }
X
X } else if (ship->type==OTYPE_BERS && ship->destruct) {
X if (ship->bombard && ship->whatorbits==LEVEL_PLAN &&
X ship->whatdest==LEVEL_PLAN &&
X ship->storbits==ship->deststar &&
X ship->pnumorbits==ship->destpnum &&
X !ship->is_docked)
X if (!Bombard(ship, shipno, planets[ship->storbits][ship->pnumorbits],
X races[ship->owner-1])) {
X /* we killed everyone here; go somewhere else */
X ship->destpnum = int_rand(0,Stars[ship->storbits]->numplanets);
X } else {
X /* exact revenge */
X if (Sdata.VN_hitlist[ship->object.number-1]>0)
X Sdata.VN_hitlist[ship->object.number-1]--;
X }
X } else if (can_bombard(ship) && ship->bombard &&
X ship->whatorbits==LEVEL_PLAN &&
X ship->whatdest==LEVEL_PLAN &&
X ship->storbits==ship->deststar &&
X ship->pnumorbits==ship->destpnum &&
X !ship->is_docked)
X Bombard(ship, shipno, planets[ship->storbits][ship->pnumorbits], races[ship->owner-1]);
X
X
X }
X shipno = ship->nextship;
Xcheck(planet,2);
X }
X
X
X if (!Stinfo[starnum][planetnum].inhab &&
X !Stinfo[starnum][planetnum].Thing_add)
X return 0; /* (no one's explored the planet) */
X
X
X /* check for space mirrors (among other things) warming the planet */
X /* if a change in any artificial warming/cooling trends */
X if (Stinfo[starnum][planetnum].temp_add != 0) {
X int final_temp;
X
X final_temp = planet->conditions[RTEMP] +
X Stinfo[starnum][planetnum].temp_add + int_rand(-5,5);
X
X planet->conditions[TEMP] = final_temp;
X }
X else planet->conditions[TEMP] = planet->conditions[RTEMP] + int_rand(-5,5);
X
X if (planet->slaved_to)
X planet->is_sheep = 1; /* this is set to 0 at the end of ea. turn */
X
X check(planet,3);
X
X if (Stinfo[starnum][planetnum].Thing_add>0) {
X /* start a meso colony */
X int p;
X/* printf(" getting sectmap pos %d\n",planet->sectormappos); */
X opensectdata(§data);
X getsmap(sectdata,Smap,planet);
X close_file(sectdata);
X
X PermuteSects(planet);
X bzero((char *)Sectinfo, sizeof(Sectinfo) );
X x = int_rand(0,planet->Maxx-1);
X y = int_rand(0,planet->Maxy-1);
X p = Stinfo[starnum][planetnum].Thing_add;
X/* printf("spore landed st %d, plan %d, play %d.\n", starnum,planetnum,p);*/
X planet->info[p-1].numsectsowned = 1;
X
X planet->info[p-1].explored = 1;
X Sector(*planet,x,y).popn = 1;
X Sector(*planet,x,y).owner = p;
X Sector(*planet,x,y).is_wasted = 0;
X}
X
Xbzero((char *)avg_mob, sizeof(avg_mob) );
Xbzero((char *)sects_gained, sizeof(sects_gained) );
Xbzero((char *)sects_lost, sizeof(sects_lost) );
Xbzero((char *)populations, sizeof(populations) );
Xbzero((char *)prod_res, sizeof(prod_res) );
Xbzero((char *)prod_fuel, sizeof(prod_fuel) );
Xbzero((char *)prod_destruct, sizeof(prod_destruct) );
X
Xtot_resdep = prod_eff= prod_mob = tot_captured = 0;
XClaims = 0;
X
Xoldplanetmaxpopn = planet->maxpopn;
Xplanet->maxpopn = 0;
X
Xoldplanetpopn = planet->popn;
Xplanet->popn = 0; /* initialize population for recount */
X
X/* reset global variables */
Xfor (i=1; i<=Num_races; i++) {
X Compat[i-1] = compatibility(planet, races[i-1]);
X planet->info[i-1].numsectsowned = 0;
X populations[i-1] = 0;
X prod_fuel[i-1] = 0;
X prod_destruct[i-1] = 0;
X prod_res[i-1] = 0;
X avg_mob[i-1] = 0.0;
X}
X
XGetxysect(planet, &x, &y, 1);
X/*printf(" while %d\n",Getxysect(planet, &x, &y, 1)); /* reset */
X
Xcheck(planet,4);
Xwhile (Getxysect(planet, &x, &y, 0)) {
X p = &Sector(*planet,x,y);
X if (p->owner) {
X /* (all modified; sectors belonging to that player modified) */
X allmod = 1;
X if (p->popn == 0) {
X p->owner=0; /* make wasted/unowned sects go to player 0 */
X } else {
X if (!Stars[starnum]->nova_stage) {
X /* spread excess popn to surrounding sects */
X produce(planet,p); /* >produce stuff there */
X spread(planet,p,x,y);
X } else {
X /* damage sector from supernova */
X p->resource++;
X p->fert *= 0.95;
X if (Stars[starnum]->nova_stage == 14)
X p->popn = p->owner = 0;
X else
X p->popn = round_rand((float)p->popn * .50);
X }
X
X }
X
X Sectinfo[x][y].done = 1;
X
X }
X
X
X if (p->owner) {
X planet->info[p->owner-1].numsectsowned++;
X planet->popn += p->popn;
X Power[p->owner-1].popn += p->popn;
X Power[p->owner-1].sum_eff += p->eff;
X Power[p->owner-1].sum_mob += p->mobilization;
X starpopns[starnum][p->owner-1] += populations[p->owner-1] += p->popn;
X planet->maxpopn += maxsupport(races[p->owner-1],p,
X Compat[p->owner-1],planet->conditions[TOXIC]);
X }
X
X
X
X if (p->is_wasted) {
X if (x>1 && x<planet->Maxx-2) {
X if (p->des==DES_SEA || p->des==DES_GAS) {
X /* don't reclaim pole sectors */
X if ( y>1 && y<planet->Maxy-2 &&
X (!(p-1)->is_wasted || !(p+1)->is_wasted)
X && !random()%5)
X p->is_wasted = 0;
X } else if (p->des==DES_LAND || p->des==DES_MOUNT || p->des==DES_ICE) {
X if ( y>1 && y<planet->Maxy-2 &&
X ((p-1)->popn || (p+1)->popn)
X && !random()%10)
X p->is_wasted = 0;
X }
X }
X }
X
X /* evaporate the oceans on novae */
X if (Stars[starnum]->nova_stage) {
X if (p->des==DES_ICE)
X p->des = DES_LAND;
X else if (p->des==DES_SEA)
X
X if ( (x>0 && (p-1)->des==DES_LAND) ||
X (x<planet->Maxx-1 && (p+1)->des==DES_LAND) ||
X (y>0 && (p-planet->Maxx)->des==DES_LAND) ||
X (y<planet->Maxy-1 && (p+planet->Maxx)->des==DES_LAND ) ) {
X p->des = DES_LAND;
X p->popn = p->owner = 0;
X p->resource += 3;
X p->fert = int_rand(1,4);
X/* printf("sect %d,%d evaporated.\n",x,y); */
X }
X }
X
X}
Xcheck(planet,5);
X
Xif (allmod) { /* ( >= 1 inhabited sector on the planet) */
X
Xcheck(planet,51);
X if (planet->expltimer >= 1)
X planet->expltimer--;
X if (!Stars[starnum]->nova_stage && !planet->expltimer) {
X if (!planet->expltimer)
X planet->expltimer = 5;
X for (i=1; !Claims && !allexp && i<=Num_races; i++) {
Xcheck(planet,6);
X /* sectors have been modified for this player*/
X
X if (planet->info[i-1].numsectsowned)
X while (!Claims && !allexp && timer>0) {
X timer -= 1;
X o = 1;
X Getxysect(planet, &x, &y, 1);
X while (!Claims && Getxysect(planet, &x, &y, 0)) {
X /* find out if all sectors have been explored */
X o &= Sectinfo[x][y].explored;
X p = &Sector(*planet,x,y);
X if (( (Sectinfo[x][y].explored==i) && !(random()&02) )
X && (!p->owner && !p->is_wasted && p->des==races[i-1]->likesbest) ) {
X /* explorations have found an island */
X/* printf("found island @ %d,%d\n",x,y);*/
X Claims = i;
X /* give them some free people there */
X p->popn = races[i-1]->number_sexes;
X p->owner = i;
X tot_captured = 1;
X } else {
X
X explore(planet, p, x, y, i);
X check(planet,63);
X }
X }
X allexp |= o; /* all sectors explored for this player */
X
X }
X }
X }
X if (allexp)
X planet->expltimer = 5;
X
Xcheck(planet,7);
X /* environment nukes a random sector */
X if (planet->conditions[TOXIC] > ENVIR_DAMAGE_TOX) {
X nukex = int_rand(0,planet->Maxx-1);
X nukey = int_rand(0,planet->Maxy-1);
X p = &Sector(*planet,nukex,nukey);
X if (p->owner)
X planet->info[p->owner-1].numsectsowned--;
X p->is_wasted = 1;
X /* index into accident type array */
X nukem = p->popn ?
X /* random disaster */
X Accidents_inhab[int_rand(0,sizeof(Accidents_inhab)/sizeof(char *))]
X /* random of two disasters for that sec type*/
X : Accidents_uninhab[p->des * 2 + (random()&01)];
X p->popn = p->owner = 0;
X }
X
X for (i=1; i<=Num_races; i++)
X if (sects_gained[i-1] || sects_lost[i-1]) {
X sprintf(telegram_buf,"****** Report: Planet /%s/%s ******\n",
X Stars[starnum]->name, Stars[starnum]->pnames[planetnum] );
X sprintf(buf," \nWAR STATUS: %d sectors gained, %d sectors lost.\n", sects_gained[i-1],sects_lost[i-1]);
X str_cat(telegram_buf, buf);
X push_message(TELEG_PLAYER_AUTO, i, telegram_buf);
X }
X
X for (i=1; i<=Num_races; i++)
X if (planet->info[i-1].autorep) {
X
Xcheck(planet,8);
X/* planet->info[i-1].autorep = planet->info[i-1].autorep - 1; */
Xcheck(planet,85);
X sprintf(telegram_buf,"\nFrom /%s/%s\n",
X Stars[starnum]->name, Stars[starnum]->pnames[planetnum] );
X if (Stinfo[starnum][planetnum].temp_add) {
X sprintf(buf,"Temp: %d to %d\n",
X Temp(planet->conditions[RTEMP]), Temp(planet->conditions[TEMP]));
X str_cat(telegram_buf, buf);
X }
X sprintf(buf, "Total Prod: %dr %df %dd\n", prod_res[i-1], prod_fuel[i-1],
X prod_destruct[i-1]);
X str_cat(telegram_buf, buf);
X
X if(tot_captured) {
X sprintf(buf,"%d sectors captured\n", tot_captured);
X str_cat(telegram_buf, buf);
X }
X
X if (Stars[starnum]->nova_stage) {
X sprintf(buf,"This planet's primary is in a Stage %d nova.\n",
X Stars[starnum]->nova_stage);
X str_cat(telegram_buf, buf);
X }
X
X /* remind the player that he should clean up the environment. */
X if (planet->conditions[TOXIC] > ENVIR_DAMAGE_TOX) {
X sprintf(buf,"Environmental damage on sector %d,%d\n", nukex, nukey);
X str_cat(telegram_buf, buf);
X }
X
X if (planet->slaved_to) {
X sprintf(buf, "ENSLAVED to player %d\n", planet->slaved_to);
X str_cat(telegram_buf, buf);
X }
X
X push_message(TELEG_PLAYER_AUTO, i, telegram_buf);
X
X }
Xcheck(planet,9);
X
X /* find out who is on this planet, for nova notification */
X if (Stars[starnum]->nova_stage == 1) {
X sprintf(telegram_buf,"BULLETIN from /%s/%s\n", Stars[starnum]->name, Stars[starnum]->pnames[planetnum]);
X sprintf(buf,"\nStar %s is undergoing nova.\n", Stars[starnum]->name);
X str_cat(telegram_buf, buf);
X if (planet->type==TYPE_EARTH) {
X sprintf(buf,"Seas and rivers are boiling!\n",telegram_buf,0);
X str_cat(telegram_buf, buf);
X }
X sprintf(buf, "This planet must be evacuated immediately!\n%c", TELEG_DELIM);
X str_cat(telegram_buf, buf);
X for (i=1; i<=Num_races; i++)
X if (planet->info[i-1].numsectsowned) {
X push_message(TELEG_PLAYER_AUTO, i, telegram_buf);
X }
X }
X
X
Xcheck(planet,10);
X for (i=1; i<=Num_races; i++) {
X
X/* check to see if your guys steal all alien resources on the planet,
X this requires that you be the only one inhabiting the planet */
X
X if (planet->info[i-1].numsectsowned > 0) {
X int aliensects=0,stolenres=0,stolendes=0,stolenfuel=0;
X int stuff=0;
X
X
X for (j=2; j<=Num_races; j++)
X if(j!=i)
X {
X aliensects += planet->info[j-1].numsectsowned;
X if(planet->info[j-1].resource >0 ||
X planet->info[j-1].destruct >0 ||
X planet->info[j-1].fuel > 0.0) stuff=1;
X }
X
X if(!aliensects && stuff)
X {
X for (j=1; j<=Num_races; j++)
X if(j!=i)
X {
X stolenres += planet->info[j-1].resource;
X stolendes += planet->info[j-1].destruct;
X stolenfuel += planet->info[j-1].fuel;
X planet->info[j-1].resource = 0;
X planet->info[j-1].destruct = 0;
X planet->info[j-1].fuel = 0;
X }
X planet->info[i-1].resource += stolenres;
X planet->info[i-1].destruct += stolendes;
X planet->info[i-1].fuel += stolenfuel;
X/* notify player of recovered stockpiles */
X sprintf(telegram_buf,"****** Report: Planet /%s/%s ******\n\n",
X Stars[starnum]->name, Stars[starnum]->pnames[planetnum] );
X sprintf(buf," %d resources \n %d destruct \n %d fuel recovered from alien stock piles",stolenres,stolendes,stolenfuel);
X str_cat(telegram_buf, buf);
X push_message(TELEG_PLAYER_AUTO, i, telegram_buf);
X } /*aliensect==0*/
X }
X
X if (planet->info[i-1].numsectsowned) {
X /* combat readiness naturally moves towards the avg mobilization */
X avg_mob[i-1] /= planet->info[i-1].numsectsowned;
X planet->info[i-1].comread +=
X sgn(avg_mob[i-1] - planet->info[i-1].comread);
X }
X }
X
X if (planet->maxpopn > 0 && planet->conditions[TOXIC]<100)
X planet->conditions[TOXIC] +=
X/* round_rand(MIN((float)(planet->popn /
X (float)planet->maxpopn),2.0)); */
X planet->popn/planet->maxpopn;
X /* Rob, this is a better idea, or toxic go wild
X other effects can make this happen
X keeps waste containers down too -
X playtesting has proved this to us at OSU */
X
X if (planet->conditions[TOXIC] > 100)
X planet->conditions[TOXIC] = 100;
X else if (planet->conditions[TOXIC] < 0)
X planet->conditions[TOXIC] = 0;
X
X /* deal with enslaved planets */
X if (planet->slaved_to) {
X if (populations[planet->slaved_to-1] >= planet->popn * 0.001 ||
X (Stinfo[starnum][planetnum].intimidated && random()&01) ) {
X/* printf("enslaved!\n"); */
X for (i=1; i<=Num_races; i++)
X /* add production to slave holder of planet */
X if (planet->info[i-1].numsectsowned) {
X planet->info[planet->slaved_to-1].resource +=
X prod_res[i-1];
X prod_res[i-1] = 0;
X planet->info[planet->slaved_to-1].fuel +=
X prod_fuel[i-1];
X prod_fuel[i-1] = 0;
X planet->info[planet->slaved_to-1].destruct +=
X prod_destruct[i-1];
X prod_destruct[i-1] = 0;
X }
X } else {
X /* slave revolt! */
X/* printf("slave revolt!\n"); */
X /* first nuke some random sectors from the revolt */
X i = planet->popn / 1000 + 1;
X/* printf("i %d Maxx %d Maxy %d\n",i,planet->Maxx,planet->Maxy); */
X while (--i) {
X p = &Sector(*planet,int_rand(0,planet->Maxx-1),
X int_rand(0,planet->Maxy-1));
X if (p->popn) {
X p->owner = p->popn = 0;
X p->is_wasted = 1;
X }
X }
X /* now nuke all sectors belonging to former master */
X Getxysect(planet, &x, &y, 1);
X while (Getxysect(planet, &x, &y, 0)) {
X if (Stinfo[starnum][planetnum].intimidated && random()&01) {
X p = &Sector(*planet,x,y);
X if (p->owner==planet->slaved_to) {
X p->owner = 0;
X p->popn = 0;
X p->is_wasted = 1;
X }
X }
X }
X sprintf(telegram_buf,"NOTICE from planet /%s/%s!\n",
X Stars[starnum]->name,
X Stars[starnum]->pnames[planetnum]);
X sprintf(buf,"\nThere has been a SLAVE REVOLT on this planet!\n");
X str_cat(telegram_buf, buf);
X sprintf(buf,"All population belonging to player #%d on the planet have been killed!\n",planet->slaved_to);
X str_cat(telegram_buf, buf);
X sprintf(buf,"Productions now go to their rightful owners.\n");
X str_cat(telegram_buf, buf);
X for (i=1; i<=Num_races; i++)
X if (planet->info[i-1].numsectsowned && i!=planet->slaved_to) {
X push_message(TELEG_PLAYER_AUTO, i, telegram_buf);
X }
X /* send to previous slave holder */
X push_message(TELEG_PLAYER_AUTO, planet->slaved_to, telegram_buf);
X
X planet->slaved_to = 0;
X planet->is_sheep = 0;
X }
X
X } else {
X /* add production to all people here */
X for (i=1; i<=Num_races; i++) {
X
X if (planet->info[i-1].numsectsowned) {
X
X if (planet->info[i-1].fuel + prod_fuel[i-1] > 100000)
X planet->info[i-1].fuel = 100000;
X else
X planet->info[i-1].fuel += prod_fuel[i-1];
X
X if (planet->info[i-1].resource + prod_res[i-1] > 100000)
X planet->info[i-1].resource = 100000;
X else
X planet->info[i-1].resource += prod_res[i-1];
X
X if (planet->info[i-1].destruct + prod_destruct[i-1] > 100000)
X planet->info[i-1].destruct = 100000;
X else
X planet->info[i-1].destruct += prod_destruct[i-1];
X
X /* do tech investments */
X if (planet->info[i-1].resource >= planet->info[i-1].tech_invest) {
X races[i-1]->tech +=
X log10(1.0+(double)planet->info[i-1].tech_invest) * TECH_INVEST;
X planet->info[i-1].resource -= planet->info[i-1].tech_invest;
X }
X
X /* build wc's if it's been ordered */
X if (planet->info[i-1].tox_thresh>0 &&
X planet->conditions[TOXIC] >= planet->info[i-1].tox_thresh &&
X planet->info[i-1].resource >= Shipdata[OTYPE_TOXWC][ABIL_COST]) {
X shiptype *s2; reg int t;
X ++Num_ships;
X ships = (shiptype **)realloc(ships, (unsigned)((Num_ships+1)*sizeof(shiptype*)));
X s2 = ships[Num_ships] = Malloc(shiptype);
X/* printf("planet /%s/%s made Tox wc #%d.\n",Stars[starnum]->name,
X Stars[starnum]->pnames[planetnum],Num_ships); */
X bzero((char *)s2,sizeof(shiptype));
X s2->type = OTYPE_TOXWC;
X
X s2->armor = Shipdata[OTYPE_TOXWC][ABIL_ARMOR];
X s2->guns = Shipdata[OTYPE_TOXWC][ABIL_GUNS];
X s2->size = Shipdata[OTYPE_TOXWC][ABIL_TARGET];
X s2->max_crew = Shipdata[OTYPE_TOXWC][ABIL_MAXCREW];
X s2->max_resource = Shipdata[OTYPE_TOXWC][ABIL_CARGO];
X s2->max_fuel = Shipdata[OTYPE_TOXWC][ABIL_FUELCAP];
X s2->max_destruct = Shipdata[OTYPE_TOXWC][ABIL_DESTCAP];
X s2->max_speed = Shipdata[OTYPE_TOXWC][ABIL_SPEED];
X s2->base_mass = getmass(s2);
X s2->mass = s2->base_mass;
X s2->is_alive = 1;
X sprintf(s2->name,"Scum%04d",Num_ships);
X
X insert_sh_plan(planet,s2,Num_ships);
X
X s2->whatorbits = LEVEL_PLAN;
X s2->storbits = starnum;
X s2->pnumorbits = planetnum;
X s2->is_docked = 1;
X s2->xpos = int_rand(0,planet->Maxx-1);
X s2->ypos = int_rand(0,planet->Maxy-1);
X s2->whatdest = LEVEL_PLAN;
X s2->deststar = starnum;
X s2->destpnum = planetnum;
X s2->owner = i;
X t = MIN(TOXMAX,planet->conditions[TOXIC]); /* amt of tox */
X planet->conditions[TOXIC] -= t;
X s2->object.number = t;
X }
X } /* (if numsectsowned[i]) */
X
X } /* (for i=1 to Num_races) */
X
X } /* (else (if slaved_to)) */
X
X
X planet->is_sheep = 0;
X
X }
X
X for (i=1; i<=Num_races; i++) {
X Power[i-1].resource += planet->info[i-1].resource;
X Power[i-1].destruct += planet->info[i-1].destruct;
X Power[i-1].fuel += planet->info[i-1].fuel;
X Power[i-1].planets_owned += !!planet->info[i-1].numsectsowned;
X Power[i-1].sectors_owned += planet->info[i-1].numsectsowned;
X/* Power[i-1].sum_mob += avg_mob[i-1]; */
X }
X
Xcheck(planet,12);
X return allmod;
X}
X
X
Xcheck(p,n)
Xplanettype *p;
Xint n;
X{
X if (p->sectormappos != Sectormappos)
X fprintf(stderr," WHOA! sectormappos %d != %d (%d)\n",
X p->sectormappos, Sectormappos, n);
X /*else
X fprintf(stderr, "OK (%d)\n",n);*/
X}
END_OF_FILE
if test 21893 -ne `wc -c <'server/doplanet.c'`; then
echo shar: \"'server/doplanet.c'\" unpacked with wrong size!
fi
# end of 'server/doplanet.c'
fi
if test -f 'server/order.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'server/order.c'\"
else
echo shar: Extracting \"'server/order.c'\" \(21412 characters\)
sed "s/^X//" >'server/order.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 * order.c -- give orders to ship
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 <curses.h>
X#include <ctype.h>
X#include <signal.h>
X#include <math.h>
X
Xchar *prin_aimed_at(), *prin_ship_dest();
X
Xint order_shdata,order_pdata,order_stardata;
Xint n_ships;
Xstatic boolean first,prerror,was_obj = 0;
Xboolean Order_types[NUMSTYPES];
X
Xorder(Playernum, APcount, argn,args)
Xint Playernum;
Xint APcount;
Xint argn;
Xchar args[MAXARGS][COMMANDSIZE];
X{
Xint shipno, i;
Xint order_shdata = NEUTRAL_FD;
Xint sh, pdata;
Xplanettype *p;
X
Xfor (i=0; i<NUMSTYPES; i++) Order_types[i]=0;
X
Xif(argn==1) { /* display all ship orders */
X switch(Dir[Playernum-1].level) {
X case LEVEL_UNIV:
X sh = Sdata.ships;
X DispOrdersHeader(Playernum);
X while (sh)
X DispOrders(Playernum, sh, &sh, 0);
X break;
X case LEVEL_STAR:
X sh = Stars[Dir[Playernum-1].snum]->ships;
X DispOrdersHeader(Playernum);
X while (sh)
X DispOrders(Playernum, sh, &sh, 0);
X break;
X case LEVEL_PLAN:
X openpdata(&pdata);
X getplanet(pdata,&p,
X Stars[Dir[Playernum-1].snum]->planetpos[Dir[Playernum-1].pnum]);
X close_file(pdata);
X sh = p->ships;
X DispOrdersHeader(Playernum);
X while (sh)
X DispOrders(Playernum, sh, &sh, 0);
X free(p);
X break;
X case LEVEL_SHIP:
X sh = Dir[Playernum-1].shipno;
X DispOrdersHeader(Playernum);
X DispOrders(Playernum, sh, &sh, 0);
X break;
X default:
X notify(Playernum, "Bad scope.\n");
X break;
X }
X
X} else if (argn>=2) { /* display one ship's orders (if argn==2), otherwise assigne orders */
X
X if(*args[1] == '#' || isdigit(*args[1])) {
X sscanf(args[1]+(args[1][0]=='#'),"%d",&shipno);
X
X openshdata(&order_shdata);
X n_ships = Numships(order_shdata);
Xclose_file(order_shdata);
X
X if(shipno <=0 || shipno > n_ships) {
X sprintf(buf, "Illegal ship number %d.\n", shipno);
X notify(Playernum, buf);
X return;
X }
X
X if(argn > 2)
X give_orders(Playernum, APcount, argn, args, shipno, 0);
X
X/* display the orders anyway */
X DispOrdersHeader(Playernum);
X DispOrders(Playernum, shipno, &sh, 0);
X } else { /* you want to order all types on this level */
X int l;
X l = strlen(args[1]);
X
X while (l--) {
X i = NUMSTYPES;
X while (--i && Shipltrs[i]!=args[1][l]);
X if (Shipltrs[i]!=args[1][l]) {
X sprintf(buf,"'%c' -- no such ship letter\n",args[1][l]);
X notify(Playernum, buf);
X } else
X Order_types[i] = 1;
X }
X
X
Xswitch(Dir[Playernum-1].level) {
X case LEVEL_PLAN:
X openpdata(&pdata);
X getplanet(pdata,&p,
X Stars[Dir[Playernum-1].snum]->planetpos[Dir[Playernum-1].pnum]);
X close_file(pdata);
X shipno = p->ships;
X break;
X case LEVEL_STAR:
X shipno = Stars[Dir[Playernum-1].snum]->ships;
X break;
X default:
X notify(Playernum, "You can't do multiple orders from this level. Must be planet of star.\n");
X return;
X }
X
X DispOrdersHeader(Playernum);
X while (shipno) {
X if(argn > 2)
X give_orders(Playernum, APcount, argn, args, shipno, 1);
X DispOrders(Playernum, shipno, &shipno, 1);
X }
X
X
X }
X } else
X notify(Playernum, "I don't understand what you mean.\n");
X
X}
X
X
Xint give_orders(Playernum, APcount, argn, args, shipno, check)
Xint Playernum;
Xint APcount;
Xint argn;
Xchar args[MAXARGS][COMMANDSIZE];
Xint shipno;
Xint check;
X{
X boolean Mod=0,q=0,redraw=1;
X placetype where,pl;
X int i = 0, j=0, in_list=0;
X shiptype *ship, *oldship, ship2;
X char c,s[PLACENAMESIZE];
X planettype *planet;
X
X openshdata(&order_shdata);
X if (!getship(order_shdata,&ship,shipno)) {
X notify(Playernum, "order:error in getship.\n");
X return;
X }
Xclose_file(order_shdata);
Xif(ship->type == OTYPE_CANIST)
X i=1;
X
Xif(check) {
X in_list = 0;
X for(j=0; j<NUMSTYPES; j++) {
X if(Order_types[j] && ship->type==j) in_list = 1;
X }
X if(!in_list) {
X free(ship);
X return;
X }
X }
X
X if (ship->owner==Playernum) {
X
X if (!ship->is_alive) {
X sprintf(buf, "%s #%d has been destroyed.\n", Shipnames[ship->type], shipno);
X notify(Playernum, buf);
X free(ship);
X return;
X } else {
X
X if (!ship->active) {
X sprintf(buf, "%s #%d is irradiated (%d); it cannot be give orders.\n",
X Shipnames[ship->type], shipno,ship->rad);
X notify(Playernum, buf);
X free(ship);
X return;
X }
X if (ship->type != OTYPE_TRANSDEV && !ship->popn &&
X Max_crew(ship)) {
X sprintf(buf, "%s #%d has no crew and is not a robotic ship.\n",
X Shipnames[ship->type], shipno);
X notify(Playernum, buf);
X free(ship);
X return;
X }
X
X }
X
X i=strlen(args[2]);
X
X if (!strncmp(args[2],"defense",i)) {
X if (can_bombard(ship) || ship->type == OTYPE_GR) {
X if(!strncmp(args[3],"off", strlen(args[3]))) {
X ship->protect.planet = 0;
X notify(Playernum, "Planetary defense canceled.\n");
X } else {
X ship->protect.planet = 1;
X notify(Playernum, "Ship assigned to planetary defense.\n");
X }
X } else {
X notify(Playernum, "That ship cannot be assigned those orders.\n");
X free(ship);
X return;
X }
X } else if (!strncmp(args[2],"jump",i)) {
X if(Shipdata[ship->type][ABIL_JUMP]) {
X if(!strncmp(args[3],"off", strlen(args[3]))) {
X ship->hyper_drive.on = 0;
X notify(Playernum, "Hyper drive turned off.\n");
X } else {
X if(ship->whatdest != LEVEL_STAR) {
X notify(Playernum, "Destination must be star.\n");
X free(ship);
X return;
X }
X ship->hyper_drive.on = 1;
X ship->navigate.on = 0;
X notify(Playernum, "Hyper drive engine's activated.\n");
X/* estimate how much fuel it will cost for this ship to get there */
X }
X } else {
X notify(Playernum, "This ship does not have hyper drive capability.\n");
X free(ship);
X return;
X }
X
X } else if (!strncmp(args[2],"protect",i)) {
X
X sscanf(args[3]+(args[3][0]=='#'),"%d",&j);
X
X if(j < 0 || j > n_ships || j==shipno) {
X notify(Playernum, "You can't protect that!\n");
X free(ship);
X return;
X }
X if (can_bombard(ship) || ship->type==OTYPE_GR) {
X if(!j) {
X ship->protect.on = 0;
X notify(Playernum, "Protection orders halted.\n");
X } else {
X ship->protect.on = 1;
X ship->protect.ship = j;
X sprintf(buf, "Protecting ship #%d.\n", j);
X notify(Playernum, buf);
X }
X
X } else {
X notify(Playernum, "That ship cannot protect.\n");
X free(ship);
X return;
X }
X } else if (!strncmp(args[2],"navigate",i)) {
X if(argn >= 5) {
X ship->navigate.on = 1;
X ship->navigate.bearing = atoi(args[3]);
X ship->navigate.turns = atoi(args[4]);
X sprintf(buf, "Navigating %d degrees for %d turns.\n",
X ship->navigate.bearing, ship->navigate.turns);
X notify(Playernum, buf);
X } else {
X ship->navigate.on = 0;
X }
X if(ship->hyper_drive.on) {
X ship->hyper_drive.on = 0;
X notify(Playernum, "Hyper drive turned off.\n");
X }
X } else if (!strncmp(args[2],"switch",i)) {
X if(has_switch(ship)) {
X ship->on = !ship->on;
X } else {
X sprintf(buf, "That ship does not have an on/off setting.\n");
X notify(Playernum, buf);
X free(ship);
X return;
X }
X if(ship->on) {
X notify(Playernum, "Turned on.\n");
X switch (ship->type) {
X case STYPE_MINE:
X notify(Playernum, "Mine armed and ready.\n");
X break;
X case OTYPE_TRANSDEV:
X notify(Playernum, "Transporter ready to receive.\n");
X break;
X default: break;
X }
X } else {
X notify(Playernum, "Turned off.\n");
X switch (ship->type) {
X case STYPE_MINE:
X notify(Playernum, "Mine disarmed.\n");
X break;
X case OTYPE_TRANSDEV:
X notify(Playernum, "No longer receiving.\n");
X break;
X default: break;
X }
X }
X } else if (!strncmp(args[2],"destination",i)) {
X if (speed_rating(ship)) {
X if (ship->is_docked) {
X notify(Playernum, "That ship is docked; use undock or launch first.\n");
X free(ship);
X return;
X }
X where = Getplace(Playernum, args[3], 1);
X if (!where.err) {
X if (where.level==LEVEL_SHIP) {
X ship->destshipno = where.shipno;
X ship->whatdest = LEVEL_SHIP;
X } else {
X ship->whatdest = where.level;
X ship->deststar = where.snum;
X ship->destpnum = where.pnum;
X }
X } else {
X notify(Playernum, "Illegal destination.\n");
X free(ship);
X return;
X }
X
X sprintf(buf, "Ship's destination set to %*s\n", -PLACENAMESIZE,
X prin_ship_dest(Playernum, ship) );
X notify(Playernum, buf);
X
X } else {
X notify(Playernum, "That ship cannot be launched.\n");
X free(ship);
X return;
X }
X } else if (!strncmp(args[2],"evade",i)) {
X if (Max_crew(ship) && Max_speed(ship)) {
X if(!strlen(args[3],"on",strlen(args[3]))) {
X ship->protect.evade = 1;
X notify(Playernum, "Ship is undergoing evasive maneuvers.\n");
X } else {
X ship->protect.evade = 0;
X notify(Playernum, "Ship no longer undergoing evasive maneuvers.\n");
X }
X } else {
X notify(Playernum, "You can't make this type of ship do this.\n");
X free(ship);
X return;
X }
X
X } else if (!strncmp(args[2],"bombard",i)) {
X if (ship->type!=OTYPE_OMCL) {
X if (can_bombard(ship)) {
X if(!strncmp(args[3],"off",strlen(args[3]))) {
X ship->bombard = 0;
X notify(Playernum, "Bombardment option turned off.\n");
X } else {
X ship->bombard = 1;
X notify(Playernum, "Ship will bombard upon reaching its destination.\n");
X }
X
X } else {
X notify(Playernum, "This type of ship cannot be set to retaliate.\n");
X }
X }
X } else if (!strncmp(args[2],"retaliate",i)) {
X if (ship->type!=OTYPE_OMCL) {
X if (can_bombard(ship) || ship->type==OTYPE_GR) {
X if(!strncmp(args[3],"off",strlen(args[3]))) {
X ship->protect.self = 0;
X notify(Playernum, "Retaliation option turned off.\n");
X } else {
X ship->protect.self = 1;
X notify(Playernum, "Ship will retaliate if attacked and damaged.\n");
X }
X
X } else {
X notify(Playernum, "This type of ship cannot be set to retaliate.\n");
X }
X }
X } else if (!strncmp(args[2],"speed",i)) {
X if (speed_rating(ship)) {
X j = atoi(args[3]);
X if(j < 0) {
X notify(Playernum, "Specify a positive speed.\n");
X free(ship);
X return;
X } else {
X if(j > speed_rating(ship)) j = speed_rating(ship);
X ship->speed = j;
X sprintf(buf, "Ship speed set to %d.\n", j);
X notify(Playernum, buf);
X }
X
X } else {
X notify(Playernum, "This ship does not have a speed rating.\n");
X free(ship);
X return;
X }
X
X } else if(!strncmp(args[2], "explosive", i)) {
X if(ship->type==STYPE_MINE) {
X ship->mine.mode = 1;
X notify(Playernum, "This mine is set for explosive mode.\n");
X } else {
X notify(Playernum, "This ship cannot be set for this.\n");
X free(ship);
X return;
X }
X } else if(!strncmp(args[2], "radiative", i)) {
X if(ship->type==STYPE_MINE) {
X ship->mine.mode = 0;
X notify(Playernum, "This mine is set for radiation mode.\n");
X } else {
X notify(Playernum, "This ship cannot be set for this.\n");
X free(ship);
X return;
X }
X } else if(!strncmp(args[2], "move", i)) {
X if (ship->type==OTYPE_TERRA) {
X ship->object.number = atoi(args[3]);
X ship->object.number2 = atoi(args[4]);
X if(ship->object.number != 0)
X ship->object.number = sgn(ship->object.number);
X if(ship->object.number2 != 0)
X ship->object.number2 = sgn(ship->object.number2);
X sprintf(buf, "Terraformer moving in direction %d,%d\n",
X ship->object.number,ship->object.number2);
X notify(Playernum, buf);
X } else {
X notify(Playernum, "That ship is not a terraformer.\n");
X free(ship);
X return;
X }
X } else if(!strncmp(args[2], "trigger", i)) {
X if (ship->type==STYPE_MINE) {
X ship->object.number = atoi(args[3]);
X if (ship->object.number < 0)
X ship->object.number = 0;
X sprintf(buf, "Trigger radius set to %3d\n",ship->object.number);
X notify(Playernum, buf);
X } else {
X notify(Playernum, "This ship cannot be assigned a trigger radius.\n");
X free(ship);
X return;
X }
X } else if(!strncmp(args[2], "transport", i)) {
X if (ship->type==OTYPE_TRANSDEV) {
X ship->object.number = atoi(args[3]);
X if(ship->object.number < 0 || ship->object.number > n_ships)
X ship->object.number = 0;
X sprintf(buf, "Target ship is %d.\n",ship->object.number);
X notify(Playernum, buf);
X } else {
X notify(Playernum, "This ship is not a transporter.\n");
X free(ship);
X return;
X }
X } else if(!strncmp(args[2], "aim", i)) {
X if (can_aim(ship)) {
X if (ship->type==OTYPE_GTELE || ship->type==OTYPE_TRACT
X || ship->fuel>=FUEL_MANEUVER) {
X if (ship->type==STYPE_MIRROR && ship->is_docked) {
X sprintf(buf, "docked; use undock or launch first.\n");
X notify(Playernum, buf);
X free(ship);
X return;
X }
X pl = Getplace(Playernum, args[3],1);
X if (pl.err) {
X notify(Playernum, "Error in destination.\n");
X free(ship);
X return;
X } else {
X ship->aimed_at.level = pl.level;
X ship->aimed_at.pnum = pl.pnum;
X ship->aimed_at.snum = pl.snum;
X ship->aimed_at.shipno = pl.shipno;
X if (ship->type!=OTYPE_TRACT &&
X ship->type!=OTYPE_GTELE)
X ship->fuel -= FUEL_MANEUVER;
X if (ship->type==OTYPE_GTELE ||
X ship->type==OTYPE_STELE)
X mk_expl_aimed_at(Playernum, ship);
X sprintf(buf, "Aimed at %s\n", prin_aimed_at(Playernum, ship) );
X notify(Playernum, buf);
X }
X } else {
X sprintf(buf, "Not enough maneuvering fuel (%.2f).\n",FUEL_MANEUVER);
X notify(Playernum, buf);
X free(ship);
X return;
X }
X
X
X } else {
X notify(Playernum, "You can't aim that kind of ship.\n");
X free(ship);
X return;
X }
X } else if(!strncmp(args[2], "intensity", i)) {
X if (ship->type==STYPE_MIRROR) {
X ship->aimed_at.intensity = atoi(args[3]);
X if (ship->aimed_at.intensity>100)
X ship->aimed_at.intensity=100;
X else if (ship->aimed_at.intensity<0)
X ship->aimed_at.intensity=0;
X sprintf(buf, "Mirror intensisty set to %3d\n",ship->aimed_at.intensity);
X notify(Playernum, buf);
X } else {
X notify(Playernum, "You can't do that with this kind of ship.\n");
X }
X } else if(!strncmp(args[2], "on", i)) {
X
X if(ship->type==OTYPE_FACTORY) {
X if(ship->on) {
X notify(Playernum, "It's already online.\n");
X free(ship);
X return;
X }
X/* check to see if player has enough resources to activate the factory */
X openpdata(&order_pdata);
X getplanet(order_pdata,&planet, Stars[ship->deststar]->planetpos[ship->destpnum]);
X close_file(order_pdata);
X
X if(planet->info[Playernum-1].resource < 2*ship->build_cost) {
X sprintf(buf, "You don't have %s resources on the planet to activate this factory.\n",
X 2*ship->build_cost);
X notify(Playernum, buf);
X free(ship);
X free(planet);
X return;
X } else {
X planet->info[Playernum-1].resource -= 2*ship->build_cost;
X
X openpdata(&order_pdata);
X putplanet(order_pdata, planet, Stars[ship->deststar]->planetpos[ship->destpnum]);
X close_file(order_pdata);
X free(planet);
X sprintf(buf, "Factory activated at a cost of %d resources.\n",
X 2*ship->build_cost);
X notify(Playernum, buf);
X }
X
X }
X ship->on = 1;
X notify(Playernum, "Activated.\n");
X } else if(!strncmp(args[2], "off", i)) {
X
X if(ship->type==OTYPE_FACTORY && ship->on) {
X notify(Playernum, "You can't deactivate a factory once it's online. Consider using 'scrap'.\n");
X free(ship);
X return;
X }
X
X ship->on = 0;
X notify(Playernum, "Deactivated.\n");
X} else {
X notify(Playernum, "I don't understand what you mean.\n");
X }
X
X ship->notified = 0;
X openshdata(&order_shdata);
X putship(order_shdata, ship, shipno);
X close_file(order_shdata);
X } else {
X notify(Playernum, "You don't own that ship!\n");
X }
X
X free(ship);
X}
X
X
X
X/*
X * return what the ship is aimed at, if it's a mirror
X */
Xchar *prin_aimed_at(Playernum, ship)
Xint Playernum;
Xshiptype *ship;
X{
X placetype targ;
X
X targ.level = ship->aimed_at.level;
X targ.snum = ship->aimed_at.snum;
X targ.pnum = ship->aimed_at.pnum;
X targ.shipno = ship->aimed_at.shipno;
X return Dispplace(Playernum, &targ);
X}
X
Xchar *prin_ship_dest(Playernum, ship)
Xint Playernum;
Xshiptype *ship;
X{
X placetype dest;
X
X dest.level = ship->whatdest;
X dest.snum = ship->deststar;
X dest.pnum = ship->destpnum;
X dest.shipno = ship->destshipno;
X return Dispplace(Playernum, &dest);
X}
X
X
X/*
X * mark wherever the ship is aimed at, as explored by the owning player.
X */
Xmk_expl_aimed_at(Playernum, s)
Xint Playernum;
Xshiptype *s;
X{
Xdouble dist;
Xstartype *str;
Xplanettype *p;
Xint sdata,pdata;
Xfloat xf,yf;
X
X str = Stars[s->aimed_at.snum];
X
X if (s->is_docked && s->whatdest==LEVEL_PLAN) {
X openpdata(&pdata);
X getplanet(pdata, &p, Stars[s->storbits]->planetpos[s->pnumorbits]);
X close_file(pdata);
X xf = Stars[s->storbits]->xpos + p->xpos + s->xpos;
X yf = Stars[s->storbits]->ypos + p->ypos + s->ypos;
X free(p);
X } else {
X xf = s->xpos;
X yf = s->ypos;
X }
X
X switch (s->aimed_at.level) {
X case LEVEL_UNIV:
X sprintf(buf, "There is nothing out here to aim at.");
X notify(Playernum, buf);
X break;
X case LEVEL_STAR:
X sprintf(buf, "Star %s ", prin_aimed_at(Playernum, s));
X notify(Playernum, buf);
X if ((dist=sqrt(Distsq(xf, yf, str->xpos, str->ypos))) <= tele_range(s->type, s->tech) ) {
X openstardata(&sdata);
X getstar(sdata, &str, s->aimed_at.snum);
X setbit(str->explored,Playernum);
X putstar(sdata, str, s->aimed_at.snum);
X close_file(sdata); /* don't need to care about Stars */
X sprintf(buf, "Surveyed, distance %g.\n",dist);
X notify(Playernum, buf);
X } else {
X sprintf(buf, "Too far to see (%g, max %g).\n",
X dist, tele_range(s->type, s->tech) );
X notify(Playernum, buf);
X }
X break;
X case LEVEL_PLAN:
X sprintf(buf, "Planet %s ", prin_aimed_at(Playernum, s));
X notify(Playernum, buf);
X openpdata(&pdata);
X getplanet(pdata, &p, str->planetpos[s->aimed_at.pnum]);
X close_file(pdata);
X if ((dist=sqrt(Distsq(xf, yf, str->xpos+p->xpos, str->ypos+p->ypos))) <= tele_range(s->type,s->tech) ) {
X setbit(str->explored,Playernum);
X p->info[Playernum-1].explored = 1;
X openpdata(&pdata);
X putplanet(pdata, p, str->planetpos[s->aimed_at.pnum]);
X close_file(pdata);
X free(p);
X sprintf(buf, "Surveyed, distance %g.\n", dist);
X notify(Playernum, buf);
X } else {
X sprintf(buf, "Too far to see (%g, max %g).\n",
X dist, tele_range(s->type, s->tech) );
X notify(Playernum, buf);
X }
X break;
X case LEVEL_SHIP:
X sprintf(buf, "You can't see anything of use there.\n");
X notify(Playernum, buf);
X break;
X }
X}
X
XDispOrdersHeader(Playernum)
Xint Playernum;
X{
Xnotify(Playernum, " name destination orbits spd options\n");
X}
X
XDispOrders(Playernum, sh, next, check)
Xint Playernum;
Xint sh;
Xint *next;
Xint check;
X{
Xint order_shdata, in_list;
Xshiptype *ship;
Xchar temp[128];
X
Xopenshdata(&order_shdata);
X if (!getship(order_shdata,&ship, sh)) {
X sprintf(buf, "order:error in getship.\n");
X notify(Playernum, buf);
X *next = 0;
X return;
X}
Xclose_file(order_shdata);
X
X*next = ship->nextship;
X
Xif(ship->owner != Playernum || !ship->is_alive) { /* cant look at other ships */
X free(ship);
X return;
X }
X
Xif(check) {
X int j;
X in_list = 0;
X for(j=0; j<NUMSTYPES; j++)
X if(Order_types[j] && ship->type==j) in_list = 1;
X if(!in_list) {
X free(ship);
X return;
X }
X }
X
X sprintf(buf, "%4d %c %14s %15s %15s %1d ", sh, Shipltrs[ship->type], ship->name,
X prin_ship_dest(Playernum, ship), prin_ship_orbits(ship), ship->speed);
X
Xif(ship->hyper_drive.on) {
X sprintf(temp, "/jump %s %d", (ship->hyper_drive.ready ? "ready" : "charging"),
X ship->hyper_drive.charge);
X strcat(buf, temp);
X }
Xif(ship->protect.self) strcat(buf, "/retal");
Xif(ship->protect.planet) strcat(buf, "/defense");
Xif(ship->protect.on) {
X sprintf(temp, "/prot %d", ship->protect.ship);
X strcat(buf, temp);
X }
Xif(ship->navigate.on) {
X sprintf(temp, "/nav %d (%d)", ship->navigate.bearing, ship->navigate.turns);
X strcat(buf, temp);
X }
Xif(has_switch(ship)) {
X if(ship->on) strcat(buf, "/on");
X else strcat(buf, "/off");
X }
Xif(ship->protect.evade) strcat(buf, "/evade");
Xif(ship->bombard) strcat(buf, "/bomb");
Xif(ship->type==STYPE_MINE) {
X if(ship->mine.mode) strcat(buf, "/explode");
X else strcat(buf, "/radiate");
X }
Xif(ship->type==OTYPE_TERRA) {
X sprintf(temp, "/(%d, %d)", ship->object.number, ship->object.number2);
X strcat(buf, temp);
X }
Xif(ship->type==STYPE_MINE) {
X sprintf(temp, "/trigger %d", ship->object.number);
X strcat(buf, temp);
X }
Xif(ship->type==OTYPE_TRANSDEV) {
X sprintf(temp, "/target %d", ship->object.number);
X strcat(buf, temp);
X }
Xif(ship->type == STYPE_MIRROR) {
X sprintf(temp, "/aim %s/int %d", prin_aimed_at(Playernum, ship), ship->aimed_at.intensity);
X strcat(buf, temp);
X }
X
Xstrcat(buf, "\n");
Xnotify(Playernum, buf);
X/* if hyper space is on estimate how much fuel it will cost to get to the destination */
X if(ship->hyper_drive.on) {
X double dist, fuse;
X
X dist = sqrt( Distsq(ship->xpos, ship->ypos, Stars[ship->deststar]->xpos,
X Stars[ship->deststar]->ypos));
X fuse = HYPER_DRIVE_FUEL_USE * ship->mass
X * (dist/HYPER_DIST_FACTOR) * (dist/HYPER_DIST_FACTOR);
X sprintf(buf, " *** jump will cost %.1ff ***\n", fuse);
X notify(Playernum, buf);
X if(ship->max_fuel < fuse)
X notify(Playernum, "Your ship cannot carry enough fuel to do this jump.\n");
X }
X
Xfree(ship);
X}
X
X
END_OF_FILE
if test 21412 -ne `wc -c <'server/order.c'`; then
echo shar: \"'server/order.c'\" unpacked with wrong size!
fi
# end of 'server/order.c'
fi
if test -f 'server/ships.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'server/ships.h'\"
else
echo shar: Extracting \"'server/ships.h'\" \(7417 characters\)
sed "s/^X//" >'server/ships.h' <<'END_OF_FILE'
X/*
X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky,
X * smq@ucscb.ucsc.edu, mods by people in GB.c, enroll.dat.
X * Restrictions in GB.c.
X */
X
X
X#define STYPE_POD 0
X#define STYPE_SHUTTLE 1
X#define STYPE_CARRIER 2
X#define STYPE_DREADNT 3
X#define STYPE_BATTLE 4
X#define STYPE_INTCPT 5
X#define STYPE_CRUISER 6
X#define STYPE_DESTROYER 7
X#define STYPE_FIGHTER 8
X#define STYPE_EXPLORER 9
X#define STYPE_HABITAT 10
X#define STYPE_STATION 11
X#define STYPE_ASS 12
X#define STYPE_CARGO 13
X#define STYPE_TANKER 14
X#define STYPE_GOD 15
X#define STYPE_MINE 16
X#define STYPE_MIRROR 17
X
X#define OTYPE_STELE 18
X#define OTYPE_GTELE 19
X#define OTYPE_TRACT 20
X#define OTYPE_AP 21
X#define OTYPE_CANIST 22
X#define OTYPE_VN 23
X#define OTYPE_BERS 24
X#define OTYPE_GOV 25
X#define OTYPE_OMCL 26
X#define OTYPE_TOXWC 27
X#define OTYPE_PROBE 28
X#define OTYPE_GR 29
X#define OTYPE_FACTORY 30
X#define OTYPE_TERRA 31
X#define OTYPE_BERSCTLC 32
X#define OTYPE_AUTOFAC 33
X#define OTYPE_TRANSDEV 34
X#define OTYPE_REPAIR 35
X#define OTYPE_PLANDEF 36
X
X#define ABIL_CARGO 0
X#define ABIL_DESTCAP 1
X#define ABIL_GUNS 2
X#define ABIL_FUELCAP 3
X#define ABIL_TECH 4
X#define ABIL_MAXCREW 5
X#define ABIL_ARMOR 6
X#define ABIL_TARGET 7
X#define ABIL_COST 8
X#define ABIL_JUMP 9
X#define ABIL_CANLAND 10
X#define ABIL_HASSWITCH 11
X#define ABIL_SPEED 12
X#define ABIL_DAMAGE 13
X#define ABIL_BUILD 14
X#define ABIL_CONSTRUCT 15
X#define ABIL_SIGHT 16
X#define ABIL_PROGRAMMED 17
X
X#define NUMSTYPES (OTYPE_PLANDEF+1)
X#define NUMABILS (ABIL_PROGRAMMED+1)
X
X#define SHIP_NAMESIZE 18
X
X
X
Xtypedef struct ship shiptype;
Xtypedef struct ship_new shiptype_new;
Xtypedef struct place placetype;
X
X
Xstruct ship {
X float xpos,ypos;
X float fuel,mass;
X char name[SHIP_NAMESIZE]; /* name of ship (optional) */
X char class[SHIP_NAMESIZE]; /* class of ship - designated by players */
X percent morale; /* morale of the crew */
X unsigned short command; /* captain+staff leadership value */
X
X unsigned short destshipno; /* destination ship # */
X unsigned short nextship; /* next ship in linked list */
X
X unsigned bombard : 1; /* bombard planet we're orbiting */
X
X percent armor;
X percent guns;
X percent size;
X
X unsigned short max_crew;
X unsigned short max_resource;
X unsigned short max_destruct;
X unsigned short max_fuel;
X unsigned short max_speed;
X unsigned short build_type; /* for factories - type of ship it makes */
X unsigned short build_cost; /* how much it cost to build the ship - into VPs too? */
X
X float base_mass;
X float tech; /* technology rating */
X
X struct a { /* if the ship is a Space Mirror */
X unsigned short shipno; /* aimed at what ship */
X char snum; /* aimed at what star */
X percent intensity; /* intensity of aiming */
X unsigned pnum : BITS_MAXPLANETS; /* aimed at what planet */
X unsigned level : 2; /* aimed at what level */
X } aimed_at;
X
X struct o2 {
X short number; /* for misc functions */
X short number2; /* again */
X short number3;
X short number4; /* again */
X } object;
X
X struct m {
X unsigned mode : 1; /* 0 for radiation, 1 for damage */
X } mine;
X
X struct nv {
X unsigned on : 1; /* toggles navigate mode */
X unsigned speed : 3; /* speed for navigate command */
X unsigned turns : 16;/* number turns left in maneuver */
X unsigned bearing : 9; /* course */
X } navigate;
X
X struct prot {
X float maxrng; /* maximum range for autoshoot */
X unsigned on : 1; /* toggle on/off */
X unsigned planet : 1; /* planet defender */
X unsigned self : 1; /* retaliate if attacked */
X unsigned evade : 1; /* evasive action */
X unsigned ship : 14; /* ship it is protecting */
X } protect;
X
X struct hd {
X unsigned char charge;
X unsigned ready : 1;
X unsigned on : 1;
X unsigned dummy : 6; /* dummy bits for development */
X } hyper_drive;
X
X char storbits; /* what star # orbits */
X char deststar; /* destination star */
X unsigned destpnum : BITS_MAXPLANETS; /* destination planet */
X unsigned pnumorbits : BITS_MAXPLANETS; /* # of planet if orbiting */
X unsigned damage : 7; /* amt of damage */
X unsigned rad : 7; /* radiation level */
X unsigned active: 1; /* tells whether the ship is active */
X unsigned short destruct; /* stuff it's carrying */
X unsigned short resource;
X unsigned short popn; /* crew */
X unsigned owner : BITS_MAXPLAYERS; /* owner of ship */
X unsigned speed : 4; /* what speed to travel at 0-9 */
X unsigned whatdest : 2; /* where going (same as Dir) */
X unsigned whatorbits : 2; /* where orbited (same as Dir) */
X unsigned type : 6; /* what type ship is */
X unsigned is_cloaked : 1; /* 1 bit: is cloaked ship */
X unsigned is_sheep : 1; /* 1 bit: is under influence of mind control */
X unsigned is_docked : 1; /* 1 bit: is landed on a planet or docked */
X unsigned notified : 1; /* 1bit: has been notified of something */
X unsigned is_alive : 1; /* 1 bit: ship is alive */
X unsigned is_examined : 1; /* 1 bit: has been examined */
X unsigned on : 1; /* on or off */
X};
X
X
Xstruct place { /* used in function return for finding place */
X char snum;
X char pnum;
X short shipno;
X shiptype *shipptr;
X unsigned level : 2; /* .level: same as Dir */
X unsigned err : 1; /* if error */
X};
X
X /* whether ship is an object or not */
X#define is_object(s) ((s)->type > STYPE_MIRROR)
X
X /* can takeoff & land, is mobile, etc. */
X#define speed_rating(s) (Shipdata[(s)->type][ABIL_SPEED])
X
X /* has an on/off switch */
X#define has_switch(s) (Shipdata[(s)->type][ABIL_HASSWITCH])
X
X /* can bombard planets */
X#define can_bombard(s) \
X (Shipdata[(s)->type][ABIL_GUNS] && ((s)->type != STYPE_MINE))
X
X/* can navigate */
X#define can_navigate(s) (Shipdata[(s)->type][ABIL_SPEED] > 0 && (s)->type != OTYPE_TERRA && (s)->type != OTYPE_VN)
X
X /* can aim at things. */
X#define can_aim(s) ((s)->type>=STYPE_MIRROR && (s)->type<=OTYPE_TRACT)
X
X /* macro for killing a ship. !notified means we have not yet written it
X to the dead_ship file. */
X#define kill_ship(s) ((s)->is_alive = 0, (s)->damage = 100, (s)->notified = 0)
X
X/* macros to get ship stats */
X#define Armor(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_ARMOR] : (s)->armor)
X#define Guns(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_GUNS] : (s)->guns)
X#define Size(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_TARGET] : (s)->size)
X#define Max_crew(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_MAXCREW] : (s)->max_crew)
X#define Max_resource(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_CARGO] : (s)->max_resource)
X#define Max_fuel(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_FUELCAP] : (s)->max_fuel)
X#define Max_destruct(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_DESTCAP] : (s)->max_destruct)
X#define Max_speed(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_SPEED] : (s)->max_speed)
X#define Cost(s) ( ((s)->type==OTYPE_FACTORY) ? Shipdata[(s)->type][ABIL_COST ] : (s)->build_cost)
X#define Mass(s) ( ((s)->type==OTYPE_FACTORY) ? (s)->mass : (s)->base_mass)
X
Xextern placetype Getplace();
Xextern char *Dispplace(),*Dispshiporbits(),*prin_ship_orbits(),
X *prin_aimed_at(), *prin_ship_dest();
Xextern int Shipdata[NUMSTYPES][NUMABILS];
Xextern char Shipltrs[];
Xextern char *Shipnames[];
Xextern float tele_range(), gun_range();
X
XEXTERN shiptype **ships;
XEXTERN shiptype *shipptr;
END_OF_FILE
if test 7417 -ne `wc -c <'server/ships.h'`; then
echo shar: \"'server/ships.h'\" unpacked with wrong size!
fi
# end of 'server/ships.h'
fi
echo shar: End of archive 3 \(of 14\).
cp /dev/null ark3isdone
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