From decwrl!shelby!agate!ucbvax!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!ginosko!uunet!zephyr!tektronix!tekgen!tekred!saab!billr Thu Aug 3 07:42:55 PDT 1989 Article 655 of comp.sources.games: Path: decwrl!shelby!agate!ucbvax!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!ginosko!uunet!zephyr!tektronix!tekgen!tekred!saab!billr From: billr@saab.CNA.TEK.COM (Bill Randle) Newsgroups: comp.sources.games Subject: v07i045: GB2 - Galactic Bloodshed, an empire-like war game [Ver. 1.0], Part02/08 Message-ID: <4284@tekred.CNA.TEK.COM> Date: 19 Jul 89 14:38:34 GMT Sender: nobody@tekred.CNA.TEK.COM Lines: 2044 Approved: billr@saab.CNA.TEK.COM Submitted-by: VANCLEEF@mps.ohio-state.edu Posting-number: Volume 7, Issue 45 Archive-name: GB2/Part02 #! /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 'Docs/power.doc' <<'END_OF_FILE' XPOWER Galactic Bloodshed POWER X X XNAME X [0] power -- list empires and their approximate influence X XSYNOPSIS X power X XDESCRIPTION X X This command lists all players currently in the game, and their accumulated Xtotal stockpiles, number of planets on which they have colonies, number of Xships, and various other information. X END_OF_FILE if test 333 -ne `wc -c <'Docs/power.doc'`; then echo shar: \"'Docs/power.doc'\" unpacked with wrong size! fi # end of 'Docs/power.doc' fi if test -f 'doship.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'doship.c'\" else echo shar: Extracting \"'doship.c'\" \(17771 characters\) sed "s/^X//" >'doship.c' <<'END_OF_FILE' X/* X * Galactic Bloodshed (Robert Chansky, smq@b) X * doship -- do one ship turn. X */ X X#include "vars.h" X#include "ships.h" X#include "races.h" X#include "doturn.h" X#include "power.h" X#include X#include Xextern struct power Power[]; X X Xdoship(shipno,ship) Xint shipno; Xshiptype *ship; X{ X int sh,sh2,j,shfdata; X char buf[300]; X X if (!ship->is_dead && (ship->owner == 0 && ship->type != OTYPE_VN X && ship->type != OTYPE_AMOEBA) ) X/* a hack by gvc to get rid of owner 0, space pod which occasionally Xgets created for unknown reason (and consequentially causes problems) */ X { X ship->is_dead = 1; X ship->owner = 1; X X} /* used to counteract bugs */ X X if (!ship->is_dead) { X X /* add ships, popn to total count to add AP's */ X if (ship->type==OTYPE_VN) X Power[ship->owner].ships_owned += ship->orders.object.number; X else X Power[ship->owner].ships_owned++; X Power[ship->owner].resource += ship->resource; X Power[ship->owner].fuel += ship->fuel; X Power[ship->owner].destruct += ship->destruct; X Power[ship->owner].popn += ship->popn; X if (ship->whatorbits==LEVEL_UNIV) { X Sdatanumships[ship->owner]++; X Sdatapopns[ship->owner] += ship->popn; X } else { X starnumships[ship->storbits][ship->owner] += X (ship->type==OTYPE_VN) ? ship->orders.object.number : 1; X /* add popn of ships to popn */ X starpopns[ship->storbits][ship->owner] += ship->popn; X /* set inhabited for ship */ X setbit(Stars[ship->storbits]->inhabited, ship->owner); X } X X /* repair radiation */ X if (ship->rad) { X /* kill off some people */ X ship->popn = round_rand(ship->popn * .90); X if (ship->rad > REPAIR_RATE) X ship->rad -= REPAIR_RATE; X else X ship->rad = 0; X } else { X /* irradiated ships are immobile.. */ X X /* make sure of an update if someones bombarding the planet */ X if (can_bombard(ship) && ship->orders.o.bombard && X ship->whatorbits==LEVEL_PLAN) X Stinfo[ship->storbits][ship->pnumorbits].inhab = 1; X X Moveship(shipno, ship); X X /* repair ship by the amount of crew it has */ X if (ship->damage && ship->popn) { reg int d; X if ((d = ((float)ship->popn / X Shipdata[ship->type][ABIL_MAXCREW]) * REPAIR_RATE) X > ship->damage) X ship->damage = 0; X else X ship->damage -= d; X } X X switch (ship->type) { X X case OTYPE_CANIST: X if (ship->whatorbits == LEVEL_PLAN && !ship->is_docked) { short *t; X if (--ship->orders.object.number) { X t = &Stinfo[ship->storbits][ship->pnumorbits].temp_add; X if (*t - 10 < -120) X *t = -120; X else X *t -= 10; X } else { /* timer expired; destroy canister */ X reg int j=0; X kill_ship(ship); X teleg_add("",telegram_buf); X sprintf(buf,"Notice from /%s/%s\n\n", X Stars[ship->storbits]->name, X Stars[ship->storbits]->pnames[ship->pnumorbits]); X teleg_add(buf,telegram_buf); X teleg_add("Canister of dust previously covering this planet has dissipated.\n",telegram_buf); X for (j=1; j<=Num_races; j++) X if (planets[ship->storbits][ship->pnumorbits]->info[j-1].numsectsowned) X teleg_send(TELEG_PLAYER_AUTO, j, telegram_buf); X } X } X break; X X case STYPE_MINE: X /* check around and see if we should explode. */ X if (ship->on) { X int rad=0; float xd,yd; int p; X if (ship->whatorbits==LEVEL_STAR) X sh = Stars[ship->storbits]->ships; X else if (ship->whatorbits==LEVEL_PLAN) X sh = planets[ship->storbits][ship->pnumorbits]->ships; X else X sh = 0; /* don't explode in interstellar space. so what. */ X sh2 = sh; X /* traverse the list, look for ships that X are closer than the trigger radius... */ X while (sh) { X xd = ships[sh]->xpos - ship->xpos; X yd = ships[sh]->ypos - ship->ypos; X if ( (ships[sh]->type != STYPE_MINE) && X (ships[sh]->owner != Playernum) && X ( xd*xd+yd*yd < ship->orders.object.number * ship->orders.object.number) ) X rad = 1; X sh = ships[sh]->nextship; X } X if (rad) { X kill_ship(ship); X teleg_add("",telegram_buf); X sprintf(buf, "BULLETIN!\n mine #%d triggered at system /%s",shipno,Stars[ship->storbits]->name); X teleg_add(buf, telegram_buf); X teleg_send(TELEG_PLAYER_AUTO,ship->owner,telegram_buf); X while (sh2) { /* sh2=beginning of list */ X xd = ships[sh2]->xpos - ship->xpos; X yd = ships[sh2]->ypos - ship->ypos; X X if ( ships[sh2]->popn != 0 ) { X rad = round_rand(ship->destruct X * (2500/(xd*xd + yd*yd + 1.)) ); X if (ships[sh2]->rad + rad > 100) X ships[sh2]->rad = 100; X else X ships[sh2]->rad += rad; X X teleg_add("",telegram_buf); X sprintf(buf, "BULLETIN!\n ship #%d irradiated by mine at system /%s - dosage %d percent", X sh2, Stars[ship->storbits]->name, rad); X teleg_add(buf, telegram_buf); X teleg_send(TELEG_PLAYER_AUTO,ships[sh2]->owner,telegram_buf); X } X sh2 = ships[sh2]->nextship; X } X } X } X break; X X case STYPE_MIRROR: X switch (ship->orders.aimed_at.level) { X case LEVEL_SHIP: /* ship aimed at is a legal ship now */ X /* if in the same system */ X if ( (ship->whatorbits==LEVEL_STAR || ship->whatorbits==LEVEL_PLAN) X && (ships[ship->orders.aimed_at.shipno]!=NULL) X && (ships[ship->orders.aimed_at.shipno]->whatorbits==LEVEL_STAR || X ships[ship->orders.aimed_at.shipno]->whatorbits==LEVEL_PLAN) X && ship->storbits == ships[ship->orders.aimed_at.shipno]->storbits X && !ships[ship->orders.aimed_at.shipno]->is_dead ) X ships[ship->orders.aimed_at.shipno]->damage += 10; X break; X case LEVEL_PLAN: { reg short *t; reg int i; X t = &Stinfo[ship->storbits][ship->orders.aimed_at.pnum].temp_add; X i = ship->orders.aimed_at.intensity; X if (*t + i > 120) X *t = 120; X else if (*t + i < -120) X *t = -120; X else X *t += i; X } X break; X case LEVEL_STAR: X if (ship->orders.aimed_at.snum>0 && X ship->orders.aimed_at.snumorders.aimed_at.snum]->stability += random()&01; X break; X case LEVEL_UNIV: X break; X } X break; X case STYPE_GOD: X /* gods have infinite power.... heh heh heh */ X ship->fuel = Shipdata[ship->type][ABIL_FUELCAP]; X ship->popn = Shipdata[ship->type][ABIL_MAXCREW]; X ship->destruct = Shipdata[ship->type][ABIL_DESTCAP]; X ship->resource = Shipdata[ship->type][ABIL_CARGO]; X break; X X case OTYPE_AP: /* terraforming device */ X /* if landed on planet, change conditions to be like race */ X if (ship->is_docked && ship->whatdest==LEVEL_PLAN && ship->on) { X int j,d,a;planettype *p; X p = planets[ship->storbits][ship->pnumorbits]; X if (ship->fuel >= 3.0) { X ship->fuel -= 3.0; X for (j=RTEMP+1; j<=OTHER; j++) { X if ( (d = races[ship->owner]->conditions[j] - p->conditions[j]) != 0) { X a = int_rand(sgn(d)*3,-sgn(d)); X if (p->conditions[j] + a < 0) X p->conditions[j] = 0; X else if (p->conditions[j] + a > 100) X p->conditions[j] = 100; X else p->conditions[j] += a; X } X } X } X } X break; X X case OTYPE_AMOEBA: /* space amoeba */ X if (ship->orders.amoeba.dig) { X /* we are currently digesting a planet. */ X if (planets[ship->storbits][ship->pnumorbits]->digested) { X reg int i,s; reg bool f=0; X /* the planet has been digested. get rid of it. */ X /* move the highest-#'d planet over this one */ X /*Stars[ship->storbits]->numplanets--; X Stars[ship->storbits]->planetpos[ship->pnumorbits] = X Stars[ship->storbits]->planetpos[Stars[ship->storbits]->numplanets]; X strcpy(Stars[ship->storbits]->pnames[ship->pnumorbits], X Stars[ship->storbits]->pnames[Stars[ship->storbits]->numplanets]); X /* insert into star list */ X /*ship->nextship = Stars[ship->storbits]->ships; X Stars[ship->storbits]->ships = shipno;*/ X X /* kill all ships here; take their stuff */ X /*sh = planets[ship->storbits][ship->pnumorbits]->ships; X while (sh) { X if (sh!=shipno) ) { X ship->destruct += ships[sh]->destruct; X ship->mass += ships[sh]->destruct*MASS_DESTRUCT; X ship->fuel += ships[sh]->fuel; X ship->mass += ships[sh]->fuel*MASS_FUEL; X kill_ship(ships[sh]); X } X sh = ships[sh]->nextship; X } X /* no longer orbiting star */ X /*ship->whatorbits = LEVEL_STAR; X ship->whatdest = LEVEL_UNIV;*/ X /* no longer digesting */ X ship->orders.amoeba.dig = 0; X /* find a new place to digest */ X ship->orders.amoeba.dest = 0; X } X } else { X /* we have a planet in mind. */ X if (!ship->orders.amoeba.dest || ship->whatdest==LEVEL_UNIV) { X /* we have orders; wait to get to destination */ X if (ship->whatdest == LEVEL_PLAN && X ship->whatorbits == LEVEL_PLAN && X ship->deststar == ship->storbits && X ship->destpnum == ship->pnumorbits) { X /* we just arrived at our destination. */ X Stinfo[ship->storbits][ship->pnumorbits].amoeba_add = 1; X /* start digesting */ X ship->orders.amoeba.dig = 1; X /* telegram people */ X teleg_add("", telegram_buf); X teleg_add("BULLETIN!!\n\n ",telegram_buf); X sprintf(buf, "%s #%d is attacking your planet /%s/%s!\n\n", X Shipnames[ship->type], X shipno, Stars[ship->storbits]->name, X Stars[ship->storbits]->pnames[ship->pnumorbits]); X teleg_add(buf, telegram_buf); X for (j=1; j<=Num_races; j++) X if (planets[ship->storbits][ship->pnumorbits]->info[j-1].numsectsowned) X teleg_send(TELEG_PLAYER_AUTO, j, telegram_buf); X } X X } else { X reg int s,min=0,min2=0,i; X char expl=0,expl2=0; X X /* find a yummy planet to munch on */ X /* find closest _explored_ star */ X /* (this is the opposite method VN's use) */ X for (s=0; sstorbits && X Distsq(Stars[s]->xpos,Stars[s]->ypos,ship->xpos,ship->ypos) < X Distsq(Stars[min]->xpos,Stars[min]->ypos,ship->xpos,ship->ypos)) X min2 = min,min = s; X for (i=0; iinhabited[i]; X expl2 |= Stars[min2]->inhabited[i]; X } X if (!expl) X if (!expl2) X ship->deststar = int_rand(0,Sdata.numstars-1); X else X ship->deststar = min2; /* 2nd closest star */ X else X ship->deststar = min; X /* find a good planet to go to */ X X if (Stars[ship->deststar]->numplanets) { X ship->destpnum = X int_rand(0,Stars[ship->deststar]->numplanets-1); X ship->whatdest = LEVEL_PLAN; X ship->orders.amoeba.dest = 1; X } else { X /* no good; find someplace else. */ X ship->orders.amoeba.dest = 0; X } X ship->speed = 1; /* amoebae are very fastidious,too */ X fprintf(stderr,"amoeba #%d headed for star %d, pl %d.\n",shipno,ship->deststar, ship->destpnum); X } X } X break; X X case OTYPE_VN: /* Von Neumann machine */ X do_VN(ship,shipno); X break; X X case STYPE_ASS: X /* "indimidate" the planet below, for enslavement purposes. */ X if (ship->whatorbits==LEVEL_PLAN) X Stinfo[ship->storbits][ship->pnumorbits].intimidated = 1; X break; X X case OTYPE_OMCL: X /* orbital mind control laser */ X if (ship->orders.aimed_at.level==LEVEL_PLAN && ship->on && X ship->speed==1) { X planets[ship->orders.aimed_at.snum][ship->orders.aimed_at.pnum] X ->is_sheep = 1; X } X break; X X case STYPE_HABITAT:{ reg int add; X /* habitats multiply some resources inside them. */ X add = ship->resource * X ((float)ship->popn / Shipdata[STYPE_HABITAT][ABIL_MAXCREW]) X * (100 - ship->damage) * 0.001; X if (ship->resource+add > Shipdata[STYPE_HABITAT][ABIL_CARGO]) X add = Shipdata[STYPE_HABITAT][ABIL_CARGO] - ship->resource; X ship->resource += add; X ship->mass += add * MASS_RESOURCE; X add = ship->popn * races[ship->owner]->birthrate * X (100 - ship->damage) * 0.005; X if (ship->popn+add > Shipdata[STYPE_HABITAT][ABIL_MAXCREW]) X add = Shipdata[STYPE_HABITAT][ABIL_MAXCREW] - ship->popn; X ship->popn += add; X ship->mass += add * races[ship->owner]->mass; X } break; X X case STYPE_POD: X if (ship->notified) { X /* we just arrived at this system -- explode */ X /* or, we are floating in space with no fuel -- just die */ X reg int i,f= -1; X kill_ship(ship); X if (ship->whatorbits==LEVEL_STAR) { X for (i=0; f== -1 && istorbits]->numplanets; i++) X if (sqrt((double)Distsq(ship->xpos, ship->ypos, X Stars[ship->storbits]->xpos + planets[ship->storbits][i]->xpos, X Stars[ship->storbits]->ypos + planets[ship->storbits][i]->ypos))/SYSTEMSIZE < float_rand()) X f = i; X teleg_add("",telegram_buf); X sprintf(buf, "Bulletin\n\nSpore pod #%d has warmed and exploded.\n",shipno); X teleg_add(buf,telegram_buf); X if (f != -1) { X sprintf(buf,"A spore has landed on planet %s.\n",Stars[ship->storbits]->pnames[f]); X Stinfo[ship->storbits][f].Thing_add = ship->owner; X /* so doplanet does not pass over it */ X setbit(Stars[ship->storbits]->inhabited,ship->owner); X planets[ship->storbits][f]->info[ship->owner-1].explored = 1; X } else { X sprintf(buf,"No spores have survived.\n"); X } X teleg_add(buf,telegram_buf); X teleg_send(TELEG_PLAYER_AUTO, ship->owner, telegram_buf); X teleg_add("",telegram_buf); X sprintf(buf,"BULLETIN!\n\n A spore pod has exploded in system /%s.\n",Stars[ship->storbits]->name); X teleg_add(buf,telegram_buf); X teleg_add("Spores may have drifted to planets here.\n",telegram_buf); X for (i=1; i<=Num_races; i++) X if (i!=ship->owner && isset(Stars[ship->storbits]->inhabited,i)) X teleg_send(TELEG_PLAYER_AUTO, i, telegram_buf); X } X } X break; X X default: X break; X } X X } X X } else if (ship->owner ==0 || !ship->notified) { X /* ship is dead -- add to shipfree file, remove from all lists. */ X /* if notified, this means it's already been deleted and written. */ X ship->notified = 1; X makeshipdead(shipno); X printf("destroyed ship #%d\n",shipno); X } X X} X X X Xdo_VN(ship,shipno) Xshiptype *ship; Xint shipno; X{ Xint r; Xplanettype *p; Xchar buf[150]; X X if (ship->on) { X X if (ship->whatorbits==LEVEL_PLAN) X p = planets[ship->storbits][ship->pnumorbits]; X X if (ship->whatorbits==LEVEL_PLAN && X ship->is_docked && ship->whatdest==LEVEL_PLAN) { X /* make sure the planet is updated */ X Stinfo[ship->storbits][ship->pnumorbits].inhab = 1; X /* try to launch it */ X if (ship->orders.object.number2 == 0) { /* launch if no assignment */ X /* steal some fuel from other players,telegram */ X int f=0; X if (ship->fuel < Shipdata[OTYPE_VN][ABIL_COST]) { X for (r=1; !f && r<=Num_races; r++) X if (p->info[r-1].fuel >= Shipdata[OTYPE_VN][ABIL_COST]) X f = r; X if (f) { X ship->fuel += Shipdata[OTYPE_VN][ABIL_FUELCAP]; X p->info[f-1].fuel -= Shipdata[OTYPE_VN][ABIL_FUELCAP]; X teleg_add("",telegram_buf); X teleg_add("Bulletin!\n\n",telegram_buf); X sprintf(buf,"%d fuel stolen by %s #%d on planet /%s/%s!\n", X Shipdata[OTYPE_VN][ABIL_FUELCAP], X Shipnames[OTYPE_VN], X shipno, Stars[ship->storbits]->name, X Stars[ship->storbits]->pnames[ship->pnumorbits]); X teleg_add(buf,telegram_buf); X teleg_send(TELEG_PLAYER_AUTO, f, telegram_buf); X X ship->orders.object.number2 = 0; /* no current assignment */ X ship->xpos = Stars[ship->storbits]->xpos + planets[ship->storbits][ship->pnumorbits]->xpos + int_rand(-10,10); X ship->ypos = Stars[ship->storbits]->ypos + planets[ship->storbits][ship->pnumorbits]->ypos + int_rand(-10,10); X ship->is_docked = 0; X ship->whatdest = LEVEL_UNIV; X } X } X } else { X /* we have an assignment. Since we are landed, this means X we are engaged in building up resources/fuel. */ X /* steal resources from other players,telegram */ X reg int i,f; int nums[MAXPLAYERS+1]; X /* permute list of people to steal from */ X for (i=1; i<=Num_races; i++) X nums[i] = i; X for (i=1; i<=Num_races; i++) { X f = int_rand(1,Num_races); X swap(nums[i], nums[f]); X } X for (f=0,i=1; i<=Num_races; i++) X if (p->info[nums[i]-1].resource) X f = nums[i]; X if (f) { X p->info[f-1].resource -= Shipdata[OTYPE_VN][ABIL_COST]; X ship->resource += Shipdata[OTYPE_VN][ABIL_COST]; X ship->mass += Shipdata[OTYPE_VN][ABIL_COST] * MASS_RESOURCE; X teleg_add("",telegram_buf); X teleg_add("Bulletin!\n\n",telegram_buf); X sprintf(buf,"%d resources stolen by %s #%d\non planet ", X Shipdata[OTYPE_VN][ABIL_COST], X Shipnames[OTYPE_VN], shipno); X teleg_add(buf,telegram_buf); X sprintf(buf,"/%s/%s!\n", X Stars[ship->storbits]->name, X Stars[ship->storbits]->pnames[ship->pnumorbits]); X teleg_add(buf,telegram_buf); X teleg_send(TELEG_PLAYER_AUTO, f, telegram_buf); X } else { X /*if no resources to steal, more will be produced in doplanet*/ X } X } X } else { X /* we are not landed */ X if (ship->orders.object.number2) { X /* we've arrived from somewhere -- look for a place to land. X this is done on planet turn */ X } else { X /* we were just built & launched */ X reg int s,min=0,min2=0; X /* find closest unexplored star */ X for (s=1; sstorbits && X Distsq(Stars[s]->xpos,Stars[s]->ypos,ship->xpos,ship->ypos) < X Distsq(Stars[min]->xpos,Stars[min]->ypos,ship->xpos,ship->ypos)) X min2 = min,min = s; X /* don't go there if we have a choice, X and we have VN's there already */ X if (isset(Stars[min]->inhabited,1)) X if (isset(Stars[min2]->inhabited,1)) X ship->deststar = int_rand(0,Sdata.numstars-1); X else X ship->deststar = min2; /* 2nd closest star */ X else X ship->deststar = min; X if (Stars[ship->deststar]->numplanets) { X ship->destpnum = X int_rand(0,Stars[ship->deststar]->numplanets-1); X ship->whatdest = LEVEL_PLAN; X ship->orders.object.number2 = 1; X } else { X /* no good; find someplace else. */ X ship->orders.object.number2 = 0; X } X ship->speed = 1; /* VN's are very fastidious */ X fprintf(stderr,"VN #%d headed for star %d, pl %d.\n",shipno,ship->deststar, ship->destpnum); X /* we are assigned to go */ X } X } X X } X X} END_OF_FILE if test 17771 -ne `wc -c <'doship.c'`; then echo shar: \"'doship.c'\" unpacked with wrong size! fi # end of 'doship.c' fi if test -f 'load.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'load.c'\" else echo shar: Extracting \"'load.c'\" \(12762 characters\) sed "s/^X//" >'load.c' <<'END_OF_FILE' X/* X * Galactic Bloodshed (Robert Chansky, smq@b) X * load.c -- load/unload stuff X */ X X#include "vars.h" X#include "ships.h" X#include "races.h" X#include X#include Xextern jmp_buf main_jenv; Xextern char telegram_buf[AUTO_TELEG_SIZE]; Xint load_shdata,load_pdata,load_sectdata; X X Xload(APcount, argn,args) Xint APcount; Xint argn; Xchar args[MAXARGS][COMMANDSIZE]; X{ Xbool jett=0,sh=0; Xint first=1,proc,Mod=0,lolim,uplim, shipno,amt; Xfloat flolim,fuplim, famt; Xchar commod, buf[100],bufr[70],bufd[70],buff[70],bufc[70]; Xshiptype *s,*s2; Xplanettype *p; Xsectortype *sect; Xint load_handler(); X X load_shdata = load_pdata = load_sectdata = NEUTRAL_FD; X signal(SIGINT, load_handler); X X if (argn==1) { X printf("ship #"); X scanf("%d",&shipno); X getchr(); X } else X sscanf(args[1]+(args[1][0]=='#'),"%d",&shipno); X X openshdata(&load_shdata); X if (!getship(load_shdata,&s,shipno)) { X load_handler(); X } X if (s->owner!=Playernum || s->is_dead) { X DontOwnErr(shipno); X printf("(%d)\n",s->owner); X free(s); X load_handler(); X } X if (s->rad) { X printf("%s #%d is irradiated and inactive.\n", Shipnames[s->type],shipno); X free(s); X load_handler(); X } X if (s->whatorbits==LEVEL_UNIV) { X if (!enufAP(Sdata.AP, APcount)) X load_handler(); X } else X if (!enufAP(Stars[s->storbits]->AP, APcount)) X load_handler(); X X X do { X X proc = 0; X X if (s->type == OTYPE_TRANSDEV && s->orders.object.number > 0) { X Locks(1); X if (!getship(load_shdata,&s2, s->orders.object.number)) { X printf("The hopper seems to be blocked.\n"); X load_handler(); X } X Locks(0); X X if (s2->is_dead) { X printf("The target device does not exist.\n"); X load_handler(); X } X if (s2->type!=OTYPE_TRANSDEV || !s2->on) { X printf("s2->type = %d\n",s2->type); X printf("OTYPE_TRANSDEV = %d\n",OTYPE_TRANSDEV); X X printf("s2->on = %d\n",s2->on); X printf("The target device is not receiving.\n"); X load_handler(); X } X } else if (!s->is_docked) { X if (s->type==OTYPE_TRANSDEV) { X printf("It does not seem to work in zero-g environments.\n"); X load_handler(); X } X printf("%s #%d is not landed.\n",is_object(s)?"object":"ship",shipno); X tty_on(); X printf(" jettison into open space (y/n)?"); X jett = 1; X commod=getchr(); X tty_off(); X if (commod!='y') X load_handler(); X } else { X if (s->whatdest==LEVEL_PLAN) X printf("Ship #%d at %.0f,%.0f\n", shipno,s->xpos, s->ypos); X else { X Locks(1); X if (!getship(load_shdata, &s2, s->destshipno) || s2->is_dead || 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(load_shdata); X free(s); X printf("ship #%u is not docked.\n", s->destshipno); X load_handler(); X } X Locks(0); X printf("Ship #%d docked with %s #%d\n", shipno, X Shipnames[s2->type], s->destshipno); X sh = 1; X } X } X X X if (!jett && !sh) { X openpdata(&load_pdata); X getplanet(load_pdata,&p,Stars[Dir.snum]->planetpos[Dir.pnum]); X } X X X X do { X X tty_on(); X printf("%s #%d:(rfdc? q) >", Shipnames[s->type], shipno); X commod = getchr(); X putchr('\n'); X tty_off(); X X if (!jett && !sh && commod=='c') { X opensectdata(&load_sectdata); X getsector(load_sectdata,§,p->sectormappos + ( (int)s->ypos*p->Maxx+(int)s->xpos) * sizeof(sectortype) ); 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 = MIN(s2->popn, X Shipdata[s->type][ABIL_MAXCREW] - s->popn); X lolim = - MIN(s->popn, X Shipdata[s2->type][ABIL_MAXCREW] - s2->popn); X } else { X uplim = MIN(sect->popn, X Shipdata[s->type][ABIL_MAXCREW] - 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 = MIN(s2->destruct, X Shipdata[s->type][ABIL_DESTCAP] - s->destruct); X lolim = - MIN(s->destruct, X Shipdata[s2->type][ABIL_DESTCAP]-s2->destruct); X } else { X uplim = MIN(p->info[Playernum-1].destruct, X Shipdata[s->type][ABIL_DESTCAP]-s->destruct); X lolim = - s->destruct; X } X proc = 1; X break; X X case 'f': if (jett) { X fuplim = 0.0; X flolim = - s->fuel; X } else X if (sh) { X fuplim = MIN(s2->fuel, X Shipdata[s->type][ABIL_FUELCAP] - s->fuel); X flolim = - MIN(s->fuel, X Shipdata[s2->type][ABIL_FUELCAP] - s2->fuel); X } else { X fuplim = MIN(p->info[Playernum-1].fuel, X Shipdata[s->type][ABIL_FUELCAP]- s->fuel); X flolim = - 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 = s2->resource; X else X uplim = MIN(s2->resource, X Shipdata[s->type][ABIL_CARGO] - s->resource); X if (s2->type==STYPE_SHUTTLE) X lolim = - s->resource; X else X lolim = - MIN(s->resource, X Shipdata[s2->type][ABIL_CARGO]-s2->resource); X } else { X uplim = MIN(p->info[Playernum-1].resource, X Shipdata[s->type][ABIL_CARGO]-s->resource); X lolim = - s->resource; X } X proc = 1; X break; X X case '?': printf("\n%s #%3d:\n", Shipnames[s->type], shipno); X printf(" res:%7u (%d)\n", s->resource, X Shipdata[s->type][ABIL_CARGO]); X printf(" fuel:%7.1f (%d)\n",s->fuel, X Shipdata[s->type][ABIL_FUELCAP]); X printf(" crew:%7u (%d)\n", s->popn, X Shipdata[s->type][ABIL_MAXCREW]); X printf(" dest:%7u (%d)\n", s->destruct, X Shipdata[s->type][ABIL_DESTCAP]); X printf(" mass:%7.1f (%.1f)\n",s->mass, X (float)Shipdata[s->type][ABIL_MASS] + X Shipdata[s->type][ABIL_FUELCAP] * MASS_FUEL + X Shipdata[s->type][ABIL_CARGO] * MASS_RESOURCE + X Shipdata[s->type][ABIL_MAXCREW] * Race->mass); X if (sh) { X printf("docked with %s #%d:\n",Shipnames[s2->type], X s->destshipno); X printf(" res:%7u (%d)\n", s2->resource, X Shipdata[s2->type][ABIL_CARGO]); X printf(" fuel:%7.1f (%d)\n", s2->fuel, X Shipdata[s2->type][ABIL_FUELCAP]); X printf(" crew:%7u (%d)\n", s2->popn, X Shipdata[s2->type][ABIL_MAXCREW]); X printf(" dest:%7u (%d)\n", s2->destruct, X Shipdata[s2->type][ABIL_DESTCAP]); X printf(" mass:7%.1f (%.1f)\n",s2->mass, X (float)Shipdata[s2->type][ABIL_MASS] + X Shipdata[s2->type][ABIL_FUELCAP] * MASS_FUEL + X Shipdata[s2->type][ABIL_CARGO] * MASS_RESOURCE + X Shipdata[s2->type][ABIL_MAXCREW] * Race->mass); X } X printf("commands:\n r -- transfer resources\n"); X printf(" f -- transfer fuel\n"); X printf(" c -- transfer crew members\n"); X printf(" d -- transfer destruct\n"); X printf("' ',q -- quit\n"); X proc = 0; X break; X case 'q': X case ' ': X load_handler(); X break; X default: printf("%c not valid.\n",commod); X proc = 0; X load_handler(); X } X } while (!proc); X X tty_off(); X X if (commod=='f') { X famt = fuplim + 1.0; X while (famtfuplim) { X printf(" amount (%.2f to %.2f) ",flolim,fuplim); X if (scanf("%f",&famt)!=1) X famt=fuplim+1.0; /* force error */ X getchr(); X } X } else { X amt = uplim + 1; X while (amtuplim) { X printf(" amount (%d to %d) ",lolim,uplim); X if (scanf("%d",&amt)!=1) X amt=uplim+1; /* force error */ X getchr(); X } X } X X switch (commod) { X case 'c': if (!jett) { X if (sh) { X s2->popn -= amt; X s2->mass -= amt*Race->mass; X } else { X if (sect->popn==0 && amt<0) { X p->info[Playernum-1].numsectsowned++; X sect->owner = Playernum; X printf("sector %.0f,%.0f COLONIZED.\n",s->xpos,s->ypos); 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 printf("sector %.0f,%.0f evacuated.\n",s->xpos,s->ypos); X } X } X } X printf("crew complement of ship #%d is now %u.\n", X shipno, s->popn+amt); X s->popn += amt; X s->mass += amt*Race->mass; X Mod = 1; X break; X X case 'd': s->destruct += amt; X s->mass += amt*MASS_DESTRUCT; 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 += famt; X s->mass += famt*MASS_FUEL; X X if (sh) { X s2->fuel -= famt; X s2->mass -= famt*MASS_FUEL; X } else if (!jett) X p->info[Playernum-1].fuel -= famt; X X Mod = 1; X break; X X case 'r': s->resource += amt; X s->mass += amt*MASS_RESOURCE; 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 case 'q': X case ' ': X case '?': X default: X break; X } X X putship(load_shdata,s,shipno); X X if (s->type==OTYPE_TRANSDEV && s->orders.object.number > 0) { X X printf("Zap\007!\n"); 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 printf("%d resources transferred.\n", s->resource); 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 printf("%g fuel transferred.\n", s->fuel); 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 printf("%d destruct transferred.\n", s->destruct); 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 printf("%d popn transferred.\n", s->popn); 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 teleg_add("", telegram_buf); X teleg_add("BULLETIN!\n\n Audio-vibatory-physio-molecular transport device #",telegram_buf); X sprintf(buf,"%d just gave your ship #%d the following:\n", shipno, s->orders.object.number); X teleg_add(buf,telegram_buf); X teleg_add(bufr,telegram_buf); X teleg_add(bufd,telegram_buf); X teleg_add(buff,telegram_buf); X teleg_add(bufc,telegram_buf); X teleg_send(TELEG_PLAYER_AUTO, s2->owner, telegram_buf); X } X X putship(load_shdata,s,shipno); X putship(load_shdata, s2, s->orders.object.number); X X X } else if (sh) { X /* ship to ship transfer, non-transport device */ X putship(load_shdata,s2,s->destshipno); X buff[0] = bufr[0] = bufd[0] = bufc[0] = '\0'; X switch (commod) { X case 'r': X printf("%d resources transferred.\n", amt); X sprintf(bufr, "%d Resources\n",amt); X break; X case 'f': X printf("%.2f fuel transferred.\n", famt); X sprintf(buff, "%d.2f Fuel\n",famt); X break; X case 'd': X printf("%d destruct transferred.\n", amt); X sprintf(bufd, "%d Destruct\n",amt); X break; X case 'c': X printf("%d popn transferred.\n", amt); 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 teleg_add("", telegram_buf); X teleg_add("BULLETIN!\n\n Audio-vibatory-physio-molecular transport device #",telegram_buf); X sprintf(buf,"%d just gave your ship #%d the following:\n", shipno, s->orders.object.number); X teleg_add(buf,telegram_buf); X teleg_add(bufr,telegram_buf); X teleg_add(bufd,telegram_buf); X teleg_add(buff,telegram_buf); X teleg_add(bufc,telegram_buf); X teleg_send(TELEG_PLAYER_AUTO, s2->owner, telegram_buf); X } X } X X if (!jett && !sh) { X X if (commod=='c') { X putsector(load_sectdata,sect,p->sectormappos + ( (int)s->ypos*p->Maxx+(int)s->xpos) * sizeof(sectortype) ); X close(load_sectdata); X free(sect); X } X X putplanet(load_pdata,p,Stars[Dir.snum]->planetpos[Dir.pnum]); X close(load_pdata); X free(p); X } X X if (Mod && first) { X first = 0; X if (s->whatorbits==LEVEL_UNIV) X deductAPs(APcount, 0, 1); /* ded from sdata */ X else X deductAPs(APcount, s->storbits, 0); X X } X X } while (1); X X X} X X X Xload_handler() X{ X tty_off(); X close(load_shdata); X close(load_pdata); X close(load_sectdata); X longjmp(main_jenv,1); X} X X END_OF_FILE if test 12762 -ne `wc -c <'load.c'`; then echo shar: \"'load.c'\" unpacked with wrong size! fi # end of 'load.c' fi if test -f 'makeuniv.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'makeuniv.c'\" else echo shar: Extracting \"'makeuniv.c'\" \(6157 characters\) sed "s/^X//" >'makeuniv.c' <<'END_OF_FILE' X/* X * Galactic Bloodshed (Robert Chansky, smq@b) X * makeuniv.c -- make data files for the game X */ X X#include "vars.h" X#include "ships.h" X#include "races.h" X#include "power.h" /* (for power) */ X#include X XFILE *fopen(); Xplanettype Makeplanet(); Xchar *Numbers[] = { "1","2","3","4","5","6","7","8","9","10","11", X "12","13","14","15" }; /* for planet naming*/ X Xmain(argc,argv) Xint argc; Xchar *argv[]; X{ XFILE *teledata,*racedata,*stardata,*planetdata,*sectordata,*shipdata; Xplanettype planet; Xstartype *Star; Xint star,e,e2,type,lowp,hip; Xregister int i,y,x; Xchar str[200]; Xfloat att,xspeed[NUMSTARS],yspeed[NUMSTARS]; X X srandom(getpid()); X X Bzero(Sdata); X printf("# of stars(1-%d):",NUMSTARS-1); X scanf("%d",&(Sdata.numstars)); X printf("low # of planets (1-%d):",MAXPLANETS-1); X scanf("%d",&lowp); X printf("hi # of planets (%d-%d):",lowp,MAXPLANETS-1); X scanf("%d",&hip); X getchr(); X X sprintf(str, "/bin/mkdir %s", DATADIR ); X system(str); X X if ( (planetdata = fopen(PLANETDATAFL,"w+"))==NULL) { X printf("unable to open %s\n",PLANETDATAFL); X exit(-1); X } X if ( (sectordata = fopen(SECTORDATAFL,"w+")) == NULL ) { X printf("unable to open %s\n",SECTORDATAFL); X exit(-1); X } X X /* get names, positions of stars first */ X for (star=0; starnumplanets=int_rand(lowp,hip); X Star->gravity = int_rand(10000,100000) / 100.0; X printf("name of star (%d planets):",Star->numplanets); X for (i=0; iname); X getchr(); X Star->xpos=(float)int_rand(-UNIVSIZE,UNIVSIZE); X xspeed[star] = 0; X Star->ypos=(float)int_rand(-UNIVSIZE,UNIVSIZE); X yspeed[star] = 0; X } X X for (star=0; starnumplanets; i++) { X sprintf(Star->pnames[i],"%s",Numbers[i]); X X planet = Makeplanet(int_rand(TYPE_EARTH,TYPE_GASGIANT)); X X if (argc==2 && argv[1][1]=='v') X printf("planet %s is type %u\n",Star->pnames[i],planet.type); X X do { X planet.xpos=(float)int_rand(-SYSTEMSIZE,SYSTEMSIZE); X planet.ypos=(float)int_rand(-SYSTEMSIZE,SYSTEMSIZE); X } while ( sqrt(Distsq( planet.xpos, planet.ypos, 0, 0)) >= SYSTEMSIZE ); X X if (argc==2 && argv[1][1]=='v') { X printf("at %f,%f relative to %s.\n",planet.xpos,planet.ypos,Star->name); X printf("sect map(%d X %d):\n",planet.Maxx,planet.Maxy); X for (y=0; yplanetpos[i] = (int)ftell(planetdata); X /* posn of file-last write*/ X planet.sectormappos = (int)ftell(sectordata); /* sector map pos */ X fwrite(&planet,sizeof(planettype),1,planetdata); /* write planet */ X /* write each sector row */ X for (y=0; y < planet.Maxy; y++) X fwrite( &Sector(planet,0,y), X sizeof(sectortype),planet.Maxx,sectordata); X } X } X fchmod(planetdata,00660); /* change data files to group readwrite */ X fclose(planetdata); X fchmod(sectordata,00660); X fclose(sectordata); X X /* get rid of this */ X if ((stardata = fopen("data.starB","w+"))==NULL) { X printf(" unable to open %s\n","data.starB"); X exit(-1); X } X fwrite(&(Sdata),sizeof(Sdata),1,stardata); X for (star=0; starxpos, Stars[star]->ypos, Stars[x]->xpos, Stars[x]->ypos); X xspeed[star] += att * (Stars[star]->xpos - Stars[x]->xpos); X if (Stars[star]->xpos>UNIVSIZE || Stars[star]->xpos< -UNIVSIZE) X xspeed[star] *= -1; X yspeed[star] += att * (Stars[star]->ypos - Stars[x]->ypos); X if (Stars[star]->ypos>UNIVSIZE || Stars[star]->ypos< -UNIVSIZE) X yspeed[star] *= -1; X } X Stars[star]->xpos += xspeed[star]; X Stars[star]->ypos += yspeed[star]; X } X X if ((stardata = fopen(STARDATAFL,"w+"))==NULL) { X printf(" unable to open %s\n",STARDATAFL); X exit(-1); X } X fwrite(&(Sdata),sizeof(Sdata),1,stardata); X for (star=0; star'orbit.c' <<'END_OF_FILE' X/* X * Galactic Bloodshed (Robert Chansky, smq@b) X * orbit.c -- display orbits of planets (graphic representation) X * X * OPTIONS X * -p : If this option is set, ``orbit'' will not display planet names. X * X * -S : Do not display star names. X * X * -s : Do not display ships. X * X * -(number) : Do not display that #'d ship or planet (in case it obstructs X * the view of another object) X */ X X X#define S_X (stdscr->_maxx - NAMESIZE) X#define S_Y (stdscr->_maxy - 1) X#define Midx ((S_X - NAMESIZE)/2.0) X#define Midy (S_Y /2.0) X X#include "vars.h" X#include "ships.h" X#include Xextern char Shipltrs[]; Xfloat Lastx, Lasty, Zoom; Xextern int God; X X Xorbit(APcount, argn,args) Xint APcount; Xint argn; Xchar args[MAXARGS][COMMANDSIZE]; X{ Xregister int sh,i,iq; Xint DontDispNum= -1, t, flag; Xplanettype *p; Xshiptype *s; Xplacetype where,shipwhere; Xbool err, DontDispPlanets, DontDispShips, DontDispStars; Xchar str[PLACENAMESIZE]; Xint orbit_shdata,orbit_pdata,orbit_stardata; X X DontDispPlanets = DontDispShips = DontDispStars = 0; X X /* find options, set flags accordingly */ X for (flag=1; flag<=argn-1; flag++) X if (*args[flag]=='-') { X for (i=1; args[flag][i]!='\0'; i++) X switch (args[flag][i]) { X case 's': DontDispShips = 1; X break; X case 'S': DontDispStars = 1; X break; X case 'p': DontDispPlanets = 1; X break; X default : if (sscanf(args[flag]+1,"%d",&DontDispNum)!=1) { X printf("Bad number %s.\n",args[flag]+1); X DontDispNum = -1; X } X if (DontDispNum) X DontDispNum--; /* make a '1' into a '0' */ X break; X } X } X X if (argn==1) { X where = Getplace(":",0); X Lastx = Dir.lastx; X Lasty = Dir.lasty; X Zoom = Dir.zoom; X } else { X where = Getplace(args[argn-1],0); X Lastx = Lasty = 0.0; X Zoom = 1.0; X } X X if (where.err) { X printf("orbit: error in args.\n"); X return; X } X X X clear(); X X switch (where.level) { X case LEVEL_UNIV: X for (i=0; inextship; X free(s); X } X X close(orbit_shdata); X } X break; X X case LEVEL_STAR: X DispStar(LEVEL_STAR, Stars[where.snum], DontDispStars); X X openpdata(&orbit_pdata); X X X for (i=0; inumplanets; i++) { X if (DontDispNum!=i) { X Locks(1); X getplanet(orbit_pdata,&p,Stars[where.snum]->planetpos[i]); X Locks(0); X DispPlanet(LEVEL_STAR,p,Stars[where.snum]->pnames[i],DontDispPlanets); X free(p); X } X } X close(orbit_pdata); X X/* check to see if you have ships at orbiting the star, if so you can Xsee enemy ships */ X iq = 0; X if(sh = Stars[where.snum]->ships){ X openshdata(&orbit_shdata); X while (sh) { X Locks(1); X (void)getship(orbit_shdata, &s, sh); X Locks(0); X if(s->owner == Playernum && s->popn) X iq = 1; /* you are there to sight, need a crew */ X sh = s->nextship; X free(s); X } X close(orbit_shdata); X } X X X if (!DontDispShips && (sh = Stars[where.snum]->ships)) { X openshdata(&orbit_shdata); X X while (sh) { X Locks(1); X (void)getship(orbit_shdata, &s, sh); X Locks(0); X if (DontDispNum != sh && !(s->owner != Playernum && s->type == STYPE_MINE) ) { X X if((s->owner == Playernum) || (iq == 1)) X DispShip(&where, s, sh, NULL ); X } X sh = s->nextship; X free(s); X } X close(orbit_shdata); X } X break; X X case LEVEL_PLAN: X X openpdata(&orbit_pdata); X Locks(1); X getplanet(orbit_pdata,&p,Stars[where.snum]->planetpos[where.pnum]); X Locks(0); X close(orbit_pdata); X DispPlanet(LEVEL_PLAN, p, Stars[where.snum]->pnames[where.pnum], DontDispPlanets); X X/* check to see if you have ships at landed or X orbiting the planet, if so you can see orbiting enemy ships */ X iq = 0; X X if(sh = p->ships){ X openshdata(&orbit_shdata); X while (sh) { X Locks(1); X (void)getship(orbit_shdata, &s, sh); X Locks(0); X if(s->owner == Playernum && s->popn) X iq = 1; /* you are there to sight, need a crew */ X sh = s->nextship; X free(s); X } X close(orbit_shdata); X } X X/* end check */ X X if (!DontDispShips && (sh = p->ships)) { X openshdata(&orbit_shdata); X while (sh) { X Locks(1); X (void)getship(orbit_shdata, &s, sh); X Locks(0); X if (DontDispNum != sh) { X if( !(s->is_docked && s->whatdest==LEVEL_PLAN) ) { X if((s->owner == Playernum) || (iq ==1)) X DispShip(&where, s, sh, p); X } X } X sh = s->nextship; X free(s); X } X close(orbit_shdata); X } X free(p); X break; X X case LEVEL_SHIP: { X char gs[MAXARGS][COMMANDSIZE]; X shipwhere.level = where.shipptr->whatorbits; X shipwhere.snum = where.shipptr->storbits; X shipwhere.pnum = where.shipptr->pnumorbits; X sprintf(gs[1],"%s",Dispplace(&shipwhere) ); X orbit(0,2,gs); X } break; X X default: X printf("bleah!!!\n"); X exit(-1); X } X /* move to bottom of screen and draw */ X move(S_Y,0); X refresh(); X X} X Xchar *Novae[16][7] = { X " ", X " ", X " ", X " %* ", X " ", X " ", X " ", X X " ", X " ", X " % ", X " %*% ", X " % ", X " ", X " ", X X " ", X " ", X " %% ", X " %%*%% ", X " %% ", X " ", X " ", X X " ", X " ", X " %%% ", X " %*%%% ", X " %%% ", X " ", X " ", X X " ", X " ", X " %%% ", X " %%*%%% ", X " %%%% ", X " ", X " ", X X " ", X " % ", X " %%%% ", X " %%%*%%% ", X " %%%%% ", X " ", X " ", X X " ", X " % ", X " %%%%% ", X " %% *%%% ", X " %%%%% ", X " % ", X " ", X X " ", X " % ", X " %%%%%%% ", X " %%% * %%% ", X " %%%%% ", X " %% ", X " ", X X " ", X " %%% ", X " %%%%%%% ", X " %%% * %%% ", X " %%% %%% ", X " %%% ", X " ", X X " ", X " %%%% ", X " %%% %%% ", X " %%% * %%% ", X " %%% %%%% ", X " %%%%%% ", X " %% ", X X " ", X " %%%% ", X " %%% %%% ", X " %%% * %%% ", X " %%% %%% ", X " %%%%%% ", X " %% ", X X " %% ", X " %%%%%% ", X " %% %%% ", X " %%% * %%%", X " %%%% %%% ", X " %%%%%%%% ", X " %%% ", X X " %%%% ", X " %%%%%%%% ", X " %%% % %%%", X " %% * %%", X " %%% %%%", X " %%%%%% % ", X " % %%% ", X X " %%% %% ", X " %%% %% %% ", X "%% %%%", X "%%% * % %%", X " % % %%", X " %%% % % % ", X " %%%%%%% ", X X "% % % %% ", X " % % ", X "%% % %", X "% * % ", X " % %", X " % % % ", X " % %%% ", X X " % % ", X " %", X "% ", X " * %", X "% ", X " % %", X " % % % " X}; X X X XDispStar(level, star, DontDispStars) Xint level; Xstartype *star; Xint DontDispStars; X{ X int x,y; X register int x2,y2; X float fac; X char *c; X X if (level==LEVEL_UNIV) { X fac = 1.0; X x = (int)(Midx+(star->xpos-Lastx)*(Midx/UNIVSIZE) / Zoom)*1.1; X y = (int)(Midy+(star->ypos-Lasty)*(Midy/UNIVSIZE) / Zoom); X } else if (level==LEVEL_STAR) { X fac = 1000.0; X x = (int)(Midx+(-Lastx)*(Midx/SYSTEMSIZE) / Zoom); X y = (int)(Midy+(-Lasty)*(Midy/SYSTEMSIZE) / Zoom); X } X if (star->nova_stage) X DispArray(x, y, 11,7, Novae[star->nova_stage-1], fac); X else if (y>=0 && y<=S_Y && x>=0 && x<=S_X) { X move(y,x); X addch('*'); X if (!DontDispStars) { X move(y, x+2); X addstr(star->name); X } X } X X} X X XDispPlanet(level, p, name, DontDispPlanets) Xint level; Xplanettype *p; Xchar *name; Xint DontDispPlanets; X{ Xint x,y; X X if (level==LEVEL_STAR) { X y = (int)(Midy +(p->ypos-Lasty)*(Midy/SYSTEMSIZE) / Zoom); X x = (int)(Midx +(p->xpos-Lastx)*(Midx/SYSTEMSIZE) / Zoom); X } else if (level==LEVEL_PLAN) { X y = (int)(Midy +(-Lasty)*(Midy/PLORBITSIZE) / Zoom); X x = (int)(Midx +(-Lastx)*(Midx/PLORBITSIZE) / Zoom); X } X if (x>=0 && x<=S_X && y>=0 && y<=S_Y) { X mvaddch(y,x,'@'); X if (!DontDispPlanets) { X addch(' '); X addstr(name); X } X } X} X X Xchar *Amoeba[] = { X " && ", X " & &&&& ", X " &&&@&& ", X " &&&& ", X " && ", X}; X Xchar *Mirror[8][5] = { X X " ", X " ", X "\\===m===/", X " ", X " ", X X " | ", X " \\\\ ", X " m ", X " \\\\ ", X " \\__", X X " / ", X " || ", X " m ", X " || ", X " \\ ", X X " __", X " // ", X " m ", X " // ", X " | ", X X " ", X " ", X "/===m===\\", /* cc thinks this is a quoted " w/o the \ */ X " ", X " ", X X "__ ", X " \\\\ ", /* weird stuff again */ X " m ", X " \\\\ ", X " | ", X X " \\ ", X " || ", X " m ", X " || ", X " / ", X X " | ", X " // ", X " m ", X "__// ", X " " X}; X X XDispShip(where, ship, shipno, pl ) Xplacetype *where; Xshiptype *ship; Xint shipno; Xplanettype *pl; /* orbits planet */ X{ X int x,y,x2,y2,wm,pdata,shipdata; X shiptype *aship; X planettype *apl; X float xt,yt,slope; X char *c; X X if (ship->is_dead) X return; X X switch (where->level) { X case LEVEL_PLAN: X x = Midx + (ship->xpos-(Stars[where->snum]->xpos+pl->xpos) - Lastx)*(Midx/PLORBITSIZE) / Zoom; X y = Midy + (ship->ypos-(Stars[where->snum]->ypos+pl->ypos) - Lasty)*(Midy/PLORBITSIZE) / Zoom; X break; X case LEVEL_STAR: X x = Midx + (ship->xpos-Stars[where->snum]->xpos - Lastx)*(Midx/SYSTEMSIZE) / Zoom; X y = Midy + (ship->ypos-Stars[where->snum]->ypos - Lasty)*(Midy/SYSTEMSIZE) / Zoom; X break; X case LEVEL_UNIV: X x = Midx + (ship->xpos-Lastx)*(Midx/UNIVSIZE) / Zoom; X y = Midy + (ship->ypos-Lasty)*(Midy/UNIVSIZE) / Zoom; X break; X default: X printf("WHOA! error.\n"); X exit(-1); X } X X switch (ship->type) { X X case STYPE_MIRROR: X if (ship->orders.aimed_at.level==LEVEL_STAR) { X xt = Stars[ship->orders.aimed_at.snum]->xpos; X yt = Stars[ship->orders.aimed_at.snum]->ypos; X } else if (ship->orders.aimed_at.level==LEVEL_PLAN) { X if (where->level==LEVEL_PLAN && X ship->orders.aimed_at.pnum == where->pnum) { X /* same planet */ X xt = Stars[ship->orders.aimed_at.snum]->xpos + pl->xpos; X yt = Stars[ship->orders.aimed_at.snum]->ypos + pl->ypos; X } else { /* different planet */ X openpdata(&pdata); X getplanet(pdata,&apl,Stars[where->snum]->planetpos[where->pnum]); X close(pdata); X xt = Stars[ship->orders.aimed_at.snum]->xpos + apl->xpos; X yt = Stars[ship->orders.aimed_at.snum]->ypos + apl->ypos; X free(apl); X } X } else if (ship->orders.aimed_at.level==LEVEL_SHIP) { X openshdata(&shipdata); X if (getship(shipdata,&aship,ship->orders.aimed_at.shipno)) { X xt = aship->xpos; X yt = aship->ypos; X } else X xt = yt = 0.0; X close(shipdata); X free(aship); X } else X xt = yt = 0.0; X X slope = (xt - ship->xpos) / (yt - ship->ypos); X X if (yt - ship->ypos > 0) { X if (slope > 0) { X if (slope > 1) { X if (slope > 2) X wm = 0; X else X wm = 1; X } else { X if (slope > .5) X wm = 1; X else X wm = 2; X } X } else { X if (slope < -1) { X if (slope < -2) X wm = 0; X else X wm = 7; X } else { X if (slope < .5) X wm = 7; X else X wm = 6; X } X } X } else { X if (slope > 0) { X if (slope > 1) { X if (slope > 2) X wm = 4; X else X wm = 5; X } else { X if (slope > .5) X wm = 5; X else X wm = 6; X } X } else { X if (slope < -1) { X if (slope < -2) X wm = 4; X else X wm = 3; X } else { X if (slope < .5) X wm = 3; X else X wm = 2; X } X } X } X X DispArray(x,y, 9,5, Mirror[wm], X ship->whatorbits==LEVEL_UNIV ? (float)100.0 : X (ship->whatorbits==LEVEL_STAR ? (float)10.0 : X (ship->whatorbits==LEVEL_PLAN ? (float)1.0 :0))); X /* (magnification) */ X if (x>=0 && x<=S_X && y>=0 && y<=S_Y) { X move(y,x+1); X printw("%d",shipno); X } X break; X X case OTYPE_CANIST: X break; X X case OTYPE_AMOEBA: X DispArray(x,y, 9,5, Amoeba, X ship->whatorbits==LEVEL_UNIV ? (float)100.0 : X (ship->whatorbits==LEVEL_STAR ? (float)10.0 : X (ship->whatorbits==LEVEL_PLAN ? (float)1.0 :0))); X move(y,x+1); X printw("%d", shipno); X break; X X case OTYPE_VN: { register int n,xa,ya; X register float fac; X /* make a cloud of Von Neumann machines */ X if (ship->whatorbits!=LEVEL_UNIV || (ship->owner == Playernum || God)) { X fac = ship->orders.object.number / X ((ship->whatorbits==LEVEL_UNIV ? 100.0 : X (ship->whatorbits==LEVEL_STAR ? 30.0 : 4.0)) * Zoom); X for (n=1; n<=ship->orders.object.number && n<267; n++) { X xa = int_rand(x - (int)fac, x + (int)fac); X ya = int_rand(y - (int)(fac*S_Y/S_X), X y + (int)(fac*S_Y/S_X)); X if (xa>=0 && xa<=S_X && ya>=0 && ya<=S_Y) { X mvaddch(ya,xa, Shipltrs[ship->type]); X printw("%d",shipno); X } X } X } X } X break; X X default: X /* other ships can only be seen when in system */ X if (ship->whatorbits!=LEVEL_UNIV || (ship->owner == Playernum || God)) X if (x>=0 && x<=S_X && y>=0 && y<=S_Y) { X mvaddch(y,x, Shipltrs[ship->type]); X printw("%d",shipno); X } X break; X } X X X} X X X X/* display array on screen. at the moment magnification is not X * implemented. X */ XDispArray(x, y, maxx,maxy, array, mag) Xint x,y; Xint maxx,maxy; Xchar *array[]; Xfloat mag; X{ Xregister int x2,y2,curx,cury, Cx,Cy,cx,cy; X X for (cury=y-maxy/2,y2=0; y2= 0 && cury <= S_Y) { X move(cury, curx = x - maxx / 2 ); X for (x2=0; x2=0 && curx <= S_X) X if (inch()==' ') X addch( array[y2][x2] ); X else X move(cury, curx); /* one to right */ X x2++; X } X } X y2++; X } X X} END_OF_FILE if test 13727 -ne `wc -c <'orbit.c'`; then echo shar: \"'orbit.c'\" unpacked with wrong size! fi # end of 'orbit.c' fi echo shar: End of archive 2 \(of 8\). cp /dev/null ark2isdone MISSING="" for I in 1 2 3 4 5 6 7 8 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 8 archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0