DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T r

⟦b7b827cbd⟧ TextFile

    Length: 6461 (0x193d)
    Types: TextFile
    Names: »rst.c«

Derivation

└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
    └─⟦this⟧ »EUUGD18/General/Gb/rst.c« 

TextFile


/*
 * Galactic Bloodshed (Robert Chansky, smq@b)
 *  ship -- report -- stock -- tactical -- stuff on ship
 */

#define REPORT	0
#define STOCK	1
#define TACTICAL 2
#define SHIP	3
#define OBJECT	4

#include <math.h>
#include "vars.h"
#include "ships.h"
extern char Shipltrs[];
extern char *prin_ship_dest();
extern int God;
extern int Ignore_filelocks;
static bool Object,Ship,Stock,Report,Tactical,first;

struct reportdata {
	shiptype *s;
	short n;
	float x,y;
};

int Num_ships;

rst(APcount, argn,args,Rst)
int APcount;
int argn;
char args[MAXARGS][COMMANDSIZE];
int Rst;
{
 int shdata,shipno;
 reg int i;
 struct reportdata sh[MAXTOTALSHIPS];

 Num_ships = 0;
 first = 1;
 switch (Rst) {
	case REPORT:	Report = 1;
			Object = Stock = Ship = Tactical = 0;
			break;
	case STOCK:	Stock = 1;
			Object = Report = Ship = Tactical = 0;
			break;
	case TACTICAL:	Tactical = 1;
			Object = Report = Ship = Stock = 0;
			break;
	case SHIP:	Ship = Report = Stock = Tactical = 1;
			Object = 0;
			break;
	case OBJECT:	Object = Report = Stock = Tactical = 1;
			Ship = 0;
			break;
 }

 if (argn==2) {
   sscanf(args[1] + (*args[1]=='#' ? 1 : 0),"%d",&shipno);
   openshdata(&shdata);
   Getrship(shdata,sh, shipno, 0.0, 0.0);
   close(shdata);
   ship_report(sh,0);		/* first ship report */

 } else

  switch (Dir.level) {
   case LEVEL_UNIV:
      if (Sdata.numships) {
	  openshdata(&shdata);
	  for (i=0; i<MAXUSHIPS; i++) {
	    if (Sdata.shipnums[i])
	      Getrship(shdata,sh, Sdata.shipnums[i],0.0, 0.0);
	  }
	  close(shdata);
      }
      for (i=0; i<Sdata.numstars; i++)
        star_getrships(sh,i);
      for (i=0; i<Num_ships; i++)
        ship_report(sh,i);
      break;
   case LEVEL_STAR:
      star_getrships(sh,Dir.snum);
      for (i=0; i<Num_ships; i++)
        ship_report(sh,i);
      break;
   case LEVEL_PLAN:
      plan_getrships(sh,Stars[Dir.snum]->planetpos[Dir.pnum],Stars[Dir.snum]->xpos,Stars[Dir.snum]->ypos);
      for (i=0; i<Num_ships; i++)
        ship_report(sh,i);
      break;
   case LEVEL_SHIP:
      openshdata(&shdata);
      Getrship(shdata,sh, Dir.shipno,0.0,0.0);
      close(shdata);
      ship_report(sh,0);		/* first ship report */
      break;
  }

  Free_shiplist(sh);

}


ship_report(sh,indx)
struct reportdata sh[];
int indx;
{
 shiptype *s;
 int shipno;
 reg int i;
 placetype where;
 char orb[PLACENAMESIZE];
 float Dist;
 
	/* last ship gotten from disk */
  s = sh[indx].s;
  shipno = sh[indx].n;


	/* a launched canister doesn't show up */
  if ( !(s->type==OTYPE_CANIST && !s->is_docked) ) {


   if (Stock) {
    if (first) {
      printf("  #   mass res  ^res  dest ^dest   fuel ^fuel  crew ^crew dock\n");
      if (!Ship && !Object)
	      first=0;
    }
    /*if (is_object(s) == Object)*/
     if (s->owner == Playernum || God) {
      printf("%3d %c%5.1f%4u%6d%6u%6d%7.1f%6d%6u%6d%5s",
	shipno, Shipltrs[s->type], s->mass,
	s->resource, Shipdata[s->type][ABIL_CARGO],
	s->destruct, Shipdata[s->type][ABIL_DESTCAP],
	s->fuel, Shipdata[s->type][ABIL_FUELCAP],
	s->popn, Shipdata[s->type][ABIL_MAXCREW],
	(s->is_docked) ? ((s->whatdest==LEVEL_PLAN) ? "land" : "dock") :"    ");
      if (s->type==OTYPE_VN) 
	printf(" * %d",s->orders.object.number);
      if (s->rad)
	printf(" INACTIVE(%d)",s->rad);
      putchr('\n');

    }
   }
   if (Report) {
         if (first) {
		 printf("  #   own dam dest  fuel land               orbits           destination\n");
		 if (!Ship && !Object)
		      first=0;
	 }

	if (s->owner == Playernum || God) {
	 /*if (is_object(s) == Object) */
 	  printf("%3d %c%4u%4u%5u%6.1f%5s %20s %21s",
		shipno, Shipltrs[s->type],
		s->owner, s->damage, s->destruct, s->fuel, 
		(s->is_docked) ? ( (s->whatdest==LEVEL_SHIP) ? "dock" 
			: "land") : "    ",
		prin_ship_orbits(s), prin_ship_dest(s) );
         if (s->type==OTYPE_VN) printf("* %d",s->orders.object.number);
      if (s->rad)
	printf(" INACTIVE(%d)",s->rad);
         putchr('\n');

	}
   }
	/* objects dont have a tac display */
   if (Tactical) {
	printf("  # typ dest  fuel dam    x,y abs     x,y rel    orbits\n");
 	where.level = s->whatorbits;
 	where.snum = s->storbits;
 	where.pnum = s->pnumorbits;
	sprintf(orb, "%.30s", Dispplace(&where));
	printf("%3d  %c%6u%6.1f%4u%7.0f,%-7.0f%7.0f,%-7.0%10s",
		shipno, Shipltrs[s->type], s->destruct,
		s->fuel, s->damage, 
		s->xpos, s->ypos, s->xpos-sh[indx].x, s->ypos-sh[indx].y, orb );
	if (s->type == OTYPE_VN)
		printf(" * %d", s->orders.object.number);
        if (s->rad)
		printf(" INACTIVE(%d)",s->rad);
	putchr('\n');

	if (!s->rad && Shipdata[s->type][ABIL_GUNS]) {
	  printf("Tac display:  # own typ   rng  %dam\n");
	  for (i=0; i<Num_ships; i++)
		if (sh[i].s->owner != Playernum && sh[i].n!=shipno &&
		    (Dist = sqrt(Distsq(s->xpos, s->ypos, sh[i].s->xpos,
				sh[i].s->ypos))) < SYSTEMSIZE) {
		   printf("%15d%4d%6.0f%6.0f",
			sh[i].n, sh[i].s->owner, Shipltrs[sh[i].s->type], 
			Dist, 0.0 );
		   if (sh[i].s->type==OTYPE_VN)
			printf(" * %d", sh[i].s->orders.object.number);
		   putchr('\n');
		}
	}
   }


  }

}



plan_getrships(sh,filepos,starx,stary)
struct reportdata sh[];
int filepos;
float starx,stary;
{
 register int i;
 planettype *p;
 int shdata,pdata;

 openpdata(&pdata);
 getplanet(pdata, &p,filepos);
 close(pdata);

 if (p->info[Playernum-1].explored) {

   openshdata(&shdata);
 	for (i=0; i<MAXPSHIPS; i++)
  	   if (p->shipnums[i])
		Getrship(shdata, sh, p->shipnums[i], starx, stary);
   close(shdata);
 }
 free(p);
}


star_getrships(sh,snum)
struct reportdata sh[];
int snum;
{
 register int i;
 int shdata;

 if (isset(Stars[snum]->inhabited, Playernum)) {
   openshdata(&shdata);
   for (i=0; i<MAXSSHIPS; i++)
     if (Stars[snum]->shipnums[i])
	Getrship(shdata, sh, Stars[snum]->shipnums[i], Stars[snum]->xpos, 
		Stars[snum]->ypos);
   close(shdata);
   for (i=0; i<Stars[snum]->numplanets; i++)
     plan_getrships(sh,Stars[snum]->planetpos[i],Stars[snum]->xpos,Stars[snum]->ypos);
 }
}


/* get a ship from the disk and add it to the ship list we're maintaining. */
Getrship(shdata,sh, shipno,xoff, yoff)
int shdata,shipno;
struct reportdata sh[];
float xoff, yoff;
{
int noerr;

   Ignore_filelocks = 1;
    noerr = getship(shdata,&sh[Num_ships].s,shipno);
   Ignore_filelocks = 0;
   sh[Num_ships].n = shipno;
   sh[Num_ships].x = xoff;
   sh[Num_ships].y = yoff;
  if (noerr)
	Num_ships++;
}


Free_shiplist(sh)
struct reportdata sh[];
{
 reg int i;

 for (i=0; i<Num_ships; i++)
	free(sh[i].s);
}