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 p

⟦47e9b0624⟧ TextFile

    Length: 1177 (0x499)
    Types: TextFile
    Names: »power.c«

Derivation

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

TextFile


/*
 * Galactic Bloodshed (Robert Chansky, smq@ucscb.ucsc.edu)
 * power.c -- display power report
 */

#include "vars.h"
#include "races.h"
#include "power.h"
#include <errno.h>
extern int errno;
extern int God;

power(APcount, argn,args)
int APcount, argn;
char *args[];
{
register int i,n;
int power_fd;
racetype *r;
struct power p[MAXPLAYERS];

  if (argn>1) {
	printf("usage: power\n");
	return;
  }

  printf("         ========== Galactic Bloodshed Power Report ==========\n");
  printf(" #  Name            sects   popn eff mob #shp #plan    res   fuel   dest\n");

  if ( (power_fd = open(POWFL, O_RDONLY, 0777)) < 0) {
	  perror("open power data");
  } else {
	  read(power_fd, (char *)p, sizeof(*p)*MAXPLAYERS);
	  close(power_fd);

	  n = Numraces();
	  for (i=1; i<=n; i++) {
		  getrace(&r,i);
		  printf("%2d %-17.17s%5u%7u%4.0f%4.0f%5u%6u%7u%7u%7u\n", 
			i, r->name,
			p[i].sectors_owned, p[i].popn, 
			p[i].sectors_owned ? 
				(float)p[i].sum_eff/p[i].sectors_owned : 0.0,
			p[i].sectors_owned ? 
				(float)p[i].sum_mob/p[i].sectors_owned : 0.0,
			p[i].ships_owned, p[i].planets_owned,
			p[i].resource, p[i].fuel, p[i].destruct);
		  free(r);
	  }
  }
}