home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / games / volume6 / gb / part03 / survey.c < prev   
C/C++ Source or Header  |  1989-07-06  |  4KB  |  122 lines

  1. /*
  2.  * Galactic Bloodshed (Robert Chansky, smq@b)
  3.  * survey.c -- print out survey for planets  
  4.  */
  5.  
  6. #include "vars.h"
  7. #include "races.h"
  8. float compatibility();
  9. extern char desshow();
  10.  
  11. survey(APcount, argn,args)
  12. int APcount;
  13. int argn;
  14. char args[MAXARGS][COMMANDSIZE];
  15. {
  16. int lowx,hix,lowy,hiy,x2;
  17. sectortype *s;
  18. planettype *p;
  19. int survey_pdata,survey_sectdata;
  20.  
  21. if (argn==1) {   /* no args */
  22.  
  23.  if (Dir.level==LEVEL_PLAN) {
  24.   openpdata(&survey_pdata);
  25.   getplanet(survey_pdata,&p,Stars[Dir.snum]->planetpos[Dir.pnum]);
  26.   close(survey_pdata);
  27.   printf("%s:\n",Stars[Dir.snum]->pnames[Dir.pnum]);
  28.   printf("gravity   x,y absolute     x,y relative to %s\n",Stars[Dir.snum]->name);
  29.   printf("%7.2f   %7.1f,%7.1f   %8.1f,%8.1f\n", 
  30.         gravity(p),
  31.         p->xpos + Stars[Dir.snum]->xpos,
  32.         p->ypos + Stars[Dir.snum]->ypos,
  33.         p->xpos, p->ypos );
  34.  
  35.   printf("======== planetary conditions: ========\n");
  36.   printf("atmosphere concentrations:\n");
  37.   printf("     methane %02d%%(%02d%%)     oxygen %02d%%(%02d%%)\n",
  38.         p->conditions[METHANE], Race->conditions[METHANE],
  39.         p->conditions[OXYGEN], Race->conditions[OXYGEN] );
  40.   printf("         CO2 %02d%%(%02d%%)   hydrogen %02d%%(%02d%%)      temperature: %3d (%3d)\n",
  41.         p->conditions[CO2], Race->conditions[CO2],
  42.         p->conditions[HYDROGEN], Race->conditions[HYDROGEN],
  43.         Temp(p->conditions[TEMP]), Temp(Race->conditions[TEMP]) );
  44.   printf("    nitrogen %02d%%(%02d%%)     sulfur %02d%%(%02d%%)           normal: %3d\n",
  45.         p->conditions[NITROGEN], Race->conditions[NITROGEN],
  46.         p->conditions[SULFUR], Race->conditions[SULFUR],
  47.         Temp(p->conditions[RTEMP]) );
  48.   printf("      helium %02d%%(%02d%%)      other %02d%%(%02d%%)         %s: %d%%\n",
  49.         p->conditions[HELIUM], Race->conditions[HELIUM],
  50.         p->conditions[OTHER], Race->conditions[OTHER],
  51.         p->conditions[TOXIC] > 80 ? "TOXICITY" : "toxicity",
  52.         p->conditions[TOXIC]);
  53.   printf("Total planetary compatibility: %.2f%%\n", compatibility(p, Race) );
  54.  
  55.   printf("fuel_stock  resource_stock dest_pot.   %s    ^%s\n",
  56.             Race->Thing ? "biomass" : "popltn",
  57.             Race->Thing ? "biomass" : "popltn");
  58.   printf("%10lu  %14lu %9lu  %7lu%11lu\n", p->info[Playernum-1].fuel, 
  59.          p->info[Playernum-1].resource, 
  60.          p->info[Playernum-1].destruct,
  61.          p->popn, p->maxpopn);
  62.  
  63.   free(p);
  64.  
  65.  } else if (Dir.level==LEVEL_STAR) {
  66.  
  67.   printf("Star %s\n",Stars[Dir.snum]->name);
  68.   printf("locn: %f,%f\n",Stars[Dir.snum]->xpos,Stars[Dir.snum]->ypos);
  69.   printf("gravity: %.2f\tstability: ", Stars[Dir.snum]->gravity);
  70.   if (Race->tech >= TECH_SEE_STABILITY)
  71.       printf("%d%% (%s)\n",
  72.         Stars[Dir.snum]->stability, 
  73.         Stars[Dir.snum]->stability<20 ? "stable" :
  74.         Stars[Dir.snum]->stability<40 ? "unstable" : 
  75.         Stars[Dir.snum]->stability<60 ? "dangerous" : 
  76.         Stars[Dir.snum]->stability<100 ? "WARNING! nova iminent!" : 
  77.         "undergoing nova" );
  78.   else
  79.     printf("(cannot determine)\n");
  80.  
  81.   printf("%d planets are ",Stars[Dir.snum]->numplanets);
  82.   for (x2=0; x2<Stars[Dir.snum]->numplanets; x2++)
  83.     printf("%s\t", Stars[Dir.snum]->pnames[x2]);
  84.   putchr('\n');
  85.  
  86.  } else if (Dir.level==LEVEL_UNIV)
  87.   printf("It's just _there_, you know?\n");
  88. } else if (argn==2)      /* argn==2, survey is on a sector */
  89.  if (Dir.level==LEVEL_PLAN) {
  90.   openpdata(&survey_pdata);
  91.   getplanet(survey_pdata,&p,Stars[Dir.snum]->planetpos[Dir.pnum]);
  92.   close(survey_pdata);
  93.   opensectdata(&survey_sectdata);
  94.   getsmap(survey_sectdata,Smap,p->sectormappos,p->Maxx*p->Maxy);
  95.   close(survey_sectdata);
  96.  
  97.   get4args(args[1],&x2,&hix,&lowy,&hiy); 
  98.   if (hix>=p->Maxx) hix=p->Maxx-1;
  99.   if (x2<0) x2=0;
  100.   if (lowy>=p->Maxy) lowy=p->Maxy-1;
  101.   if (hiy<0) hiy=0;
  102.           /* ^^^ translate to lowx:hix,lowy:hiy */
  103.  
  104.   printf(" x,y des eff mob frt res popn ^popn\n");
  105.  
  106.   for (; lowy<=hiy; lowy++)
  107.        for (lowx=x2; lowx<=hix; lowx++) {
  108.             s=(&(Smap[lowy*p->Maxx+lowx]));
  109.             /*if (s->owner==Playernum)*/
  110.                printf("%2d,%-2d %c%4u%4u%4u%4u%5u%6d\n",
  111.             lowx,lowy,desshow(p,lowx,lowy), s->eff, s->mobilization,
  112.             s->fert, s->resource, s->popn,
  113.             maxsupport(s) );
  114.      }
  115.  free(p);
  116.  } else
  117.     printf("scope must be a planet.\n");
  118.  else if (argn>2)
  119.      printf("survey: error in args.\n");
  120.  
  121. }
  122.