home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
games
/
volume6
/
gb
/
part03
/
survey.c
< prev
Wrap
C/C++ Source or Header
|
1989-07-06
|
4KB
|
122 lines
/*
* Galactic Bloodshed (Robert Chansky, smq@b)
* survey.c -- print out survey for planets
*/
#include "vars.h"
#include "races.h"
float compatibility();
extern char desshow();
survey(APcount, argn,args)
int APcount;
int argn;
char args[MAXARGS][COMMANDSIZE];
{
int lowx,hix,lowy,hiy,x2;
sectortype *s;
planettype *p;
int survey_pdata,survey_sectdata;
if (argn==1) { /* no args */
if (Dir.level==LEVEL_PLAN) {
openpdata(&survey_pdata);
getplanet(survey_pdata,&p,Stars[Dir.snum]->planetpos[Dir.pnum]);
close(survey_pdata);
printf("%s:\n",Stars[Dir.snum]->pnames[Dir.pnum]);
printf("gravity x,y absolute x,y relative to %s\n",Stars[Dir.snum]->name);
printf("%7.2f %7.1f,%7.1f %8.1f,%8.1f\n",
gravity(p),
p->xpos + Stars[Dir.snum]->xpos,
p->ypos + Stars[Dir.snum]->ypos,
p->xpos, p->ypos );
printf("======== planetary conditions: ========\n");
printf("atmosphere concentrations:\n");
printf(" methane %02d%%(%02d%%) oxygen %02d%%(%02d%%)\n",
p->conditions[METHANE], Race->conditions[METHANE],
p->conditions[OXYGEN], Race->conditions[OXYGEN] );
printf(" CO2 %02d%%(%02d%%) hydrogen %02d%%(%02d%%) temperature: %3d (%3d)\n",
p->conditions[CO2], Race->conditions[CO2],
p->conditions[HYDROGEN], Race->conditions[HYDROGEN],
Temp(p->conditions[TEMP]), Temp(Race->conditions[TEMP]) );
printf(" nitrogen %02d%%(%02d%%) sulfur %02d%%(%02d%%) normal: %3d\n",
p->conditions[NITROGEN], Race->conditions[NITROGEN],
p->conditions[SULFUR], Race->conditions[SULFUR],
Temp(p->conditions[RTEMP]) );
printf(" helium %02d%%(%02d%%) other %02d%%(%02d%%) %s: %d%%\n",
p->conditions[HELIUM], Race->conditions[HELIUM],
p->conditions[OTHER], Race->conditions[OTHER],
p->conditions[TOXIC] > 80 ? "TOXICITY" : "toxicity",
p->conditions[TOXIC]);
printf("Total planetary compatibility: %.2f%%\n", compatibility(p, Race) );
printf("fuel_stock resource_stock dest_pot. %s ^%s\n",
Race->Thing ? "biomass" : "popltn",
Race->Thing ? "biomass" : "popltn");
printf("%10lu %14lu %9lu %7lu%11lu\n", p->info[Playernum-1].fuel,
p->info[Playernum-1].resource,
p->info[Playernum-1].destruct,
p->popn, p->maxpopn);
free(p);
} else if (Dir.level==LEVEL_STAR) {
printf("Star %s\n",Stars[Dir.snum]->name);
printf("locn: %f,%f\n",Stars[Dir.snum]->xpos,Stars[Dir.snum]->ypos);
printf("gravity: %.2f\tstability: ", Stars[Dir.snum]->gravity);
if (Race->tech >= TECH_SEE_STABILITY)
printf("%d%% (%s)\n",
Stars[Dir.snum]->stability,
Stars[Dir.snum]->stability<20 ? "stable" :
Stars[Dir.snum]->stability<40 ? "unstable" :
Stars[Dir.snum]->stability<60 ? "dangerous" :
Stars[Dir.snum]->stability<100 ? "WARNING! nova iminent!" :
"undergoing nova" );
else
printf("(cannot determine)\n");
printf("%d planets are ",Stars[Dir.snum]->numplanets);
for (x2=0; x2<Stars[Dir.snum]->numplanets; x2++)
printf("%s\t", Stars[Dir.snum]->pnames[x2]);
putchr('\n');
} else if (Dir.level==LEVEL_UNIV)
printf("It's just _there_, you know?\n");
} else if (argn==2) /* argn==2, survey is on a sector */
if (Dir.level==LEVEL_PLAN) {
openpdata(&survey_pdata);
getplanet(survey_pdata,&p,Stars[Dir.snum]->planetpos[Dir.pnum]);
close(survey_pdata);
opensectdata(&survey_sectdata);
getsmap(survey_sectdata,Smap,p->sectormappos,p->Maxx*p->Maxy);
close(survey_sectdata);
get4args(args[1],&x2,&hix,&lowy,&hiy);
if (hix>=p->Maxx) hix=p->Maxx-1;
if (x2<0) x2=0;
if (lowy>=p->Maxy) lowy=p->Maxy-1;
if (hiy<0) hiy=0;
/* ^^^ translate to lowx:hix,lowy:hiy */
printf(" x,y des eff mob frt res popn ^popn\n");
for (; lowy<=hiy; lowy++)
for (lowx=x2; lowx<=hix; lowx++) {
s=(&(Smap[lowy*p->Maxx+lowx]));
/*if (s->owner==Playernum)*/
printf("%2d,%-2d %c%4u%4u%4u%4u%5u%6d\n",
lowx,lowy,desshow(p,lowx,lowy), s->eff, s->mobilization,
s->fert, s->resource, s->popn,
maxsupport(s) );
}
free(p);
} else
printf("scope must be a planet.\n");
else if (argn>2)
printf("survey: error in args.\n");
}